[mapguide-commits] r1309 - in trunk/MgDev/Oem/gdal-1.4.0: . ogr port
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Mar 20 20:50:26 EDT 2007
Author: stevedang
Date: 2007-03-20 20:50:25 -0400 (Tue, 20 Mar 2007)
New Revision: 1309
Added:
trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr.vcproj
trunk/MgDev/Oem/gdal-1.4.0/port/cpl.vcproj
Modified:
trunk/MgDev/Oem/gdal-1.4.0/nmake.opt
trunk/MgDev/Oem/gdal-1.4.0/ogr/Makefile
trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr_srs_api.h
trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr_srs_proj4.cpp
trunk/MgDev/Oem/gdal-1.4.0/ogr/ogrspatialreference.cpp
trunk/MgDev/Oem/gdal-1.4.0/port/cpl_findfile.cpp
trunk/MgDev/Oem/gdal-1.4.0/port/makefile.vc
Log:
GDAL 1.4.0 upgrade (part 1):
- Fix MapGuide crashing problem on debug Windows.
- Incorporate changes made to GDAL 1.3.0 (e.g. adding support for additional projections, fixing leaks in CPLFinderClean, allowing custom name for PDB file).
Modified: trunk/MgDev/Oem/gdal-1.4.0/nmake.opt
===================================================================
--- trunk/MgDev/Oem/gdal-1.4.0/nmake.opt 2007-03-21 00:47:37 UTC (rev 1308)
+++ trunk/MgDev/Oem/gdal-1.4.0/nmake.opt 2007-03-21 00:50:25 UTC (rev 1309)
@@ -1,278 +1,278 @@
-
-# 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.
-# But the paths *should* be absolute (relative paths mess up in submakefiles).
-
-GDAL_HOME = "C:\warmerda\bld"
-BINDIR = $(GDAL_HOME)\bin
-PY_INST_DIR = $(GDAL_HOME)\pymod
-LIBDIR = $(GDAL_HOME)\lib
-INCDIR = $(GDAL_HOME)\include
-DATADIR = $(GDAL_HOME)\data
-HTMLDIR = $(GDAL_HOME)\html
-
-# Set this to the installed directory containing python. If you don't
-# have python just let it point to a directory that does not exist (as now).
-PYDIR = "C:\Software\Python24"
-
-# Set the location of your SWIG installation
-SWIG = D:\swig\swig-1.3.25\swig.exe
-
-# Uncomment the first for an optimized build or the second for a debug build.
-#OPTFLAGS= /nologo /MD /EHsc /Ox
-OPTFLAGS= /nologo /MD /EHsc /Zi /Fd$(GDAL_ROOT)\gdal.pdb
-
-# Uncomment the following if you are building for 64-bit windows
-# (x64). You'll need to have PATH, INCLUDE and LIB set up for 64-bit
-# compiles.
-#WIN64=YES
-
-# If you don't want some entry points to have STDCALL conventions,
-# comment out the following and add -DCPL_DISABLE_STDCALL in OPTFLAGS.
-# This option has no effect on 64-bit windows.
-STDCALL=YES
-
-# Version number embedded in DLL name.
-VERSION = 14
-
-# Uncomment the following to link OGR utilities against main GDAL DLL
-# instead of statically linking against OGR libraries.
-DLLBUILD=1
-
-# Enable all OGR formats, or only raster formats? Comment out to disable
-# vector formats.
-INCLUDE_OGR_FRMTS = YES
-
-# Location of Visual C++ directory (only required for following SETARGV stuff)
-VCDIR = D:\Software\VStudio\VC98
-
-# Enable the following if VCDIR set properly, and you want the utility
-# programs to be able to expand wildcards.
-#SETARGV = "$(VCDIR)\lib\setargv.obj"
-
-# Comment out the following to disable BSB support.
-BSB_SUPPORTED = 1
-
-# Comment out the following to disable ODBC support.
-ODBC_SUPPORTED = 1
-
-# Comment out the following to disable JPEG support.
-JPEG_SUPPORTED = 1
-
-#if using an external jpeg library uncomment the follwing lines
-#JPEG_EXTERNAL_LIB = 1
-#JPEGDIR = c:/projects/jpeg-6b
-#JPEG_LIB = $(JPEGDIR)/libjpeg.lib
-
-#if using an external png library uncomment the follwing lines
-#PNG_EXTERNAL_LIB = 1
-#PNGDIR = c:/projects/libpng-1.0.8
-#PNG_LIB = $(PNGDIR)/libpng.lib
-
-# if using an external libtiff library
-#TIFF_INC = -Ic:/warmerda/libtiff/libtiff
-#TIFF_LIB = c:/warmerda/libtiff/libtiff/libtiff_i.lib
-
-# if using an external libgeotiff library
-#GEOTIFF_INC = -Ic:/warmerda/libgeotiff -Ic:/warmerda/libgeotiff/libxtiff
-#GEOTIFF_LIB = C:/warmerda/libgeotiff/geotiff_i.lib
-
-# Uncomment the following and update to enable ECW support.
-#ECWDIR = C:\warmerda\libecwj2-3.3
-#ECWLIB = $(ECWDIR)\Source\NCSBuildQmake\Debug\libecwj2.lib
-
-# DWG/DXF support via DWGdirect from Open Design Alliance
-
-#DWGDIRECT=C:\warmerda\DWGdirect
-#DWG_LIB_DIR=$(DWGDIRECT)\lib\VC6MD
-#DWG_LIB=$(DWG_LIB_DIR)\DD_AcisBuilder_dll.lib $(DWG_LIB_DIR)\DD_AcisRenderer_dll.lib $(DWG_LIB_DIR)\DD_Alloc_dll.lib $(DWG_LIB_DIR)\DD_BmpExport_dll.lib $(DWG_LIB_DIR)\DD_Br_dll.lib $(DWG_LIB_DIR)\DD_Db_dll.lib $(DWG_LIB_DIR)\DD_DwfExport_dll.lib $(DWG_LIB_DIR)\DD_DwfImport_dll.lib $(DWG_LIB_DIR)\DD_Ge_dll.lib $(DWG_LIB_DIR)\DD_Gi_dll.lib $(DWG_LIB_DIR)\DD_Gs_dll.lib $(DWG_LIB_DIR)\DD_ModelerGeometry_dll.lib $(DWG_LIB_DIR)\DD_Root_dll.lib $(DWG_LIB_DIR)\DD_Sm_dll.lib $(DWG_LIB_DIR)\DD_SpatialIndex_dll.lib $(DWG_LIB_DIR)\DD_VC6MD_OleDataAccess_dll.lib
-
-# Uncomment the following and update to enable OGDI support.
-#OGDIDIR = D:\warmerda\iii\devdir
-#OGDIVER = 31
-#OGDILIB = $(OGDIDIR)\lib\$(TARGET)\ogdi$(OGDIVER).lib \
-# $(OGDIDIR)\lib\$(TARGET)\zlib_ogdi$(OGDIVER).lib
-
-# Uncomment for Xerces based GML support.
-#XERCES_DIR = c:\warmerda\supportlibs\xerces-c_2_6_0
-#XERCES_INCLUDE = -I$(XERCES_DIR)/include -I$(XERCES_DIR)/include/xercesc
-#XERCES_LIB = $(XERCES_DIR)/lib/xerces-c_2.lib
-
-# Uncomment the following for Interlis support. Note that a Xercex 2.x
-# is also required (see above). Also, Interlis support only works with
-# Visual Studio.NET or newer, not VC6.
-#ILI_ENABLED = YES
-
-# Uncomment for JasPer based JPEG2000 support
-#JASPER_DIR = d:\projects\jasper-1.700.2.uuid
-#JASPER_INCLUDE = -I$(JASPER_DIR)\src\libjasper\include -DJAS_WIN_MSVC_BUILD
-#JASPER_LIB = $(JASPER_DIR)\src\msvc\Win32_Release\libjasper.lib
-# Uncomment the following line if you have patched UUID-enabled version
-# of JasPer from ftp://ftp.remotesensing.org/gdal/
-#JASPER_INCLUDE = $(JASPER_INCLUDE) -DHAVE_JASPER_UUID
-
-# Uncommment if you have Kakadu 4.0 or newer
-#KAKDIR = D:\warmerda\jp2\kakadu
-
-# Uncomment the following and update to enable NCSA HDF Release 4 support.
-#HDF4_DIR = D:\warmerda\HDF41r5
-#HDF4_LIB = /LIBPATH:$(HDF4_DIR)\lib Ws2_32.lib
-
-# Uncomment the following and update to enable NCSA HDF Release 5 support.
-#HDF5_DIR = c:\warmerda\supportlibs\hdf5\5-164-win
-#SZIP_DIR = c:\warmerda\supportlibs\hdf5\szip20
-#HDF5_LIB = $(HDF5_DIR)\dll\hdf5dll.lib \
-# $(SZIP_DIR)\dll\szlibdll.lib
-
-# Uncomment the following for MrSID support.
-# You will likely require /MD and /EHsc in OPTFLAGS.
-#MRSID_DIR = d:\projects\mrsid
-#MRSID_INCLUDE = -I$(MRSID_DIR)\include\base -I$(MRSID_DIR)\include\support \
-# -I$(MRSID_DIR)\include\metadata \
-# -I$(MRSID_DIR)\include\mrsid_readers \
-# -I$(MRSID_DIR)\include\j2k_readers
-#MRSID_LIB = $(MRSID_DIR)\lib\Release_md\lti_dsdk_dll.lib advapi32.lib user32.lib
-# Enable these, if you have the MrSID Encoding SDK and want
-# to create MrSID files
-#MRSID_FLAGS = -DMRSID_ESDK $(MRSID_FLAGS)
-#MRSID_INCLUDE = -I$(MRSID_DIR)\include\mrsid_writers \
-# -I$(MRSID_DIR)\include\j2k_writers $(MRSID_INCLUDE)
-#MRSID_LIB = $(MRSID_DIR)\lib\Release_md\lti_esdk_dll.lib $(MRSID_LIB)
-# Enable the following if you prefer to build MrSID support as a plugin.
-#MRSID_PLUGIN = YES
-
-# PostGIS Libraries
-#PG_INC_DIR = n:\pkg\libpq_win32\include
-#PG_LIB = n:\pkg\libpq_win32\lib\libpqdll.lib wsock32.lib
-
-# MySQL Libraries
-# NOTE: Need /MT instead of /MD, also enable /EHsc switch.
-#MYSQL_INC_DIR = D:\Software\MySQLServer4.1\include
-#MYSQL_LIB = D:\Software\MySQLServer4.1\lib\opt\libmysql.lib advapi32.lib
-
-# SQLite Libraries
-#SQLITE_INC=-IN:\pkg\sqlite-win32
-#SQLITE_LIB=N:\pkg\sqlite-win32\sqlite3_i.lib
-
-# Informix Data Blade
-#INFORMIXDIR="C:\Program Files\IBM\Informix\Client-SDK"
-#IDB_INC=-I$(INFORMIXDIR)\incl\cpp -I$(INFORMIXDIR)\incl\dmi \
-# -I$(INFORMIXDIR)\incl\esql
-#IDB_LIB=$(INFORMIXDIR)\lib\cpp\libthc++.lib \
-# $(INFORMIXDIR)\lib\dmi\libthdmi.lib $(INFORMIXDIR)\lib\isqlt09a.lib
-
-# Uncomment the following and update to enable FME support.
-#FME_DIR = d:\Software\fme
-
-# Uncomment the following to enable FITS format support
-#FITS_INC_DIR = c:\dev32\usr\include\cfitsio
-#FITS_LIB = c:\dev32\usr\lib\cfitsio.lib
-
-# Uncomment the following to enable NetCDF format.
-#NETCDF_SETTING=yes
-#NETCDF_LIB=C:\Software\netcdf\lib\netcdf.lib
-#NETCDF_INC_DIR=C:\Software\netcdf\include
-# PROJ.4 stuff
-# Uncomment the following lines to link PROJ.4 library statically. Otherwise
-# it will be linked dynamically during runtime.
-#PROJ_FLAGS = -DPROJ_STATIC
-#PROJ_INCLUDE = -Id:\projects\proj.4\src
-#PROJ_LIBRARY = d:\projects\proj.4\src\proj_i.lib
-
-# Add ORACLE support.
-
-#ORACLE_HOME = C:/Software/Oracle/Product/10.1.0/db_1
-#OCI_PLUGIN = YES
-
-!IFDEF ORACLE_HOME
-OCI_LIB = $(ORACLE_HOME)\oci\lib\msvc\ociw32.lib \
- $(ORACLE_HOME)\oci\lib\msvc\oci.lib
-!ENDIF
-
-#SDE_ENABLED = YES
-#SDE_VERSION=90
-#SDE_PLUGIN = YES
-#SDE_SDK = C:\arcgis\arcsde
-#SDE_INC = $(SDE_SDK)\include
-#SDE_LIB = $(SDE_SDK)\lib\pe$(SDE_VERSION).lib \
-# $(SDE_SDK)\lib\sde$(SDE_VERSION).lib $(SDE_SDK)\lib\sg$(SDE_VERSION).lib
-
-# Uncomment to use libcurl (for WCS)
-#CURL_DIR=C:\curl-7.15.0
-#CURL_INC = -I$(CURL_DIR)/include
-#CURL_LIB = $(CURL_DIR)/libcurl.lib
-
-# Uncomment for GEOS support
-#GEOS_CFLAGS = -Ic:/warmerda/geos/capi -DHAVE_GEOS
-#GEOS_LIB = C:/warmerda/geos/source/geos_c_i.lib
-
-# Uncomment for Panorama GIS support
-#PANORAMA_INC = z:/panorama/include
-
-# Any extra libraries needed on this platform?
-ADD_LIBS =
-
-# Comment out the following if you want to build with Python support, but
-# you don't have Numeric Python installed (with include files). Numeric
-# integration may not work.
-#HAVE_NUMPY=1
-
-########### END OF STUFF THAT NORMALLY NEEDS TO BE UPDATED ##################
-
-
-# Location of MS Data Access SDK (not really needed anymore I think)
-#MSDASDK = D:\Software\MDAC_2.6
-
-GDAL_DLL = gdal$(VERSION).dll
-
-INC = -I$(GDAL_ROOT)\port -I$(GDAL_ROOT)\ogr -I$(GDAL_ROOT)\gcore \
- -I$(GDAL_ROOT)\alg
-
-#LINKER_FLAGS = /NODEFAULTLIB:LIBC
-#LINKER_FLAGS = /debug
-
-CFLAGS = $(OPTFLAGS) $(INC) $(EXTRAFLAGS)
-MAKE = nmake /nologo
-
-CC = cl
-
-CPLLIB = $(GDAL_ROOT)/port/cpl.lib
-
-!IFDEF DLLBUILD
-GDALLIB = $(GDAL_ROOT)/gdal_i.lib
-!ELSE
-GDALLIB = $(GDAL_ROOT)/gdal.lib
-!ENDIF
-
-!IFDEF ODBC_SUPPORTED
-ODBCLIB = odbc32.lib odbccp32.lib user32.lib
-!ENDIF
-
-!IFDEF MRSID_DIR
-!IFNDEF MRSID_PLUGIN
-MRSID_ELIB = $(MRSID_LIB)
-!ENDIF
-!ENDIF
-
-# Under win64, symbols for function names lack the underscore prefix
-# present on win32. Also the STDCALL calling convention is not used.
-!IFDEF WIN64
-!UNDEF STDCALL
-!ELSE
-SYM_PREFIX=_
-!ENDIF
-
-EXTERNAL_LIBS = $(OGDILIB) $(XERCES_LIB) $(OCI_LIB) $(PG_LIB) $(ODBCLIB) \
- $(ECWLIB) $(HDF4_LIB) $(FME_LIB) $(JASPER_LIB) $(MRSID_ELIB) \
- $(FITS_LIB) $(JPEG_LIB) $(PNG_LIB) $(NETCDF_LIB) $(PROJ4_LIB) \
- $(GEOTIFF_LIB) $(TIFF_LIB) $(PROJ_LIBRARY) $(SQLITE_LIB) \
- $(MYSQL_LIB) $(GEOS_LIB) $(HDF5_LIB) $(SDE_LIB) $(DWG_LIB) \
- $(IDB_LIB) $(CURL_LIB) $(ADD_LIBS)
-
-.c.obj:
- $(CC) $(CFLAGS) /c $*.c
-
-.cpp.obj:
- $(CC) $(CFLAGS) /c $*.cpp
-
+
+# 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.
+# But the paths *should* be absolute (relative paths mess up in submakefiles).
+
+GDAL_HOME = "C:\warmerda\bld"
+BINDIR = $(GDAL_HOME)\bin
+PY_INST_DIR = $(GDAL_HOME)\pymod
+LIBDIR = $(GDAL_HOME)\lib
+INCDIR = $(GDAL_HOME)\include
+DATADIR = $(GDAL_HOME)\data
+HTMLDIR = $(GDAL_HOME)\html
+
+# Set this to the installed directory containing python. If you don't
+# have python just let it point to a directory that does not exist (as now).
+PYDIR = "C:\Software\Python24"
+
+# Set the location of your SWIG installation
+SWIG = D:\swig\swig-1.3.25\swig.exe
+
+# Uncomment the first for an optimized build or the second for a debug build.
+OPTFLAGS= /nologo /Ox /MD /EHsc
+#OPTFLAGS= /nologo /Od /MDd /EHsc /Zi /Fd$(PDB_NAME)
+
+# Uncomment the following if you are building for 64-bit windows
+# (x64). You'll need to have PATH, INCLUDE and LIB set up for 64-bit
+# compiles.
+#WIN64=YES
+
+# If you don't want some entry points to have STDCALL conventions,
+# comment out the following and add -DCPL_DISABLE_STDCALL in OPTFLAGS.
+# This option has no effect on 64-bit windows.
+STDCALL=YES
+
+# Version number embedded in DLL name.
+VERSION = 14
+
+# Uncomment the following to link OGR utilities against main GDAL DLL
+# instead of statically linking against OGR libraries.
+DLLBUILD=1
+
+# Enable all OGR formats, or only raster formats? Comment out to disable
+# vector formats.
+INCLUDE_OGR_FRMTS = YES
+
+# Location of Visual C++ directory (only required for following SETARGV stuff)
+VCDIR = D:\Software\VStudio\VC98
+
+# Enable the following if VCDIR set properly, and you want the utility
+# programs to be able to expand wildcards.
+#SETARGV = "$(VCDIR)\lib\setargv.obj"
+
+# Comment out the following to disable BSB support.
+BSB_SUPPORTED = 1
+
+# Comment out the following to disable ODBC support.
+ODBC_SUPPORTED = 1
+
+# Comment out the following to disable JPEG support.
+JPEG_SUPPORTED = 1
+
+#if using an external jpeg library uncomment the follwing lines
+#JPEG_EXTERNAL_LIB = 1
+#JPEGDIR = c:/projects/jpeg-6b
+#JPEG_LIB = $(JPEGDIR)/libjpeg.lib
+
+#if using an external png library uncomment the follwing lines
+#PNG_EXTERNAL_LIB = 1
+#PNGDIR = c:/projects/libpng-1.0.8
+#PNG_LIB = $(PNGDIR)/libpng.lib
+
+# if using an external libtiff library
+#TIFF_INC = -Ic:/warmerda/libtiff/libtiff
+#TIFF_LIB = c:/warmerda/libtiff/libtiff/libtiff_i.lib
+
+# if using an external libgeotiff library
+#GEOTIFF_INC = -Ic:/warmerda/libgeotiff -Ic:/warmerda/libgeotiff/libxtiff
+#GEOTIFF_LIB = C:/warmerda/libgeotiff/geotiff_i.lib
+
+# Uncomment the following and update to enable ECW support.
+#ECWDIR = C:\warmerda\libecwj2-3.3
+#ECWLIB = $(ECWDIR)\Source\NCSBuildQmake\Debug\libecwj2.lib
+
+# DWG/DXF support via DWGdirect from Open Design Alliance
+
+#DWGDIRECT=C:\warmerda\DWGdirect
+#DWG_LIB_DIR=$(DWGDIRECT)\lib\VC6MD
+#DWG_LIB=$(DWG_LIB_DIR)\DD_AcisBuilder_dll.lib $(DWG_LIB_DIR)\DD_AcisRenderer_dll.lib $(DWG_LIB_DIR)\DD_Alloc_dll.lib $(DWG_LIB_DIR)\DD_BmpExport_dll.lib $(DWG_LIB_DIR)\DD_Br_dll.lib $(DWG_LIB_DIR)\DD_Db_dll.lib $(DWG_LIB_DIR)\DD_DwfExport_dll.lib $(DWG_LIB_DIR)\DD_DwfImport_dll.lib $(DWG_LIB_DIR)\DD_Ge_dll.lib $(DWG_LIB_DIR)\DD_Gi_dll.lib $(DWG_LIB_DIR)\DD_Gs_dll.lib $(DWG_LIB_DIR)\DD_ModelerGeometry_dll.lib $(DWG_LIB_DIR)\DD_Root_dll.lib $(DWG_LIB_DIR)\DD_Sm_dll.lib $(DWG_LIB_DIR)\DD_SpatialIndex_dll.lib $(DWG_LIB_DIR)\DD_VC6MD_OleDataAccess_dll.lib
+
+# Uncomment the following and update to enable OGDI support.
+#OGDIDIR = D:\warmerda\iii\devdir
+#OGDIVER = 31
+#OGDILIB = $(OGDIDIR)\lib\$(TARGET)\ogdi$(OGDIVER).lib \
+# $(OGDIDIR)\lib\$(TARGET)\zlib_ogdi$(OGDIVER).lib
+
+# Uncomment for Xerces based GML support.
+#XERCES_DIR = c:\warmerda\supportlibs\xerces-c_2_6_0
+#XERCES_INCLUDE = -I$(XERCES_DIR)/include -I$(XERCES_DIR)/include/xercesc
+#XERCES_LIB = $(XERCES_DIR)/lib/xerces-c_2.lib
+
+# Uncomment the following for Interlis support. Note that a Xercex 2.x
+# is also required (see above). Also, Interlis support only works with
+# Visual Studio.NET or newer, not VC6.
+#ILI_ENABLED = YES
+
+# Uncomment for JasPer based JPEG2000 support
+#JASPER_DIR = d:\projects\jasper-1.700.2.uuid
+#JASPER_INCLUDE = -I$(JASPER_DIR)\src\libjasper\include -DJAS_WIN_MSVC_BUILD
+#JASPER_LIB = $(JASPER_DIR)\src\msvc\Win32_Release\libjasper.lib
+# Uncomment the following line if you have patched UUID-enabled version
+# of JasPer from ftp://ftp.remotesensing.org/gdal/
+#JASPER_INCLUDE = $(JASPER_INCLUDE) -DHAVE_JASPER_UUID
+
+# Uncommment if you have Kakadu 4.0 or newer
+#KAKDIR = D:\warmerda\jp2\kakadu
+
+# Uncomment the following and update to enable NCSA HDF Release 4 support.
+#HDF4_DIR = D:\warmerda\HDF41r5
+#HDF4_LIB = /LIBPATH:$(HDF4_DIR)\lib Ws2_32.lib
+
+# Uncomment the following and update to enable NCSA HDF Release 5 support.
+#HDF5_DIR = c:\warmerda\supportlibs\hdf5\5-164-win
+#SZIP_DIR = c:\warmerda\supportlibs\hdf5\szip20
+#HDF5_LIB = $(HDF5_DIR)\dll\hdf5dll.lib \
+# $(SZIP_DIR)\dll\szlibdll.lib
+
+# Uncomment the following for MrSID support.
+# You will likely require /MD and /EHsc in OPTFLAGS.
+#MRSID_DIR = d:\projects\mrsid
+#MRSID_INCLUDE = -I$(MRSID_DIR)\include\base -I$(MRSID_DIR)\include\support \
+# -I$(MRSID_DIR)\include\metadata \
+# -I$(MRSID_DIR)\include\mrsid_readers \
+# -I$(MRSID_DIR)\include\j2k_readers
+#MRSID_LIB = $(MRSID_DIR)\lib\Release_md\lti_dsdk_dll.lib advapi32.lib user32.lib
+# Enable these, if you have the MrSID Encoding SDK and want
+# to create MrSID files
+#MRSID_FLAGS = -DMRSID_ESDK $(MRSID_FLAGS)
+#MRSID_INCLUDE = -I$(MRSID_DIR)\include\mrsid_writers \
+# -I$(MRSID_DIR)\include\j2k_writers $(MRSID_INCLUDE)
+#MRSID_LIB = $(MRSID_DIR)\lib\Release_md\lti_esdk_dll.lib $(MRSID_LIB)
+# Enable the following if you prefer to build MrSID support as a plugin.
+#MRSID_PLUGIN = YES
+
+# PostGIS Libraries
+#PG_INC_DIR = n:\pkg\libpq_win32\include
+#PG_LIB = n:\pkg\libpq_win32\lib\libpqdll.lib wsock32.lib
+
+# MySQL Libraries
+# NOTE: Need /MT instead of /MD, also enable /EHsc switch.
+#MYSQL_INC_DIR = D:\Software\MySQLServer4.1\include
+#MYSQL_LIB = D:\Software\MySQLServer4.1\lib\opt\libmysql.lib advapi32.lib
+
+# SQLite Libraries
+#SQLITE_INC=-IN:\pkg\sqlite-win32
+#SQLITE_LIB=N:\pkg\sqlite-win32\sqlite3_i.lib
+
+# Informix Data Blade
+#INFORMIXDIR="C:\Program Files\IBM\Informix\Client-SDK"
+#IDB_INC=-I$(INFORMIXDIR)\incl\cpp -I$(INFORMIXDIR)\incl\dmi \
+# -I$(INFORMIXDIR)\incl\esql
+#IDB_LIB=$(INFORMIXDIR)\lib\cpp\libthc++.lib \
+# $(INFORMIXDIR)\lib\dmi\libthdmi.lib $(INFORMIXDIR)\lib\isqlt09a.lib
+
+# Uncomment the following and update to enable FME support.
+#FME_DIR = d:\Software\fme
+
+# Uncomment the following to enable FITS format support
+#FITS_INC_DIR = c:\dev32\usr\include\cfitsio
+#FITS_LIB = c:\dev32\usr\lib\cfitsio.lib
+
+# Uncomment the following to enable NetCDF format.
+#NETCDF_SETTING=yes
+#NETCDF_LIB=C:\Software\netcdf\lib\netcdf.lib
+#NETCDF_INC_DIR=C:\Software\netcdf\include
+# PROJ.4 stuff
+# Uncomment the following lines to link PROJ.4 library statically. Otherwise
+# it will be linked dynamically during runtime.
+#PROJ_FLAGS = -DPROJ_STATIC
+#PROJ_INCLUDE = -Id:\projects\proj.4\src
+#PROJ_LIBRARY = d:\projects\proj.4\src\proj_i.lib
+
+# Add ORACLE support.
+
+#ORACLE_HOME = C:/Software/Oracle/Product/10.1.0/db_1
+#OCI_PLUGIN = YES
+
+!IFDEF ORACLE_HOME
+OCI_LIB = $(ORACLE_HOME)\oci\lib\msvc\ociw32.lib \
+ $(ORACLE_HOME)\oci\lib\msvc\oci.lib
+!ENDIF
+
+#SDE_ENABLED = YES
+#SDE_VERSION=90
+#SDE_PLUGIN = YES
+#SDE_SDK = C:\arcgis\arcsde
+#SDE_INC = $(SDE_SDK)\include
+#SDE_LIB = $(SDE_SDK)\lib\pe$(SDE_VERSION).lib \
+# $(SDE_SDK)\lib\sde$(SDE_VERSION).lib $(SDE_SDK)\lib\sg$(SDE_VERSION).lib
+
+# Uncomment to use libcurl (for WCS)
+#CURL_DIR=C:\curl-7.15.0
+#CURL_INC = -I$(CURL_DIR)/include
+#CURL_LIB = $(CURL_DIR)/libcurl.lib
+
+# Uncomment for GEOS support
+#GEOS_CFLAGS = -Ic:/warmerda/geos/capi -DHAVE_GEOS
+#GEOS_LIB = C:/warmerda/geos/source/geos_c_i.lib
+
+# Uncomment for Panorama GIS support
+#PANORAMA_INC = z:/panorama/include
+
+# Any extra libraries needed on this platform?
+ADD_LIBS =
+
+# Comment out the following if you want to build with Python support, but
+# you don't have Numeric Python installed (with include files). Numeric
+# integration may not work.
+#HAVE_NUMPY=1
+
+########### END OF STUFF THAT NORMALLY NEEDS TO BE UPDATED ##################
+
+
+# Location of MS Data Access SDK (not really needed anymore I think)
+#MSDASDK = D:\Software\MDAC_2.6
+
+GDAL_DLL = gdal$(VERSION).dll
+
+INC = -I$(GDAL_ROOT)\port -I$(GDAL_ROOT)\ogr -I$(GDAL_ROOT)\gcore \
+ -I$(GDAL_ROOT)\alg
+
+#LINKER_FLAGS = /NODEFAULTLIB:LIBC
+#LINKER_FLAGS = /debug
+
+CFLAGS = $(OPTFLAGS) $(INC) $(EXTRAFLAGS)
+MAKE = nmake /nologo
+
+CC = cl
+
+CPLLIB = $(GDAL_ROOT)/port/cpl.lib
+
+!IFDEF DLLBUILD
+GDALLIB = $(GDAL_ROOT)/gdal_i.lib
+!ELSE
+GDALLIB = $(GDAL_ROOT)/gdal.lib
+!ENDIF
+
+!IFDEF ODBC_SUPPORTED
+ODBCLIB = odbc32.lib odbccp32.lib user32.lib
+!ENDIF
+
+!IFDEF MRSID_DIR
+!IFNDEF MRSID_PLUGIN
+MRSID_ELIB = $(MRSID_LIB)
+!ENDIF
+!ENDIF
+
+# Under win64, symbols for function names lack the underscore prefix
+# present on win32. Also the STDCALL calling convention is not used.
+!IFDEF WIN64
+!UNDEF STDCALL
+!ELSE
+SYM_PREFIX=_
+!ENDIF
+
+EXTERNAL_LIBS = $(OGDILIB) $(XERCES_LIB) $(OCI_LIB) $(PG_LIB) $(ODBCLIB) \
+ $(ECWLIB) $(HDF4_LIB) $(FME_LIB) $(JASPER_LIB) $(MRSID_ELIB) \
+ $(FITS_LIB) $(JPEG_LIB) $(PNG_LIB) $(NETCDF_LIB) $(PROJ4_LIB) \
+ $(GEOTIFF_LIB) $(TIFF_LIB) $(PROJ_LIBRARY) $(SQLITE_LIB) \
+ $(MYSQL_LIB) $(GEOS_LIB) $(HDF5_LIB) $(SDE_LIB) $(DWG_LIB) \
+ $(IDB_LIB) $(CURL_LIB) $(ADD_LIBS)
+
+.c.obj:
+ $(CC) $(CFLAGS) /c $*.c
+
+.cpp.obj:
+ $(CC) $(CFLAGS) /c $*.cpp
+
Modified: trunk/MgDev/Oem/gdal-1.4.0/ogr/Makefile
===================================================================
--- trunk/MgDev/Oem/gdal-1.4.0/ogr/Makefile 2007-03-21 00:47:37 UTC (rev 1308)
+++ trunk/MgDev/Oem/gdal-1.4.0/ogr/Makefile 2007-03-21 00:50:25 UTC (rev 1309)
@@ -1,144 +1,145 @@
-
-LINKFLAGS = /Zi /MTd
-EXTRAFLAGS = -I$(MSDASDK)\inc \
- -I"$(VCDIR)\ATL\Include" -DWIN32 \
- -I. -Iogrsf_frmts -I..\frmts\gtiff\libgeotiff \
- $(PROJ_FLAGS) $(PROJ_INCLUDE) $(GEOS_CFLAGS)
-
-GDAL_ROOT = ..
-
-!INCLUDE ..\nmake.opt
-
-!IFDEF INCLUDE_OGR_FRMTS
-EXTRAFLAGS = $(EXTRAFLAGS) -DOGR_ENABLED
-!ENDIF
-
-OLE_LIBS = oledb.lib ole32.lib oleaut32.lib
-
-ALL_LIBS = $(OLE_LIBS) $(GDAL_ROOT)/port/cpl.lib $(EXTERNAL_LIBS) $(LIBS)
-
-OGR_FRMTS = ogrsf_frmts\ogrsf_frmts.lib ogrsf_frmts\ogrsf_frmts_sup.lib
-OBJ_OGR = ogrgeometryfactory.obj ogrpoint.obj ogrcurve.obj ogr_api.obj \
- ogrlinestring.obj ogrpolygon.obj ogrlinearring.obj \
- ogrutils.obj ogrgeometry.obj ogrgeometrycollection.obj \
- ogrmultipolygon.obj ogrmultilinestring.obj ogr_opt.obj \
- ogrmultipoint.obj ogrfeature.obj ogrfeaturedefn.obj \
- ogrfielddefn.obj ogr_srsnode.obj ogrspatialreference.obj \
- ogr_srs_proj4.obj ogr_fromepsg.obj ogrct.obj swq.obj \
- ogrfeaturestyle.obj ogr_srs_esri.obj ogrfeaturequery.obj \
- ogr_srs_validate.obj ogr_srs_xml.obj ograssemblepolygon.obj \
- ogr2gmlgeometry.obj gml2ogrgeometry.obj ogr_srs_pci.obj \
- ogr_srs_usgs.obj ogr_srs_dict.obj ogr_srs_panorama.obj
-
-OBJ_OLEDB = oledb_sup.obj \
- sfcenumerator.obj sfcdatasource.obj sfctable.obj
-
-!IFDEF DLLBUILD
-LINKARGS = ..\gdal_i.lib $(LIBS)
-DEPLIBS = ..\gdal_i.lib
-!ELSE
-LINKARGS = $(OBJ_OGR) $(OGR_FRMTS) $(ALL_LIBS)
-DEPLIBS = $(OGR_FRMTS)
-!ENDIF
-
-default: ogr.lib ogrinfo.exe test_ogrsf.exe ogr2ogr.exe ogrtindex.exe
-
-ogrsf_frmts\ogrsf_frmts.lib:
-
-sublibs: frmts
-
-frmts:
- cd ogrsf_frmts
- $(MAKE)
- cd ..
-
-oledb: ogroledb.lib
- cd sfcom_oledb
- $(MAKE)
- cd ..
-
-all: frmts default oledb sfcdump.exe
-
-geometryidl.h: geometryidl.idl spatialreferenceidl.h
- midl geometryidl.idl
-
-spatialreferenceidl.h: spatialreferenceidl.idl
- midl spatialreferenceidl.idl
-
-ogr.lib: $(OBJ_OGR)
- lib /out:ogr.lib $(OBJ_OGR)
-
-ogroledb.lib: $(OBJ_OLEDB)
- lib /out:ogroledb.lib $(OBJ_OLEDB)
-
-sfcdump.exe: geometryidl.h sfcdump.obj ogr.lib ogroledb.lib
- cl $(LINKFLAGS) sfcdump.obj ogroledb.lib $(LINKARGS) \
- /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-test1.exe: test1.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) test1.obj $(OBJ_OGR) $(ALL_LIBS) \
- /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-test2.exe: test2.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) test2.obj $(OBJ_OGR) $(OGR_FRMTS) \
- $(ALL_LIBS) /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-test3.exe: test3.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) test3.obj $(OBJ_OGR) $(OGR_FRMTS) \
- $(ALL_LIBS) /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-test_ogrsf.exe: test_ogrsf.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) test_ogrsf.obj $(OBJ_OGR) $(OGR_FRMTS) \
- $(ALL_LIBS) /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-test_rep.exe: test_rep.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) test_rep.obj $(OBJ_OGR) $(OGR_FRMTS) \
- $(ALL_LIBS) /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-testepsg.exe: testepsg.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) testepsg.obj $(LINKARGS) /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-ogrinfo.exe: ogrinfo.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) ogrinfo.obj $(LINKARGS) /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-ogr2ogr.exe: ogr2ogr.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) ogr2ogr.obj $(LINKARGS) /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-ogrtindex.exe: ogrtindex.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) ogrtindex.obj $(SETARGV) $(LINKARGS) /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-sdts2mi.exe: sdts2mi.obj $(OBJ_OGR) $(DEPLIBS)
- cl $(LINKFLAGS) sdts2mi.obj $(OBJ_OGR) $(OGR_FRMTS) \
- $(ALL_LIBS) /link $(LINKER_FLAGS)
- if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
-
-install: default
- copy ogrinfo.exe $(BINDIR)
- copy ogr2ogr.exe $(BINDIR)
- copy ogrtindex.exe $(BINDIR)
-
-clean:
- -del *.obj
- -del *.exe
- -del *.exe.manifest
- -del *.lib
- -del *.pdb
- -del *.ilk
-
-allclean: clean
- cd ogrsf_frmts
- $(MAKE) clean
- cd ..\sfcom_oledb
- $(MAKE) clean
- cd ..
-
+
+LINKFLAGS = /Zi /MTd
+EXTRAFLAGS = -I$(MSDASDK)\inc \
+ -I"$(VCDIR)\ATL\Include" -DWIN32 \
+ -I. -Iogrsf_frmts -I..\frmts\gtiff\libgeotiff \
+ $(PROJ_FLAGS) $(PROJ_INCLUDE) $(GEOS_CFLAGS)
+
+GDAL_ROOT = ..
+PDB_NAME = ogr.pdb
+
+!INCLUDE ..\nmake.opt
+
+!IFDEF INCLUDE_OGR_FRMTS
+EXTRAFLAGS = $(EXTRAFLAGS) -DOGR_ENABLED
+!ENDIF
+
+OLE_LIBS = oledb.lib ole32.lib oleaut32.lib
+
+ALL_LIBS = $(OLE_LIBS) $(GDAL_ROOT)/port/cpl.lib $(EXTERNAL_LIBS) $(LIBS)
+
+OGR_FRMTS = ogrsf_frmts\ogrsf_frmts.lib ogrsf_frmts\ogrsf_frmts_sup.lib
+OBJ_OGR = ogrgeometryfactory.obj ogrpoint.obj ogrcurve.obj ogr_api.obj \
+ ogrlinestring.obj ogrpolygon.obj ogrlinearring.obj \
+ ogrutils.obj ogrgeometry.obj ogrgeometrycollection.obj \
+ ogrmultipolygon.obj ogrmultilinestring.obj ogr_opt.obj \
+ ogrmultipoint.obj ogrfeature.obj ogrfeaturedefn.obj \
+ ogrfielddefn.obj ogr_srsnode.obj ogrspatialreference.obj \
+ ogr_srs_proj4.obj ogr_fromepsg.obj ogrct.obj swq.obj \
+ ogrfeaturestyle.obj ogr_srs_esri.obj ogrfeaturequery.obj \
+ ogr_srs_validate.obj ogr_srs_xml.obj ograssemblepolygon.obj \
+ ogr2gmlgeometry.obj gml2ogrgeometry.obj ogr_srs_pci.obj \
+ ogr_srs_usgs.obj ogr_srs_dict.obj ogr_srs_panorama.obj
+
+OBJ_OLEDB = oledb_sup.obj \
+ sfcenumerator.obj sfcdatasource.obj sfctable.obj
+
+!IFDEF DLLBUILD
+LINKARGS = ..\gdal_i.lib $(LIBS)
+DEPLIBS = ..\gdal_i.lib
+!ELSE
+LINKARGS = $(OBJ_OGR) $(OGR_FRMTS) $(ALL_LIBS)
+DEPLIBS = $(OGR_FRMTS)
+!ENDIF
+
+default: ogr.lib ogrinfo.exe test_ogrsf.exe ogr2ogr.exe ogrtindex.exe
+
+ogrsf_frmts\ogrsf_frmts.lib:
+
+sublibs: frmts
+
+frmts:
+ cd ogrsf_frmts
+ $(MAKE)
+ cd ..
+
+oledb: ogroledb.lib
+ cd sfcom_oledb
+ $(MAKE)
+ cd ..
+
+all: frmts default oledb sfcdump.exe
+
+geometryidl.h: geometryidl.idl spatialreferenceidl.h
+ midl geometryidl.idl
+
+spatialreferenceidl.h: spatialreferenceidl.idl
+ midl spatialreferenceidl.idl
+
+ogr.lib: $(OBJ_OGR)
+ lib /out:ogr.lib $(OBJ_OGR)
+
+ogroledb.lib: $(OBJ_OLEDB)
+ lib /out:ogroledb.lib $(OBJ_OLEDB)
+
+sfcdump.exe: geometryidl.h sfcdump.obj ogr.lib ogroledb.lib
+ cl $(LINKFLAGS) sfcdump.obj ogroledb.lib $(LINKARGS) \
+ /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+test1.exe: test1.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) test1.obj $(OBJ_OGR) $(ALL_LIBS) \
+ /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+test2.exe: test2.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) test2.obj $(OBJ_OGR) $(OGR_FRMTS) \
+ $(ALL_LIBS) /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+test3.exe: test3.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) test3.obj $(OBJ_OGR) $(OGR_FRMTS) \
+ $(ALL_LIBS) /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+test_ogrsf.exe: test_ogrsf.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) test_ogrsf.obj $(OBJ_OGR) $(OGR_FRMTS) \
+ $(ALL_LIBS) /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+test_rep.exe: test_rep.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) test_rep.obj $(OBJ_OGR) $(OGR_FRMTS) \
+ $(ALL_LIBS) /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+testepsg.exe: testepsg.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) testepsg.obj $(LINKARGS) /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+ogrinfo.exe: ogrinfo.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) ogrinfo.obj $(LINKARGS) /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+ogr2ogr.exe: ogr2ogr.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) ogr2ogr.obj $(LINKARGS) /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+ogrtindex.exe: ogrtindex.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) ogrtindex.obj $(SETARGV) $(LINKARGS) /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+sdts2mi.exe: sdts2mi.obj $(OBJ_OGR) $(DEPLIBS)
+ cl $(LINKFLAGS) sdts2mi.obj $(OBJ_OGR) $(OGR_FRMTS) \
+ $(ALL_LIBS) /link $(LINKER_FLAGS)
+ if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
+
+install: default
+ copy ogrinfo.exe $(BINDIR)
+ copy ogr2ogr.exe $(BINDIR)
+ copy ogrtindex.exe $(BINDIR)
+
+clean:
+ -del *.obj
+ -del *.exe
+ -del *.exe.manifest
+ -del *.lib
+ -del *.pdb
+ -del *.ilk
+
+allclean: clean
+ cd ogrsf_frmts
+ $(MAKE) clean
+ cd ..\sfcom_oledb
+ $(MAKE) clean
+ cd ..
+
Added: trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr.vcproj
===================================================================
--- trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr.vcproj (rev 0)
+++ trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr.vcproj 2007-03-21 00:50:25 UTC (rev 1309)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="OGR"
+ ProjectGUID="{E8F6DBAE-C078-4826-C885-01EFA74219F6}"
+ Keyword="MakeFileProj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="0"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ >
+ <Tool
+ Name="VCNMakeTool"
+ BuildCommandLine="nmake /f makefile ogr.lib"
+ ReBuildCommandLine="nmake /f makefile clean ogr.lib"
+ CleanCommandLine="nmake /f makefile clean"
+ Output=""
+ PreprocessorDefinitions=""
+ IncludeSearchPath=""
+ ForcedIncludes=""
+ AssemblySearchPath=""
+ ForcedUsingAssemblies=""
+ CompileAsManaged=""
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="0"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ >
+ <Tool
+ Name="VCNMakeTool"
+ BuildCommandLine="nmake /f makefile ogr.lib"
+ ReBuildCommandLine="nmake /f makefile clean ogr.lib"
+ CleanCommandLine="nmake /f makefile clean"
+ Output=""
+ PreprocessorDefinitions=""
+ IncludeSearchPath=""
+ ForcedIncludes=""
+ AssemblySearchPath=""
+ ForcedUsingAssemblies=""
+ CompileAsManaged=""
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\Makefile"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Property changes on: trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr.vcproj
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr_srs_api.h
===================================================================
--- trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr_srs_api.h 2007-03-21 00:47:37 UTC (rev 1308)
+++ trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr_srs_api.h 2007-03-21 00:50:25 UTC (rev 1309)
@@ -1,738 +1,777 @@
-/******************************************************************************
- * $Id: ogr_srs_api.h,v 1.58 2006/04/11 18:45:41 fwarmerdam Exp $
- *
- * Project: OpenGIS Simple Features Reference Implementation
- * Purpose: C API and constant declarations for OGR Spatial References.
- * Author: Frank Warmerdam, warmerdam at 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: ogr_srs_api.h,v $
- * Revision 1.58 2006/04/11 18:45:41 fwarmerdam
- * Fixed definition of a chain.
- *
- * Revision 1.57 2006/03/31 17:44:20 fwarmerdam
- * header updates
- *
- * Revision 1.56 2005/12/01 04:59:46 fwarmerdam
- * added two point equidistant support
- *
- * Revision 1.55 2005/10/10 14:45:47 dron
- * Added OSRImportFromPanorama()/OSRExportToPanorama() wrappers.
- *
- * Revision 1.54 2005/10/03 18:13:28 fwarmerdam
- * Fixed prototype for OSRSetGEOS().
- *
- * Revision 1.53 2005/09/21 00:50:08 fwarmerdam
- * Added Release
- *
- * Revision 1.52 2005/05/09 15:39:44 fwarmerdam
- * Added TM_MI_21 as per email from Safe.
- *
- * Revision 1.51 2005/04/06 00:02:05 fwarmerdam
- * various osr and oct functions now stdcall
- *
- * Revision 1.50 2005/02/17 16:34:17 fwarmerdam
- * OSRCloneCS() should be OSRClone().
- *
- * Revision 1.49 2005/02/11 14:21:28 fwarmerdam
- * added GEOS projection support
- *
- * Revision 1.48 2005/01/05 21:02:33 fwarmerdam
- * added Goode Homolosine
- *
- * Revision 1.47 2004/11/11 18:28:45 fwarmerdam
- * added Bonne projection support
- *
- * Revision 1.46 2004/09/23 16:20:13 fwarmerdam
- * added OSRCleanup
- *
- * Revision 1.45 2004/05/12 19:25:54 dron
- * SRS_DN_WGS72 constant added.
- *
- * Revision 1.44 2004/05/10 17:05:14 warmerda
- * added AutoIdentifyEPSG()
- *
- * Revision 1.43 2004/05/06 19:26:04 dron
- * Added OSRSetProjection() function.
- *
- * Revision 1.42 2004/03/04 18:04:45 warmerda
- * added importFromDict() support
- *
- * Revision 1.41 2004/02/07 17:31:21 dron
- * Added OSRExportToUSGS() method.
- *
- * Revision 1.40 2004/02/05 17:07:59 dron
- * Support for HOM projection, specified by two points on centerline.
- *
- * Revision 1.39 2004/02/01 14:23:29 dron
- * Added OSRImportFromUSGS().
- *
- * Revision 1.38 2004/01/24 09:35:00 warmerda
- * added TransformEx support to capture per point reprojection failure
- *
- * Revision 1.37 2003/09/09 07:49:52 dron
- * Added OSRExportToPCI().
- *
- * Revision 1.36 2003/08/31 14:51:01 dron
- * Added OSRImportFromPCI().
- *
- * Revision 1.35 2003/08/18 13:26:01 warmerda
- * added SetTMVariant() and related definitions
- *
- * Revision 1.34 2003/06/21 23:24:36 warmerda
- * added Set/Get TOWGS84 calls
- *
- * Revision 1.33 2003/06/19 17:10:26 warmerda
- * a couple fixes in last commit
- *
- * Revision 1.32 2003/06/18 18:24:17 warmerda
- * added projection specific set methods to C API
- *
- * Revision 1.31 2003/06/10 09:31:12 dron
- * Added OSRSetAngularUnits() and OSRGetAngularUnits().
- *
- * Revision 1.30 2003/05/30 15:39:53 warmerda
- * Added override units capability for SetStatePlane()
- *
- * Revision 1.29 2003/03/21 22:15:11 warmerda
- * added C XML import/export entry points
- *
- * Revision 1.28 2003/03/12 14:29:34 warmerda
- * Rename OGRAxisOrientation and OGRDatumType values to avoid conflicts with
- * the real OGC definitions in applications such as Cadcorps.
- *
- * Revision 1.27 2003/02/25 04:53:38 warmerda
- * added OSRCopyGeogCSFrom
- *
- * Revision 1.26 2003/02/06 04:53:12 warmerda
- * added Fixup() method
- *
- * Revision 1.25 2003/01/08 18:14:28 warmerda
- * added FixupOrdering()
- *
- * Revision 1.24 2002/12/16 17:07:13 warmerda
- * added NormProjParm functions, and OSRGetPrimeMeridian
- *
- * Revision 1.23 2002/12/14 22:59:14 warmerda
- * added Krovak in ESRI compatible way
- *
- * Revision 1.22 2002/12/09 18:55:07 warmerda
- * moved DMS stuff to gdal/port
- *
- * Revision 1.21 2002/12/09 16:11:53 warmerda
- * added DMS translation
- *
- * Revision 1.20 2002/11/25 16:12:54 warmerda
- * added GetAuthorityCode/Name
- *
- * Revision 1.19 2002/09/26 18:13:25 warmerda
- * avoid double def
- *
- * Revision 1.18 2002/06/11 18:02:03 warmerda
- * add PROJ.4 normalization and EPSG support
- *
- * Revision 1.17 2001/10/11 19:27:12 warmerda
- * upgraded validation infrastructure
- *
- * Revision 1.16 2001/10/10 20:42:43 warmerda
- * added ESRI WKT morphing support
- *
- * Revision 1.15 2001/09/21 16:21:02 warmerda
- * added Clear(), and SetFromUserInput() methods
- *
- * Revision 1.14 2000/11/09 06:21:32 warmerda
- * added limited ESRI prj support
- *
- * Revision 1.13 2000/10/20 04:19:38 warmerda
- * added setstateplane
- *
- * Revision 1.12 2000/10/16 21:26:07 warmerda
- * added some level of LOCAL_CS support
- *
- * Revision 1.11 2000/09/01 20:58:01 warmerda
- * added CPL_DLL for entry points
- *
- * Revision 1.10 2000/08/30 20:06:14 warmerda
- * added projection method list functions
- *
- * Revision 1.9 2000/08/28 20:13:23 warmerda
- * added importFromProj4
- *
- * Revision 1.8 2000/07/11 01:02:06 warmerda
- * added ExportToProj4()
- *
- * Revision 1.7 2000/07/09 20:48:02 warmerda
- * added exportToPrettyWkt
- *
- * Revision 1.6 2000/05/30 22:45:44 warmerda
- * added OSRCloneGeogCS()
- *
- * Revision 1.5 2000/04/26 18:25:56 warmerda
- * added missing CPL_DLL attributes
- *
- * Revision 1.4 2000/03/22 01:09:43 warmerda
- * added SetProjCS and SetWellKnownTextCS
- *
- * Revision 1.3 2000/03/20 23:33:51 warmerda
- * updated docs a bit
- *
- * Revision 1.2 2000/03/20 22:39:31 warmerda
- * Added C API.
- *
- * Revision 1.1 2000/03/16 19:04:14 warmerda
- * New
- *
- */
-
-#ifndef _OGR_SRS_API_H_INCLUDED
-#define _OGR_SRS_API_H_INCLUDED
-
-#include "ogr_core.h"
-
-CPL_C_START
-
-/**
- * \file ogr_srs_api.h
- *
- * C spatial reference system services and defines.
- *
- * See also: ogr_spatialref.h
- */
-
-/* -------------------------------------------------------------------- */
-/* Axis orientations (corresponds to CS_AxisOrientationEnum). */
-/* -------------------------------------------------------------------- */
-typedef enum {
- OAO_Other=0,
- OAO_North=1,
- OAO_South=2,
- OAO_East=3,
- OAO_West=4,
- OAO_Up=5,
- OAO_Down=6
-} OGRAxisOrientation;
-
-/* -------------------------------------------------------------------- */
-/* Datum types (corresponds to CS_DatumType). */
-/* -------------------------------------------------------------------- */
-
-typedef enum {
- ODT_HD_Min=1000,
- ODT_HD_Other=1000,
- ODT_HD_Classic=1001,
- ODT_HD_Geocentric=1002,
- ODT_HD_Max=1999,
- ODT_VD_Min=2000,
- ODT_VD_Other=2000,
- ODT_VD_Orthometric=2001,
- ODT_VD_Ellipsoidal=2002,
- ODT_VD_AltitudeBarometric=2003,
- ODT_VD_Normal=2004,
- ODT_VD_GeoidModelDerived=2005,
- ODT_VD_Depth=2006,
- ODT_VD_Max=2999,
- ODT_LD_Min=10000,
- ODT_LD_Max=32767
-} OGRDatumType;
-
-/* ==================================================================== */
-/* Some "standard" strings. */
-/* ==================================================================== */
-
-#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_BONNE "Bonne"
-#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_GEOSTATIONARY_SATELLITE "Geostationary_Satellite"
-#define SRS_PT_GOODE_HOMOLOSINE "Goode_Homolosine"
-#define SRS_PT_GNOMONIC "Gnomonic"
-#define SRS_PT_HOTINE_OBLIQUE_MERCATOR \
- "Hotine_Oblique_Mercator"
-#define SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN \
- "Hotine_Oblique_Mercator_Two_Point_Natural_Origin"
-#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"
-
-/* special mapinfo variants on Transverse Mercator */
-#define SRS_PT_TRANSVERSE_MERCATOR_MI_21 \
- "Transverse_Mercator_MapInfo_21"
-#define SRS_PT_TRANSVERSE_MERCATOR_MI_22 \
- "Transverse_Mercator_MapInfo_22"
-#define SRS_PT_TRANSVERSE_MERCATOR_MI_23 \
- "Transverse_Mercator_MapInfo_23"
-#define SRS_PT_TRANSVERSE_MERCATOR_MI_24 \
- "Transverse_Mercator_MapInfo_24"
-#define SRS_PT_TRANSVERSE_MERCATOR_MI_25 \
- "Transverse_Mercator_MapInfo_25"
-
-#define SRS_PT_TUNISIA_MINING_GRID \
- "Tunisia_Mining_Grid"
-#define SRS_PT_TWO_POINT_EQUIDISTANT \
- "Two_Point_Equidistant"
-#define SRS_PT_VANDERGRINTEN "VanDerGrinten"
-#define SRS_PT_KROVAK "Krovak"
-
-
-
-#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_PSEUDO_STD_PARALLEL_1 "pseudo_standard_parallel_1"
-#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_SATELLITE_HEIGHT "satellite_height"
-#define SRS_PP_FIPSZONE "fipszone"
-#define SRS_PP_ZONE "zone"
-#define SRS_PP_LATITUDE_OF_1ST_POINT "Latitude_Of_1st_Point"
-#define SRS_PP_LONGITUDE_OF_1ST_POINT "Longitude_Of_1st_Point"
-#define SRS_PP_LATITUDE_OF_2ND_POINT "Latitude_Of_2nd_Point"
-#define SRS_PP_LONGITUDE_OF_2ND_POINT "Longitude_Of_2nd_Point"
-
-#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 "20.116684023368047"
-#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_WGS72 "WGS_1972"
-#define SRS_DN_WGS84 "WGS_1984"
-
-#define SRS_WGS84_SEMIMAJOR 6378137.0
-#define SRS_WGS84_INVFLATTENING 298.257223563
-
-/* -------------------------------------------------------------------- */
-/* C Wrappers for C++ objects and methods. */
-/* -------------------------------------------------------------------- */
-#ifndef _DEFINED_OGRSpatialReferenceH
-#define _DEFINED_OGRSpatialReferenceH
-
-typedef void *OGRSpatialReferenceH;
-typedef void *OGRCoordinateTransformationH;
-
-#endif
-
-
-OGRSpatialReferenceH CPL_DLL CPL_STDCALL
- OSRNewSpatialReference( const char * /* = NULL */);
-OGRSpatialReferenceH CPL_DLL CPL_STDCALL OSRCloneGeogCS( OGRSpatialReferenceH );
-OGRSpatialReferenceH CPL_DLL CPL_STDCALL OSRClone( OGRSpatialReferenceH );
-void CPL_DLL CPL_STDCALL OSRDestroySpatialReference( OGRSpatialReferenceH );
-
-int CPL_DLL OSRReference( OGRSpatialReferenceH );
-int CPL_DLL OSRDereference( OGRSpatialReferenceH );
-void CPL_DLL OSRRelease( OGRSpatialReferenceH );
-
-OGRErr CPL_DLL OSRValidate( OGRSpatialReferenceH );
-OGRErr CPL_DLL OSRFixupOrdering( OGRSpatialReferenceH );
-OGRErr CPL_DLL OSRFixup( OGRSpatialReferenceH );
-OGRErr CPL_DLL OSRStripCTParms( OGRSpatialReferenceH );
-
-OGRErr CPL_DLL CPL_STDCALL OSRImportFromEPSG( OGRSpatialReferenceH, int );
-OGRErr CPL_DLL OSRImportFromWkt( OGRSpatialReferenceH, char ** );
-OGRErr CPL_DLL OSRImportFromProj4( OGRSpatialReferenceH, const char *);
-OGRErr CPL_DLL OSRImportFromESRI( OGRSpatialReferenceH, char **);
-OGRErr CPL_DLL OSRImportFromPCI( OGRSpatialReferenceH hSRS, const char *,
- const char *, double * );
-OGRErr CPL_DLL OSRImportFromUSGS( OGRSpatialReferenceH,
- long, long, double *, long);
-OGRErr CPL_DLL OSRImportFromXML( OGRSpatialReferenceH, const char * );
-OGRErr CPL_DLL OSRImportFromDict( OGRSpatialReferenceH, const char *,
- const char * );
-OGRErr OSRImportFromPanorama( OGRSpatialReferenceH, long, long, long, long,
- double, double, double, double );
-
-OGRErr CPL_DLL CPL_STDCALL OSRExportToWkt( OGRSpatialReferenceH, char ** );
-OGRErr CPL_DLL CPL_STDCALL OSRExportToPrettyWkt( OGRSpatialReferenceH, char **, int);
-OGRErr CPL_DLL CPL_STDCALL OSRExportToProj4( OGRSpatialReferenceH, char **);
-OGRErr CPL_DLL OSRExportToPCI( OGRSpatialReferenceH, char **, char **,
- double ** );
-OGRErr CPL_DLL OSRExportToUSGS( OGRSpatialReferenceH, long *, long *,
- double **, long * );
-OGRErr CPL_DLL OSRExportToXML( OGRSpatialReferenceH, char **, const char * );
-OGRErr OSRExportToPanorama( OGRSpatialReferenceH, long *, long *, long *,
- long *, double *, double *, double *, double * );
-
-OGRErr CPL_DLL OSRMorphToESRI( OGRSpatialReferenceH );
-OGRErr CPL_DLL OSRMorphFromESRI( OGRSpatialReferenceH );
-
-OGRErr CPL_DLL CPL_STDCALL OSRSetAttrValue( OGRSpatialReferenceH hSRS,
- const char * pszNodePath,
- const char * pszNewNodeValue );
-const char CPL_DLL * CPL_STDCALL OSRGetAttrValue( OGRSpatialReferenceH hSRS,
- const char * pszName, int iChild /* = 0 */ );
-
-OGRErr CPL_DLL OSRSetAngularUnits( OGRSpatialReferenceH, const char *, double );
-double CPL_DLL OSRGetAngularUnits( OGRSpatialReferenceH, char ** );
-OGRErr CPL_DLL OSRSetLinearUnits( OGRSpatialReferenceH, const char *, double );
-double CPL_DLL OSRGetLinearUnits( OGRSpatialReferenceH, char ** );
-
-double CPL_DLL OSRGetPrimeMeridian( OGRSpatialReferenceH, char ** );
-
-int CPL_DLL OSRIsGeographic( OGRSpatialReferenceH );
-int CPL_DLL OSRIsLocal( OGRSpatialReferenceH );
-int CPL_DLL OSRIsProjected( OGRSpatialReferenceH );
-int CPL_DLL OSRIsSameGeogCS( OGRSpatialReferenceH, OGRSpatialReferenceH );
-int CPL_DLL OSRIsSame( OGRSpatialReferenceH, OGRSpatialReferenceH );
-
-OGRErr CPL_DLL OSRSetLocalCS( OGRSpatialReferenceH hSRS, const char *pszName );
-OGRErr CPL_DLL OSRSetProjCS( OGRSpatialReferenceH hSRS, const char * pszName );
-OGRErr CPL_DLL OSRSetWellKnownGeogCS( OGRSpatialReferenceH hSRS,
- const char * pszName );
-OGRErr CPL_DLL CPL_STDCALL OSRSetFromUserInput( OGRSpatialReferenceH hSRS,
- const char * );
-OGRErr CPL_DLL OSRCopyGeogCSFrom( OGRSpatialReferenceH hSRS,
- OGRSpatialReferenceH hSrcSRS );
-OGRErr CPL_DLL OSRSetTOWGS84( OGRSpatialReferenceH hSRS,
- double, double, double,
- double, double, double, double );
-OGRErr CPL_DLL OSRGetTOWGS84( OGRSpatialReferenceH hSRS, double *, int );
-
-
-OGRErr CPL_DLL OSRSetGeogCS( 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 */ );
-
-double CPL_DLL OSRGetSemiMajor( OGRSpatialReferenceH, OGRErr * /* = NULL */ );
-double CPL_DLL OSRGetSemiMinor( OGRSpatialReferenceH, OGRErr * /* = NULL */ );
-double CPL_DLL OSRGetInvFlattening( OGRSpatialReferenceH, OGRErr * /*=NULL*/);
-
-OGRErr CPL_DLL OSRSetAuthority( OGRSpatialReferenceH hSRS,
- const char * pszTargetKey,
- const char * pszAuthority,
- int nCode );
-const char CPL_DLL *OSRGetAuthorityCode( OGRSpatialReferenceH hSRS,
- const char * pszTargetKey );
-const char CPL_DLL *OSRGetAuthorityName( OGRSpatialReferenceH hSRS,
- const char * pszTargetKey );
-OGRErr CPL_DLL OSRSetProjection( OGRSpatialReferenceH, const char * );
-OGRErr CPL_DLL OSRSetProjParm( OGRSpatialReferenceH, const char *, double );
-double CPL_DLL OSRGetProjParm( OGRSpatialReferenceH hSRS,
- const char * pszParmName,
- double dfDefault /* = 0.0 */,
- OGRErr * /* = NULL */ );
-OGRErr CPL_DLL OSRSetNormProjParm( OGRSpatialReferenceH, const char *, double);
-double CPL_DLL OSRGetNormProjParm( OGRSpatialReferenceH hSRS,
- const char * pszParmName,
- double dfDefault /* = 0.0 */,
- OGRErr * /* = NULL */ );
-
-OGRErr CPL_DLL OSRSetUTM( OGRSpatialReferenceH hSRS, int nZone, int bNorth );
-int CPL_DLL OSRGetUTMZone( OGRSpatialReferenceH hSRS, int *pbNorth );
-OGRErr CPL_DLL OSRSetStatePlane( OGRSpatialReferenceH hSRS,
- int nZone, int bNAD83 );
-OGRErr CPL_DLL OSRSetStatePlaneWithUnits( OGRSpatialReferenceH hSRS,
- int nZone, int bNAD83,
- const char *pszOverrideUnitName,
- double dfOverrideUnit );
-OGRErr CPL_DLL OSRAutoIdentifyEPSG( OGRSpatialReferenceH hSRS );
-
-/** Albers Conic Equal Area */
-OGRErr CPL_DLL OSRSetACEA( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Azimuthal Equidistant */
-OGRErr CPL_DLL OSRSetAE( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Bonne */
-OGRErr CPL_DLL OSRSetBonne(OGRSpatialReferenceH hSRS,
- double dfStandardParallel, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Cylindrical Equal Area */
-OGRErr CPL_DLL OSRSetCEA( OGRSpatialReferenceH hSRS, double dfStdP1, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Cassini-Soldner */
-OGRErr CPL_DLL OSRSetCS( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Equidistant Conic */
-OGRErr CPL_DLL OSRSetEC( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Eckert IV */
-OGRErr CPL_DLL OSRSetEckertIV( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Eckert VI */
-OGRErr CPL_DLL OSRSetEckertVI( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Equirectangular */
-OGRErr CPL_DLL OSRSetEquirectangular(OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Gall Stereograpic */
-OGRErr CPL_DLL OSRSetGS( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Goode Homolosine */
-OGRErr CPL_DLL OSRSetGH( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** GEOS - Geostationary Satellite View */
-OGRErr CPL_DLL OSRSetGEOS( OGRSpatialReferenceH hSRS,
- double dfCentralMeridian, double dfSatelliteHeight,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Gnomonic */
-OGRErr CPL_DLL OSRSetGnomonic(OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Hotine Oblique Mercator using azimuth angle */
-OGRErr CPL_DLL OSRSetHOM( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfAzimuth, double dfRectToSkew,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Hotine Oblique Mercator using two points on centerline */
-OGRErr CPL_DLL OSRSetHOM2PNO( OGRSpatialReferenceH hSRS, double dfCenterLat,
- double dfLat1, double dfLong1,
- double dfLat2, double dfLong2,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Krovak Oblique Conic Conformal */
-OGRErr CPL_DLL OSRSetKrovak( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfAzimuth, double dfPseudoStdParallelLat,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Lambert Azimuthal Equal-Area */
-OGRErr CPL_DLL OSRSetLAEA( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Lambert Conformal Conic */
-OGRErr CPL_DLL OSRSetLCC( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Lambert Conformal Conic 1SP */
-OGRErr CPL_DLL OSRSetLCC1SP( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Lambert Conformal Conic (Belgium) */
-OGRErr CPL_DLL OSRSetLCCB( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Miller Cylindrical */
-OGRErr CPL_DLL OSRSetMC( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Mercator */
-OGRErr CPL_DLL OSRSetMercator( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Mollweide */
-OGRErr CPL_DLL OSRSetMollweide( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** New Zealand Map Grid */
-OGRErr CPL_DLL OSRSetNZMG( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Oblique Stereographic */
-OGRErr CPL_DLL OSRSetOS( OGRSpatialReferenceH hSRS, double dfOriginLat, double dfCMeridian,
- double dfScale,
- double dfFalseEasting,double dfFalseNorthing);
-
-/** Orthographic */
-OGRErr CPL_DLL OSRSetOrthographic( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,double dfFalseNorthing);
-
-/** Polyconic */
-OGRErr CPL_DLL OSRSetPolyconic( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Polar Stereographic */
-OGRErr CPL_DLL OSRSetPS( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing);
-
-/** Robinson */
-OGRErr CPL_DLL OSRSetRobinson( OGRSpatialReferenceH hSRS, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Sinusoidal */
-OGRErr CPL_DLL OSRSetSinusoidal( OGRSpatialReferenceH hSRS, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Stereographic */
-OGRErr CPL_DLL OSRSetStereographic( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting,double dfFalseNorthing);
-
-/** Swiss Oblique Cylindrical */
-OGRErr CPL_DLL OSRSetSOC( OGRSpatialReferenceH hSRS, double dfLatitudeOfOrigin, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Transverse Mercator */
-OGRErr CPL_DLL OSRSetTM( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Transverse Mercator variant */
-OGRErr CPL_DLL OSRSetTMVariant(
- OGRSpatialReferenceH hSRS, const char *pszVariantName,
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Tunesia Mining Grid */
-OGRErr CPL_DLL OSRSetTMG( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** Transverse Mercator (South Oriented) */
-OGRErr CPL_DLL OSRSetTMSO( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing );
-
-/** VanDerGrinten */
-OGRErr CPL_DLL OSRSetVDG( OGRSpatialReferenceH hSRS,
- double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing );
-
-void CPL_DLL OSRCleanup( void );
-
-/* -------------------------------------------------------------------- */
-/* OGRCoordinateTransform C API. */
-/* -------------------------------------------------------------------- */
-OGRCoordinateTransformationH CPL_DLL CPL_STDCALL
-OCTNewCoordinateTransformation( OGRSpatialReferenceH hSourceSRS,
- OGRSpatialReferenceH hTargetSRS );
-void CPL_DLL CPL_STDCALL
- OCTDestroyCoordinateTransformation( OGRCoordinateTransformationH );
-
-int CPL_DLL CPL_STDCALL
-OCTTransform( OGRCoordinateTransformationH hCT,
- int nCount, double *x, double *y, double *z );
-
-int CPL_DLL CPL_STDCALL
-OCTTransformEx( OGRCoordinateTransformationH hCT,
- int nCount, double *x, double *y, double *z,
- int *pabSuccess );
-
-/* this is really private to OGR. */
-char *OCTProj4Normalize( const char *pszProj4Src );
-
-/* -------------------------------------------------------------------- */
-/* Projection transform dictionary query. */
-/* -------------------------------------------------------------------- */
-
-char CPL_DLL ** OPTGetProjectionMethods();
-char CPL_DLL ** OPTGetParameterList( const char * pszProjectionMethod,
- char ** ppszUserName );
-int CPL_DLL OPTGetParameterInfo( const char * pszProjectionMethod,
- const char * pszParameterName,
- char ** ppszUserName,
- char ** ppszType,
- double *pdfDefaultValue );
-
-CPL_C_END
-
-#endif /* ndef _OGR_SRS_API_H_INCLUDED */
+/******************************************************************************
+ * $Id: ogr_srs_api.h,v 1.58 2006/04/11 18:45:41 fwarmerdam Exp $
+ *
+ * Project: OpenGIS Simple Features Reference Implementation
+ * Purpose: C API and constant declarations for OGR Spatial References.
+ * Author: Frank Warmerdam, warmerdam at 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: ogr_srs_api.h,v $
+ * Revision 1.58 2006/04/11 18:45:41 fwarmerdam
+ * Fixed definition of a chain.
+ *
+ * Revision 1.57 2006/03/31 17:44:20 fwarmerdam
+ * header updates
+ *
+ * Revision 1.56 2005/12/01 04:59:46 fwarmerdam
+ * added two point equidistant support
+ *
+ * Revision 1.55 2005/10/10 14:45:47 dron
+ * Added OSRImportFromPanorama()/OSRExportToPanorama() wrappers.
+ *
+ * Revision 1.54 2005/10/03 18:13:28 fwarmerdam
+ * Fixed prototype for OSRSetGEOS().
+ *
+ * Revision 1.53 2005/09/21 00:50:08 fwarmerdam
+ * Added Release
+ *
+ * Revision 1.52 2005/05/09 15:39:44 fwarmerdam
+ * Added TM_MI_21 as per email from Safe.
+ *
+ * Revision 1.51 2005/04/06 00:02:05 fwarmerdam
+ * various osr and oct functions now stdcall
+ *
+ * Revision 1.50 2005/02/17 16:34:17 fwarmerdam
+ * OSRCloneCS() should be OSRClone().
+ *
+ * Revision 1.49 2005/02/11 14:21:28 fwarmerdam
+ * added GEOS projection support
+ *
+ * Revision 1.48 2005/01/05 21:02:33 fwarmerdam
+ * added Goode Homolosine
+ *
+ * Revision 1.47 2004/11/11 18:28:45 fwarmerdam
+ * added Bonne projection support
+ *
+ * Revision 1.46 2004/09/23 16:20:13 fwarmerdam
+ * added OSRCleanup
+ *
+ * Revision 1.45 2004/05/12 19:25:54 dron
+ * SRS_DN_WGS72 constant added.
+ *
+ * Revision 1.44 2004/05/10 17:05:14 warmerda
+ * added AutoIdentifyEPSG()
+ *
+ * Revision 1.43 2004/05/06 19:26:04 dron
+ * Added OSRSetProjection() function.
+ *
+ * Revision 1.42 2004/03/04 18:04:45 warmerda
+ * added importFromDict() support
+ *
+ * Revision 1.41 2004/02/07 17:31:21 dron
+ * Added OSRExportToUSGS() method.
+ *
+ * Revision 1.40 2004/02/05 17:07:59 dron
+ * Support for HOM projection, specified by two points on centerline.
+ *
+ * Revision 1.39 2004/02/01 14:23:29 dron
+ * Added OSRImportFromUSGS().
+ *
+ * Revision 1.38 2004/01/24 09:35:00 warmerda
+ * added TransformEx support to capture per point reprojection failure
+ *
+ * Revision 1.37 2003/09/09 07:49:52 dron
+ * Added OSRExportToPCI().
+ *
+ * Revision 1.36 2003/08/31 14:51:01 dron
+ * Added OSRImportFromPCI().
+ *
+ * Revision 1.35 2003/08/18 13:26:01 warmerda
+ * added SetTMVariant() and related definitions
+ *
+ * Revision 1.34 2003/06/21 23:24:36 warmerda
+ * added Set/Get TOWGS84 calls
+ *
+ * Revision 1.33 2003/06/19 17:10:26 warmerda
+ * a couple fixes in last commit
+ *
+ * Revision 1.32 2003/06/18 18:24:17 warmerda
+ * added projection specific set methods to C API
+ *
+ * Revision 1.31 2003/06/10 09:31:12 dron
+ * Added OSRSetAngularUnits() and OSRGetAngularUnits().
+ *
+ * Revision 1.30 2003/05/30 15:39:53 warmerda
+ * Added override units capability for SetStatePlane()
+ *
+ * Revision 1.29 2003/03/21 22:15:11 warmerda
+ * added C XML import/export entry points
+ *
+ * Revision 1.28 2003/03/12 14:29:34 warmerda
+ * Rename OGRAxisOrientation and OGRDatumType values to avoid conflicts with
+ * the real OGC definitions in applications such as Cadcorps.
+ *
+ * Revision 1.27 2003/02/25 04:53:38 warmerda
+ * added OSRCopyGeogCSFrom
+ *
+ * Revision 1.26 2003/02/06 04:53:12 warmerda
+ * added Fixup() method
+ *
+ * Revision 1.25 2003/01/08 18:14:28 warmerda
+ * added FixupOrdering()
+ *
+ * Revision 1.24 2002/12/16 17:07:13 warmerda
+ * added NormProjParm functions, and OSRGetPrimeMeridian
+ *
+ * Revision 1.23 2002/12/14 22:59:14 warmerda
+ * added Krovak in ESRI compatible way
+ *
+ * Revision 1.22 2002/12/09 18:55:07 warmerda
+ * moved DMS stuff to gdal/port
+ *
+ * Revision 1.21 2002/12/09 16:11:53 warmerda
+ * added DMS translation
+ *
+ * Revision 1.20 2002/11/25 16:12:54 warmerda
+ * added GetAuthorityCode/Name
+ *
+ * Revision 1.19 2002/09/26 18:13:25 warmerda
+ * avoid double def
+ *
+ * Revision 1.18 2002/06/11 18:02:03 warmerda
+ * add PROJ.4 normalization and EPSG support
+ *
+ * Revision 1.17 2001/10/11 19:27:12 warmerda
+ * upgraded validation infrastructure
+ *
+ * Revision 1.16 2001/10/10 20:42:43 warmerda
+ * added ESRI WKT morphing support
+ *
+ * Revision 1.15 2001/09/21 16:21:02 warmerda
+ * added Clear(), and SetFromUserInput() methods
+ *
+ * Revision 1.14 2000/11/09 06:21:32 warmerda
+ * added limited ESRI prj support
+ *
+ * Revision 1.13 2000/10/20 04:19:38 warmerda
+ * added setstateplane
+ *
+ * Revision 1.12 2000/10/16 21:26:07 warmerda
+ * added some level of LOCAL_CS support
+ *
+ * Revision 1.11 2000/09/01 20:58:01 warmerda
+ * added CPL_DLL for entry points
+ *
+ * Revision 1.10 2000/08/30 20:06:14 warmerda
+ * added projection method list functions
+ *
+ * Revision 1.9 2000/08/28 20:13:23 warmerda
+ * added importFromProj4
+ *
+ * Revision 1.8 2000/07/11 01:02:06 warmerda
+ * added ExportToProj4()
+ *
+ * Revision 1.7 2000/07/09 20:48:02 warmerda
+ * added exportToPrettyWkt
+ *
+ * Revision 1.6 2000/05/30 22:45:44 warmerda
+ * added OSRCloneGeogCS()
+ *
+ * Revision 1.5 2000/04/26 18:25:56 warmerda
+ * added missing CPL_DLL attributes
+ *
+ * Revision 1.4 2000/03/22 01:09:43 warmerda
+ * added SetProjCS and SetWellKnownTextCS
+ *
+ * Revision 1.3 2000/03/20 23:33:51 warmerda
+ * updated docs a bit
+ *
+ * Revision 1.2 2000/03/20 22:39:31 warmerda
+ * Added C API.
+ *
+ * Revision 1.1 2000/03/16 19:04:14 warmerda
+ * New
+ *
+ */
+
+#ifndef _OGR_SRS_API_H_INCLUDED
+#define _OGR_SRS_API_H_INCLUDED
+
+#include "ogr_core.h"
+
+CPL_C_START
+
+/**
+ * \file ogr_srs_api.h
+ *
+ * C spatial reference system services and defines.
+ *
+ * See also: ogr_spatialref.h
+ */
+
+/* -------------------------------------------------------------------- */
+/* Axis orientations (corresponds to CS_AxisOrientationEnum). */
+/* -------------------------------------------------------------------- */
+typedef enum {
+ OAO_Other=0,
+ OAO_North=1,
+ OAO_South=2,
+ OAO_East=3,
+ OAO_West=4,
+ OAO_Up=5,
+ OAO_Down=6
+} OGRAxisOrientation;
+
+/* -------------------------------------------------------------------- */
+/* Datum types (corresponds to CS_DatumType). */
+/* -------------------------------------------------------------------- */
+
+typedef enum {
+ ODT_HD_Min=1000,
+ ODT_HD_Other=1000,
+ ODT_HD_Classic=1001,
+ ODT_HD_Geocentric=1002,
+ ODT_HD_Max=1999,
+ ODT_VD_Min=2000,
+ ODT_VD_Other=2000,
+ ODT_VD_Orthometric=2001,
+ ODT_VD_Ellipsoidal=2002,
+ ODT_VD_AltitudeBarometric=2003,
+ ODT_VD_Normal=2004,
+ ODT_VD_GeoidModelDerived=2005,
+ ODT_VD_Depth=2006,
+ ODT_VD_Max=2999,
+ ODT_LD_Min=10000,
+ ODT_LD_Max=32767
+} OGRDatumType;
+
+/* ==================================================================== */
+/* Some "standard" strings. */
+/* ==================================================================== */
+
+// The EQUAL() macro does a simple case insensitive string compare with these strings,
+// but it should also ignore white space, "-", "_" and "," characters so that more matches are found.
+// The following should all be considered equal:
+// Transverse_Mercator
+// Transverse-Mercator
+// Transverse Mercator
+// TransverseMercator
+
+/* Abbreviation for Albers_Conic_Equal_Area */
+#define SRS_PT_AE "AE"
+#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_CASSINI_SOLDNER1 "Cassini-Soldner"
+#define SRS_PT_CYLINDRICAL_EQUAL_AREA "Cylindrical_Equal_Area"
+#define SRS_PT_BONNE "Bonne"
+#define SRS_PT_ECKERT_IV "Eckert_IV"
+#define SRS_PT_ECKERT_VI "Eckert_VI"
+#define SRS_PT_EQUIDISTANT_CONIC "Equidistant_Conic"
+#define SRS_PT_EQUIDISTANT_CYLINDRICAL "Equidistant_Cylindrical"
+#define SRS_PT_EQUIRECTANGULAR "Equirectangular"
+#define SRS_PT_GALL_STEREOGRAPHIC "Gall_Stereographic"
+#define SRS_PT_GEOSTATIONARY_SATELLITE "Geostationary_Satellite"
+#define SRS_PT_GOODE_HOMOLOSINE "Goode_Homolosine"
+#define SRS_PT_GNOMONIC "Gnomonic"
+#define SRS_PT_HOTINE_OBLIQUE_MERCATOR \
+ "Hotine_Oblique_Mercator"
+#define SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN \
+ "Hotine_Oblique_Mercator_Two_Point_Natural_Origin"
+#define SRS_PT_LABORDE_OBLIQUE_MERCATOR \
+ "Laborde_Oblique_Mercator"
+/* Abbreviation for Lambert Conformal Conic */
+#define SRS_PT_LCC "LCC"
+#define SRS_PT_LM "LM"
+#define SRS_PT_LAMBERT_CONFORMAL_CONIC \
+ "Lambert Conformal Conic"
+#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_CONFORMAL_CONIC_ALT \
+ "Lambert_Conformal_Conic"
+#define SRS_PT_LAMBERT_CONIC_CONFORMAL \
+ "Lambert Conic Conformal"
+#define SRS_PT_LAMBERT_CONIC_CONFORMAL_1SP \
+ "Lambert_Conic_Conformal_1SP"
+#define SRS_PT_LAMBERT_CONIC_CONFORMAL_2SP_BELGIUM \
+ "Lambert_Conic_Conformal_2SP_Belgium"
+#define SRS_PT_LAMBERT_CONIC_CONFORMAL_WEST_ORIENTATED \
+ "Lambert_Conic_Conformal_West_Orientated"
+#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"
+/* Abbreviation for Miller_Cylindrical */
+#define SRS_PT_MILLER "Miller"
+#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_MERCATOR \
+ "Oblique_Mercator"
+#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"
+/* Abbreviation for Swiss_Oblique_Cylindrical */
+#define SRS_PT_SWISS "Swiss"
+#define SRS_PT_SWISS_OBLIQUE_CYLINDRICAL \
+ "Swiss_Oblique_Cylindrical"
+/* Abbreviations for Transverse_Mercator */
+#define SRS_PT_TM "TM"
+#define SRS_PT_TRANSVERSE_MERCATOR \
+ "Transverse_Mercator"
+#define SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED \
+ "Transverse_Mercator_South_Orientated"
+
+/* special mapinfo variants on Transverse Mercator */
+#define SRS_PT_TRANSVERSE_MERCATOR_MI_21 \
+ "Transverse_Mercator_MapInfo_21"
+#define SRS_PT_TRANSVERSE_MERCATOR_MI_22 \
+ "Transverse_Mercator_MapInfo_22"
+#define SRS_PT_TRANSVERSE_MERCATOR_MI_23 \
+ "Transverse_Mercator_MapInfo_23"
+#define SRS_PT_TRANSVERSE_MERCATOR_MI_24 \
+ "Transverse_Mercator_MapInfo_24"
+#define SRS_PT_TRANSVERSE_MERCATOR_MI_25 \
+ "Transverse_Mercator_MapInfo_25"
+
+#define SRS_PT_TUNISIA_MINING_GRID \
+ "Tunisia_Mining_Grid"
+#define SRS_PT_TWO_POINT_EQUIDISTANT \
+ "Two_Point_Equidistant"
+
+/* Mentor abbreviation for Transverse Mercator */
+#define SRS_PT_UTM "UTM"
+
+#define SRS_PT_VANDERGRINTEN "VanDerGrinten"
+#define SRS_PT_KROVAK "Krovak"
+
+
+
+#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_PSEUDO_STD_PARALLEL_1 "pseudo_standard_parallel_1"
+#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_SATELLITE_HEIGHT "satellite_height"
+#define SRS_PP_FIPSZONE "fipszone"
+#define SRS_PP_ZONE "zone"
+#define SRS_PP_LATITUDE_OF_1ST_POINT "Latitude_Of_1st_Point"
+#define SRS_PP_LONGITUDE_OF_1ST_POINT "Longitude_Of_1st_Point"
+#define SRS_PP_LATITUDE_OF_2ND_POINT "Latitude_Of_2nd_Point"
+#define SRS_PP_LONGITUDE_OF_2ND_POINT "Longitude_Of_2nd_Point"
+
+#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 "20.116684023368047"
+#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_WGS72 "WGS_1972"
+#define SRS_DN_WGS84 "WGS_1984"
+
+#define SRS_WGS84_SEMIMAJOR 6378137.0
+#define SRS_WGS84_INVFLATTENING 298.257223563
+
+/* -------------------------------------------------------------------- */
+/* C Wrappers for C++ objects and methods. */
+/* -------------------------------------------------------------------- */
+#ifndef _DEFINED_OGRSpatialReferenceH
+#define _DEFINED_OGRSpatialReferenceH
+
+typedef void *OGRSpatialReferenceH;
+typedef void *OGRCoordinateTransformationH;
+
+#endif
+
+
+OGRSpatialReferenceH CPL_DLL CPL_STDCALL
+ OSRNewSpatialReference( const char * /* = NULL */);
+OGRSpatialReferenceH CPL_DLL CPL_STDCALL OSRCloneGeogCS( OGRSpatialReferenceH );
+OGRSpatialReferenceH CPL_DLL CPL_STDCALL OSRClone( OGRSpatialReferenceH );
+void CPL_DLL CPL_STDCALL OSRDestroySpatialReference( OGRSpatialReferenceH );
+
+int CPL_DLL OSRReference( OGRSpatialReferenceH );
+int CPL_DLL OSRDereference( OGRSpatialReferenceH );
+void CPL_DLL OSRRelease( OGRSpatialReferenceH );
+
+OGRErr CPL_DLL OSRValidate( OGRSpatialReferenceH );
+OGRErr CPL_DLL OSRFixupOrdering( OGRSpatialReferenceH );
+OGRErr CPL_DLL OSRFixup( OGRSpatialReferenceH );
+OGRErr CPL_DLL OSRStripCTParms( OGRSpatialReferenceH );
+
+OGRErr CPL_DLL CPL_STDCALL OSRImportFromEPSG( OGRSpatialReferenceH, int );
+OGRErr CPL_DLL OSRImportFromWkt( OGRSpatialReferenceH, char ** );
+OGRErr CPL_DLL OSRImportFromProj4( OGRSpatialReferenceH, const char *);
+OGRErr CPL_DLL OSRImportFromESRI( OGRSpatialReferenceH, char **);
+OGRErr CPL_DLL OSRImportFromPCI( OGRSpatialReferenceH hSRS, const char *,
+ const char *, double * );
+OGRErr CPL_DLL OSRImportFromUSGS( OGRSpatialReferenceH,
+ long, long, double *, long);
+OGRErr CPL_DLL OSRImportFromXML( OGRSpatialReferenceH, const char * );
+OGRErr CPL_DLL OSRImportFromDict( OGRSpatialReferenceH, const char *,
+ const char * );
+OGRErr OSRImportFromPanorama( OGRSpatialReferenceH, long, long, long, long,
+ double, double, double, double );
+
+OGRErr CPL_DLL CPL_STDCALL OSRExportToWkt( OGRSpatialReferenceH, char ** );
+OGRErr CPL_DLL CPL_STDCALL OSRExportToPrettyWkt( OGRSpatialReferenceH, char **, int);
+OGRErr CPL_DLL CPL_STDCALL OSRExportToProj4( OGRSpatialReferenceH, char **);
+OGRErr CPL_DLL OSRExportToPCI( OGRSpatialReferenceH, char **, char **,
+ double ** );
+OGRErr CPL_DLL OSRExportToUSGS( OGRSpatialReferenceH, long *, long *,
+ double **, long * );
+OGRErr CPL_DLL OSRExportToXML( OGRSpatialReferenceH, char **, const char * );
+OGRErr OSRExportToPanorama( OGRSpatialReferenceH, long *, long *, long *,
+ long *, double *, double *, double *, double * );
+
+OGRErr CPL_DLL OSRMorphToESRI( OGRSpatialReferenceH );
+OGRErr CPL_DLL OSRMorphFromESRI( OGRSpatialReferenceH );
+
+OGRErr CPL_DLL CPL_STDCALL OSRSetAttrValue( OGRSpatialReferenceH hSRS,
+ const char * pszNodePath,
+ const char * pszNewNodeValue );
+const char CPL_DLL * CPL_STDCALL OSRGetAttrValue( OGRSpatialReferenceH hSRS,
+ const char * pszName, int iChild /* = 0 */ );
+
+OGRErr CPL_DLL OSRSetAngularUnits( OGRSpatialReferenceH, const char *, double );
+double CPL_DLL OSRGetAngularUnits( OGRSpatialReferenceH, char ** );
+OGRErr CPL_DLL OSRSetLinearUnits( OGRSpatialReferenceH, const char *, double );
+double CPL_DLL OSRGetLinearUnits( OGRSpatialReferenceH, char ** );
+
+double CPL_DLL OSRGetPrimeMeridian( OGRSpatialReferenceH, char ** );
+
+int CPL_DLL OSRIsGeographic( OGRSpatialReferenceH );
+int CPL_DLL OSRIsLocal( OGRSpatialReferenceH );
+int CPL_DLL OSRIsProjected( OGRSpatialReferenceH );
+int CPL_DLL OSRIsSameGeogCS( OGRSpatialReferenceH, OGRSpatialReferenceH );
+int CPL_DLL OSRIsSame( OGRSpatialReferenceH, OGRSpatialReferenceH );
+
+OGRErr CPL_DLL OSRSetLocalCS( OGRSpatialReferenceH hSRS, const char *pszName );
+OGRErr CPL_DLL OSRSetProjCS( OGRSpatialReferenceH hSRS, const char * pszName );
+OGRErr CPL_DLL OSRSetWellKnownGeogCS( OGRSpatialReferenceH hSRS,
+ const char * pszName );
+OGRErr CPL_DLL CPL_STDCALL OSRSetFromUserInput( OGRSpatialReferenceH hSRS,
+ const char * );
+OGRErr CPL_DLL OSRCopyGeogCSFrom( OGRSpatialReferenceH hSRS,
+ OGRSpatialReferenceH hSrcSRS );
+OGRErr CPL_DLL OSRSetTOWGS84( OGRSpatialReferenceH hSRS,
+ double, double, double,
+ double, double, double, double );
+OGRErr CPL_DLL OSRGetTOWGS84( OGRSpatialReferenceH hSRS, double *, int );
+
+
+OGRErr CPL_DLL OSRSetGeogCS( 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 */ );
+
+double CPL_DLL OSRGetSemiMajor( OGRSpatialReferenceH, OGRErr * /* = NULL */ );
+double CPL_DLL OSRGetSemiMinor( OGRSpatialReferenceH, OGRErr * /* = NULL */ );
+double CPL_DLL OSRGetInvFlattening( OGRSpatialReferenceH, OGRErr * /*=NULL*/);
+
+OGRErr CPL_DLL OSRSetAuthority( OGRSpatialReferenceH hSRS,
+ const char * pszTargetKey,
+ const char * pszAuthority,
+ int nCode );
+const char CPL_DLL *OSRGetAuthorityCode( OGRSpatialReferenceH hSRS,
+ const char * pszTargetKey );
+const char CPL_DLL *OSRGetAuthorityName( OGRSpatialReferenceH hSRS,
+ const char * pszTargetKey );
+OGRErr CPL_DLL OSRSetProjection( OGRSpatialReferenceH, const char * );
+OGRErr CPL_DLL OSRSetProjParm( OGRSpatialReferenceH, const char *, double );
+double CPL_DLL OSRGetProjParm( OGRSpatialReferenceH hSRS,
+ const char * pszParmName,
+ double dfDefault /* = 0.0 */,
+ OGRErr * /* = NULL */ );
+OGRErr CPL_DLL OSRSetNormProjParm( OGRSpatialReferenceH, const char *, double);
+double CPL_DLL OSRGetNormProjParm( OGRSpatialReferenceH hSRS,
+ const char * pszParmName,
+ double dfDefault /* = 0.0 */,
+ OGRErr * /* = NULL */ );
+
+OGRErr CPL_DLL OSRSetUTM( OGRSpatialReferenceH hSRS, int nZone, int bNorth );
+int CPL_DLL OSRGetUTMZone( OGRSpatialReferenceH hSRS, int *pbNorth );
+OGRErr CPL_DLL OSRSetStatePlane( OGRSpatialReferenceH hSRS,
+ int nZone, int bNAD83 );
+OGRErr CPL_DLL OSRSetStatePlaneWithUnits( OGRSpatialReferenceH hSRS,
+ int nZone, int bNAD83,
+ const char *pszOverrideUnitName,
+ double dfOverrideUnit );
+OGRErr CPL_DLL OSRAutoIdentifyEPSG( OGRSpatialReferenceH hSRS );
+
+/** Albers Conic Equal Area */
+OGRErr CPL_DLL OSRSetACEA( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Azimuthal Equidistant */
+OGRErr CPL_DLL OSRSetAE( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Bonne */
+OGRErr CPL_DLL OSRSetBonne(OGRSpatialReferenceH hSRS,
+ double dfStandardParallel, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Cylindrical Equal Area */
+OGRErr CPL_DLL OSRSetCEA( OGRSpatialReferenceH hSRS, double dfStdP1, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Cassini-Soldner */
+OGRErr CPL_DLL OSRSetCS( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Equidistant Conic */
+OGRErr CPL_DLL OSRSetEC( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Eckert IV */
+OGRErr CPL_DLL OSRSetEckertIV( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Eckert VI */
+OGRErr CPL_DLL OSRSetEckertVI( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Equirectangular */
+OGRErr CPL_DLL OSRSetEquirectangular(OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Gall Stereograpic */
+OGRErr CPL_DLL OSRSetGS( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Goode Homolosine */
+OGRErr CPL_DLL OSRSetGH( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** GEOS - Geostationary Satellite View */
+OGRErr CPL_DLL OSRSetGEOS( OGRSpatialReferenceH hSRS,
+ double dfCentralMeridian, double dfSatelliteHeight,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Gnomonic */
+OGRErr CPL_DLL OSRSetGnomonic(OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Hotine Oblique Mercator using azimuth angle */
+OGRErr CPL_DLL OSRSetHOM( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfAzimuth, double dfRectToSkew,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Hotine Oblique Mercator using two points on centerline */
+OGRErr CPL_DLL OSRSetHOM2PNO( OGRSpatialReferenceH hSRS, double dfCenterLat,
+ double dfLat1, double dfLong1,
+ double dfLat2, double dfLong2,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Krovak Oblique Conic Conformal */
+OGRErr CPL_DLL OSRSetKrovak( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfAzimuth, double dfPseudoStdParallelLat,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Lambert Azimuthal Equal-Area */
+OGRErr CPL_DLL OSRSetLAEA( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Lambert Conformal Conic */
+OGRErr CPL_DLL OSRSetLCC( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Lambert Conformal Conic 1SP */
+OGRErr CPL_DLL OSRSetLCC1SP( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Lambert Conformal Conic (Belgium) */
+OGRErr CPL_DLL OSRSetLCCB( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Miller Cylindrical */
+OGRErr CPL_DLL OSRSetMC( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Mercator */
+OGRErr CPL_DLL OSRSetMercator( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Mollweide */
+OGRErr CPL_DLL OSRSetMollweide( OGRSpatialReferenceH hSRS, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** New Zealand Map Grid */
+OGRErr CPL_DLL OSRSetNZMG( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Oblique Stereographic */
+OGRErr CPL_DLL OSRSetOS( OGRSpatialReferenceH hSRS, double dfOriginLat, double dfCMeridian,
+ double dfScale,
+ double dfFalseEasting,double dfFalseNorthing);
+
+/** Orthographic */
+OGRErr CPL_DLL OSRSetOrthographic( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,double dfFalseNorthing);
+
+/** Polyconic */
+OGRErr CPL_DLL OSRSetPolyconic( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Polar Stereographic */
+OGRErr CPL_DLL OSRSetPS( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing);
+
+/** Robinson */
+OGRErr CPL_DLL OSRSetRobinson( OGRSpatialReferenceH hSRS, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Sinusoidal */
+OGRErr CPL_DLL OSRSetSinusoidal( OGRSpatialReferenceH hSRS, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Stereographic */
+OGRErr CPL_DLL OSRSetStereographic( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting,double dfFalseNorthing);
+
+/** Swiss Oblique Cylindrical */
+OGRErr CPL_DLL OSRSetSOC( OGRSpatialReferenceH hSRS, double dfLatitudeOfOrigin, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Transverse Mercator */
+OGRErr CPL_DLL OSRSetTM( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Transverse Mercator variant */
+OGRErr CPL_DLL OSRSetTMVariant(
+ OGRSpatialReferenceH hSRS, const char *pszVariantName,
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Tunesia Mining Grid */
+OGRErr CPL_DLL OSRSetTMG( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** Transverse Mercator (South Oriented) */
+OGRErr CPL_DLL OSRSetTMSO( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing );
+
+/** VanDerGrinten */
+OGRErr CPL_DLL OSRSetVDG( OGRSpatialReferenceH hSRS,
+ double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing );
+
+void CPL_DLL OSRCleanup( void );
+
+/* -------------------------------------------------------------------- */
+/* OGRCoordinateTransform C API. */
+/* -------------------------------------------------------------------- */
+OGRCoordinateTransformationH CPL_DLL CPL_STDCALL
+OCTNewCoordinateTransformation( OGRSpatialReferenceH hSourceSRS,
+ OGRSpatialReferenceH hTargetSRS );
+void CPL_DLL CPL_STDCALL
+ OCTDestroyCoordinateTransformation( OGRCoordinateTransformationH );
+
+int CPL_DLL CPL_STDCALL
+OCTTransform( OGRCoordinateTransformationH hCT,
+ int nCount, double *x, double *y, double *z );
+
+int CPL_DLL CPL_STDCALL
+OCTTransformEx( OGRCoordinateTransformationH hCT,
+ int nCount, double *x, double *y, double *z,
+ int *pabSuccess );
+
+/* this is really private to OGR. */
+char *OCTProj4Normalize( const char *pszProj4Src );
+
+/* -------------------------------------------------------------------- */
+/* Projection transform dictionary query. */
+/* -------------------------------------------------------------------- */
+
+char CPL_DLL ** OPTGetProjectionMethods();
+char CPL_DLL ** OPTGetParameterList( const char * pszProjectionMethod,
+ char ** ppszUserName );
+int CPL_DLL OPTGetParameterInfo( const char * pszProjectionMethod,
+ const char * pszParameterName,
+ char ** ppszUserName,
+ char ** ppszType,
+ double *pdfDefaultValue );
+
+CPL_C_END
+
+#endif /* ndef _OGR_SRS_API_H_INCLUDED */
Modified: trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr_srs_proj4.cpp
===================================================================
--- trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr_srs_proj4.cpp 2007-03-21 00:47:37 UTC (rev 1308)
+++ trunk/MgDev/Oem/gdal-1.4.0/ogr/ogr_srs_proj4.cpp 2007-03-21 00:50:25 UTC (rev 1309)
@@ -1,1964 +1,1981 @@
-/******************************************************************************
- * $Id: ogr_srs_proj4.cpp,v 1.66 2006/11/24 17:58:30 fwarmerdam Exp $
- *
- * Project: OpenGIS Simple Features Reference Implementation
- * Purpose: OGRSpatialReference interface to PROJ.4.
- * Author: Frank Warmerdam <warmerdam at pobox.com>
- *
- ******************************************************************************
- * Copyright (c) 1999, Les Technologies SoftMap 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: ogr_srs_proj4.cpp,v $
- * Revision 1.66 2006/11/24 17:58:30 fwarmerdam
- * added support for +wktext / PROJ4 EXTENSION hackery
- *
- * Revision 1.65 2006/11/01 04:37:39 fwarmerdam
- * fixed two point equidistant, preliminary mercator2sp support
- *
- * Revision 1.64 2006/05/05 17:02:54 fwarmerdam
- * Added Krovak PROJ.4 to WKT translation.
- *
- * Revision 1.63 2006/04/21 03:33:23 fwarmerdam
- * Per bug 811 we should not actually be adjusting the central meridian or
- * other longitudes. They are relative to the geogcs prime meridian in
- * WKT and PROJ.4 format. Ugg.
- *
- * Revision 1.62 2006/04/21 02:44:35 fwarmerdam
- * Fixed bogota meridian sign (west, not east).
- *
- * Revision 1.61 2006/03/21 15:12:22 fwarmerdam
- * Fixed support for +R parameter.
- *
- * Revision 1.60 2005/12/13 15:57:28 dron
- * Export scale coefficient when exporting to stereographic projection.
- *
- * Revision 1.59 2005/12/01 04:59:46 fwarmerdam
- * added two point equidistant support
- *
- * Revision 1.58 2005/11/10 04:12:40 fwarmerdam
- * The last change related to:
- * http://bugzilla.remotesensing.org/show_bug.cgi?id=980
- *
- * Revision 1.57 2005/11/10 04:12:14 fwarmerdam
- * Changed the translation for Oblique Stereographic from proj=stere to
- * proj=sterea.
- *
- * Revision 1.56 2005/09/29 20:22:26 dmorissette
- * Improved support for MapInfo modified TM projections in exportToProj4()
- * (Anthony D - MITAB bug 1155)
- *
- * Revision 1.55 2005/09/05 20:42:52 fwarmerdam
- * ensure that non-geographic, non-projected srses return empty string
- *
- * Revision 1.54 2005/04/06 00:02:05 fwarmerdam
- * various osr and oct functions now stdcall
- *
- * Revision 1.53 2005/02/28 15:01:56 fwarmerdam
- * Applied patch to add +towgs84 parameter if one is well known for a given
- * EPSG GEOGCS, and no datum shifting info is available in the source defn.
- * See http://bugzilla.remotesensing.org/show_bug.cgi?id=784
- *
- * Revision 1.52 2005/02/09 20:25:39 fwarmerdam
- * Changed default height for GEOS projection.
- *
- * Revision 1.51 2005/01/05 21:02:33 fwarmerdam
- * added Goode Homolosine
- *
- * Revision 1.50 2004/11/11 18:28:45 fwarmerdam
- * added Bonne projection support
- *
- * Revision 1.49 2004/09/10 21:04:51 fwarmerdam
- * Various fixes for swiss oblique mercator (somerc) support.
- * http://bugzilla.remotesensing.org/show_bug.cgi?id=423
- *
- * Revision 1.48 2004/09/10 20:29:16 fwarmerdam
- * Re bug 423: fixed up SRS_PT_SWISS_OBLIQUE_CYLINDRICAL to use somerc.
- *
- * Revision 1.47 2004/05/12 14:27:47 warmerda
- * added translation for nzgd49 and potsdam using epsg codes
- *
- * Revision 1.46 2004/05/04 18:49:43 warmerda
- * Fixed handling of prime meridian. In PROJ.4 strings the central meridian
- * or other longitude parameters are relative to the prime meridian. Apply
- * appropriate transformations going and coming from WKT where that is not
- * the case.
- *
- * Revision 1.45 2004/02/05 17:07:59 dron
- * Support for HOM projection, specified by two points on centerline.
- *
- * Revision 1.44 2003/06/27 19:02:04 warmerda
- * added OSRProj4Tokenize(), fixes plus related tokenizing bug in bug 355
- *
- * Revision 1.43 2003/06/27 17:54:12 warmerda
- * allow k_0 in place of k parsing proj4, bug 355
- *
- * Revision 1.42 2003/06/21 23:25:03 warmerda
- * added +towgs84 support in importFromProj4()
- *
- * Revision 1.41 2003/05/28 18:17:38 warmerda
- * treat meter or m as meter
- *
- * Revision 1.40 2003/05/20 18:09:36 warmerda
- * fixed so that importFromProj4() will transform linear parameter units
- *
- * Revision 1.39 2003/02/13 19:27:28 warmerda
- * always append no_defs to avoid getting hosted by defaults file
- *
- * Revision 1.38 2002/12/15 23:42:59 warmerda
- * added initial support for normalizing proj params
- *
- * Revision 1.37 2002/12/14 19:50:21 warmerda
- * implement support for NZMG (New Zealand Map Grid)
- *
- * Revision 1.36 2002/12/10 04:05:04 warmerda
- * fixed some translation problems with prime meridians
- *
- * Revision 1.35 2002/12/09 23:03:45 warmerda
- * Fixed translation of paris prime meridian.
- *
- * Revision 1.34 2002/12/09 18:55:07 warmerda
- * moved DMS stuff to gdal/port
- *
- * Revision 1.33 2002/12/09 16:12:14 warmerda
- * added +pm= support
- *
- * Revision 1.32 2002/12/03 15:38:10 warmerda
- * dont write linear units to geograpic srs but avoid freaking out
- *
- * Revision 1.31 2002/12/01 20:19:21 warmerda
- * use %.16g to preserve precision as per bug 184
- *
- * Revision 1.30 2002/11/29 21:23:38 warmerda
- * implement LCC1SP PROJ.4 to WKT translation
- *
- * Revision 1.29 2002/11/29 20:56:37 warmerda
- * added LCC1SP conversion to PROJ.4, missing reverse
- *
- * Revision 1.28 2002/11/25 03:28:16 warmerda
- * added/improved documentation
- *
- * Revision 1.27 2002/07/09 14:49:07 warmerda
- * Improved translation from/to polar stereographic as per
- * http://bugzilla.remotesensing.org/show_bug.cgi?id=172
- *
- * Revision 1.26 2002/06/11 18:02:03 warmerda
- * add PROJ.4 normalization and EPSG support
- *
- * Revision 1.25 2002/04/18 14:22:45 warmerda
- * made OGRSpatialReference and co 'const correct'
- *
- * Revision 1.24 2002/03/08 20:17:52 warmerda
- * assume WGS84 if ellipse info missing
- *
- * Revision 1.23 2002/01/18 04:48:48 warmerda
- * clean tabs, and newlines from input to importProj4
- *
- * Revision 1.22 2001/12/12 20:18:06 warmerda
- * added support for units in proj.4 to WKT
- *
- * Revision 1.21 2001/11/07 22:08:51 warmerda
- * dont put + in to_meter value
- *
- * Revision 1.20 2001/11/02 22:21:15 warmerda
- * fixed memory leak
- *
- * Revision 1.19 2001/10/11 19:23:30 warmerda
- * fixed datum names
- *
- * Revision 1.18 2001/07/18 05:03:05 warmerda
- * added CPL_CVSID
- *
- * Revision 1.17 2001/03/02 04:37:43 danmo
- * Return empty string for LOCAL_CS in exportToProj4().
- *
- * Revision 1.16 2001/01/22 14:00:28 warmerda
- * added untested support for Swiss Oblique Cylindrical
- *
- * Revision 1.15 2001/01/19 21:10:46 warmerda
- * replaced tabs
- *
- * Revision 1.14 2000/12/05 23:10:34 warmerda
- * Added cassini support
- *
- * Revision 1.13 2000/12/05 17:46:16 warmerda
- * Use +R_A for VanDerGrinten and miller
- *
- * Revision 1.12 2000/09/25 20:22:21 warmerda
- * ensure pszPROJ4Units is initialized
- *
- * Revision 1.11 2000/09/25 15:46:56 warmerda
- * added sphere
- *
- * Revision 1.10 2000/08/28 20:13:23 warmerda
- * added importFromProj4
- *
- * Revision 1.9 2000/07/11 01:02:06 warmerda
- * added ExportToProj4()
- *
- * Revision 1.8 2000/07/09 20:49:21 warmerda
- * added +datum support
- *
- * Revision 1.7 2000/03/06 02:23:54 warmerda
- * don't use +datum syntax
- *
- * Revision 1.6 1999/12/22 15:39:43 warmerda
- * fix to differentiate WGS variants
- *
- * Revision 1.5 1999/12/13 16:29:59 warmerda
- * Added improved units, and ellipse support.
- *
- * Revision 1.4 1999/12/08 16:34:05 warmerda
- * added five or six more projections
- *
- * Revision 1.1 1999/07/29 17:29:15 warmerda
- * New
- *
- */
-
-#include "ogr_spatialref.h"
-#include "ogr_p.h"
-#include "cpl_conv.h"
-
-extern int EPSGGetWGS84Transform( int nGeogCS, double *padfTransform );
-
-CPL_CVSID("$Id: ogr_srs_proj4.cpp,v 1.66 2006/11/24 17:58:30 fwarmerdam Exp $");
-
-/* -------------------------------------------------------------------- */
-/* The following list comes from osrs/proj/src/pj_ellps.c */
-/* ... please update from time to time. */
-/* -------------------------------------------------------------------- */
-static const char *ogr_pj_ellps[] = {
-"MERIT", "a=6378137.0", "rf=298.257", "MERIT 1983",
-"SGS85", "a=6378136.0", "rf=298.257", "Soviet Geodetic System 85",
-"GRS80", "a=6378137.0", "rf=298.257222101", "GRS 1980(IUGG, 1980)",
-"IAU76", "a=6378140.0", "rf=298.257", "IAU 1976",
-"airy", "a=6377563.396", "b=6356256.910", "Airy 1830",
-"APL4.9", "a=6378137.0.", "rf=298.25", "Appl. Physics. 1965",
-"NWL9D", "a=6378145.0.", "rf=298.25", "Naval Weapons Lab., 1965",
-"mod_airy", "a=6377340.189", "b=6356034.446", "Modified Airy",
-"andrae", "a=6377104.43", "rf=300.0", "Andrae 1876 (Den., Iclnd.)",
-"aust_SA", "a=6378160.0", "rf=298.25", "Australian Natl & S. Amer. 1969",
-"GRS67", "a=6378160.0", "rf=298.2471674270", "GRS 67(IUGG 1967)",
-"bessel", "a=6377397.155", "rf=299.1528128", "Bessel 1841",
-"bess_nam", "a=6377483.865", "rf=299.1528128", "Bessel 1841 (Namibia)",
-"clrk66", "a=6378206.4", "b=6356583.8", "Clarke 1866",
-"clrk80", "a=6378249.145", "rf=293.4663", "Clarke 1880 mod.",
-"CPM", "a=6375738.7", "rf=334.29", "Comm. des Poids et Mesures 1799",
-"delmbr", "a=6376428.", "rf=311.5", "Delambre 1810 (Belgium)",
-"engelis", "a=6378136.05", "rf=298.2566", "Engelis 1985",
-"evrst30", "a=6377276.345", "rf=300.8017", "Everest 1830",
-"evrst48", "a=6377304.063", "rf=300.8017", "Everest 1948",
-"evrst56", "a=6377301.243", "rf=300.8017", "Everest 1956",
-"evrst69", "a=6377295.664", "rf=300.8017", "Everest 1969",
-"evrstSS", "a=6377298.556", "rf=300.8017", "Everest (Sabah & Sarawak)",
-"fschr60", "a=6378166.", "rf=298.3", "Fischer (Mercury Datum) 1960",
-"fschr60m", "a=6378155.", "rf=298.3", "Modified Fischer 1960",
-"fschr68", "a=6378150.", "rf=298.3", "Fischer 1968",
-"helmert", "a=6378200.", "rf=298.3", "Helmert 1906",
-"hough", "a=6378270.0", "rf=297.", "Hough",
-"intl", "a=6378388.0", "rf=297.", "International 1909 (Hayford)",
-"krass", "a=6378245.0", "rf=298.3", "Krassovsky, 1942",
-"kaula", "a=6378163.", "rf=298.24", "Kaula 1961",
-"lerch", "a=6378139.", "rf=298.257", "Lerch 1979",
-"mprts", "a=6397300.", "rf=191.", "Maupertius 1738",
-"new_intl", "a=6378157.5", "b=6356772.2", "New International 1967",
-"plessis", "a=6376523.", "b=6355863.", "Plessis 1817 (France)",
-"SEasia", "a=6378155.0", "b=6356773.3205", "Southeast Asia",
-"walbeck", "a=6376896.0", "b=6355834.8467", "Walbeck",
-"WGS60", "a=6378165.0", "rf=298.3", "WGS 60",
-"WGS66", "a=6378145.0", "rf=298.25", "WGS 66",
-"WGS72", "a=6378135.0", "rf=298.26", "WGS 72",
-"WGS84", "a=6378137.0", "rf=298.257223563", "WGS 84",
-"sphere", "a=6370997.0", "b=6370997.0", "Normal Sphere (r=6370997)",
-0, 0, 0, 0,
-};
-
-/************************************************************************/
-/* OSRProj4Tokenize() */
-/* */
-/* Custom tokenizing function for PROJ.4 strings. The main */
-/* reason we can't just use CSLTokenizeString is to handle */
-/* strings with a + sign in the exponents of parameter values. */
-/************************************************************************/
-
-char **OSRProj4Tokenize( const char *pszFull )
-
-{
- char *pszStart = NULL;
- char *pszFullWrk;
- char **papszTokens = NULL;
- int i;
-
- if( pszFull == NULL )
- return NULL;
-
- pszFullWrk = CPLStrdup( pszFull );
-
- for( i=0; pszFullWrk[i] != '\0'; i++ )
- {
- switch( pszFullWrk[i] )
- {
- case '+':
- if( i == 0 || pszFullWrk[i-1] == '\0' )
- {
- if( pszStart != NULL )
- {
- if( strstr(pszStart,"=") != NULL )
- papszTokens = CSLAddString( papszTokens, pszStart );
- else
- {
- CPLString osAsBoolean = pszStart;
- osAsBoolean += "=yes";
- papszTokens = CSLAddString( papszTokens, osAsBoolean );
- }
- }
- pszStart = pszFullWrk + i + 1;
- }
- break;
-
- case ' ':
- case '\t':
- case '\n':
- pszFullWrk[i] = '\0';
- break;
-
- default:
- break;
- }
- }
-
- if( pszStart != NULL && strlen(pszStart) > 0 )
- papszTokens = CSLAddString( papszTokens, pszStart );
-
- CPLFree( pszFullWrk );
-
- return papszTokens;
-}
-
-
-/************************************************************************/
-/* OSRImportFromProj4() */
-/************************************************************************/
-
-OGRErr OSRImportFromProj4( OGRSpatialReferenceH hSRS, const char *pszProj4 )
-
-{
- return ((OGRSpatialReference *) hSRS)->importFromProj4( pszProj4 );
-}
-
-/************************************************************************/
-/* OSR_GDV() */
-/* */
-/* Fetch a particular parameter out of the parameter list, or */
-/* the indicated default if it isn't available. This is a */
-/* helper function for importFromProj4(). */
-/************************************************************************/
-
-static double OSR_GDV( char **papszNV, const char * pszField,
- double dfDefaultValue )
-
-{
- const char * pszValue;
-
- pszValue = CSLFetchNameValue( papszNV, pszField );
-
- // special hack to use k_0 if available.
- if( pszValue == NULL && EQUAL(pszField,"k") )
- pszValue = CSLFetchNameValue( papszNV, "k_0" );
-
- if( pszValue == NULL )
- return dfDefaultValue;
- else
- return CPLDMSToDec(pszValue);
-}
-
-/************************************************************************/
-/* importFromProj4() */
-/************************************************************************/
-
-/**
- * Import PROJ.4 coordinate string.
- *
- * The OGRSpatialReference is initialized from the passed PROJ.4 style
- * coordinate system string. In addition to many +proj formulations which
- * have OGC equivelents, it is also possible to import "+init=epsg:n" style
- * definitions. These are passed to importFromEPSG(). Other init strings
- * (such as the state plane zones) are not currently supported.
- *
- * Example:
- * pszProj4 = "+proj=utm +zone=11 +datum=WGS84"
- *
- * This method is the equivelent of the C function OSRImportFromProj4().
- *
- * @param pszProj4 the PROJ.4 style string.
- *
- * @return OGRERR_NONE on success or OGRERR_CORRUPT_DATA on failure.
- */
-
-OGRErr OGRSpatialReference::importFromProj4( const char * pszProj4 )
-
-{
- char **papszNV = NULL;
- char **papszTokens;
- int i;
- char *pszCleanCopy;
-
-/* -------------------------------------------------------------------- */
-/* Strip any newlines or other "funny" stuff that might occur */
-/* if this string just came from reading a file. */
-/* -------------------------------------------------------------------- */
- pszCleanCopy = CPLStrdup( pszProj4 );
- for( i = 0; pszCleanCopy[i] != '\0'; i++ )
- {
- if( pszCleanCopy[i] == 10
- || pszCleanCopy[i] == 13
- || pszCleanCopy[i] == 9 )
- pszCleanCopy[i] = ' ';
- }
-
-/* -------------------------------------------------------------------- */
-/* Try to normalize the definition. This should expand +init= */
-/* clauses and so forth. */
-/* -------------------------------------------------------------------- */
- char *pszNormalized;
-
- pszNormalized = OCTProj4Normalize( pszCleanCopy );
- CPLFree( pszCleanCopy );
-
-/* -------------------------------------------------------------------- */
-/* If we have an EPSG based init string, try to process it */
-/* directly to get the fullest possible EPSG definition. */
-/* -------------------------------------------------------------------- */
- if( strstr(pszNormalized,"init=epsg:") != NULL )
- {
- OGRErr eErr;
- const char *pszNumber = strstr(pszNormalized,"init=epsg:") + 10;
-
- eErr = importFromEPSG( atoi(pszNumber) );
- if( eErr == OGRERR_NONE )
- {
- CPLFree( pszNormalized );
- return eErr;
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Parse the PROJ.4 string into a cpl_string.h style name/value */
-/* list. */
-/* -------------------------------------------------------------------- */
- papszTokens = OSRProj4Tokenize( pszNormalized );
- CPLFree( pszNormalized );
-
- for( i = 0; papszTokens != NULL && papszTokens[i] != NULL; i++ )
- {
- char *pszEqual = strstr(papszTokens[i],"=");
-
- if( pszEqual == NULL )
- papszNV = CSLAddNameValue(papszNV, papszTokens[i], "" );
- else
- {
- pszEqual[0] = '\0';
- papszNV = CSLAddNameValue( papszNV, papszTokens[i], pszEqual+1 );
- }
- }
-
- CSLDestroy( papszTokens );
-
-/* -------------------------------------------------------------------- */
-/* Extract the prime meridian, if there is one set. */
-/* -------------------------------------------------------------------- */
- const char *pszPM = CSLFetchNameValue( papszNV, "pm" );
- double dfFromGreenwich = 0.0;
- int nPMCode = -1;
-
- if( pszPM != NULL )
- {
- if( EQUAL(pszPM,"lisbon") )
- {
- dfFromGreenwich = CPLDMSToDec( "9d07'54.862\"W" );
- nPMCode = 8902;
- }
- else if( EQUAL(pszPM,"paris") )
- {
- dfFromGreenwich = CPLDMSToDec( "2d20'14.025\"E" );
- nPMCode = 8903;
- }
- else if( EQUAL(pszPM,"bogota") )
- {
- dfFromGreenwich = CPLDMSToDec( "74d04'51.3\"W" );
- nPMCode = 8904;
- }
- else if( EQUAL(pszPM,"madrid") )
- {
- dfFromGreenwich = CPLDMSToDec( "3d41'16.48\"W" );
- nPMCode = 8905;
- }
- else if( EQUAL(pszPM,"rome") )
- {
- dfFromGreenwich = CPLDMSToDec( "12d27'8.4\"E" );
- nPMCode = 8906;
- }
- else if( EQUAL(pszPM,"bern") )
- {
- dfFromGreenwich = CPLDMSToDec( "7d26'22.5\"E" );
- nPMCode = 8907;
- }
- else if( EQUAL(pszPM,"jakarta") )
- {
- dfFromGreenwich = CPLDMSToDec( "106d48'27.79\"E" );
- nPMCode = 8908;
- }
- else if( EQUAL(pszPM,"ferro") )
- {
- dfFromGreenwich = CPLDMSToDec( "17d40'W" );
- nPMCode = 8909;
- }
- else if( EQUAL(pszPM,"brussels") )
- {
- dfFromGreenwich = CPLDMSToDec( "4d22'4.71\"E" );
- nPMCode = 8910;
- }
- else if( EQUAL(pszPM,"stockholm") )
- {
- dfFromGreenwich = CPLDMSToDec( "18d3'29.8\"E" );
- nPMCode = 8911;
- }
- else if( EQUAL(pszPM,"athens") )
- {
- dfFromGreenwich = CPLDMSToDec( "23d42'58.815\"E" );
- nPMCode = 8912;
- }
- else if( EQUAL(pszPM,"oslo") )
- {
- dfFromGreenwich = CPLDMSToDec( "10d43'22.5\"E" );
- nPMCode = 8913;
- }
- else
- {
- dfFromGreenwich = CPLDMSToDec( pszPM );
- pszPM = "unnamed";
- }
- }
- else
- pszPM = "Greenwich";
-
-/* -------------------------------------------------------------------- */
-/* Operate on the basis of the projection name. */
-/* -------------------------------------------------------------------- */
- const char *pszProj = CSLFetchNameValue(papszNV,"proj");
-
- if( pszProj == NULL )
- {
- CPLDebug( "OGR_PROJ4", "Can't find +proj= in:\n%s", pszProj4 );
- CSLDestroy( papszNV );
- return OGRERR_CORRUPT_DATA;
- }
-
- else if( EQUAL(pszProj,"longlat") || EQUAL(pszProj,"latlong") )
- {
- }
-
- else if( EQUAL(pszProj,"bonne") )
- {
- SetBonne( OSR_GDV( papszNV, "lat_1", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"cass") )
- {
- SetCS( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"nzmg") )
- {
- SetNZMG( OSR_GDV( papszNV, "lat_0", -41.0 ),
- OSR_GDV( papszNV, "lon_0", 173.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 2510000.0 ),
- OSR_GDV( papszNV, "y_0", 6023150.0 ) );
- }
-
- else if( EQUAL(pszProj,"cea") )
- {
- SetCEA( OSR_GDV( papszNV, "lat_ts", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"tmerc") )
- {
- SetTM( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "k", 1.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"utm") )
- {
- SetUTM( (int) OSR_GDV( papszNV, "zone", 0.0 ),
- (int) OSR_GDV( papszNV, "south", 1.0 ) );
- }
-
- else if( EQUAL(pszProj,"merc") /* 2SP form */
- && OSR_GDV(papszNV, "lat_ts", 1000.0) < 999.0 )
- {
- SetMercator2SP( OSR_GDV( papszNV, "lat_ts", 0.0 ),
- 0.0,
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"merc") ) /* 1SP form */
- {
- SetMercator( 0.0,
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "k", 1.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"stere")
- && ABS(OSR_GDV( papszNV, "lat_0", 0.0 ) - 90) < 0.001 )
- {
- SetPS( OSR_GDV( papszNV, "lat_ts", 90.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "k", 1.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"stere")
- && ABS(OSR_GDV( papszNV, "lat_0", 0.0 ) + 90) < 0.001 )
- {
- SetPS( OSR_GDV( papszNV, "lat_ts", -90.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "k", 1.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUALN(pszProj,"stere",5) /* mostly sterea */
- && CSLFetchNameValue(papszNV,"k") != NULL )
- {
- SetOS( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- OSR_GDV( papszNV, "k", 1.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"stere") )
- {
- SetStereographic( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
- 1.0,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"eqc") )
- {
- SetEquirectangular( OSR_GDV( papszNV, "lat_ts", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"gnom") )
- {
- SetGnomonic( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"ortho") )
- {
- SetOrthographic( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"laea") )
- {
- SetLAEA( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"aeqd") )
- {
- SetAE( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"eqdc") )
- {
- SetEC( OSR_GDV( papszNV, "lat_1", 0.0 ),
- OSR_GDV( papszNV, "lat_2", 0.0 ),
- OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"mill") )
- {
- SetMC( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"moll") )
- {
- SetMollweide( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"eck4") )
- {
- SetEckertIV( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"eck6") )
- {
- SetEckertVI( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"poly") )
- {
- SetPolyconic( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"aea") )
- {
- SetACEA( OSR_GDV( papszNV, "lat_1", 0.0 ),
- OSR_GDV( papszNV, "lat_2", 0.0 ),
- OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"robin") )
- {
- SetRobinson( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"vandg") )
- {
- SetVDG( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"sinu") )
- {
- SetSinusoidal( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"gall") )
- {
- SetGS( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"goode") )
- {
- SetGH( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"geos") )
- {
- SetGEOS( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "h", 35785831.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"lcc") )
- {
- if( OSR_GDV(papszNV, "lat_0", 0.0 )
- == OSR_GDV(papszNV, "lat_1", 0.0 ) )
- {
- /* 1SP form */
- SetLCC1SP( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "k_0", 1.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
- else
- {
- /* 2SP form */
- SetLCC( OSR_GDV( papszNV, "lat_1", 0.0 ),
- OSR_GDV( papszNV, "lat_2", 0.0 ),
- OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
- }
-
- else if( EQUAL(pszProj,"omerc") )
- {
- SetHOM( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lonc", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "alpha", 0.0 ),
- 0.0, /* ??? */
- OSR_GDV( papszNV, "k", 1.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"somerc") )
- {
- SetHOM( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- 90.0, 90.0,
- OSR_GDV( papszNV, "k", 1.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"krovak") )
- {
- SetKrovak( OSR_GDV( papszNV, "lat_0", 0.0 ),
- OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "alpha", 0.0 ),
- 0.0, // pseudo_standard_parallel_1
- OSR_GDV( papszNV, "k", 1.0 ),
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else if( EQUAL(pszProj,"tpeqd") )
- {
- SetTPED( OSR_GDV( papszNV, "lat_1", 0.0 ),
- OSR_GDV( papszNV, "lon_1", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "lat_2", 0.0 ),
- OSR_GDV( papszNV, "lon_2", 0.0 )+dfFromGreenwich,
- OSR_GDV( papszNV, "x_0", 0.0 ),
- OSR_GDV( papszNV, "y_0", 0.0 ) );
- }
-
- else
- {
- CPLDebug( "OGR_PROJ4", "Unsupported projection: %s", pszProj );
- CSLDestroy( papszNV );
- return OGRERR_CORRUPT_DATA;
- }
-
-/* -------------------------------------------------------------------- */
-/* Try to translate the datum. */
-/* -------------------------------------------------------------------- */
- const char *pszValue;
- int bFullyDefined = FALSE;
-
- pszValue = CSLFetchNameValue(papszNV, "datum");
- if( pszValue == NULL )
- {
- /* do nothing */
- }
- else if( (EQUAL(pszValue,"NAD27") || EQUAL(pszValue,"NAD83")
- || EQUAL(pszValue,"WGS84") || EQUAL(pszValue,"WGS72"))
- && dfFromGreenwich == 0.0 )
- {
- SetWellKnownGeogCS( pszValue );
- bFullyDefined = TRUE;
- }
- else if( EQUAL(pszValue,"potsdam") )
- {
- OGRSpatialReference oGCS;
- oGCS.importFromEPSG( 4314 );
- CopyGeogCSFrom( &oGCS );
- bFullyDefined = TRUE;
- }
- else if( EQUAL(pszValue,"nzgd49") )
- {
- OGRSpatialReference oGCS;
- oGCS.importFromEPSG( 4272 );
- CopyGeogCSFrom( &oGCS );
- bFullyDefined = TRUE;
- }
- else
- {
- /* we don't recognise the datum, and ignore it */
- }
-
-/* -------------------------------------------------------------------- */
-/* Set the ellipsoid information. */
-/* -------------------------------------------------------------------- */
- double dfSemiMajor, dfInvFlattening, dfSemiMinor;
-
- pszValue = CSLFetchNameValue(papszNV, "ellps");
- if( pszValue != NULL && !bFullyDefined )
- {
- for( i = 0; ogr_pj_ellps[i] != NULL; i += 4 )
- {
- if( !EQUAL(ogr_pj_ellps[i],pszValue) )
- continue;
-
- CPLAssert( EQUALN(ogr_pj_ellps[i+1],"a=",2) );
-
- dfSemiMajor = atof(ogr_pj_ellps[i+1]+2);
- if( EQUALN(ogr_pj_ellps[i+2],"rf=",3) )
- dfInvFlattening = atof(ogr_pj_ellps[i+2]+3);
- else
- {
- CPLAssert( EQUALN(ogr_pj_ellps[i+2],"b=",2) );
- dfSemiMinor = atof(ogr_pj_ellps[i+2]+2);
-
- if( ABS(dfSemiMajor/dfSemiMinor) - 1.0 < 0.0000000000001 )
- dfInvFlattening = 0.0;
- else
- dfInvFlattening = -1.0 / (dfSemiMinor/dfSemiMajor - 1.0);
- }
-
- SetGeogCS( ogr_pj_ellps[i+3], "unknown", ogr_pj_ellps[i],
- dfSemiMajor, dfInvFlattening,
- pszPM, dfFromGreenwich );
-
- bFullyDefined = TRUE;
- break;
- }
- }
-
- if( !bFullyDefined )
- {
- dfSemiMajor = OSR_GDV( papszNV, "a", 0.0 );
- if( dfSemiMajor == 0.0 )
- {
- dfSemiMajor = OSR_GDV( papszNV, "R", 0.0 );
- if( dfSemiMajor != 0.0 )
- {
- dfSemiMinor = -1.0;
- dfInvFlattening = 0.0;
- }
- else
- {
- CPLDebug( "OGR_PROJ4", "Can't find ellipse definition, default to WGS84:\n%s",
- pszProj4 );
-
- dfSemiMajor = SRS_WGS84_SEMIMAJOR;
- dfSemiMinor = -1.0;
- dfInvFlattening = SRS_WGS84_INVFLATTENING;
- }
- }
- else
- {
- dfSemiMinor = OSR_GDV( papszNV, "b", -1.0 );
- dfInvFlattening = OSR_GDV( papszNV, "rf", -1.0 );
- }
-
- if( dfSemiMinor == -1.0 && dfInvFlattening == -1.0 )
- {
- CPLDebug( "OGR_PROJ4", "Can't find ellipse definition in:\n%s",
- pszProj4 );
- CSLDestroy( papszNV );
- return OGRERR_UNSUPPORTED_SRS;
- }
-
- if( dfInvFlattening == -1.0 )
- {
- if( ABS(dfSemiMajor/dfSemiMinor) - 1.0 < 0.0000000000001 )
- dfInvFlattening = 0.0;
- else
- dfInvFlattening = -1.0 / (dfSemiMinor/dfSemiMajor - 1.0);
- }
-
- SetGeogCS( "unnamed ellipse", "unknown", "unnamed",
- dfSemiMajor, dfInvFlattening,
- pszPM, dfFromGreenwich );
-
- bFullyDefined = TRUE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Handle TOWGS84 conversion. */
-/* -------------------------------------------------------------------- */
- pszValue = CSLFetchNameValue(papszNV, "towgs84");
- if(pszValue!=NULL)
- {
- char **papszToWGS84 = CSLTokenizeStringComplex( pszValue, ",",
- FALSE, TRUE );
-
- if( CSLCount(papszToWGS84) >= 7 )
- SetTOWGS84( atof(papszToWGS84[0]),
- atof(papszToWGS84[1]),
- atof(papszToWGS84[2]),
- atof(papszToWGS84[3]),
- atof(papszToWGS84[4]),
- atof(papszToWGS84[5]),
- atof(papszToWGS84[6]) );
- else if( CSLCount(papszToWGS84) >= 3 )
- SetTOWGS84( atof(papszToWGS84[0]),
- atof(papszToWGS84[1]),
- atof(papszToWGS84[2]) );
- else
- CPLError( CE_Warning, CPLE_AppDefined,
- "Seemingly corrupt +towgs84 option (%s), ignoring.",
- pszValue );
-
- CSLDestroy(papszToWGS84);
- }
-
-/* -------------------------------------------------------------------- */
-/* Linear units translation */
-/* -------------------------------------------------------------------- */
- if( IsProjected() || IsLocal() )
- {
- pszValue = CSLFetchNameValue(papszNV, "to_meter");
-
- if( pszValue != NULL && atof(pszValue) > 0.0 )
- {
- SetLinearUnits( "unknown", atof(pszValue) );
- }
- else if( (pszValue = CSLFetchNameValue(papszNV, "units")) != NULL )
- {
- if( EQUAL(pszValue,"meter" ) || EQUAL(pszValue,"m") )
- SetLinearUnits( SRS_UL_METER, 1.0 );
- else if( EQUAL(pszValue,"us-ft" ) )
- SetLinearUnits( SRS_UL_US_FOOT, atof(SRS_UL_US_FOOT_CONV) );
- else if( EQUAL(pszValue,"ft" ) )
- SetLinearUnits( SRS_UL_FOOT, atof(SRS_UL_FOOT_CONV) );
- else if( EQUAL(pszValue,"yd" ) )
- SetLinearUnits( pszValue, 0.9144 );
- else if( EQUAL(pszValue,"us-yd" ) )
- SetLinearUnits( pszValue, 0.914401828803658 );
- else // This case is untranslatable. Should add all proj.4 unts
- SetLinearUnits( pszValue, 1.0 );
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Adjust linear parameters into PROJCS units if the linear */
-/* units are not meters. */
-/* -------------------------------------------------------------------- */
- if( GetLinearUnits() != 1.0 && IsProjected() )
- {
- OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
- int i;
-
- for( i = 0; i < poPROJCS->GetChildCount(); i++ )
- {
- OGR_SRSNode *poParm = poPROJCS->GetChild(i);
- if( !EQUAL(poParm->GetValue(),"PARAMETER")
- || poParm->GetChildCount() != 2 )
- continue;
-
- const char *pszParmName = poParm->GetChild(0)->GetValue();
-
- if( IsLinearParameter(pszParmName) )
- SetNormProjParm(pszParmName,GetProjParm(pszParmName));
- }
- }
-
-
-/* -------------------------------------------------------------------- */
-/* do we want to insert a PROJ.4 EXTENSION item? */
-/* -------------------------------------------------------------------- */
- if( strstr(pszProj4,"wktext") != NULL )
- SetExtension( GetRoot()->GetValue(), "PROJ4", pszProj4 );
-
- CSLDestroy( papszNV );
-
- return OGRERR_NONE;
-}
-
-
-/************************************************************************/
-/* OSRExportToProj4() */
-/************************************************************************/
-
-OGRErr CPL_STDCALL OSRExportToProj4( OGRSpatialReferenceH hSRS,
- char ** ppszReturn )
-
-{
- *ppszReturn = NULL;
-
- return ((OGRSpatialReference *) hSRS)->exportToProj4( ppszReturn );
-}
-
-/************************************************************************/
-/* exportToProj4() */
-/************************************************************************/
-
-/**
- * Export coordinate system in PROJ.4 format.
- *
- * Converts the loaded coordinate reference system into PROJ.4 format
- * to the extent possible. The string returned in ppszProj4 should be
- * deallocated by the caller with CPLFree() when no longer needed.
- *
- * LOCAL_CS coordinate systems are not translatable. An empty string
- * will be returned along with OGRERR_NONE.
- *
- * This method is the equivelent of the C function OSRExportToProj4().
- *
- * @param ppszProj4 pointer to which dynamically allocated PROJ.4 definition
- * will be assigned.
- *
- * @return OGRERR_NONE on success or an error code on failure.
- */
-
-OGRErr OGRSpatialReference::exportToProj4( char ** ppszProj4 ) const
-
-{
- char szProj4[512];
- const char *pszProjection = GetAttrValue("PROJECTION");
-
- szProj4[0] = '\0';
-
-/* -------------------------------------------------------------------- */
-/* Do we have a PROJ.4 override definition? */
-/* -------------------------------------------------------------------- */
- const char *pszPredefProj4 = GetExtension( GetRoot()->GetValue(),
- "PROJ4", NULL );
- if( pszPredefProj4 != NULL )
- {
- *ppszProj4 = CPLStrdup( pszPredefProj4 );
- return OGRERR_NONE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Get the prime meridian info. */
-/* -------------------------------------------------------------------- */
- const OGR_SRSNode *poPRIMEM = GetAttrNode( "PRIMEM" );
- double dfFromGreenwich = 0.0;
-
- if( poPRIMEM != NULL && poPRIMEM->GetChildCount() >= 2
- && atof(poPRIMEM->GetChild(1)->GetValue()) != 0.0 )
- {
- dfFromGreenwich = atof(poPRIMEM->GetChild(1)->GetValue());
- }
-
-/* ==================================================================== */
-/* Handle the projection definition. */
-/* ==================================================================== */
-
- if( pszProjection == NULL && IsGeographic() )
- {
- sprintf( szProj4+strlen(szProj4), "+proj=longlat " );
- }
- else if( pszProjection == NULL && !IsGeographic() )
- {
- // LOCAL_CS, or incompletely initialized coordinate systems.
- *ppszProj4 = CPLStrdup("");
- return OGRERR_NONE;
- }
- else if( EQUAL(pszProjection,SRS_PT_CYLINDRICAL_EQUAL_AREA) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=cea +lon_0=%.16g +lat_ts=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_BONNE) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=bonne +lon_0=%.16g +lat_1=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_CASSINI_SOLDNER) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=cass +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_NEW_ZEALAND_MAP_GRID) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=nzmg +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR) ||
- EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_21) ||
- EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_22) ||
- EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_23) ||
- EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_24) ||
- EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_25) )
- {
- int bNorth;
- int nZone = GetUTMZone( &bNorth );
-
- if( nZone != 0 )
- {
- if( bNorth )
- sprintf( szProj4+strlen(szProj4), "+proj=utm +zone=%d ",
- nZone );
- else
- sprintf( szProj4+strlen(szProj4),"+proj=utm +zone=%d +south ",
- nZone );
- }
- else
- sprintf( szProj4+strlen(szProj4),
- "+proj=tmerc +lat_0=%.16g +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_MERCATOR_1SP) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=merc +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_MERCATOR_2SP) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=merc +lon_0=%.16g +lat_ts=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_OBLIQUE_STEREOGRAPHIC) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=sterea +lat_0=%.16g +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
-// "+proj=stere +lat_0=%.16g +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_STEREOGRAPHIC) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=stere +lat_0=%.16g +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_POLAR_STEREOGRAPHIC) )
- {
- if( GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0) >= 0.0 )
- sprintf( szProj4+strlen(szProj4),
- "+proj=stere +lat_0=90 +lat_ts=%.16g +lon_0=%.16g "
- "+k=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,90.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- else
- sprintf( szProj4+strlen(szProj4),
- "+proj=stere +lat_0=-90 +lat_ts=%.16g +lon_0=%.16g "
- "+k=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,-90.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_EQUIRECTANGULAR) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=eqc +lat_ts=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_GNOMONIC) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=gnom +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_ORTHOGRAPHIC) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=ortho +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=laea +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_AZIMUTHAL_EQUIDISTANT) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=aeqd +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_EQUIDISTANT_CONIC) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=eqdc +lat_0=%.16g +lon_0=%.16g +lat_1=%.16g +lat_2=%.16g"
- " +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_CENTER,0.0),
- GetNormProjParm(SRS_PP_LONGITUDE_OF_CENTER,0.0),
- GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
- GetNormProjParm(SRS_PP_STANDARD_PARALLEL_2,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_MILLER_CYLINDRICAL) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=mill +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g +R_A ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_MOLLWEIDE) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=moll +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_ECKERT_IV) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=eck4 +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_ECKERT_VI) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=eck6 +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_POLYCONIC) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=poly +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_ALBERS_CONIC_EQUAL_AREA) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=aea +lat_1=%.16g +lat_2=%.16g +lat_0=%.16g +lon_0=%.16g"
- " +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
- GetNormProjParm(SRS_PP_STANDARD_PARALLEL_2,0.0),
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_ROBINSON) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=robin +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_VANDERGRINTEN) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=vandg +lon_0=%.16g +x_0=%.16g +y_0=%.16g +R_A ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_SINUSOIDAL) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=sinu +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LONGITUDE_OF_CENTER,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_GALL_STEREOGRAPHIC) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=gall +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_GOODE_HOMOLOSINE) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=goode +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_GEOSTATIONARY_SATELLITE) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=geos +lon_0=%.16g +h=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_SATELLITE_HEIGHT,35785831.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP)
- || EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=lcc +lat_1=%.16g +lat_2=%.16g +lat_0=%.16g +lon_0=%.16g"
- " +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
- GetNormProjParm(SRS_PP_STANDARD_PARALLEL_2,0.0),
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=lcc +lat_1=%.16g +lat_0=%.16g +lon_0=%.16g"
- " +k_0=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_HOTINE_OBLIQUE_MERCATOR) )
- {
- /* not clear how ProjParm[3] - angle from rectified to skewed grid -
- should be applied ... see the +not_rot flag for PROJ.4.
- Just ignoring for now. */
-
- /* special case for swiss oblique mercator : see bug 423 */
- if( fabs(GetNormProjParm(SRS_PP_AZIMUTH,0.0) - 90.0) < 0.0001
- && fabs(GetNormProjParm(SRS_PP_RECTIFIED_GRID_ANGLE,0.0)-90.0) < 0.0001 )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=somerc +lat_0=%.16g +lon_0=%.16g"
- " +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
- else
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=omerc +lat_0=%.16g +lonc=%.16g +alpha=%.16g"
- " +k=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_AZIMUTH,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
- }
-
- else if( EQUAL(pszProjection,
- SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=omerc +lat_0=%.16g"
- " +lon_1=%.16g +lat_1=%.16g +lon_2=%.16g +lat_2=%.16g"
- " +k=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_LATITUDE_OF_POINT_1,0.0),
- GetNormProjParm(SRS_PP_LONGITUDE_OF_POINT_1,0.0),
- GetNormProjParm(SRS_PP_LATITUDE_OF_POINT_2,0.0),
- GetNormProjParm(SRS_PP_LONGITUDE_OF_POINT_2,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_KROVAK) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=krovak +lat_0=%.16g +lon_0=%.16g +alpha=%.16g"
- " +k=%.16g +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_CENTER,0.0),
- GetNormProjParm(SRS_PP_LONGITUDE_OF_CENTER,0.0),
- GetNormProjParm(SRS_PP_AZIMUTH,0.0),
- GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- else if( EQUAL(pszProjection,SRS_PT_TWO_POINT_EQUIDISTANT) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=tpeqd +lat_1=%.16g +lon_1=%.16g "
- "+lat_2=%.16g +lon_2=%.16g "
- "+x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_1ST_POINT,0.0),
- GetNormProjParm(SRS_PP_LONGITUDE_OF_1ST_POINT,0.0),
- GetNormProjParm(SRS_PP_LATITUDE_OF_2ND_POINT,0.0),
- GetNormProjParm(SRS_PP_LONGITUDE_OF_2ND_POINT,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
- /* Note: This never really gets used currently. See bug 423 */
- else if( EQUAL(pszProjection,SRS_PT_SWISS_OBLIQUE_CYLINDRICAL) )
- {
- sprintf( szProj4+strlen(szProj4),
- "+proj=somerc +lat_0=%.16g +lon_0=%.16g"
- " +x_0=%.16g +y_0=%.16g ",
- GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
- GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
- GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
- GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
- }
-
-/* -------------------------------------------------------------------- */
-/* Handle earth model. For now we just always emit the user */
-/* defined ellipsoid parameters. */
-/* -------------------------------------------------------------------- */
- double dfSemiMajor = GetSemiMajor();
- double dfInvFlattening = GetInvFlattening();
- const char *pszPROJ4Ellipse = NULL;
- const char *pszDatum = GetAttrValue("DATUM");
-
- if( ABS(dfSemiMajor-6378249.145) < 0.01
- && ABS(dfInvFlattening-293.465) < 0.0001 )
- {
- pszPROJ4Ellipse = "clrk80"; /* Clark 1880 */
- }
- else if( ABS(dfSemiMajor-6378245.0) < 0.01
- && ABS(dfInvFlattening-298.3) < 0.0001 )
- {
- pszPROJ4Ellipse = "krass"; /* Krassovsky */
- }
- else if( ABS(dfSemiMajor-6378388.0) < 0.01
- && ABS(dfInvFlattening-297.0) < 0.0001 )
- {
- pszPROJ4Ellipse = "intl"; /* International 1924 */
- }
- else if( ABS(dfSemiMajor-6378160.0) < 0.01
- && ABS(dfInvFlattening-298.25) < 0.0001 )
- {
- pszPROJ4Ellipse = "aust_SA"; /* Australian */
- }
- else if( ABS(dfSemiMajor-6377397.155) < 0.01
- && ABS(dfInvFlattening-299.1528128) < 0.0001 )
- {
- pszPROJ4Ellipse = "bessel"; /* Bessel 1841 */
- }
- else if( ABS(dfSemiMajor-6377483.865) < 0.01
- && ABS(dfInvFlattening-299.1528128) < 0.0001 )
- {
- pszPROJ4Ellipse = "bess_nam"; /* Bessel 1841 (Namibia / Schwarzeck)*/
- }
- else if( ABS(dfSemiMajor-6378160.0) < 0.01
- && ABS(dfInvFlattening-298.247167427) < 0.0001 )
- {
- pszPROJ4Ellipse = "GRS67"; /* GRS 1967 */
- }
- else if( ABS(dfSemiMajor-6378137) < 0.01
- && ABS(dfInvFlattening-298.257222101) < 0.000001 )
- {
- pszPROJ4Ellipse = "GRS80"; /* GRS 1980 */
- }
- else if( ABS(dfSemiMajor-6378206.4) < 0.01
- && ABS(dfInvFlattening-294.9786982) < 0.0001 )
- {
- pszPROJ4Ellipse = "clrk66"; /* Clarke 1866 */
- }
- else if( ABS(dfSemiMajor-6378206.4) < 0.01
- && ABS(dfInvFlattening-294.9786982) < 0.0001 )
- {
- pszPROJ4Ellipse = "mod_airy"; /* Modified Airy */
- }
- else if( ABS(dfSemiMajor-6377563.396) < 0.01
- && ABS(dfInvFlattening-299.3249646) < 0.0001 )
- {
- pszPROJ4Ellipse = "airy"; /* Modified Airy */
- }
- else if( ABS(dfSemiMajor-6378200) < 0.01
- && ABS(dfInvFlattening-298.3) < 0.0001 )
- {
- pszPROJ4Ellipse = "helmert"; /* Helmert 1906 */
- }
- else if( ABS(dfSemiMajor-6378155) < 0.01
- && ABS(dfInvFlattening-298.3) < 0.0001 )
- {
- pszPROJ4Ellipse = "fschr60m"; /* Modified Fischer 1960 */
- }
- else if( ABS(dfSemiMajor-6377298.556) < 0.01
- && ABS(dfInvFlattening-300.8017) < 0.0001 )
- {
- pszPROJ4Ellipse = "evrstSS"; /* Everest (Sabah & Sarawak) */
- }
- else if( ABS(dfSemiMajor-6378165.0) < 0.01
- && ABS(dfInvFlattening-298.3) < 0.0001 )
- {
- pszPROJ4Ellipse = "WGS60";
- }
- else if( ABS(dfSemiMajor-6378145.0) < 0.01
- && ABS(dfInvFlattening-298.25) < 0.0001 )
- {
- pszPROJ4Ellipse = "WGS66";
- }
- else if( ABS(dfSemiMajor-6378135.0) < 0.01
- && ABS(dfInvFlattening-298.26) < 0.0001 )
- {
- pszPROJ4Ellipse = "WGS72";
- }
- else if( ABS(dfSemiMajor-6378137.0) < 0.01
- && ABS(dfInvFlattening-298.257223563) < 0.000001 )
- {
- pszPROJ4Ellipse = "WGS84";
- }
- else if( EQUAL(pszDatum,"North_American_Datum_1927") )
- {
-// pszPROJ4Ellipse = "clrk66:+datum=nad27"; /* NAD 27 */
- pszPROJ4Ellipse = "clrk66";
- }
- else if( EQUAL(pszDatum,"North_American_Datum_1983") )
- {
-// pszPROJ4Ellipse = "GRS80:+datum=nad83"; /* NAD 83 */
- pszPROJ4Ellipse = "GRS80";
- }
-
- if( pszPROJ4Ellipse == NULL )
- sprintf( szProj4+strlen(szProj4), "+a=%.16g +b=%.16g ",
- GetSemiMajor(), GetSemiMinor() );
- else
- sprintf( szProj4+strlen(szProj4), "+ellps=%s ",
- pszPROJ4Ellipse );
-
-/* -------------------------------------------------------------------- */
-/* Translate the datum. */
-/* -------------------------------------------------------------------- */
- const char *pszPROJ4Datum = NULL;
- const OGR_SRSNode *poTOWGS84 = GetAttrNode( "TOWGS84" );
- char szTOWGS84[256];
- int nEPSGDatum = -1;
- const char *pszAuthority;
- int nEPSGGeogCS = -1;
- const char *pszGeogCSAuthority;
-
- pszAuthority = GetAuthorityName( "DATUM" );
-
- if( pszAuthority != NULL && EQUAL(pszAuthority,"EPSG") )
- nEPSGDatum = atoi(GetAuthorityCode( "DATUM" ));
-
- pszGeogCSAuthority = GetAuthorityName( "GEOGCS" );
-
- if( pszGeogCSAuthority != NULL && EQUAL(pszGeogCSAuthority,"EPSG") )
- nEPSGGeogCS = atoi(GetAuthorityCode( "GEOGCS" ));
-
- if( pszDatum == NULL )
- /* nothing */;
-
- else if( EQUAL(pszDatum,SRS_DN_NAD27) || nEPSGDatum == 6267 )
- pszPROJ4Datum = "+datum=NAD27";
-
- else if( EQUAL(pszDatum,SRS_DN_NAD83) || nEPSGDatum == 6269 )
- pszPROJ4Datum = "+datum=NAD83";
-
- else if( EQUAL(pszDatum,SRS_DN_WGS84) || nEPSGDatum == 6326 )
- pszPROJ4Datum = "+datum=WGS84";
-
- else if( nEPSGDatum == 6314 )
- pszPROJ4Datum = "+datum=potsdam";
-
- else if( nEPSGDatum == 6272 )
- pszPROJ4Datum = "+datum=nzgd49";
-
- else if( poTOWGS84 != NULL )
- {
- if( poTOWGS84->GetChildCount() > 2
- && (poTOWGS84->GetChildCount() < 6
- || EQUAL(poTOWGS84->GetChild(3)->GetValue(),"")
- && EQUAL(poTOWGS84->GetChild(4)->GetValue(),"")
- && EQUAL(poTOWGS84->GetChild(5)->GetValue(),"")
- && EQUAL(poTOWGS84->GetChild(6)->GetValue(),"")) )
- {
- sprintf( szTOWGS84, "+towgs84=%s,%s,%s",
- poTOWGS84->GetChild(0)->GetValue(),
- poTOWGS84->GetChild(1)->GetValue(),
- poTOWGS84->GetChild(2)->GetValue() );
- pszPROJ4Datum = szTOWGS84;
- }
- else if( poTOWGS84->GetChildCount() > 6 )
- {
- sprintf( szTOWGS84, "+towgs84=%s,%s,%s,%s,%s,%s,%s",
- poTOWGS84->GetChild(0)->GetValue(),
- poTOWGS84->GetChild(1)->GetValue(),
- poTOWGS84->GetChild(2)->GetValue(),
- poTOWGS84->GetChild(3)->GetValue(),
- poTOWGS84->GetChild(4)->GetValue(),
- poTOWGS84->GetChild(5)->GetValue(),
- poTOWGS84->GetChild(6)->GetValue() );
- pszPROJ4Datum = szTOWGS84;
- }
- }
-
- else if( nEPSGGeogCS != -1 )
- {
- double padfTransform[7];
- if( EPSGGetWGS84Transform( nEPSGGeogCS, padfTransform ) )
- {
- sprintf( szTOWGS84, "+towgs84=%f,%f,%f,%f,%f,%f,%f",
- padfTransform[0],
- padfTransform[1],
- padfTransform[2],
- padfTransform[3],
- padfTransform[4],
- padfTransform[5],
- padfTransform[6] );
- pszPROJ4Datum = szTOWGS84;
- }
- }
-
- if( pszPROJ4Datum != NULL )
- {
- strcat( szProj4, pszPROJ4Datum );
- strcat( szProj4, " " );
- }
-
-/* -------------------------------------------------------------------- */
-/* Is there prime meridian info to apply? */
-/* -------------------------------------------------------------------- */
- if( poPRIMEM != NULL && poPRIMEM->GetChildCount() >= 2
- && atof(poPRIMEM->GetChild(1)->GetValue()) != 0.0 )
- {
- const char *pszAuthority = GetAuthorityName( "PRIMEM" );
- char szPMValue[128];
- int nCode = -1;
-
- if( pszAuthority != NULL && EQUAL(pszAuthority,"EPSG") )
- nCode = atoi(GetAuthorityCode( "PRIMEM" ));
-
- switch( nCode )
- {
- case 8902:
- strcpy( szPMValue, "lisbon" );
- break;
-
- case 8903:
- strcpy( szPMValue, "paris" );
- break;
-
- case 8904:
- strcpy( szPMValue, "bogota" );
- break;
-
- case 8905:
- strcpy( szPMValue, "madrid" );
- break;
-
- case 8906:
- strcpy( szPMValue, "rome" );
- break;
-
- case 8907:
- strcpy( szPMValue, "bern" );
- break;
-
- case 8908:
- strcpy( szPMValue, "jakarta" );
- break;
-
- case 8909:
- strcpy( szPMValue, "ferro" );
- break;
-
- case 8910:
- strcpy( szPMValue, "brussels" );
- break;
-
- case 8911:
- strcpy( szPMValue, "stockholm" );
- break;
-
- case 8912:
- strcpy( szPMValue, "athens" );
- break;
-
- case 8913:
- strcpy( szPMValue, "oslo" );
- break;
-
- default:
- sprintf( szPMValue, "%.16g", dfFromGreenwich );
- }
-
- sprintf( szProj4+strlen(szProj4), "+pm=%s ", szPMValue );
- }
-
-/* -------------------------------------------------------------------- */
-/* Handle linear units. */
-/* -------------------------------------------------------------------- */
- const char *pszPROJ4Units=NULL;
- char *pszLinearUnits = NULL;
- double dfLinearConv;
-
- dfLinearConv = GetLinearUnits( &pszLinearUnits );
-
- if( strstr(szProj4,"longlat") != NULL )
- pszPROJ4Units = NULL;
-
- else if( dfLinearConv == 1.0 )
- pszPROJ4Units = "m";
-
- else if( dfLinearConv == 1000.0 )
- pszPROJ4Units = "km";
-
- else if( dfLinearConv == 0.0254 )
- pszPROJ4Units = "in";
-
- else if( EQUAL(pszLinearUnits,SRS_UL_FOOT) )
- pszPROJ4Units = "ft";
-
- else if( EQUAL(pszLinearUnits,"IYARD") || dfLinearConv == 0.9144 )
- pszPROJ4Units = "yd";
-
- else if( dfLinearConv == 0.001 )
- pszPROJ4Units = "mm";
-
- else if( dfLinearConv == 0.01 )
- pszPROJ4Units = "cm";
-
- else if( EQUAL(pszLinearUnits,SRS_UL_US_FOOT) )
- pszPROJ4Units = "us-ft";
-
- else if( EQUAL(pszLinearUnits,SRS_UL_NAUTICAL_MILE) )
- pszPROJ4Units = "kmi";
-
- else if( EQUAL(pszLinearUnits,"Mile")
- || EQUAL(pszLinearUnits,"IMILE") )
- pszPROJ4Units = "mi";
-
- else
- {
- sprintf( szProj4+strlen(szProj4), "+to_meter=%.16g ",
- dfLinearConv );
- }
-
- if( pszPROJ4Units != NULL )
- sprintf( szProj4+strlen(szProj4), "+units=%s ",
- pszPROJ4Units );
-
-/* -------------------------------------------------------------------- */
-/* Add the no_defs flag to ensure that no values from */
-/* proj_def.dat are implicitly used with our definitions. */
-/* -------------------------------------------------------------------- */
- sprintf( szProj4+strlen(szProj4), "+no_defs " );
-
- *ppszProj4 = CPLStrdup( szProj4 );
-
- return OGRERR_NONE;
-}
-
+/******************************************************************************
+ * $Id: ogr_srs_proj4.cpp,v 1.66 2006/11/24 17:58:30 fwarmerdam Exp $
+ *
+ * Project: OpenGIS Simple Features Reference Implementation
+ * Purpose: OGRSpatialReference interface to PROJ.4.
+ * Author: Frank Warmerdam <warmerdam at pobox.com>
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Les Technologies SoftMap 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: ogr_srs_proj4.cpp,v $
+ * Revision 1.66 2006/11/24 17:58:30 fwarmerdam
+ * added support for +wktext / PROJ4 EXTENSION hackery
+ *
+ * Revision 1.65 2006/11/01 04:37:39 fwarmerdam
+ * fixed two point equidistant, preliminary mercator2sp support
+ *
+ * Revision 1.64 2006/05/05 17:02:54 fwarmerdam
+ * Added Krovak PROJ.4 to WKT translation.
+ *
+ * Revision 1.63 2006/04/21 03:33:23 fwarmerdam
+ * Per bug 811 we should not actually be adjusting the central meridian or
+ * other longitudes. They are relative to the geogcs prime meridian in
+ * WKT and PROJ.4 format. Ugg.
+ *
+ * Revision 1.62 2006/04/21 02:44:35 fwarmerdam
+ * Fixed bogota meridian sign (west, not east).
+ *
+ * Revision 1.61 2006/03/21 15:12:22 fwarmerdam
+ * Fixed support for +R parameter.
+ *
+ * Revision 1.60 2005/12/13 15:57:28 dron
+ * Export scale coefficient when exporting to stereographic projection.
+ *
+ * Revision 1.59 2005/12/01 04:59:46 fwarmerdam
+ * added two point equidistant support
+ *
+ * Revision 1.58 2005/11/10 04:12:40 fwarmerdam
+ * The last change related to:
+ * http://bugzilla.remotesensing.org/show_bug.cgi?id=980
+ *
+ * Revision 1.57 2005/11/10 04:12:14 fwarmerdam
+ * Changed the translation for Oblique Stereographic from proj=stere to
+ * proj=sterea.
+ *
+ * Revision 1.56 2005/09/29 20:22:26 dmorissette
+ * Improved support for MapInfo modified TM projections in exportToProj4()
+ * (Anthony D - MITAB bug 1155)
+ *
+ * Revision 1.55 2005/09/05 20:42:52 fwarmerdam
+ * ensure that non-geographic, non-projected srses return empty string
+ *
+ * Revision 1.54 2005/04/06 00:02:05 fwarmerdam
+ * various osr and oct functions now stdcall
+ *
+ * Revision 1.53 2005/02/28 15:01:56 fwarmerdam
+ * Applied patch to add +towgs84 parameter if one is well known for a given
+ * EPSG GEOGCS, and no datum shifting info is available in the source defn.
+ * See http://bugzilla.remotesensing.org/show_bug.cgi?id=784
+ *
+ * Revision 1.52 2005/02/09 20:25:39 fwarmerdam
+ * Changed default height for GEOS projection.
+ *
+ * Revision 1.51 2005/01/05 21:02:33 fwarmerdam
+ * added Goode Homolosine
+ *
+ * Revision 1.50 2004/11/11 18:28:45 fwarmerdam
+ * added Bonne projection support
+ *
+ * Revision 1.49 2004/09/10 21:04:51 fwarmerdam
+ * Various fixes for swiss oblique mercator (somerc) support.
+ * http://bugzilla.remotesensing.org/show_bug.cgi?id=423
+ *
+ * Revision 1.48 2004/09/10 20:29:16 fwarmerdam
+ * Re bug 423: fixed up SRS_PT_SWISS_OBLIQUE_CYLINDRICAL to use somerc.
+ *
+ * Revision 1.47 2004/05/12 14:27:47 warmerda
+ * added translation for nzgd49 and potsdam using epsg codes
+ *
+ * Revision 1.46 2004/05/04 18:49:43 warmerda
+ * Fixed handling of prime meridian. In PROJ.4 strings the central meridian
+ * or other longitude parameters are relative to the prime meridian. Apply
+ * appropriate transformations going and coming from WKT where that is not
+ * the case.
+ *
+ * Revision 1.45 2004/02/05 17:07:59 dron
+ * Support for HOM projection, specified by two points on centerline.
+ *
+ * Revision 1.44 2003/06/27 19:02:04 warmerda
+ * added OSRProj4Tokenize(), fixes plus related tokenizing bug in bug 355
+ *
+ * Revision 1.43 2003/06/27 17:54:12 warmerda
+ * allow k_0 in place of k parsing proj4, bug 355
+ *
+ * Revision 1.42 2003/06/21 23:25:03 warmerda
+ * added +towgs84 support in importFromProj4()
+ *
+ * Revision 1.41 2003/05/28 18:17:38 warmerda
+ * treat meter or m as meter
+ *
+ * Revision 1.40 2003/05/20 18:09:36 warmerda
+ * fixed so that importFromProj4() will transform linear parameter units
+ *
+ * Revision 1.39 2003/02/13 19:27:28 warmerda
+ * always append no_defs to avoid getting hosted by defaults file
+ *
+ * Revision 1.38 2002/12/15 23:42:59 warmerda
+ * added initial support for normalizing proj params
+ *
+ * Revision 1.37 2002/12/14 19:50:21 warmerda
+ * implement support for NZMG (New Zealand Map Grid)
+ *
+ * Revision 1.36 2002/12/10 04:05:04 warmerda
+ * fixed some translation problems with prime meridians
+ *
+ * Revision 1.35 2002/12/09 23:03:45 warmerda
+ * Fixed translation of paris prime meridian.
+ *
+ * Revision 1.34 2002/12/09 18:55:07 warmerda
+ * moved DMS stuff to gdal/port
+ *
+ * Revision 1.33 2002/12/09 16:12:14 warmerda
+ * added +pm= support
+ *
+ * Revision 1.32 2002/12/03 15:38:10 warmerda
+ * dont write linear units to geograpic srs but avoid freaking out
+ *
+ * Revision 1.31 2002/12/01 20:19:21 warmerda
+ * use %.16g to preserve precision as per bug 184
+ *
+ * Revision 1.30 2002/11/29 21:23:38 warmerda
+ * implement LCC1SP PROJ.4 to WKT translation
+ *
+ * Revision 1.29 2002/11/29 20:56:37 warmerda
+ * added LCC1SP conversion to PROJ.4, missing reverse
+ *
+ * Revision 1.28 2002/11/25 03:28:16 warmerda
+ * added/improved documentation
+ *
+ * Revision 1.27 2002/07/09 14:49:07 warmerda
+ * Improved translation from/to polar stereographic as per
+ * http://bugzilla.remotesensing.org/show_bug.cgi?id=172
+ *
+ * Revision 1.26 2002/06/11 18:02:03 warmerda
+ * add PROJ.4 normalization and EPSG support
+ *
+ * Revision 1.25 2002/04/18 14:22:45 warmerda
+ * made OGRSpatialReference and co 'const correct'
+ *
+ * Revision 1.24 2002/03/08 20:17:52 warmerda
+ * assume WGS84 if ellipse info missing
+ *
+ * Revision 1.23 2002/01/18 04:48:48 warmerda
+ * clean tabs, and newlines from input to importProj4
+ *
+ * Revision 1.22 2001/12/12 20:18:06 warmerda
+ * added support for units in proj.4 to WKT
+ *
+ * Revision 1.21 2001/11/07 22:08:51 warmerda
+ * dont put + in to_meter value
+ *
+ * Revision 1.20 2001/11/02 22:21:15 warmerda
+ * fixed memory leak
+ *
+ * Revision 1.19 2001/10/11 19:23:30 warmerda
+ * fixed datum names
+ *
+ * Revision 1.18 2001/07/18 05:03:05 warmerda
+ * added CPL_CVSID
+ *
+ * Revision 1.17 2001/03/02 04:37:43 danmo
+ * Return empty string for LOCAL_CS in exportToProj4().
+ *
+ * Revision 1.16 2001/01/22 14:00:28 warmerda
+ * added untested support for Swiss Oblique Cylindrical
+ *
+ * Revision 1.15 2001/01/19 21:10:46 warmerda
+ * replaced tabs
+ *
+ * Revision 1.14 2000/12/05 23:10:34 warmerda
+ * Added cassini support
+ *
+ * Revision 1.13 2000/12/05 17:46:16 warmerda
+ * Use +R_A for VanDerGrinten and miller
+ *
+ * Revision 1.12 2000/09/25 20:22:21 warmerda
+ * ensure pszPROJ4Units is initialized
+ *
+ * Revision 1.11 2000/09/25 15:46:56 warmerda
+ * added sphere
+ *
+ * Revision 1.10 2000/08/28 20:13:23 warmerda
+ * added importFromProj4
+ *
+ * Revision 1.9 2000/07/11 01:02:06 warmerda
+ * added ExportToProj4()
+ *
+ * Revision 1.8 2000/07/09 20:49:21 warmerda
+ * added +datum support
+ *
+ * Revision 1.7 2000/03/06 02:23:54 warmerda
+ * don't use +datum syntax
+ *
+ * Revision 1.6 1999/12/22 15:39:43 warmerda
+ * fix to differentiate WGS variants
+ *
+ * Revision 1.5 1999/12/13 16:29:59 warmerda
+ * Added improved units, and ellipse support.
+ *
+ * Revision 1.4 1999/12/08 16:34:05 warmerda
+ * added five or six more projections
+ *
+ * Revision 1.1 1999/07/29 17:29:15 warmerda
+ * New
+ *
+ */
+
+#include "ogr_spatialref.h"
+#include "ogr_p.h"
+#include "cpl_conv.h"
+
+extern int EPSGGetWGS84Transform( int nGeogCS, double *padfTransform );
+
+CPL_CVSID("$Id: ogr_srs_proj4.cpp,v 1.66 2006/11/24 17:58:30 fwarmerdam Exp $");
+
+/* -------------------------------------------------------------------- */
+/* The following list comes from osrs/proj/src/pj_ellps.c */
+/* ... please update from time to time. */
+/* -------------------------------------------------------------------- */
+static const char *ogr_pj_ellps[] = {
+"MERIT", "a=6378137.0", "rf=298.257", "MERIT 1983",
+"SGS85", "a=6378136.0", "rf=298.257", "Soviet Geodetic System 85",
+"GRS80", "a=6378137.0", "rf=298.257222101", "GRS 1980(IUGG, 1980)",
+"IAU76", "a=6378140.0", "rf=298.257", "IAU 1976",
+"airy", "a=6377563.396", "b=6356256.910", "Airy 1830",
+"APL4.9", "a=6378137.0.", "rf=298.25", "Appl. Physics. 1965",
+"NWL9D", "a=6378145.0.", "rf=298.25", "Naval Weapons Lab., 1965",
+"mod_airy", "a=6377340.189", "b=6356034.446", "Modified Airy",
+"andrae", "a=6377104.43", "rf=300.0", "Andrae 1876 (Den., Iclnd.)",
+"aust_SA", "a=6378160.0", "rf=298.25", "Australian Natl & S. Amer. 1969",
+"GRS67", "a=6378160.0", "rf=298.2471674270", "GRS 67(IUGG 1967)",
+"bessel", "a=6377397.155", "rf=299.1528128", "Bessel 1841",
+"bess_nam", "a=6377483.865", "rf=299.1528128", "Bessel 1841 (Namibia)",
+"clrk66", "a=6378206.4", "b=6356583.8", "Clarke 1866",
+"clrk80", "a=6378249.145", "rf=293.4663", "Clarke 1880 mod.",
+"CPM", "a=6375738.7", "rf=334.29", "Comm. des Poids et Mesures 1799",
+"delmbr", "a=6376428.", "rf=311.5", "Delambre 1810 (Belgium)",
+"engelis", "a=6378136.05", "rf=298.2566", "Engelis 1985",
+"evrst30", "a=6377276.345", "rf=300.8017", "Everest 1830",
+"evrst48", "a=6377304.063", "rf=300.8017", "Everest 1948",
+"evrst56", "a=6377301.243", "rf=300.8017", "Everest 1956",
+"evrst69", "a=6377295.664", "rf=300.8017", "Everest 1969",
+"evrstSS", "a=6377298.556", "rf=300.8017", "Everest (Sabah & Sarawak)",
+"fschr60", "a=6378166.", "rf=298.3", "Fischer (Mercury Datum) 1960",
+"fschr60m", "a=6378155.", "rf=298.3", "Modified Fischer 1960",
+"fschr68", "a=6378150.", "rf=298.3", "Fischer 1968",
+"helmert", "a=6378200.", "rf=298.3", "Helmert 1906",
+"hough", "a=6378270.0", "rf=297.", "Hough",
+"intl", "a=6378388.0", "rf=297.", "International 1909 (Hayford)",
+"krass", "a=6378245.0", "rf=298.3", "Krassovsky, 1942",
+"kaula", "a=6378163.", "rf=298.24", "Kaula 1961",
+"lerch", "a=6378139.", "rf=298.257", "Lerch 1979",
+"mprts", "a=6397300.", "rf=191.", "Maupertius 1738",
+"new_intl", "a=6378157.5", "b=6356772.2", "New International 1967",
+"plessis", "a=6376523.", "b=6355863.", "Plessis 1817 (France)",
+"SEasia", "a=6378155.0", "b=6356773.3205", "Southeast Asia",
+"walbeck", "a=6376896.0", "b=6355834.8467", "Walbeck",
+"WGS60", "a=6378165.0", "rf=298.3", "WGS 60",
+"WGS66", "a=6378145.0", "rf=298.25", "WGS 66",
+"WGS72", "a=6378135.0", "rf=298.26", "WGS 72",
+"WGS84", "a=6378137.0", "rf=298.257223563", "WGS 84",
+"sphere", "a=6370997.0", "b=6370997.0", "Normal Sphere (r=6370997)",
+0, 0, 0, 0,
+};
+
+/************************************************************************/
+/* OSRProj4Tokenize() */
+/* */
+/* Custom tokenizing function for PROJ.4 strings. The main */
+/* reason we can't just use CSLTokenizeString is to handle */
+/* strings with a + sign in the exponents of parameter values. */
+/************************************************************************/
+
+char **OSRProj4Tokenize( const char *pszFull )
+
+{
+ char *pszStart = NULL;
+ char *pszFullWrk;
+ char **papszTokens = NULL;
+ int i;
+
+ if( pszFull == NULL )
+ return NULL;
+
+ pszFullWrk = CPLStrdup( pszFull );
+
+ for( i=0; pszFullWrk[i] != '\0'; i++ )
+ {
+ switch( pszFullWrk[i] )
+ {
+ case '+':
+ if( i == 0 || pszFullWrk[i-1] == '\0' )
+ {
+ if( pszStart != NULL )
+ {
+ if( strstr(pszStart,"=") != NULL )
+ papszTokens = CSLAddString( papszTokens, pszStart );
+ else
+ {
+ CPLString osAsBoolean = pszStart;
+ osAsBoolean += "=yes";
+ papszTokens = CSLAddString( papszTokens, osAsBoolean );
+ }
+ }
+ pszStart = pszFullWrk + i + 1;
+ }
+ break;
+
+ case ' ':
+ case '\t':
+ case '\n':
+ pszFullWrk[i] = '\0';
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if( pszStart != NULL && strlen(pszStart) > 0 )
+ papszTokens = CSLAddString( papszTokens, pszStart );
+
+ CPLFree( pszFullWrk );
+
+ return papszTokens;
+}
+
+
+/************************************************************************/
+/* OSRImportFromProj4() */
+/************************************************************************/
+
+OGRErr OSRImportFromProj4( OGRSpatialReferenceH hSRS, const char *pszProj4 )
+
+{
+ return ((OGRSpatialReference *) hSRS)->importFromProj4( pszProj4 );
+}
+
+/************************************************************************/
+/* OSR_GDV() */
+/* */
+/* Fetch a particular parameter out of the parameter list, or */
+/* the indicated default if it isn't available. This is a */
+/* helper function for importFromProj4(). */
+/************************************************************************/
+
+static double OSR_GDV( char **papszNV, const char * pszField,
+ double dfDefaultValue )
+
+{
+ const char * pszValue;
+
+ pszValue = CSLFetchNameValue( papszNV, pszField );
+
+ // special hack to use k_0 if available.
+ if( pszValue == NULL && EQUAL(pszField,"k") )
+ pszValue = CSLFetchNameValue( papszNV, "k_0" );
+
+ if( pszValue == NULL )
+ return dfDefaultValue;
+ else
+ return CPLDMSToDec(pszValue);
+}
+
+/************************************************************************/
+/* importFromProj4() */
+/************************************************************************/
+
+/**
+ * Import PROJ.4 coordinate string.
+ *
+ * The OGRSpatialReference is initialized from the passed PROJ.4 style
+ * coordinate system string. In addition to many +proj formulations which
+ * have OGC equivelents, it is also possible to import "+init=epsg:n" style
+ * definitions. These are passed to importFromEPSG(). Other init strings
+ * (such as the state plane zones) are not currently supported.
+ *
+ * Example:
+ * pszProj4 = "+proj=utm +zone=11 +datum=WGS84"
+ *
+ * This method is the equivelent of the C function OSRImportFromProj4().
+ *
+ * @param pszProj4 the PROJ.4 style string.
+ *
+ * @return OGRERR_NONE on success or OGRERR_CORRUPT_DATA on failure.
+ */
+
+OGRErr OGRSpatialReference::importFromProj4( const char * pszProj4 )
+
+{
+ char **papszNV = NULL;
+ char **papszTokens;
+ int i;
+ char *pszCleanCopy;
+
+/* -------------------------------------------------------------------- */
+/* Strip any newlines or other "funny" stuff that might occur */
+/* if this string just came from reading a file. */
+/* -------------------------------------------------------------------- */
+ pszCleanCopy = CPLStrdup( pszProj4 );
+ for( i = 0; pszCleanCopy[i] != '\0'; i++ )
+ {
+ if( pszCleanCopy[i] == 10
+ || pszCleanCopy[i] == 13
+ || pszCleanCopy[i] == 9 )
+ pszCleanCopy[i] = ' ';
+ }
+
+/* -------------------------------------------------------------------- */
+/* Try to normalize the definition. This should expand +init= */
+/* clauses and so forth. */
+/* -------------------------------------------------------------------- */
+ char *pszNormalized;
+
+ pszNormalized = OCTProj4Normalize( pszCleanCopy );
+ CPLFree( pszCleanCopy );
+
+/* -------------------------------------------------------------------- */
+/* If we have an EPSG based init string, try to process it */
+/* directly to get the fullest possible EPSG definition. */
+/* -------------------------------------------------------------------- */
+ if( strstr(pszNormalized,"init=epsg:") != NULL )
+ {
+ OGRErr eErr;
+ const char *pszNumber = strstr(pszNormalized,"init=epsg:") + 10;
+
+ eErr = importFromEPSG( atoi(pszNumber) );
+ if( eErr == OGRERR_NONE )
+ {
+ CPLFree( pszNormalized );
+ return eErr;
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Parse the PROJ.4 string into a cpl_string.h style name/value */
+/* list. */
+/* -------------------------------------------------------------------- */
+ papszTokens = OSRProj4Tokenize( pszNormalized );
+ CPLFree( pszNormalized );
+
+ for( i = 0; papszTokens != NULL && papszTokens[i] != NULL; i++ )
+ {
+ char *pszEqual = strstr(papszTokens[i],"=");
+
+ if( pszEqual == NULL )
+ papszNV = CSLAddNameValue(papszNV, papszTokens[i], "" );
+ else
+ {
+ pszEqual[0] = '\0';
+ papszNV = CSLAddNameValue( papszNV, papszTokens[i], pszEqual+1 );
+ }
+ }
+
+ CSLDestroy( papszTokens );
+
+/* -------------------------------------------------------------------- */
+/* Extract the prime meridian, if there is one set. */
+/* -------------------------------------------------------------------- */
+ const char *pszPM = CSLFetchNameValue( papszNV, "pm" );
+ double dfFromGreenwich = 0.0;
+ int nPMCode = -1;
+
+ if( pszPM != NULL )
+ {
+ if( EQUAL(pszPM,"lisbon") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "9d07'54.862\"W" );
+ nPMCode = 8902;
+ }
+ else if( EQUAL(pszPM,"paris") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "2d20'14.025\"E" );
+ nPMCode = 8903;
+ }
+ else if( EQUAL(pszPM,"bogota") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "74d04'51.3\"W" );
+ nPMCode = 8904;
+ }
+ else if( EQUAL(pszPM,"madrid") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "3d41'16.48\"W" );
+ nPMCode = 8905;
+ }
+ else if( EQUAL(pszPM,"rome") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "12d27'8.4\"E" );
+ nPMCode = 8906;
+ }
+ else if( EQUAL(pszPM,"bern") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "7d26'22.5\"E" );
+ nPMCode = 8907;
+ }
+ else if( EQUAL(pszPM,"jakarta") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "106d48'27.79\"E" );
+ nPMCode = 8908;
+ }
+ else if( EQUAL(pszPM,"ferro") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "17d40'W" );
+ nPMCode = 8909;
+ }
+ else if( EQUAL(pszPM,"brussels") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "4d22'4.71\"E" );
+ nPMCode = 8910;
+ }
+ else if( EQUAL(pszPM,"stockholm") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "18d3'29.8\"E" );
+ nPMCode = 8911;
+ }
+ else if( EQUAL(pszPM,"athens") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "23d42'58.815\"E" );
+ nPMCode = 8912;
+ }
+ else if( EQUAL(pszPM,"oslo") )
+ {
+ dfFromGreenwich = CPLDMSToDec( "10d43'22.5\"E" );
+ nPMCode = 8913;
+ }
+ else
+ {
+ dfFromGreenwich = CPLDMSToDec( pszPM );
+ pszPM = "unnamed";
+ }
+ }
+ else
+ pszPM = "Greenwich";
+
+/* -------------------------------------------------------------------- */
+/* Operate on the basis of the projection name. */
+/* -------------------------------------------------------------------- */
+ const char *pszProj = CSLFetchNameValue(papszNV,"proj");
+
+ if( pszProj == NULL )
+ {
+ CPLDebug( "OGR_PROJ4", "Can't find +proj= in:\n%s", pszProj4 );
+ CSLDestroy( papszNV );
+ return OGRERR_CORRUPT_DATA;
+ }
+
+ else if( EQUAL(pszProj,"longlat") || EQUAL(pszProj,"latlong") )
+ {
+ }
+
+ else if( EQUAL(pszProj,"bonne") )
+ {
+ SetBonne( OSR_GDV( papszNV, "lat_1", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"cass") )
+ {
+ SetCS( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"nzmg") )
+ {
+ SetNZMG( OSR_GDV( papszNV, "lat_0", -41.0 ),
+ OSR_GDV( papszNV, "lon_0", 173.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 2510000.0 ),
+ OSR_GDV( papszNV, "y_0", 6023150.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"cea") )
+ {
+ SetCEA( OSR_GDV( papszNV, "lat_ts", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"tmerc") )
+ {
+ SetTM( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "k", 1.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"utm") )
+ {
+ SetUTM( (int) OSR_GDV( papszNV, "zone", 0.0 ),
+ (int) OSR_GDV( papszNV, "south", 1.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"merc") /* 2SP form */
+ && OSR_GDV(papszNV, "lat_ts", 1000.0) < 999.0 )
+ {
+ SetMercator2SP( OSR_GDV( papszNV, "lat_ts", 0.0 ),
+ 0.0,
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"merc") ) /* 1SP form */
+ {
+ SetMercator( 0.0,
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "k", 1.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"stere")
+ && ABS(OSR_GDV( papszNV, "lat_0", 0.0 ) - 90) < 0.001 )
+ {
+ SetPS( OSR_GDV( papszNV, "lat_ts", 90.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "k", 1.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"stere")
+ && ABS(OSR_GDV( papszNV, "lat_0", 0.0 ) + 90) < 0.001 )
+ {
+ SetPS( OSR_GDV( papszNV, "lat_ts", -90.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "k", 1.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUALN(pszProj,"stere",5) /* mostly sterea */
+ && CSLFetchNameValue(papszNV,"k") != NULL )
+ {
+ SetOS( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ OSR_GDV( papszNV, "k", 1.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"stere") )
+ {
+ SetStereographic( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 ) + dfFromGreenwich,
+ 1.0,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"eqc") )
+ {
+ SetEquirectangular( OSR_GDV( papszNV, "lat_ts", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"gnom") )
+ {
+ SetGnomonic( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"ortho") )
+ {
+ SetOrthographic( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"laea") )
+ {
+ SetLAEA( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"aeqd") )
+ {
+ SetAE( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"eqdc") )
+ {
+ SetEC( OSR_GDV( papszNV, "lat_1", 0.0 ),
+ OSR_GDV( papszNV, "lat_2", 0.0 ),
+ OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"mill") )
+ {
+ SetMC( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"moll") )
+ {
+ SetMollweide( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"eck4") )
+ {
+ SetEckertIV( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"eck6") )
+ {
+ SetEckertVI( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"poly") )
+ {
+ SetPolyconic( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"aea") )
+ {
+ SetACEA( OSR_GDV( papszNV, "lat_1", 0.0 ),
+ OSR_GDV( papszNV, "lat_2", 0.0 ),
+ OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"robin") )
+ {
+ SetRobinson( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"vandg") )
+ {
+ SetVDG( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"sinu") )
+ {
+ SetSinusoidal( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"gall") )
+ {
+ SetGS( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"goode") )
+ {
+ SetGH( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"geos") )
+ {
+ SetGEOS( OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "h", 35785831.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"lcc") )
+ {
+ if( OSR_GDV(papszNV, "lat_0", 0.0 )
+ == OSR_GDV(papszNV, "lat_1", 0.0 ) )
+ {
+ /* 1SP form */
+ SetLCC1SP( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "k_0", 1.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+ else
+ {
+ /* 2SP form */
+ SetLCC( OSR_GDV( papszNV, "lat_1", 0.0 ),
+ OSR_GDV( papszNV, "lat_2", 0.0 ),
+ OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+ }
+
+ else if( EQUAL(pszProj,"omerc") )
+ {
+ SetHOM( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lonc", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "alpha", 0.0 ),
+ 0.0, /* ??? */
+ OSR_GDV( papszNV, "k", 1.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"somerc") )
+ {
+ SetHOM( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ 90.0, 90.0,
+ OSR_GDV( papszNV, "k", 1.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"krovak") )
+ {
+ SetKrovak( OSR_GDV( papszNV, "lat_0", 0.0 ),
+ OSR_GDV( papszNV, "lon_0", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "alpha", 0.0 ),
+ 0.0, // pseudo_standard_parallel_1
+ OSR_GDV( papszNV, "k", 1.0 ),
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else if( EQUAL(pszProj,"tpeqd") )
+ {
+ SetTPED( OSR_GDV( papszNV, "lat_1", 0.0 ),
+ OSR_GDV( papszNV, "lon_1", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "lat_2", 0.0 ),
+ OSR_GDV( papszNV, "lon_2", 0.0 )+dfFromGreenwich,
+ OSR_GDV( papszNV, "x_0", 0.0 ),
+ OSR_GDV( papszNV, "y_0", 0.0 ) );
+ }
+
+ else
+ {
+ CPLDebug( "OGR_PROJ4", "Unsupported projection: %s", pszProj );
+ CSLDestroy( papszNV );
+ return OGRERR_CORRUPT_DATA;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Try to translate the datum. */
+/* -------------------------------------------------------------------- */
+ const char *pszValue;
+ int bFullyDefined = FALSE;
+
+ pszValue = CSLFetchNameValue(papszNV, "datum");
+ if( pszValue == NULL )
+ {
+ /* do nothing */
+ }
+ else if( (EQUAL(pszValue,"NAD27") || EQUAL(pszValue,"NAD83")
+ || EQUAL(pszValue,"WGS84") || EQUAL(pszValue,"WGS72"))
+ && dfFromGreenwich == 0.0 )
+ {
+ SetWellKnownGeogCS( pszValue );
+ bFullyDefined = TRUE;
+ }
+ else if( EQUAL(pszValue,"potsdam") )
+ {
+ OGRSpatialReference oGCS;
+ oGCS.importFromEPSG( 4314 );
+ CopyGeogCSFrom( &oGCS );
+ bFullyDefined = TRUE;
+ }
+ else if( EQUAL(pszValue,"nzgd49") )
+ {
+ OGRSpatialReference oGCS;
+ oGCS.importFromEPSG( 4272 );
+ CopyGeogCSFrom( &oGCS );
+ bFullyDefined = TRUE;
+ }
+ else
+ {
+ /* we don't recognise the datum, and ignore it */
+ }
+
+/* -------------------------------------------------------------------- */
+/* Set the ellipsoid information. */
+/* -------------------------------------------------------------------- */
+ double dfSemiMajor, dfInvFlattening, dfSemiMinor;
+
+ pszValue = CSLFetchNameValue(papszNV, "ellps");
+ if( pszValue != NULL && !bFullyDefined )
+ {
+ for( i = 0; ogr_pj_ellps[i] != NULL; i += 4 )
+ {
+ if( !EQUAL(ogr_pj_ellps[i],pszValue) )
+ continue;
+
+ CPLAssert( EQUALN(ogr_pj_ellps[i+1],"a=",2) );
+
+ dfSemiMajor = atof(ogr_pj_ellps[i+1]+2);
+ if( EQUALN(ogr_pj_ellps[i+2],"rf=",3) )
+ dfInvFlattening = atof(ogr_pj_ellps[i+2]+3);
+ else
+ {
+ CPLAssert( EQUALN(ogr_pj_ellps[i+2],"b=",2) );
+ dfSemiMinor = atof(ogr_pj_ellps[i+2]+2);
+
+ if( ABS(dfSemiMajor/dfSemiMinor) - 1.0 < 0.0000000000001 )
+ dfInvFlattening = 0.0;
+ else
+ dfInvFlattening = -1.0 / (dfSemiMinor/dfSemiMajor - 1.0);
+ }
+
+ SetGeogCS( ogr_pj_ellps[i+3], "unknown", ogr_pj_ellps[i],
+ dfSemiMajor, dfInvFlattening,
+ pszPM, dfFromGreenwich );
+
+ bFullyDefined = TRUE;
+ break;
+ }
+ }
+
+ if( !bFullyDefined )
+ {
+ dfSemiMajor = OSR_GDV( papszNV, "a", 0.0 );
+ if( dfSemiMajor == 0.0 )
+ {
+ dfSemiMajor = OSR_GDV( papszNV, "R", 0.0 );
+ if( dfSemiMajor != 0.0 )
+ {
+ dfSemiMinor = -1.0;
+ dfInvFlattening = 0.0;
+ }
+ else
+ {
+ CPLDebug( "OGR_PROJ4", "Can't find ellipse definition, default to WGS84:\n%s",
+ pszProj4 );
+
+ dfSemiMajor = SRS_WGS84_SEMIMAJOR;
+ dfSemiMinor = -1.0;
+ dfInvFlattening = SRS_WGS84_INVFLATTENING;
+ }
+ }
+ else
+ {
+ dfSemiMinor = OSR_GDV( papszNV, "b", -1.0 );
+ dfInvFlattening = OSR_GDV( papszNV, "rf", -1.0 );
+ }
+
+ if( dfSemiMinor == -1.0 && dfInvFlattening == -1.0 )
+ {
+ CPLDebug( "OGR_PROJ4", "Can't find ellipse definition in:\n%s",
+ pszProj4 );
+ CSLDestroy( papszNV );
+ return OGRERR_UNSUPPORTED_SRS;
+ }
+
+ if( dfInvFlattening == -1.0 )
+ {
+ if( ABS(dfSemiMajor/dfSemiMinor) - 1.0 < 0.0000000000001 )
+ dfInvFlattening = 0.0;
+ else
+ dfInvFlattening = -1.0 / (dfSemiMinor/dfSemiMajor - 1.0);
+ }
+
+ SetGeogCS( "unnamed ellipse", "unknown", "unnamed",
+ dfSemiMajor, dfInvFlattening,
+ pszPM, dfFromGreenwich );
+
+ bFullyDefined = TRUE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Handle TOWGS84 conversion. */
+/* -------------------------------------------------------------------- */
+ pszValue = CSLFetchNameValue(papszNV, "towgs84");
+ if(pszValue!=NULL)
+ {
+ char **papszToWGS84 = CSLTokenizeStringComplex( pszValue, ",",
+ FALSE, TRUE );
+
+ if( CSLCount(papszToWGS84) >= 7 )
+ SetTOWGS84( atof(papszToWGS84[0]),
+ atof(papszToWGS84[1]),
+ atof(papszToWGS84[2]),
+ atof(papszToWGS84[3]),
+ atof(papszToWGS84[4]),
+ atof(papszToWGS84[5]),
+ atof(papszToWGS84[6]) );
+ else if( CSLCount(papszToWGS84) >= 3 )
+ SetTOWGS84( atof(papszToWGS84[0]),
+ atof(papszToWGS84[1]),
+ atof(papszToWGS84[2]) );
+ else
+ CPLError( CE_Warning, CPLE_AppDefined,
+ "Seemingly corrupt +towgs84 option (%s), ignoring.",
+ pszValue );
+
+ CSLDestroy(papszToWGS84);
+ }
+
+/* -------------------------------------------------------------------- */
+/* Linear units translation */
+/* -------------------------------------------------------------------- */
+ if( IsProjected() || IsLocal() )
+ {
+ pszValue = CSLFetchNameValue(papszNV, "to_meter");
+
+ if( pszValue != NULL && atof(pszValue) > 0.0 )
+ {
+ SetLinearUnits( "unknown", atof(pszValue) );
+ }
+ else if( (pszValue = CSLFetchNameValue(papszNV, "units")) != NULL )
+ {
+ if( EQUAL(pszValue,"meter" ) || EQUAL(pszValue,"m") )
+ SetLinearUnits( SRS_UL_METER, 1.0 );
+ else if( EQUAL(pszValue,"us-ft" ) )
+ SetLinearUnits( SRS_UL_US_FOOT, atof(SRS_UL_US_FOOT_CONV) );
+ else if( EQUAL(pszValue,"ft" ) )
+ SetLinearUnits( SRS_UL_FOOT, atof(SRS_UL_FOOT_CONV) );
+ else if( EQUAL(pszValue,"yd" ) )
+ SetLinearUnits( pszValue, 0.9144 );
+ else if( EQUAL(pszValue,"us-yd" ) )
+ SetLinearUnits( pszValue, 0.914401828803658 );
+ else // This case is untranslatable. Should add all proj.4 unts
+ SetLinearUnits( pszValue, 1.0 );
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Adjust linear parameters into PROJCS units if the linear */
+/* units are not meters. */
+/* -------------------------------------------------------------------- */
+ if( GetLinearUnits() != 1.0 && IsProjected() )
+ {
+ OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
+ int i;
+
+ for( i = 0; i < poPROJCS->GetChildCount(); i++ )
+ {
+ OGR_SRSNode *poParm = poPROJCS->GetChild(i);
+ if( !EQUAL(poParm->GetValue(),"PARAMETER")
+ || poParm->GetChildCount() != 2 )
+ continue;
+
+ const char *pszParmName = poParm->GetChild(0)->GetValue();
+
+ if( IsLinearParameter(pszParmName) )
+ SetNormProjParm(pszParmName,GetProjParm(pszParmName));
+ }
+ }
+
+
+/* -------------------------------------------------------------------- */
+/* do we want to insert a PROJ.4 EXTENSION item? */
+/* -------------------------------------------------------------------- */
+ if( strstr(pszProj4,"wktext") != NULL )
+ SetExtension( GetRoot()->GetValue(), "PROJ4", pszProj4 );
+
+ CSLDestroy( papszNV );
+
+ return OGRERR_NONE;
+}
+
+
+/************************************************************************/
+/* OSRExportToProj4() */
+/************************************************************************/
+
+OGRErr CPL_STDCALL OSRExportToProj4( OGRSpatialReferenceH hSRS,
+ char ** ppszReturn )
+
+{
+ *ppszReturn = NULL;
+
+ return ((OGRSpatialReference *) hSRS)->exportToProj4( ppszReturn );
+}
+
+/************************************************************************/
+/* exportToProj4() */
+/************************************************************************/
+
+/**
+ * Export coordinate system in PROJ.4 format.
+ *
+ * Converts the loaded coordinate reference system into PROJ.4 format
+ * to the extent possible. The string returned in ppszProj4 should be
+ * deallocated by the caller with CPLFree() when no longer needed.
+ *
+ * LOCAL_CS coordinate systems are not translatable. An empty string
+ * will be returned along with OGRERR_NONE.
+ *
+ * This method is the equivelent of the C function OSRExportToProj4().
+ *
+ * @param ppszProj4 pointer to which dynamically allocated PROJ.4 definition
+ * will be assigned.
+ *
+ * @return OGRERR_NONE on success or an error code on failure.
+ */
+
+OGRErr OGRSpatialReference::exportToProj4( char ** ppszProj4 ) const
+
+{
+ char szProj4[512];
+ const char *pszProjection = GetAttrValue("PROJECTION");
+
+ szProj4[0] = '\0';
+
+/* -------------------------------------------------------------------- */
+/* Do we have a PROJ.4 override definition? */
+/* -------------------------------------------------------------------- */
+ const char *pszPredefProj4 = GetExtension( GetRoot()->GetValue(),
+ "PROJ4", NULL );
+ if( pszPredefProj4 != NULL )
+ {
+ *ppszProj4 = CPLStrdup( pszPredefProj4 );
+ return OGRERR_NONE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Get the prime meridian info. */
+/* -------------------------------------------------------------------- */
+ const OGR_SRSNode *poPRIMEM = GetAttrNode( "PRIMEM" );
+ double dfFromGreenwich = 0.0;
+
+ if( poPRIMEM != NULL && poPRIMEM->GetChildCount() >= 2
+ && atof(poPRIMEM->GetChild(1)->GetValue()) != 0.0 )
+ {
+ dfFromGreenwich = atof(poPRIMEM->GetChild(1)->GetValue());
+ }
+
+/* ==================================================================== */
+/* Handle the projection definition. */
+/* ==================================================================== */
+
+ if( pszProjection == NULL && IsGeographic() )
+ {
+ sprintf( szProj4+strlen(szProj4), "+proj=longlat " );
+ }
+ else if( pszProjection == NULL && !IsGeographic() )
+ {
+ // LOCAL_CS, or incompletely initialized coordinate systems.
+ *ppszProj4 = CPLStrdup("");
+ return OGRERR_NONE;
+ }
+ else if( EQUAL(pszProjection,SRS_PT_CYLINDRICAL_EQUAL_AREA) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=cea +lon_0=%.16g +lat_ts=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_BONNE) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=bonne +lon_0=%.16g +lat_1=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_CASSINI_SOLDNER) ||
+ EQUAL(pszProjection,SRS_PT_CASSINI_SOLDNER1) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=cass +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_NEW_ZEALAND_MAP_GRID) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=nzmg +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR) ||
+ EQUAL(pszProjection,SRS_PT_TM) ||
+ EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_21) ||
+ EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_22) ||
+ EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_23) ||
+ EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_24) ||
+ EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_MI_25) ||
+ EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED) ||
+ EQUAL(pszProjection,SRS_PT_UTM) )
+ {
+ int bNorth;
+ int nZone = GetUTMZone( &bNorth );
+
+ if( nZone != 0 )
+ {
+ if( bNorth )
+ sprintf( szProj4+strlen(szProj4), "+proj=utm +zone=%d ",
+ nZone );
+ else
+ sprintf( szProj4+strlen(szProj4),"+proj=utm +zone=%d +south ",
+ nZone );
+ }
+ else
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=tmerc +lat_0=%.16g +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_MERCATOR_1SP) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=merc +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_MERCATOR_2SP) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=merc +lon_0=%.16g +lat_ts=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_OBLIQUE_STEREOGRAPHIC) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=sterea +lat_0=%.16g +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
+// "+proj=stere +lat_0=%.16g +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_STEREOGRAPHIC) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=stere +lat_0=%.16g +lon_0=%.16g +k=%f +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_POLAR_STEREOGRAPHIC) )
+ {
+ if( GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0) >= 0.0 )
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=stere +lat_0=90 +lat_ts=%.16g +lon_0=%.16g "
+ "+k=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,90.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ else
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=stere +lat_0=-90 +lat_ts=%.16g +lon_0=%.16g "
+ "+k=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,-90.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_EQUIRECTANGULAR) ||
+ EQUAL(pszProjection,SRS_PT_EQUIDISTANT_CYLINDRICAL) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=eqc +lat_ts=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_GNOMONIC) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=gnom +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_ORTHOGRAPHIC) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=ortho +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=laea +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_AZIMUTHAL_EQUIDISTANT) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=aeqd +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_EQUIDISTANT_CONIC) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=eqdc +lat_0=%.16g +lon_0=%.16g +lat_1=%.16g +lat_2=%.16g"
+ " +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_CENTER,0.0),
+ GetNormProjParm(SRS_PP_LONGITUDE_OF_CENTER,0.0),
+ GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
+ GetNormProjParm(SRS_PP_STANDARD_PARALLEL_2,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_MILLER) ||
+ EQUAL(pszProjection,SRS_PT_MILLER_CYLINDRICAL) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=mill +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g +R_A ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_MOLLWEIDE) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=moll +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_ECKERT_IV) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=eck4 +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_ECKERT_VI) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=eck6 +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_POLYCONIC) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=poly +lat_0=%.16g +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_AE) ||
+ EQUAL(pszProjection,SRS_PT_ALBERS_CONIC_EQUAL_AREA) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=aea +lat_1=%.16g +lat_2=%.16g +lat_0=%.16g +lon_0=%.16g"
+ " +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
+ GetNormProjParm(SRS_PP_STANDARD_PARALLEL_2,0.0),
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_ROBINSON) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=robin +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_VANDERGRINTEN) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=vandg +lon_0=%.16g +x_0=%.16g +y_0=%.16g +R_A ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_SINUSOIDAL) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=sinu +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LONGITUDE_OF_CENTER,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_GALL_STEREOGRAPHIC) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=gall +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_GOODE_HOMOLOSINE) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=goode +lon_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_GEOSTATIONARY_SATELLITE) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=geos +lon_0=%.16g +h=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_SATELLITE_HEIGHT,35785831.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC) ||
+ EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP) ||
+ EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM) ||
+ EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_ALT) ||
+ EQUAL(pszProjection,SRS_PT_LAMBERT_CONIC_CONFORMAL) ||
+ EQUAL(pszProjection,SRS_PT_LAMBERT_CONIC_CONFORMAL_2SP_BELGIUM) ||
+ EQUAL(pszProjection,SRS_PT_LAMBERT_CONIC_CONFORMAL_WEST_ORIENTATED) ||
+ EQUAL(pszProjection,SRS_PT_LCC) ||
+ EQUAL(pszProjection,SRS_PT_LM) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=lcc +lat_1=%.16g +lat_2=%.16g +lat_0=%.16g +lon_0=%.16g"
+ " +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0),
+ GetNormProjParm(SRS_PP_STANDARD_PARALLEL_2,0.0),
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP) ||
+ EQUAL(pszProjection,SRS_PT_LAMBERT_CONIC_CONFORMAL_1SP) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=lcc +lat_1=%.16g +lat_0=%.16g +lon_0=%.16g"
+ " +k_0=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_HOTINE_OBLIQUE_MERCATOR) ||
+ EQUAL(pszProjection,SRS_PT_OBLIQUE_MERCATOR) )
+ {
+ /* not clear how ProjParm[3] - angle from rectified to skewed grid -
+ should be applied ... see the +not_rot flag for PROJ.4.
+ Just ignoring for now. */
+
+ /* special case for swiss oblique mercator : see bug 423 */
+ if( fabs(GetNormProjParm(SRS_PP_AZIMUTH,0.0) - 90.0) < 0.0001
+ && fabs(GetNormProjParm(SRS_PP_RECTIFIED_GRID_ANGLE,0.0)-90.0) < 0.0001 )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=somerc +lat_0=%.16g +lon_0=%.16g"
+ " +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+ else
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=omerc +lat_0=%.16g +lonc=%.16g +alpha=%.16g"
+ " +k=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_AZIMUTH,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+ }
+
+ else if( EQUAL(pszProjection,
+ SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=omerc +lat_0=%.16g"
+ " +lon_1=%.16g +lat_1=%.16g +lon_2=%.16g +lat_2=%.16g"
+ " +k=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_LATITUDE_OF_POINT_1,0.0),
+ GetNormProjParm(SRS_PP_LONGITUDE_OF_POINT_1,0.0),
+ GetNormProjParm(SRS_PP_LATITUDE_OF_POINT_2,0.0),
+ GetNormProjParm(SRS_PP_LONGITUDE_OF_POINT_2,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_KROVAK) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=krovak +lat_0=%.16g +lon_0=%.16g +alpha=%.16g"
+ " +k=%.16g +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_CENTER,0.0),
+ GetNormProjParm(SRS_PP_LONGITUDE_OF_CENTER,0.0),
+ GetNormProjParm(SRS_PP_AZIMUTH,0.0),
+ GetNormProjParm(SRS_PP_SCALE_FACTOR,1.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ else if( EQUAL(pszProjection,SRS_PT_TWO_POINT_EQUIDISTANT) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=tpeqd +lat_1=%.16g +lon_1=%.16g "
+ "+lat_2=%.16g +lon_2=%.16g "
+ "+x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_1ST_POINT,0.0),
+ GetNormProjParm(SRS_PP_LONGITUDE_OF_1ST_POINT,0.0),
+ GetNormProjParm(SRS_PP_LATITUDE_OF_2ND_POINT,0.0),
+ GetNormProjParm(SRS_PP_LONGITUDE_OF_2ND_POINT,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+ /* Note: This never really gets used currently. See bug 423 */
+ else if( EQUAL(pszProjection,SRS_PT_SWISS) ||
+ EQUAL(pszProjection,SRS_PT_SWISS_OBLIQUE_CYLINDRICAL) )
+ {
+ sprintf( szProj4+strlen(szProj4),
+ "+proj=somerc +lat_0=%.16g +lon_0=%.16g"
+ " +x_0=%.16g +y_0=%.16g ",
+ GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+ GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0),
+ GetNormProjParm(SRS_PP_FALSE_EASTING,0.0),
+ GetNormProjParm(SRS_PP_FALSE_NORTHING,0.0) );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Handle earth model. For now we just always emit the user */
+/* defined ellipsoid parameters. */
+/* -------------------------------------------------------------------- */
+ double dfSemiMajor = GetSemiMajor();
+ double dfInvFlattening = GetInvFlattening();
+ const char *pszPROJ4Ellipse = NULL;
+ const char *pszDatum = GetAttrValue("DATUM");
+
+ if( ABS(dfSemiMajor-6378249.145) < 0.01
+ && ABS(dfInvFlattening-293.465) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "clrk80"; /* Clark 1880 */
+ }
+ else if( ABS(dfSemiMajor-6378245.0) < 0.01
+ && ABS(dfInvFlattening-298.3) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "krass"; /* Krassovsky */
+ }
+ else if( ABS(dfSemiMajor-6378388.0) < 0.01
+ && ABS(dfInvFlattening-297.0) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "intl"; /* International 1924 */
+ }
+ else if( ABS(dfSemiMajor-6378160.0) < 0.01
+ && ABS(dfInvFlattening-298.25) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "aust_SA"; /* Australian */
+ }
+ else if( ABS(dfSemiMajor-6377397.155) < 0.01
+ && ABS(dfInvFlattening-299.1528128) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "bessel"; /* Bessel 1841 */
+ }
+ else if( ABS(dfSemiMajor-6377483.865) < 0.01
+ && ABS(dfInvFlattening-299.1528128) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "bess_nam"; /* Bessel 1841 (Namibia / Schwarzeck)*/
+ }
+ else if( ABS(dfSemiMajor-6378160.0) < 0.01
+ && ABS(dfInvFlattening-298.247167427) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "GRS67"; /* GRS 1967 */
+ }
+ else if( ABS(dfSemiMajor-6378137) < 0.01
+ && ABS(dfInvFlattening-298.257222101) < 0.000001 )
+ {
+ pszPROJ4Ellipse = "GRS80"; /* GRS 1980 */
+ }
+ else if( ABS(dfSemiMajor-6378206.4) < 0.01
+ && ABS(dfInvFlattening-294.9786982) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "clrk66"; /* Clarke 1866 */
+ }
+ else if( ABS(dfSemiMajor-6378206.4) < 0.01
+ && ABS(dfInvFlattening-294.9786982) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "mod_airy"; /* Modified Airy */
+ }
+ else if( ABS(dfSemiMajor-6377563.396) < 0.01
+ && ABS(dfInvFlattening-299.3249646) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "airy"; /* Modified Airy */
+ }
+ else if( ABS(dfSemiMajor-6378200) < 0.01
+ && ABS(dfInvFlattening-298.3) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "helmert"; /* Helmert 1906 */
+ }
+ else if( ABS(dfSemiMajor-6378155) < 0.01
+ && ABS(dfInvFlattening-298.3) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "fschr60m"; /* Modified Fischer 1960 */
+ }
+ else if( ABS(dfSemiMajor-6377298.556) < 0.01
+ && ABS(dfInvFlattening-300.8017) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "evrstSS"; /* Everest (Sabah & Sarawak) */
+ }
+ else if( ABS(dfSemiMajor-6378165.0) < 0.01
+ && ABS(dfInvFlattening-298.3) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "WGS60";
+ }
+ else if( ABS(dfSemiMajor-6378145.0) < 0.01
+ && ABS(dfInvFlattening-298.25) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "WGS66";
+ }
+ else if( ABS(dfSemiMajor-6378135.0) < 0.01
+ && ABS(dfInvFlattening-298.26) < 0.0001 )
+ {
+ pszPROJ4Ellipse = "WGS72";
+ }
+ else if( ABS(dfSemiMajor-6378137.0) < 0.01
+ && ABS(dfInvFlattening-298.257223563) < 0.000001 )
+ {
+ pszPROJ4Ellipse = "WGS84";
+ }
+ else if( EQUAL(pszDatum,"North_American_Datum_1927") )
+ {
+// pszPROJ4Ellipse = "clrk66:+datum=nad27"; /* NAD 27 */
+ pszPROJ4Ellipse = "clrk66";
+ }
+ else if( EQUAL(pszDatum,"North_American_Datum_1983") )
+ {
+// pszPROJ4Ellipse = "GRS80:+datum=nad83"; /* NAD 83 */
+ pszPROJ4Ellipse = "GRS80";
+ }
+
+ if( pszPROJ4Ellipse == NULL )
+ sprintf( szProj4+strlen(szProj4), "+a=%.16g +b=%.16g ",
+ GetSemiMajor(), GetSemiMinor() );
+ else
+ sprintf( szProj4+strlen(szProj4), "+ellps=%s ",
+ pszPROJ4Ellipse );
+
+/* -------------------------------------------------------------------- */
+/* Translate the datum. */
+/* -------------------------------------------------------------------- */
+ const char *pszPROJ4Datum = NULL;
+ const OGR_SRSNode *poTOWGS84 = GetAttrNode( "TOWGS84" );
+ char szTOWGS84[256];
+ int nEPSGDatum = -1;
+ const char *pszAuthority;
+ int nEPSGGeogCS = -1;
+ const char *pszGeogCSAuthority;
+
+ pszAuthority = GetAuthorityName( "DATUM" );
+
+ if( pszAuthority != NULL && EQUAL(pszAuthority,"EPSG") )
+ nEPSGDatum = atoi(GetAuthorityCode( "DATUM" ));
+
+ pszGeogCSAuthority = GetAuthorityName( "GEOGCS" );
+
+ if( pszGeogCSAuthority != NULL && EQUAL(pszGeogCSAuthority,"EPSG") )
+ nEPSGGeogCS = atoi(GetAuthorityCode( "GEOGCS" ));
+
+ if( pszDatum == NULL )
+ /* nothing */;
+
+ else if( EQUAL(pszDatum,SRS_DN_NAD27) || nEPSGDatum == 6267 )
+ pszPROJ4Datum = "+datum=NAD27";
+
+ else if( EQUAL(pszDatum,SRS_DN_NAD83) || nEPSGDatum == 6269 )
+ pszPROJ4Datum = "+datum=NAD83";
+
+ else if( EQUAL(pszDatum,SRS_DN_WGS84) || nEPSGDatum == 6326 )
+ pszPROJ4Datum = "+datum=WGS84";
+
+ else if( nEPSGDatum == 6314 )
+ pszPROJ4Datum = "+datum=potsdam";
+
+ else if( nEPSGDatum == 6272 )
+ pszPROJ4Datum = "+datum=nzgd49";
+
+ else if( poTOWGS84 != NULL )
+ {
+ if( poTOWGS84->GetChildCount() > 2
+ && (poTOWGS84->GetChildCount() < 6
+ || EQUAL(poTOWGS84->GetChild(3)->GetValue(),"")
+ && EQUAL(poTOWGS84->GetChild(4)->GetValue(),"")
+ && EQUAL(poTOWGS84->GetChild(5)->GetValue(),"")
+ && EQUAL(poTOWGS84->GetChild(6)->GetValue(),"")) )
+ {
+ sprintf( szTOWGS84, "+towgs84=%s,%s,%s",
+ poTOWGS84->GetChild(0)->GetValue(),
+ poTOWGS84->GetChild(1)->GetValue(),
+ poTOWGS84->GetChild(2)->GetValue() );
+ pszPROJ4Datum = szTOWGS84;
+ }
+ else if( poTOWGS84->GetChildCount() > 6 )
+ {
+ sprintf( szTOWGS84, "+towgs84=%s,%s,%s,%s,%s,%s,%s",
+ poTOWGS84->GetChild(0)->GetValue(),
+ poTOWGS84->GetChild(1)->GetValue(),
+ poTOWGS84->GetChild(2)->GetValue(),
+ poTOWGS84->GetChild(3)->GetValue(),
+ poTOWGS84->GetChild(4)->GetValue(),
+ poTOWGS84->GetChild(5)->GetValue(),
+ poTOWGS84->GetChild(6)->GetValue() );
+ pszPROJ4Datum = szTOWGS84;
+ }
+ }
+
+ else if( nEPSGGeogCS != -1 )
+ {
+ double padfTransform[7];
+ if( EPSGGetWGS84Transform( nEPSGGeogCS, padfTransform ) )
+ {
+ sprintf( szTOWGS84, "+towgs84=%f,%f,%f,%f,%f,%f,%f",
+ padfTransform[0],
+ padfTransform[1],
+ padfTransform[2],
+ padfTransform[3],
+ padfTransform[4],
+ padfTransform[5],
+ padfTransform[6] );
+ pszPROJ4Datum = szTOWGS84;
+ }
+ }
+
+ if( pszPROJ4Datum != NULL )
+ {
+ strcat( szProj4, pszPROJ4Datum );
+ strcat( szProj4, " " );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Is there prime meridian info to apply? */
+/* -------------------------------------------------------------------- */
+ if( poPRIMEM != NULL && poPRIMEM->GetChildCount() >= 2
+ && atof(poPRIMEM->GetChild(1)->GetValue()) != 0.0 )
+ {
+ const char *pszAuthority = GetAuthorityName( "PRIMEM" );
+ char szPMValue[128];
+ int nCode = -1;
+
+ if( pszAuthority != NULL && EQUAL(pszAuthority,"EPSG") )
+ nCode = atoi(GetAuthorityCode( "PRIMEM" ));
+
+ switch( nCode )
+ {
+ case 8902:
+ strcpy( szPMValue, "lisbon" );
+ break;
+
+ case 8903:
+ strcpy( szPMValue, "paris" );
+ break;
+
+ case 8904:
+ strcpy( szPMValue, "bogota" );
+ break;
+
+ case 8905:
+ strcpy( szPMValue, "madrid" );
+ break;
+
+ case 8906:
+ strcpy( szPMValue, "rome" );
+ break;
+
+ case 8907:
+ strcpy( szPMValue, "bern" );
+ break;
+
+ case 8908:
+ strcpy( szPMValue, "jakarta" );
+ break;
+
+ case 8909:
+ strcpy( szPMValue, "ferro" );
+ break;
+
+ case 8910:
+ strcpy( szPMValue, "brussels" );
+ break;
+
+ case 8911:
+ strcpy( szPMValue, "stockholm" );
+ break;
+
+ case 8912:
+ strcpy( szPMValue, "athens" );
+ break;
+
+ case 8913:
+ strcpy( szPMValue, "oslo" );
+ break;
+
+ default:
+ sprintf( szPMValue, "%.16g", dfFromGreenwich );
+ }
+
+ sprintf( szProj4+strlen(szProj4), "+pm=%s ", szPMValue );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Handle linear units. */
+/* -------------------------------------------------------------------- */
+ const char *pszPROJ4Units=NULL;
+ char *pszLinearUnits = NULL;
+ double dfLinearConv;
+
+ dfLinearConv = GetLinearUnits( &pszLinearUnits );
+
+ if( strstr(szProj4,"longlat") != NULL )
+ pszPROJ4Units = NULL;
+
+ else if( dfLinearConv == 1.0 )
+ pszPROJ4Units = "m";
+
+ else if( dfLinearConv == 1000.0 )
+ pszPROJ4Units = "km";
+
+ else if( dfLinearConv == 0.0254 )
+ pszPROJ4Units = "in";
+
+ else if( EQUAL(pszLinearUnits,SRS_UL_FOOT) )
+ pszPROJ4Units = "ft";
+
+ else if( EQUAL(pszLinearUnits,"IYARD") || dfLinearConv == 0.9144 )
+ pszPROJ4Units = "yd";
+
+ else if( dfLinearConv == 0.001 )
+ pszPROJ4Units = "mm";
+
+ else if( dfLinearConv == 0.01 )
+ pszPROJ4Units = "cm";
+
+ else if( EQUAL(pszLinearUnits,SRS_UL_US_FOOT) )
+ pszPROJ4Units = "us-ft";
+
+ else if( EQUAL(pszLinearUnits,SRS_UL_NAUTICAL_MILE) )
+ pszPROJ4Units = "kmi";
+
+ else if( EQUAL(pszLinearUnits,"Mile")
+ || EQUAL(pszLinearUnits,"IMILE") )
+ pszPROJ4Units = "mi";
+
+ else
+ {
+ sprintf( szProj4+strlen(szProj4), "+to_meter=%.16g ",
+ dfLinearConv );
+ }
+
+ if( pszPROJ4Units != NULL )
+ sprintf( szProj4+strlen(szProj4), "+units=%s ",
+ pszPROJ4Units );
+
+/* -------------------------------------------------------------------- */
+/* Add the no_defs flag to ensure that no values from */
+/* proj_def.dat are implicitly used with our definitions. */
+/* -------------------------------------------------------------------- */
+ sprintf( szProj4+strlen(szProj4), "+no_defs " );
+
+ *ppszProj4 = CPLStrdup( szProj4 );
+
+ return OGRERR_NONE;
+}
+
Modified: trunk/MgDev/Oem/gdal-1.4.0/ogr/ogrspatialreference.cpp
===================================================================
--- trunk/MgDev/Oem/gdal-1.4.0/ogr/ogrspatialreference.cpp 2007-03-21 00:47:37 UTC (rev 1308)
+++ trunk/MgDev/Oem/gdal-1.4.0/ogr/ogrspatialreference.cpp 2007-03-21 00:50:25 UTC (rev 1309)
@@ -1,5092 +1,5095 @@
-/******************************************************************************
- * $Id: ogrspatialreference.cpp,v 1.104 2006/12/18 16:22:51 fwarmerdam Exp $
- *
- * Project: OpenGIS Simple Features Reference Implementation
- * Purpose: The OGRSpatialReference class.
- * Author: Frank Warmerdam, warmerdam at pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, Les Technologies SoftMap 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: ogrspatialreference.cpp,v $
- * Revision 1.104 2006/12/18 16:22:51 fwarmerdam
- * added support for x-ogc as well as ogc namespace
- *
- * Revision 1.103 2006/11/30 17:48:32 fwarmerdam
- * Avoid uninitialized variable warning.
- *
- * Revision 1.102 2006/11/24 17:58:15 fwarmerdam
- * added extension management methods
- *
- * Revision 1.101 2006/11/21 21:25:27 fwarmerdam
- * Applied ESRI:: modifier to dictionary lookups if requested.
- *
- * Revision 1.100 2006/11/07 18:55:07 fwarmerdam
- * added OGC importFromURN()
- *
- * Revision 1.99 2006/10/14 01:31:14 fwarmerdam
- * NULL target for GetAuthorityName/Code now returns for the root node.
- *
- * Revision 1.98 2005/12/20 02:08:07 fwarmerdam
- * UTM should default to a linear units of meter.
- *
- * Revision 1.97 2005/12/01 04:59:46 fwarmerdam
- * added two point equidistant support
- *
- * Revision 1.96 2005/10/16 01:32:41 fwarmerdam
- * Apply epsilon testing to UTM zone false easting and northing.
- *
- * Revision 1.95 2005/09/21 03:00:42 fwarmerdam
- * fixed return for Release
- *
- * Revision 1.94 2005/09/21 00:51:27 fwarmerdam
- * added Release
- *
- * Revision 1.93 2005/04/06 00:02:05 fwarmerdam
- * various osr and oct functions now stdcall
- *
- * Revision 1.92 2005/03/03 04:55:42 fwarmerdam
- * make exportToWkt() const
- *
- * Revision 1.91 2005/02/11 14:21:28 fwarmerdam
- * added GEOS projection support
- *
- * Revision 1.90 2005/01/13 05:17:37 fwarmerdam
- * added SetLinearUnitsAndUpdateParameters
- *
- * Revision 1.89 2005/01/05 21:02:33 fwarmerdam
- * added Goode Homolosine
- *
- * Revision 1.88 2004/11/11 18:28:45 fwarmerdam
- * added Bonne projection support
- *
- * Revision 1.87 2004/09/23 16:20:13 fwarmerdam
- * added OSRCleanup
- *
- * Revision 1.86 2004/09/10 20:59:06 fwarmerdam
- * Added note on SetSOC() being deprecated.
- *
- * Revision 1.85 2004/05/06 19:26:04 dron
- * Added OSRSetProjection() function.
- *
- * Revision 1.84 2004/05/04 17:54:45 warmerda
- * internal longitude format is greenwich relative - no adjustments needed
- *
- * Revision 1.83 2004/03/04 18:04:45 warmerda
- * added importFromDict() support
- *
- * Revision 1.82 2004/02/05 17:07:59 dron
- * Support for HOM projection, specified by two points on centerline.
- *
- * Revision 1.81 2003/12/05 16:22:49 warmerda
- * optimized IsProjected
- *
- * Revision 1.80 2003/10/07 04:20:50 warmerda
- * added WMS AUTO: support
- *
- * Revision 1.79 2003/09/18 14:43:40 warmerda
- * Ensure that SetAuthority() clears old nodes.
- * Don't crash on NULL root in exportToPrettyWkt().
- *
- * Revision 1.78 2003/08/18 13:26:01 warmerda
- * added SetTMVariant() and related definitions
- *
- * Revision 1.77 2003/06/19 17:10:26 warmerda
- * a couple fixes in last commit
- *
- * Revision 1.76 2003/06/18 18:24:17 warmerda
- * added projection specific set methods to C API
- *
- * Revision 1.75 2003/05/30 18:34:41 warmerda
- * clear existing authority node in SetLinearUnits if one exists
- *
- * Revision 1.74 2003/05/28 19:16:43 warmerda
- * fixed up argument names and stuff for docs
- *
- * Revision 1.73 2003/04/01 14:34:45 warmerda
- * Clarify SetUTM() documentation.
- *
- * Revision 1.72 2003/03/28 17:42:05 warmerda
- * fixed reference/dereference problem
- *
- * Revision 1.71 2003/02/25 04:55:41 warmerda
- * Added SetGeogCSFrom() method. Modified SetWellKnownGeogCS() to use it.
- * Modfied SetGeogCS() to replace an existing GEOGCS node if there is one.
- *
- * Revision 1.70 2003/02/14 22:15:04 warmerda
- * expand tabs
- *
- * Revision 1.69 2003/02/08 00:37:15 warmerda
- * try to improve documentation
- *
- * Revision 1.68 2003/02/06 04:53:12 warmerda
- * added Fixup() method
- *
- * Revision 1.67 2003/01/31 02:27:08 warmerda
- * modified SetFromUserInput() to avoid large buffer on stack
- *
- * Revision 1.66 2003/01/08 18:14:28 warmerda
- * added FixupOrdering()
- */
-
-#include "ogr_spatialref.h"
-#include "ogr_p.h"
-#include "cpl_csv.h"
-
-CPL_CVSID("$Id: ogrspatialreference.cpp,v 1.104 2006/12/18 16:22:51 fwarmerdam Exp $");
-
-// The current opinion is that WKT longitudes like central meridian
-// should be relative to greenwich, not the prime meridian in use.
-// Define the following if they should be relative to the prime meridian
-// of then geogcs.
-#undef WKT_LONGITUDE_RELATIVE_TO_PM
-
-/************************************************************************/
-/* OGRPrintDouble() */
-/************************************************************************/
-
-static void OGRPrintDouble( char * pszStrBuf, double dfValue )
-
-{
- sprintf( pszStrBuf, "%.16g", dfValue );
-
- int nLen = strlen(pszStrBuf);
-
- // The following hack is intended to truncate some "precision" in cases
- // that appear to be roundoff error.
- if( nLen > 15
- && (strcmp(pszStrBuf+nLen-6,"999999") == 0
- || strcmp(pszStrBuf+nLen-6,"000001") == 0) )
- {
- sprintf( pszStrBuf, "%.15g", dfValue );
- }
-}
-
-/************************************************************************/
-/* OGRSpatialReference() */
-/************************************************************************/
-
-/**
- * Constructor.
- *
- * This constructor takes an optional string argument which if passed
- * should be a WKT representation of an SRS. Passing this is equivelent
- * to not passing it, and then calling importFromWkt() with the WKT string.
- *
- * Note that newly created objects are given a reference count of one.
- *
- * The C function OSRNewSpatialReference() does the same thing as this
- * constructor.
- *
- * @param pszWKT well known text definition to which the object should
- * be initialized, or NULL (the default).
- */
-
-OGRSpatialReference::OGRSpatialReference( const char * pszWKT )
-
-{
- bNormInfoSet = FALSE;
- nRefCount = 1;
- poRoot = NULL;
-
- if( pszWKT != NULL )
- importFromWkt( (char **) &pszWKT );
-}
-
-/************************************************************************/
-/* OSRNewSpatialReference() */
-/************************************************************************/
-
-OGRSpatialReferenceH CPL_STDCALL OSRNewSpatialReference( const char *pszWKT )
-
-{
- OGRSpatialReference * poSRS;
-
- poSRS = new OGRSpatialReference();
-
- if( pszWKT != NULL && strlen(pszWKT) > 0 )
- {
- if( poSRS->importFromWkt( (char **) (&pszWKT) ) != OGRERR_NONE )
- {
- delete poSRS;
- poSRS = NULL;
- }
- }
-
- return poSRS;
-}
-
-/************************************************************************/
-/* OGRSpatialReference() */
-/* */
-/* Simple copy constructor. See also Clone(). */
-/************************************************************************/
-
-OGRSpatialReference::OGRSpatialReference(const OGRSpatialReference &oOther)
-
-{
- bNormInfoSet = FALSE;
- nRefCount = 1;
- poRoot = NULL;
-
- if( oOther.poRoot != NULL )
- poRoot = oOther.poRoot->Clone();
-}
-
-/************************************************************************/
-/* ~OGRSpatialReference() */
-/************************************************************************/
-
-/**
- * OGRSpatialReference destructor.
- *
- * The C function OSRDestroySpatialReference() does the same thing as this
- * method.
- */
-
-OGRSpatialReference::~OGRSpatialReference()
-
-{
- if( poRoot != NULL )
- delete poRoot;
-}
-
-/************************************************************************/
-/* OSRDestroySpatialReference() */
-/************************************************************************/
-
-void CPL_STDCALL OSRDestroySpatialReference( OGRSpatialReferenceH hSRS )
-
-{
- delete ((OGRSpatialReference *) hSRS);
-}
-
-/************************************************************************/
-/* Clear() */
-/************************************************************************/
-
-/**
- * Wipe current definition.
- *
- * Returns OGRSpatialReference to a state with no definition, as it
- * exists when first created. It does not affect reference counts.
- */
-
-void OGRSpatialReference::Clear()
-
-{
- if( poRoot )
- delete poRoot;
-
- poRoot = NULL;
-}
-
-/************************************************************************/
-/* operator=() */
-/************************************************************************/
-
-OGRSpatialReference &
-OGRSpatialReference::operator=(const OGRSpatialReference &oSource)
-
-{
- if( poRoot != NULL )
- {
- delete poRoot;
- poRoot = NULL;
- }
-
- if( oSource.poRoot != NULL )
- poRoot = oSource.poRoot->Clone();
-
- return *this;
-}
-
-/************************************************************************/
-/* Reference() */
-/************************************************************************/
-
-/**
- * Increments the reference count by one.
- *
- * The reference count is used keep track of the number of OGRGeometry objects
- * referencing this SRS.
- *
- * The method does the same thing as the C function OSRReference().
- *
- * @return the updated reference count.
- */
-
-int OGRSpatialReference::Reference()
-
-{
- return ++nRefCount;
-}
-
-/************************************************************************/
-/* OSRReference() */
-/************************************************************************/
-
-int OSRReference( OGRSpatialReferenceH hSRS )
-
-{
- return ((OGRSpatialReference *) hSRS)->Reference();
-}
-
-/************************************************************************/
-/* Dereference() */
-/************************************************************************/
-
-/**
- * Decrements the reference count by one.
- *
- * The method does the same thing as the C function OSRDereference().
- *
- * @return the updated reference count.
- */
-
-int OGRSpatialReference::Dereference()
-
-{
- return --nRefCount;
-}
-
-/************************************************************************/
-/* OSRDereference() */
-/************************************************************************/
-
-int OSRDereference( OGRSpatialReferenceH hSRS )
-
-{
- return ((OGRSpatialReference *) hSRS)->Dereference();
-}
-
-/************************************************************************/
-/* GetReferenceCount() */
-/************************************************************************/
-
-/**
- * \fn int OGRSpatialReference::GetReferenceCount() const;
- *
- * Fetch current reference count.
- *
- * @return the current reference count.
- */
-
-/************************************************************************/
-/* Release() */
-/************************************************************************/
-
-/**
- * Decrements the reference count by one, and destroy if zero.
- *
- * The method does the same thing as the C function OSRRelease().
- */
-
-void OGRSpatialReference::Release()
-
-{
- if( this && Dereference() == 0 )
- delete this;
-}
-
-/************************************************************************/
-/* OSRRelease() */
-/************************************************************************/
-
-void OSRRelease( OGRSpatialReferenceH hSRS )
-
-{
- ((OGRSpatialReference *) hSRS)->Release();
-}
-
-/************************************************************************/
-/* SetRoot() */
-/************************************************************************/
-
-/**
- * Set the root SRS node.
- *
- * If the object has an existing tree of OGR_SRSNodes, they are destroyed
- * as part of assigning the new root. Ownership of the passed OGR_SRSNode is
- * is assumed by the OGRSpatialReference.
- *
- * @param poNewRoot object to assign as root.
- */
-
-void OGRSpatialReference::SetRoot( OGR_SRSNode * poNewRoot )
-
-{
- if( poRoot != NULL )
- delete poRoot;
-
- poRoot = poNewRoot;
-}
-
-/************************************************************************/
-/* GetAttrNode() */
-/************************************************************************/
-
-/**
- * Find named node in tree.
- *
- * This method does a pre-order traversal of the node tree searching for
- * a node with this exact value (case insensitive), and returns it. Leaf
- * nodes are not considered, under the assumption that they are just
- * attribute value nodes.
- *
- * If a node appears more than once in the tree (such as UNIT for instance),
- * the first encountered will be returned. Use GetNode() on a subtree to be
- * more specific.
- *
- * @param pszNodePath the name of the node to search for. May contain multiple
- * components such as "GEOGCS|UNITS".
- *
- * @return a pointer to the node found, or NULL if none.
- */
-
-OGR_SRSNode *OGRSpatialReference::GetAttrNode( const char * pszNodePath )
-
-{
- char **papszPathTokens;
- OGR_SRSNode *poNode;
-
- papszPathTokens = CSLTokenizeStringComplex(pszNodePath, "|", TRUE, FALSE);
-
- if( CSLCount( papszPathTokens ) < 1 )
- return NULL;
-
- poNode = GetRoot();
- for( int i = 0; poNode != NULL && papszPathTokens[i] != NULL; i++ )
- {
- poNode = poNode->GetNode( papszPathTokens[i] );
- }
-
- CSLDestroy( papszPathTokens );
-
- return poNode;
-}
-
-const OGR_SRSNode *
-OGRSpatialReference::GetAttrNode( const char * pszNodePath ) const
-
-{
- OGR_SRSNode *poNode;
-
- poNode = ((OGRSpatialReference *) this)->GetAttrNode(pszNodePath);
-
- return poNode;
-}
-
-/************************************************************************/
-/* GetAttrValue() */
-/************************************************************************/
-
-/**
- * Fetch indicated attribute of named node.
- *
- * This method uses GetAttrNode() to find the named node, and then extracts
- * the value of the indicated child. Thus a call to GetAttrValue("UNIT",1)
- * would return the second child of the UNIT node, which is normally the
- * length of the linear unit in meters.
- *
- * This method does the same thing as the C function OSRGetAttrValue().
- *
- * @param pszNodeName the tree node to look for (case insensitive).
- * @param iAttr the child of the node to fetch (zero based).
- *
- * @return the requested value, or NULL if it fails for any reason.
- */
-
-const char *OGRSpatialReference::GetAttrValue( const char * pszNodeName,
- int iAttr ) const
-
-{
- const OGR_SRSNode *poNode;
-
- poNode = GetAttrNode( pszNodeName );
- if( poNode == NULL )
- return NULL;
-
- if( iAttr < 0 || iAttr >= poNode->GetChildCount() )
- return NULL;
-
- return poNode->GetChild(iAttr)->GetValue();
-}
-
-/************************************************************************/
-/* OSRGetAttrValue() */
-/************************************************************************/
-
-const char * CPL_STDCALL OSRGetAttrValue( OGRSpatialReferenceH hSRS,
- const char * pszKey, int iChild )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetAttrValue( pszKey, iChild );
-}
-
-/************************************************************************/
-/* Clone() */
-/************************************************************************/
-
-/**
- * Make a duplicate of this OGRSpatialReference.
- *
- * This method is the same as the C function OSRClone().
- *
- * @return a new SRS, which becomes the responsibility of the caller.
- */
-
-OGRSpatialReference *OGRSpatialReference::Clone() const
-
-{
- OGRSpatialReference *poNewRef;
-
- poNewRef = new OGRSpatialReference();
-
- if( poRoot != NULL )
- poNewRef->poRoot = poRoot->Clone();
-
- return poNewRef;
-}
-
-/************************************************************************/
-/* OSRClone() */
-/************************************************************************/
-
-OGRSpatialReferenceH CPL_STDCALL OSRClone( OGRSpatialReferenceH hSRS )
-
-{
- return (OGRSpatialReferenceH) ((OGRSpatialReference *) hSRS)->Clone();
-}
-
-/************************************************************************/
-/* exportToPrettyWkt() */
-/* */
-/* Translate into a nicely formatted string for display to a */
-/* person. */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::exportToPrettyWkt( char ** ppszResult,
- int bSimplify ) const
-
-{
- if( poRoot == NULL )
- {
- *ppszResult = CPLStrdup("");
- return OGRERR_NONE;
- }
-
- if( bSimplify )
- {
- OGRSpatialReference *poSimpleClone = Clone();
- OGRErr eErr;
-
- poSimpleClone->GetRoot()->StripNodes( "AXIS" );
- poSimpleClone->GetRoot()->StripNodes( "AUTHORITY" );
- poSimpleClone->GetRoot()->StripNodes( "EXTENSION" );
- eErr = poSimpleClone->GetRoot()->exportToPrettyWkt( ppszResult, 1 );
- delete poSimpleClone;
- return eErr;
- }
- else
- return poRoot->exportToPrettyWkt( ppszResult, 1 );
-}
-
-/************************************************************************/
-/* OSRExportToPrettyWkt() */
-/************************************************************************/
-
-OGRErr CPL_STDCALL OSRExportToPrettyWkt( OGRSpatialReferenceH hSRS, char ** ppszReturn,
- int bSimplify)
-
-{
- *ppszReturn = NULL;
-
- return ((OGRSpatialReference *) hSRS)->exportToPrettyWkt( ppszReturn,
- bSimplify );
-}
-
-/************************************************************************/
-/* exportToWkt() */
-/************************************************************************/
-
-/**
- * Convert this SRS into WKT format.
- *
- * Note that the returned WKT string should be freed with OGRFree() or
- * CPLFree() when no longer needed. It is the responsibility of the caller.
- *
- * This method is the same as the C function OSRExportToWkt().
- *
- * @param ppszResult the resulting string is returned in this pointer.
- *
- * @return currently OGRERR_NONE is always returned, but the future it
- * is possible error conditions will develop.
- */
-
-OGRErr OGRSpatialReference::exportToWkt( char ** ppszResult ) const
-
-{
- if( poRoot == NULL )
- {
- *ppszResult = CPLStrdup("");
- return OGRERR_NONE;
- }
- else
- {
- return poRoot->exportToWkt(ppszResult);
- }
-}
-
-/************************************************************************/
-/* OSRExportToWkt() */
-/************************************************************************/
-
-OGRErr CPL_STDCALL OSRExportToWkt( OGRSpatialReferenceH hSRS, char ** ppszReturn )
-
-{
- *ppszReturn = NULL;
-
- return ((OGRSpatialReference *) hSRS)->exportToWkt( ppszReturn );
-}
-
-/************************************************************************/
-/* importFromWkt() */
-/************************************************************************/
-
-/**
- * Import from WKT string.
- *
- * This method will wipe the existing SRS definition, and
- * reassign it based on the contents of the passed WKT string. Only as
- * much of the input string as needed to construct this SRS is consumed from
- * the input string, and the input string pointer
- * is then updated to point to the remaining (unused) input.
- *
- * This method is the same as the C function OSRImportFromWkt().
- *
- * @param ppszInput Pointer to pointer to input. The pointer is updated to
- * point to remaining unused input text.
- *
- * @return OGRERR_NONE if import succeeds, or OGRERR_CORRUPT_DATA if it
- * fails for any reason.
- */
-
-OGRErr OGRSpatialReference::importFromWkt( char ** ppszInput )
-
-{
- if( poRoot != NULL )
- delete poRoot;
-
- bNormInfoSet = FALSE;
-
- poRoot = new OGR_SRSNode();
-
- return poRoot->importFromWkt( ppszInput );
-}
-
-/************************************************************************/
-/* OSRImportFromWkt() */
-/************************************************************************/
-
-OGRErr OSRImportFromWkt( OGRSpatialReferenceH hSRS, char **ppszInput )
-
-{
- return ((OGRSpatialReference *) hSRS)->importFromWkt( ppszInput );
-}
-
-/************************************************************************/
-/* SetNode() */
-/************************************************************************/
-
-/**
- * Set attribute value in spatial reference.
- *
- * Missing intermediate nodes in the path will be created if not already
- * in existance. If the attribute has no children one will be created and
- * assigned the value otherwise the zeroth child will be assigned the value.
- *
- * This method does the same as the C function OSRSetAttrValue().
- *
- * @param pszNodePath full path to attribute to be set. For instance
- * "PROJCS|GEOGCS|UNITS".
- *
- * @param pszNewNodeValue value to be assigned to node, such as "meter".
- * This may be NULL if you just want to force creation of the intermediate
- * path.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetNode( const char * pszNodePath,
- const char * pszNewNodeValue )
-
-{
- char **papszPathTokens;
- int i;
- OGR_SRSNode *poNode;
-
- papszPathTokens = CSLTokenizeStringComplex(pszNodePath, "|", TRUE, FALSE);
-
- if( CSLCount( papszPathTokens ) < 1 )
- return OGRERR_FAILURE;
-
- if( GetRoot() == NULL || !EQUAL(papszPathTokens[0],GetRoot()->GetValue()) )
- {
- SetRoot( new OGR_SRSNode( papszPathTokens[0] ) );
- }
-
- poNode = GetRoot();
- for( i = 1; papszPathTokens[i] != NULL; i++ )
- {
- int j;
-
- for( j = 0; j < poNode->GetChildCount(); j++ )
- {
- if( EQUAL(poNode->GetChild( j )->GetValue(),papszPathTokens[i]) )
- {
- poNode = poNode->GetChild(j);
- j = -1;
- break;
- }
- }
-
- if( j != -1 )
- {
- OGR_SRSNode *poNewNode = new OGR_SRSNode( papszPathTokens[i] );
- poNode->AddChild( poNewNode );
- poNode = poNewNode;
- }
- }
-
- CSLDestroy( papszPathTokens );
-
- if( pszNewNodeValue != NULL )
- {
- if( poNode->GetChildCount() > 0 )
- poNode->GetChild(0)->SetValue( pszNewNodeValue );
- else
- poNode->AddChild( new OGR_SRSNode( pszNewNodeValue ) );
- }
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetAttrValue() */
-/************************************************************************/
-
-OGRErr CPL_STDCALL OSRSetAttrValue( OGRSpatialReferenceH hSRS,
- const char * pszPath, const char * pszValue )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetNode( pszPath, pszValue );
-}
-
-/************************************************************************/
-/* SetNode() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetNode( const char *pszNodePath,
- double dfValue )
-
-{
- char szValue[64];
-
- if( ABS(dfValue - (int) dfValue) == 0.0 )
- sprintf( szValue, "%d", (int) dfValue );
- else
- // notdef: sprintf( szValue, "%.16g", dfValue );
- OGRPrintDouble( szValue, dfValue );
-
- return SetNode( pszNodePath, szValue );
-}
-
-/************************************************************************/
-/* SetAngularUnits() */
-/************************************************************************/
-
-/**
- * Set the angular units for the geographic coordinate system.
- *
- * This method creates a UNITS subnode with the specified values as a
- * child of the GEOGCS node.
- *
- * This method does the same as the C function OSRSetAngularUnits().
- *
- * @param pszUnitsName the units name to be used. Some preferred units
- * names can be found in ogr_srs_api.h such as SRS_UA_DEGREE.
- *
- * @param dfInRadians the value to multiple by an angle in the indicated
- * units to transform to radians. Some standard conversion factors can
- * be found in ogr_srs_api.h.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetAngularUnits( const char * pszUnitsName,
- double dfInRadians )
-
-{
- OGR_SRSNode *poCS;
- OGR_SRSNode *poUnits;
- char szValue[128];
-
- bNormInfoSet = FALSE;
-
- poCS = GetAttrNode( "GEOGCS" );
-
- if( poCS == NULL )
- return OGRERR_FAILURE;
-
- OGRPrintDouble( szValue, dfInRadians );
-
- if( poCS->FindChild( "UNIT" ) >= 0 )
- {
- poUnits = poCS->GetChild( poCS->FindChild( "UNIT" ) );
- poUnits->GetChild(0)->SetValue( pszUnitsName );
- poUnits->GetChild(1)->SetValue( szValue );
- }
- else
- {
- poUnits = new OGR_SRSNode( "UNIT" );
- poUnits->AddChild( new OGR_SRSNode( pszUnitsName ) );
- poUnits->AddChild( new OGR_SRSNode( szValue ) );
-
- poCS->AddChild( poUnits );
- }
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetAngularUnits() */
-/************************************************************************/
-
-OGRErr OSRSetAngularUnits( OGRSpatialReferenceH hSRS,
- const char * pszUnits, double dfInRadians )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetAngularUnits( pszUnits,
- dfInRadians );
-}
-
-/************************************************************************/
-/* GetAngularUnits() */
-/************************************************************************/
-
-/**
- * Fetch angular geographic coordinate system units.
- *
- * If no units are available, a value of "degree" and SRS_UA_DEGREE_CONV
- * will be assumed. This method only checks directly under the GEOGCS node
- * for units.
- *
- * This method does the same thing as the C function OSRGetAngularUnits().
- *
- * @param ppszName a pointer to be updated with the pointer to the
- * units name. The returned value remains internal to the OGRSpatialReference
- * and shouldn't be freed, or modified. It may be invalidated on the next
- * OGRSpatialReference call.
- *
- * @return the value to multiply by angular distances to transform them to
- * radians.
- */
-
-double OGRSpatialReference::GetAngularUnits( char ** ppszName ) const
-
-{
- const OGR_SRSNode *poCS = GetAttrNode( "GEOGCS" );
-
- if( ppszName != NULL )
- *ppszName = "degree";
-
- if( poCS == NULL )
- return atof(SRS_UA_DEGREE_CONV);
-
- for( int iChild = 0; iChild < poCS->GetChildCount(); iChild++ )
- {
- const OGR_SRSNode *poChild = poCS->GetChild(iChild);
-
- if( EQUAL(poChild->GetValue(),"UNIT")
- && poChild->GetChildCount() >= 2 )
- {
- if( ppszName != NULL )
- *ppszName = (char *) poChild->GetChild(0)->GetValue();
-
- return atof( poChild->GetChild(1)->GetValue() );
- }
- }
-
- return 1.0;
-}
-
-/************************************************************************/
-/* OSRGetAngularUnits() */
-/************************************************************************/
-
-double OSRGetAngularUnits( OGRSpatialReferenceH hSRS, char ** ppszName )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetAngularUnits( ppszName );
-}
-
-/************************************************************************/
-/* SetLinearUnitsAndUpdateParameters() */
-/************************************************************************/
-
-/**
- * Set the linear units for the projection.
- *
- * This method creates a UNITS subnode with the specified values as a
- * child of the PROJCS or LOCAL_CS node. It works the same as the
- * SetLinearUnits() method, but it also updates all existing linear
- * projection parameter values from the old units to the new units.
- *
- * @param pszUnitsName the units name to be used. Some preferred units
- * names can be found in ogr_srs_api.h such as SRS_UL_METER, SRS_UL_FOOT
- * and SRS_UL_US_FOOT.
- *
- * @param dfInMeters the value to multiple by a length in the indicated
- * units to transform to meters. Some standard conversion factors can
- * be found in ogr_srs_api.h.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetLinearUnitsAndUpdateParameters(
- const char *pszName, double dfInMeters )
-
-{
- double dfOldInMeters = GetLinearUnits();
- OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
-
- if( dfInMeters == 0.0 )
- return OGRERR_FAILURE;
-
- if( dfInMeters == dfOldInMeters || poPROJCS == NULL )
- return SetLinearUnits( pszName, dfInMeters );
-
- for( int iChild = 0; iChild < poPROJCS->GetChildCount(); iChild++ )
- {
- const OGR_SRSNode *poChild = poPROJCS->GetChild(iChild);
-
- if( EQUAL(poChild->GetValue(),"PARAMETER")
- && poChild->GetChildCount() > 1 )
- {
- char *pszParmName = CPLStrdup(poChild->GetChild(0)->GetValue());
-
- if( IsLinearParameter( pszParmName ) )
- {
- double dfOldValue = GetProjParm( pszParmName );
-
- SetProjParm( pszParmName,
- dfOldValue * dfOldInMeters / dfInMeters );
- }
-
- CPLFree( pszParmName );
- }
- }
-
- return SetLinearUnits( pszName, dfInMeters );
-}
-
-/************************************************************************/
-/* SetLinearUnits() */
-/************************************************************************/
-
-/**
- * Set the linear units for the projection.
- *
- * This method creates a UNITS subnode with the specified values as a
- * child of the PROJCS or LOCAL_CS node.
- *
- * This method does the same as the C function OSRSetLinearUnits().
- *
- * @param pszUnitsName the units name to be used. Some preferred units
- * names can be found in ogr_srs_api.h such as SRS_UL_METER, SRS_UL_FOOT
- * and SRS_UL_US_FOOT.
- *
- * @param dfInMeters the value to multiple by a length in the indicated
- * units to transform to meters. Some standard conversion factors can
- * be found in ogr_srs_api.h.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetLinearUnits( const char * pszUnitsName,
- double dfInMeters )
-
-{
- OGR_SRSNode *poCS;
- OGR_SRSNode *poUnits;
- char szValue[128];
-
- bNormInfoSet = FALSE;
-
- poCS = GetAttrNode( "PROJCS" );
- if( poCS == NULL )
- poCS = GetAttrNode( "LOCAL_CS" );
-
- if( poCS == NULL )
- return OGRERR_FAILURE;
-
- if( dfInMeters == (int) dfInMeters )
- sprintf( szValue, "%d", (int) dfInMeters );
- else
- //notdef: sprintf( szValue, "%.16g", dfInMeters );
- OGRPrintDouble( szValue, dfInMeters );
-
- if( poCS->FindChild( "UNIT" ) >= 0 )
- {
- poUnits = poCS->GetChild( poCS->FindChild( "UNIT" ) );
- poUnits->GetChild(0)->SetValue( pszUnitsName );
- poUnits->GetChild(1)->SetValue( szValue );
- if( poUnits->FindChild( "AUTHORITY" ) != -1 )
- poUnits->DestroyChild( poUnits->FindChild( "AUTHORITY" ) );
- }
- else
- {
- poUnits = new OGR_SRSNode( "UNIT" );
- poUnits->AddChild( new OGR_SRSNode( pszUnitsName ) );
- poUnits->AddChild( new OGR_SRSNode( szValue ) );
-
- poCS->AddChild( poUnits );
- }
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetLinearUnits() */
-/************************************************************************/
-
-OGRErr OSRSetLinearUnits( OGRSpatialReferenceH hSRS,
- const char * pszUnits, double dfInMeters )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetLinearUnits( pszUnits,
- dfInMeters );
-}
-
-/************************************************************************/
-/* GetLinearUnits() */
-/************************************************************************/
-
-/**
- * Fetch linear projection units.
- *
- * If no units are available, a value of "Meters" and 1.0 will be assumed.
- * This method only checks directly under the PROJCS or LOCAL_CS node for
- * units.
- *
- * This method does the same thing as the C function OSRGetLinearUnits()/
- *
- * @param ppszName a pointer to be updated with the pointer to the
- * units name. The returned value remains internal to the OGRSpatialReference
- * and shouldn't be freed, or modified. It may be invalidated on the next
- * OGRSpatialReference call.
- *
- * @return the value to multiply by linear distances to transform them to
- * meters.
- */
-
-double OGRSpatialReference::GetLinearUnits( char ** ppszName ) const
-
-{
- const OGR_SRSNode *poCS = GetAttrNode( "PROJCS" );
-
- if( poCS == NULL )
- poCS = GetAttrNode( "LOCAL_CS" );
-
- if( ppszName != NULL )
- *ppszName = "unknown";
-
- if( poCS == NULL )
- return 1.0;
-
- for( int iChild = 0; iChild < poCS->GetChildCount(); iChild++ )
- {
- const OGR_SRSNode *poChild = poCS->GetChild(iChild);
-
- if( EQUAL(poChild->GetValue(),"UNIT")
- && poChild->GetChildCount() >= 2 )
- {
- if( ppszName != NULL )
- *ppszName = (char *) poChild->GetChild(0)->GetValue();
-
- return atof( poChild->GetChild(1)->GetValue() );
- }
- }
-
- return 1.0;
-}
-
-/************************************************************************/
-/* OSRGetLinearUnits() */
-/************************************************************************/
-
-double OSRGetLinearUnits( OGRSpatialReferenceH hSRS, char ** ppszName )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetLinearUnits( ppszName );
-}
-
-/************************************************************************/
-/* GetPrimeMeridian() */
-/************************************************************************/
-
-/**
- * Fetch prime meridian info.
- *
- * Returns the offset of the prime meridian from greenwich in degrees,
- * and the prime meridian name (if requested). If no PRIMEM value exists
- * in the coordinate system definition a value of "Greenwich" and an
- * offset of 0.0 is assumed.
- *
- * If the prime meridian name is returned, the pointer is to an internal
- * copy of the name. It should not be freed, altered or depended on after
- * the next OGR call.
- *
- * This method is the same as the C function OSRGetPrimeMeridian().
- *
- * @param ppszName return location for prime meridian name. If NULL, name
- * is not returned.
- *
- * @return the offset to the GEOGCS prime meridian from greenwich in decimal
- * degrees.
- */
-
-double OGRSpatialReference::GetPrimeMeridian( char **ppszName ) const
-
-{
- const OGR_SRSNode *poPRIMEM = GetAttrNode( "PRIMEM" );
-
- if( poPRIMEM != NULL && poPRIMEM->GetChildCount() >= 2
- && atof(poPRIMEM->GetChild(1)->GetValue()) != 0.0 )
- {
- if( ppszName != NULL )
- *ppszName = (char *) poPRIMEM->GetChild(0)->GetValue();
- return atof(poPRIMEM->GetChild(1)->GetValue());
- }
-
- if( ppszName != NULL )
- *ppszName = SRS_PM_GREENWICH;
-
- return 0.0;
-}
-
-/************************************************************************/
-/* OSRGetPrimeMeridian() */
-/************************************************************************/
-
-double OSRGetPrimeMeridian( OGRSpatialReferenceH hSRS, char **ppszName )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetPrimeMeridian( ppszName );
-}
-
-/************************************************************************/
-/* SetGeogCS() */
-/************************************************************************/
-
-/**
- * Set geographic coordinate system.
- *
- * This method is used to set the datum, ellipsoid, prime meridian and
- * angular units for a geographic coordinate system. It can be used on it's
- * own to establish a geographic spatial reference, or applied to a
- * projected coordinate system to establish the underlying geographic
- * coordinate system.
- *
- * This method does the same as the C function OSRSetGeogCS().
- *
- * @param pszGeogName user visible name for the geographic coordinate system
- * (not to serve as a key).
- *
- * @param pszDatumName key name for this datum. The OpenGIS specification
- * lists some known values, and otherwise EPSG datum names with a standard
- * transformation are considered legal keys.
- *
- * @param pszSpheroidName user visible spheroid name (not to serve as a key)
- *
- * @param dfSemiMajor the semi major axis of the spheroid.
- *
- * @param dfInvFlattening the inverse flattening for the spheroid.
- * This can be computed from the semi minor axis as
- * 1/f = 1.0 / (1.0 - semiminor/semimajor).
- *
- * @param pszPMName the name of the prime merdidian (not to serve as a key)
- * If this is NULL a default value of "Greenwich" will be used.
- *
- * @param dfPMOffset the longitude of greenwich relative to this prime
- * meridian.
- *
- * @param pszAngularUnits the angular units name (see ogr_srs_api.h for some
- * standard names). If NULL a value of "degrees" will be assumed.
- *
- * @param dfConvertToRadians value to multiply angular units by to transform
- * them to radians. A value of SRS_UL_DEGREE_CONV will be used if
- * pszAngularUnits is NULL.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr
-OGRSpatialReference::SetGeogCS( const char * pszGeogName,
- const char * pszDatumName,
- const char * pszSpheroidName,
- double dfSemiMajor, double dfInvFlattening,
- const char * pszPMName, double dfPMOffset,
- const char * pszAngularUnits,
- double dfConvertToRadians )
-
-{
- bNormInfoSet = FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Do we already have a GEOGCS? If so, blow it away so it can */
-/* be properly replaced. */
-/* -------------------------------------------------------------------- */
- if( GetAttrNode( "GEOGCS" ) != NULL )
- {
- OGR_SRSNode *poPROJCS;
-
- if( EQUAL(GetRoot()->GetValue(),"GEOGCS") )
- Clear();
- else if( (poPROJCS = GetAttrNode( "PROJCS" )) != NULL
- && poPROJCS->FindChild( "GEOGCS" ) != -1 )
- poPROJCS->DestroyChild( poPROJCS->FindChild( "GEOGCS" ) );
- else
- return OGRERR_FAILURE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Set defaults for various parameters. */
-/* -------------------------------------------------------------------- */
- if( pszGeogName == NULL )
- pszGeogName = "unnamed";
-
- if( pszPMName == NULL )
- pszPMName = SRS_PM_GREENWICH;
-
- if( pszDatumName == NULL )
- pszDatumName = "unknown";
-
- if( pszSpheroidName == NULL )
- pszSpheroidName = "unnamed";
-
- if( pszAngularUnits == NULL )
- {
- pszAngularUnits = SRS_UA_DEGREE;
- dfConvertToRadians = atof(SRS_UA_DEGREE_CONV);
- }
-
-/* -------------------------------------------------------------------- */
-/* Build the GEOGCS object. */
-/* -------------------------------------------------------------------- */
- char szValue[128];
- OGR_SRSNode *poGeogCS, *poSpheroid, *poDatum, *poPM, *poUnits;
-
- poGeogCS = new OGR_SRSNode( "GEOGCS" );
- poGeogCS->AddChild( new OGR_SRSNode( pszGeogName ) );
-
-/* -------------------------------------------------------------------- */
-/* Setup the spheroid. */
-/* -------------------------------------------------------------------- */
- poSpheroid = new OGR_SRSNode( "SPHEROID" );
- poSpheroid->AddChild( new OGR_SRSNode( pszSpheroidName ) );
-
- OGRPrintDouble( szValue, dfSemiMajor );
- poSpheroid->AddChild( new OGR_SRSNode(szValue) );
-
- OGRPrintDouble( szValue, dfInvFlattening );
- poSpheroid->AddChild( new OGR_SRSNode(szValue) );
-
-/* -------------------------------------------------------------------- */
-/* Setup the Datum. */
-/* -------------------------------------------------------------------- */
- poDatum = new OGR_SRSNode( "DATUM" );
- poDatum->AddChild( new OGR_SRSNode(pszDatumName) );
- poDatum->AddChild( poSpheroid );
-
-/* -------------------------------------------------------------------- */
-/* Setup the prime meridian. */
-/* -------------------------------------------------------------------- */
- if( dfPMOffset == 0.0 )
- strcpy( szValue, "0" );
- else
- OGRPrintDouble( szValue, dfPMOffset );
-
- poPM = new OGR_SRSNode( "PRIMEM" );
- poPM->AddChild( new OGR_SRSNode( pszPMName ) );
- poPM->AddChild( new OGR_SRSNode( szValue ) );
-
-/* -------------------------------------------------------------------- */
-/* Setup the rotational units. */
-/* -------------------------------------------------------------------- */
- OGRPrintDouble( szValue, dfConvertToRadians );
-
- poUnits = new OGR_SRSNode( "UNIT" );
- poUnits->AddChild( new OGR_SRSNode(pszAngularUnits) );
- poUnits->AddChild( new OGR_SRSNode(szValue) );
-
-/* -------------------------------------------------------------------- */
-/* Complete the GeogCS */
-/* -------------------------------------------------------------------- */
- poGeogCS->AddChild( poDatum );
- poGeogCS->AddChild( poPM );
- poGeogCS->AddChild( poUnits );
-
-/* -------------------------------------------------------------------- */
-/* Attach below the PROJCS if there is one, or make this the root. */
-/* -------------------------------------------------------------------- */
- if( GetRoot() != NULL && EQUAL(GetRoot()->GetValue(),"PROJCS") )
- poRoot->InsertChild( poGeogCS, 1 );
- else
- SetRoot( poGeogCS );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetGeogCS() */
-/************************************************************************/
-
-OGRErr OSRSetGeogCS( OGRSpatialReferenceH hSRS,
- const char * pszGeogName,
- const char * pszDatumName,
- const char * pszSpheroidName,
- double dfSemiMajor, double dfInvFlattening,
- const char * pszPMName, double dfPMOffset,
- const char * pszAngularUnits,
- double dfConvertToRadians )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetGeogCS(
- pszGeogName, pszDatumName,
- pszSpheroidName, dfSemiMajor, dfInvFlattening,
- pszPMName, dfPMOffset, pszAngularUnits, dfConvertToRadians );
-
-}
-
-/************************************************************************/
-/* SetWellKnownGeogCS() */
-/************************************************************************/
-
-/**
- * Set a GeogCS based on well known name.
- *
- * This may be called on an empty OGRSpatialReference to make a geographic
- * coordinate system, or on something with an existing PROJCS node to
- * set the underlying geographic coordinate system of a projected coordinate
- * system.
- *
- * The following well known text values are currently supported:
- * <ul>
- * <li> "WGS84": same as "EPSG:4326" but has no dependence on EPSG data files.
- * <li> "WGS72": same as "EPSG:4322" but has no dependence on EPSG data files.
- * <li> "NAD27": same as "EPSG:4267" but has no dependence on EPSG data files.
- * <li> "NAD83": same as "EPSG:4269" but has no dependence on EPSG data files.
- * <li> "EPSG:n": same as doing an ImportFromEPSG(n).
- * </ul>
- *
- * @param pszName name of well known geographic coordinate system.
- * @return OGRERR_NONE on success, or OGRERR_FAILURE if the name isn't
- * recognised, the target object is already initialized, or an EPSG value
- * can't be successfully looked up.
- */
-
-OGRErr OGRSpatialReference::SetWellKnownGeogCS( const char * pszName )
-
-{
- OGRSpatialReference oSRS2;
- OGRErr eErr;
-
-/* -------------------------------------------------------------------- */
-/* Check for EPSG authority numbers. */
-/* -------------------------------------------------------------------- */
- if( EQUALN(pszName, "EPSG:",5) )
- {
- eErr = oSRS2.importFromEPSG( atoi(pszName+5) );
- if( eErr != OGRERR_NONE )
- return eErr;
-
- if( !oSRS2.IsGeographic() )
- return OGRERR_FAILURE;
-
- return CopyGeogCSFrom( &oSRS2 );
- }
-
-/* -------------------------------------------------------------------- */
-/* Check for simple names. */
-/* -------------------------------------------------------------------- */
- char *pszWKT = NULL;
-
- if( EQUAL(pszName, "WGS84") || EQUAL(pszName,"CRS84") )
- pszWKT = "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( EQUAL(pszName, "WGS72") )
- pszWKT = "GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\",SPHEROID[\"WGS 72\",6378135,298.26,AUTHORITY[\"EPSG\",\"7043\"]],TOWGS84[0,0,4.5,0,0,0.554,0.2263],AUTHORITY[\"EPSG\",\"6322\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4322\"]]";
-
- else if( EQUAL(pszName, "NAD27") || EQUAL(pszName, "CRS27") )
- pszWKT = "GEOGCS[\"NAD27\",DATUM[\"North_American_Datum_1927\",SPHEROID[\"Clarke 1866\",6378206.4,294.978698213898,AUTHORITY[\"EPSG\",\"7008\"]],TOWGS84[-3,142,183,0,0,0,0],AUTHORITY[\"EPSG\",\"6267\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4267\"]]";
-
- else if( EQUAL(pszName, "NAD83") || EQUAL(pszName,"CRS83") )
- pszWKT = "GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6269\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4269\"]]";
-
- else
- return OGRERR_FAILURE;
-
-/* -------------------------------------------------------------------- */
-/* Import the WKT */
-/* -------------------------------------------------------------------- */
- eErr = oSRS2.importFromWkt( &pszWKT );
- if( eErr != OGRERR_NONE )
- return eErr;
-
-/* -------------------------------------------------------------------- */
-/* Copy over. */
-/* -------------------------------------------------------------------- */
- return CopyGeogCSFrom( &oSRS2 );
-}
-
-/************************************************************************/
-/* OSRSetWellKnownGeogCS() */
-/************************************************************************/
-
-OGRErr OSRSetWellKnownGeogCS( OGRSpatialReferenceH hSRS, const char *pszName )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetWellKnownGeogCS( pszName );
-}
-
-/************************************************************************/
-/* CopyGeogCSFrom() */
-/************************************************************************/
-
-/**
- * Copy GEOGCS from another OGRSpatialReference.
- *
- * The GEOGCS information is copied into this OGRSpatialReference from another.
- * If this object has a PROJCS root already, the GEOGCS is installed within
- * it, otherwise it is installed as the root.
- *
- * @param poSrcSRS the spatial reference to copy the GEOGCS information from.
- *
- * @return OGRERR_NONE on success or an error code.
- */
-
-
-OGRErr OGRSpatialReference::CopyGeogCSFrom(
- const OGRSpatialReference * poSrcSRS )
-
-{
- const OGR_SRSNode *poGeogCS = NULL;
-
- bNormInfoSet = FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Do we already have a GEOGCS? If so, blow it away so it can */
-/* be properly replaced. */
-/* -------------------------------------------------------------------- */
- if( GetAttrNode( "GEOGCS" ) != NULL )
- {
- OGR_SRSNode *poPROJCS;
-
- if( EQUAL(GetRoot()->GetValue(),"GEOGCS") )
- Clear();
- else if( (poPROJCS = GetAttrNode( "PROJCS" )) != NULL
- && poPROJCS->FindChild( "GEOGCS" ) != -1 )
- poPROJCS->DestroyChild( poPROJCS->FindChild( "GEOGCS" ) );
- else
- return OGRERR_FAILURE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Find the GEOGCS node on the source. */
-/* -------------------------------------------------------------------- */
- poGeogCS = poSrcSRS->GetAttrNode( "GEOGCS" );
- if( poGeogCS == NULL )
- return OGRERR_FAILURE;
-
-/* -------------------------------------------------------------------- */
-/* Attach below the PROJCS if there is one, or make this the root. */
-/* -------------------------------------------------------------------- */
- if( GetRoot() != NULL && EQUAL(GetRoot()->GetValue(),"PROJCS") )
- poRoot->InsertChild( poGeogCS->Clone(), 1 );
- else
- SetRoot( poGeogCS->Clone() );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRCopyGeogCSFrom() */
-/************************************************************************/
-
-OGRErr OSRCopyGeogCSFrom( OGRSpatialReferenceH hSRS,
- OGRSpatialReferenceH hSrcSRS )
-
-{
- return ((OGRSpatialReference *) hSRS)->CopyGeogCSFrom(
- (const OGRSpatialReference *) hSrcSRS );
-}
-
-/************************************************************************/
-/* SetFromUserInput() */
-/************************************************************************/
-
-/**
- * Set spatial reference from various text formats.
- *
- * This method will examine the provided input, and try to deduce the
- * format, and then use it to initialize the spatial reference system. It
- * may take the following forms:
- *
- * <ol>
- * <li> Well Known Text definition - passed on to importFromWkt().
- * <li> "EPSG:n" - number passed on to importFromEPSG().
- * <li> "AUTO:proj_id,unit_id,lon0,lat0" - WMS auto projections.
- * <li> "urn:ogc:def:crs:EPSG::n" - ogc urns
- * <li> PROJ.4 definitions - passed on to importFromProj4().
- * <li> filename - file read for WKT, XML or PROJ.4 definition.
- * <li> well known name accepted by SetWellKnownGeogCS(), such as NAD27, NAD83,
- * WGS84 or WGS72.
- * </ol>
- *
- * It is expected that this method will be extended in the future to support
- * XML and perhaps a simplified "minilanguage" for indicating common UTM and
- * State Plane definitions.
- *
- * This method is intended to be flexible, but by it's nature it is
- * imprecise as it must guess information about the format intended. When
- * possible applications should call the specific method appropriate if the
- * input is known to be in a particular format.
- *
- * This method does the same thing as the OSRSetFromUserInput() function.
- *
- * @param pszDefinition text definition to try to deduce SRS from.
- *
- * @return OGRERR_NONE on success, or an error code if the name isn't
- * recognised, the definition is corrupt, or an EPSG value can't be
- * successfully looked up.
- */
-
-OGRErr OGRSpatialReference::SetFromUserInput( const char * pszDefinition )
-
-{
- int bESRI = FALSE;
- OGRErr err;
-
- if( EQUALN(pszDefinition,"ESRI::",6) )
- {
- bESRI = TRUE;
- pszDefinition += 6;
- }
-
-/* -------------------------------------------------------------------- */
-/* Is it a recognised syntax? */
-/* -------------------------------------------------------------------- */
- if( EQUALN(pszDefinition,"PROJCS",6)
- || EQUALN(pszDefinition,"GEOGCS",6)
- || EQUALN(pszDefinition,"LOCAL_CS",8) )
- {
- err = importFromWkt( (char **) &pszDefinition );
- if( err == OGRERR_NONE && bESRI )
- err = morphFromESRI();
-
- return err;
- }
-
- if( EQUALN(pszDefinition,"EPSG:",5) )
- return importFromEPSG( atoi(pszDefinition+5) );
-
- if( EQUALN(pszDefinition,"urn:ogc:def:crs:",16)
- || EQUALN(pszDefinition,"urn:x-ogc:def:crs:",18) )
- return importFromURN( pszDefinition );
-
- if( EQUALN(pszDefinition,"AUTO:",5) )
- return importFromWMSAUTO( pszDefinition );
-
- if( EQUALN(pszDefinition,"DICT:",5)
- && strstr(pszDefinition,",") )
- {
- char *pszFile = CPLStrdup(pszDefinition+5);
- char *pszCode = strstr(pszFile,",") + 1;
-
- pszCode[-1] = '\0';
-
- err = importFromDict( pszFile, pszCode );
- CPLFree( pszFile );
-
- if( err == OGRERR_NONE && bESRI )
- err = morphFromESRI();
-
- return err;
- }
-
- if( EQUAL(pszDefinition,"NAD27")
- || EQUAL(pszDefinition,"NAD83")
- || EQUAL(pszDefinition,"WGS84")
- || EQUAL(pszDefinition,"WGS72") )
- {
- Clear();
- return SetWellKnownGeogCS( pszDefinition );
- }
-
- if( strstr(pszDefinition,"+proj") != NULL
- || strstr(pszDefinition,"+init") != NULL )
- return importFromProj4( pszDefinition );
-
-/* -------------------------------------------------------------------- */
-/* Try to open it as a file. */
-/* -------------------------------------------------------------------- */
- FILE *fp;
- int nBufMax = 100000;
- char *pszBufPtr, *pszBuffer;
- int nBytes;
-
- fp = VSIFOpen( pszDefinition, "rt" );
- if( fp == NULL )
- return OGRERR_CORRUPT_DATA;
-
- pszBuffer = (char *) CPLMalloc(nBufMax);
- nBytes = VSIFRead( pszBuffer, 1, nBufMax-1, fp );
- VSIFClose( fp );
-
- if( nBytes == nBufMax-1 )
- {
- CPLDebug( "OGR",
- "OGRSpatialReference::SetFromUserInput(%s), opened file\n"
- "but it is to large for our generous buffer. Is it really\n"
- "just a WKT definition?" );
- CPLFree( pszBuffer );
- return OGRERR_FAILURE;
- }
-
- pszBuffer[nBytes] = '\0';
-
- pszBufPtr = pszBuffer;
- while( pszBufPtr[0] == ' ' || pszBufPtr[0] == '\n' )
- pszBufPtr++;
-
- if( pszBufPtr[0] == '<' )
- err = importFromXML( pszBufPtr );
- else if( strstr(pszBuffer,"+proj") != NULL
- || strstr(pszBuffer,"+init") != NULL )
- err = importFromProj4( pszBufPtr );
- else
- {
- err = importFromWkt( &pszBufPtr );
- if( err == OGRERR_NONE && bESRI )
- err = morphFromESRI();
- }
-
- CPLFree( pszBuffer );
-
- return err;
-}
-
-/************************************************************************/
-/* OSRSetFromUserInput() */
-/************************************************************************/
-
-OGRErr CPL_STDCALL OSRSetFromUserInput( OGRSpatialReferenceH hSRS,
- const char *pszDef )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetFromUserInput( pszDef );
-}
-
-/************************************************************************/
-/* importFromURN() */
-/* */
-/* See OGC recommendation paper 06-023r1 or later for details. */
-/************************************************************************/
-
-/**
- * Initialize from OGC URN.
- *
- * Initializes this spatial reference from a coordinate system defined
- * by an OGC URN prefixed with "urn:ogc:def:crs:" per recommendation
- * paper 06-023r1. Currently EPSG and OGC authority values are supported,
- * including OGC auto codes, but not including CRS1 or CRS88 (NAVD88).
- *
- * This method is also support through SetFromUserInput() which can
- * normally be used for URNs.
- *
- * @param pszURN the urn string.
- *
- * @return OGRERR_NONE on success or an error code.
- */
-
-OGRErr OGRSpatialReference::importFromURN( const char *pszURN )
-
-{
- const char *pszCur = pszURN + 16;
-
- if( EQUALN(pszURN,"urn:ogc:def:crs:",16) )
- pszCur = pszURN + 16;
- else if( EQUALN(pszURN,"urn:x-ogc:def:crs:",18) )
- pszCur = pszURN + 18;
- else
- {
- CPLError( CE_Failure, CPLE_AppDefined,
- "URN %s not a supported format.", pszURN );
- return OGRERR_FAILURE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Find code (ignoring version) out of string like: */
-/* */
-/* authority:version:code */
-/* -------------------------------------------------------------------- */
- const char *pszAuthority = pszCur;
-
- // skip authority
- while( *pszCur != ':' && *pszCur )
- pszCur++;
- if( *pszCur == ':' )
- pszCur++;
-
- // skip version
- while( *pszCur != ':' && *pszCur )
- pszCur++;
- if( *pszCur == ':' )
- pszCur++;
-
- const char *pszCode = pszCur;
-
-/* -------------------------------------------------------------------- */
-/* Is this an EPSG code? */
-/* -------------------------------------------------------------------- */
- if( EQUALN(pszAuthority,"EPSG:",5) )
- return importFromEPSG( atoi(pszCode) );
-
-/* -------------------------------------------------------------------- */
-/* Is this an OGC code? */
-/* -------------------------------------------------------------------- */
- if( !EQUALN(pszAuthority,"OGC:",4) )
- {
- CPLError( CE_Failure, CPLE_AppDefined,
- "URN %s has unrecognised authority.",
- pszURN );
- return OGRERR_FAILURE;
- }
-
- if( EQUALN(pszCode,"CRS84",5) )
- return SetWellKnownGeogCS( pszCode );
- else if( EQUALN(pszCode,"CRS83",5) )
- return SetWellKnownGeogCS( pszCode );
- else if( EQUALN(pszCode,"CRS27",5) )
- return SetWellKnownGeogCS( pszCode );
-
-/* -------------------------------------------------------------------- */
-/* Handle auto codes. We need to convert from format */
-/* AUTO42001:99:8888 to format AUTO:42001,99,8888. */
-/* -------------------------------------------------------------------- */
- else if( EQUALN(pszCode,"AUTO",4) )
- {
- char szWMSAuto[100];
- int i;
-
- if( strlen(pszCode) > sizeof(szWMSAuto)-2 )
- return OGRERR_FAILURE;
-
- strcpy( szWMSAuto, "AUTO:" );
- strcpy( szWMSAuto + 5, pszCode + 4 );
- for( i = 5; szWMSAuto[i] != '\0'; i++ )
- {
- if( szWMSAuto[i] == ':' )
- szWMSAuto[i] = ',';
- }
-
- return importFromWMSAUTO( szWMSAuto );
- }
-
-/* -------------------------------------------------------------------- */
-/* Not a recognise OGC item. */
-/* -------------------------------------------------------------------- */
- CPLError( CE_Failure, CPLE_AppDefined,
- "URN %s value not supported.",
- pszURN );
-
- return OGRERR_FAILURE;
-}
-
-/************************************************************************/
-/* importFromWMSAUTO() */
-/* */
-/* Note that the WMS 1.3 specification does not include the */
-/* units code, while apparently earlier specs do. We try to */
-/* guess around this. */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::importFromWMSAUTO( const char * pszDefinition )
-
-{
- char **papszTokens;
- int nProjId, nUnitsId;
- double dfRefLong, dfRefLat = 0.0;
-
-/* -------------------------------------------------------------------- */
-/* Tokenize */
-/* -------------------------------------------------------------------- */
- if( EQUALN(pszDefinition,"AUTO:",5) )
- pszDefinition += 5;
-
- papszTokens = CSLTokenizeStringComplex( pszDefinition, ",", FALSE, TRUE );
-
- if( CSLCount(papszTokens) == 4 )
- {
- nProjId = atoi(papszTokens[0]);
- nUnitsId = atoi(papszTokens[1]);
- dfRefLong = atof(papszTokens[2]);
- dfRefLat = atof(papszTokens[3]);
- }
- else if( CSLCount(papszTokens) == 3 && atoi(papszTokens[0]) == 42005 )
- {
- nProjId = atoi(papszTokens[0]);
- nUnitsId = atoi(papszTokens[1]);
- dfRefLong = atof(papszTokens[2]);
- dfRefLat = 0.0;
- }
- else if( CSLCount(papszTokens) == 3 )
- {
- nProjId = atoi(papszTokens[0]);
- nUnitsId = 9001;
- dfRefLong = atof(papszTokens[1]);
- dfRefLat = atof(papszTokens[2]);
-
- }
- else if( CSLCount(papszTokens) == 2 && atoi(papszTokens[0]) == 42005 )
- {
- nProjId = atoi(papszTokens[0]);
- nUnitsId = 9001;
- dfRefLong = atof(papszTokens[1]);
- }
- else
- {
- CSLDestroy( papszTokens );
- CPLError( CE_Failure, CPLE_AppDefined,
- "AUTO projection has wrong number of arguments, expected\n"
- "AUTO:proj_id,units_id,ref_long,ref_lat or"
- "AUTO:proj_id,ref_long,ref_lat" );
- return OGRERR_FAILURE;
- }
-
- CSLDestroy( papszTokens );
-
-/* -------------------------------------------------------------------- */
-/* Build coordsys. */
-/* -------------------------------------------------------------------- */
- Clear();
-
- switch( nProjId )
- {
- case 42001: // Auto UTM
- SetUTM( (int) floor( (dfRefLong + 180.0) / 6.0 ) + 1,
- dfRefLat >= 0.0 );
- break;
-
- case 42002: // Auto TM (strangely very UTM-like).
- SetTM( 0, dfRefLong, 0.9996,
- 500000.0, (dfRefLat >= 0.0) ? 0.0 : 10000000.0 );
- break;
-
- case 42003: // Auto Orthographic.
- SetOrthographic( dfRefLat, dfRefLong, 0.0, 0.0 );
- break;
-
- case 42004: // Auto Equirectangular
- SetEquirectangular( dfRefLat, dfRefLong, 0.0, 0.0 );
- break;
-
- case 42005:
- SetMollweide( dfRefLong, 0.0, 0.0 );
- break;
-
- default:
- CPLError( CE_Failure, CPLE_AppDefined,
- "Unsupported projection id in importFromWMSAUTO(): %d",
- nProjId );
- return OGRERR_FAILURE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Set units. */
-/* -------------------------------------------------------------------- */
-
- switch( nUnitsId )
- {
- case 9001:
- SetLinearUnits( SRS_UL_METER, 1.0 );
- break;
-
- case 9002:
- SetLinearUnits( "Foot", 0.3048 );
- break;
-
- case 9003:
- SetLinearUnits( "US survey foot", 0.304800609601 );
- break;
-
- default:
- CPLError( CE_Failure, CPLE_AppDefined,
- "Unsupported units code (%d).",
- nUnitsId );
- return OGRERR_FAILURE;
- break;
- }
-
- SetAuthority( "PROJCS|UNIT", "EPSG", nUnitsId );
-
-/* -------------------------------------------------------------------- */
-/* Set WGS84. */
-/* -------------------------------------------------------------------- */
- SetWellKnownGeogCS( "WGS84" );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* GetSemiMajor() */
-/************************************************************************/
-
-/**
- * Get spheroid semi major axis.
- *
- * This method does the same thing as the C function OSRGetSemiMajor().
- *
- * @param pnErr if non-NULL set to OGRERR_FAILURE if semi major axis
- * can be found.
- *
- * @return semi-major axis, or SRS_WGS84_SEMIMAJOR if it can't be found.
- */
-
-double OGRSpatialReference::GetSemiMajor( OGRErr * pnErr ) const
-
-{
- const OGR_SRSNode *poSpheroid = GetAttrNode( "SPHEROID" );
-
- if( pnErr != NULL )
- *pnErr = OGRERR_NONE;
-
- if( poSpheroid != NULL && poSpheroid->GetChildCount() >= 3 )
- {
- return atof( poSpheroid->GetChild(1)->GetValue() );
- }
- else
- {
- if( pnErr != NULL )
- *pnErr = OGRERR_FAILURE;
-
- return SRS_WGS84_SEMIMAJOR;
- }
-}
-
-/************************************************************************/
-/* OSRGetSemiMajor() */
-/************************************************************************/
-
-double OSRGetSemiMajor( OGRSpatialReferenceH hSRS, OGRErr *pnErr )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetSemiMajor( pnErr );
-}
-
-/************************************************************************/
-/* GetInvFlattening() */
-/************************************************************************/
-
-/**
- * Get spheroid inverse flattening.
- *
- * This method does the same thing as the C function OSRGetInvFlattening().
- *
- * @param pnErr if non-NULL set to OGRERR_FAILURE if no inverse flattening
- * can be found.
- *
- * @return inverse flattening, or SRS_WGS84_INVFLATTENING if it can't be found.
- */
-
-double OGRSpatialReference::GetInvFlattening( OGRErr * pnErr ) const
-
-{
- const OGR_SRSNode *poSpheroid = GetAttrNode( "SPHEROID" );
-
- if( pnErr != NULL )
- *pnErr = OGRERR_NONE;
-
- if( poSpheroid != NULL && poSpheroid->GetChildCount() >= 3 )
- {
- return atof( poSpheroid->GetChild(2)->GetValue() );
- }
- else
- {
- if( pnErr != NULL )
- *pnErr = OGRERR_FAILURE;
-
- return SRS_WGS84_INVFLATTENING;
- }
-}
-
-/************************************************************************/
-/* OSRGetInvFlattening() */
-/************************************************************************/
-
-double OSRGetInvFlattening( OGRSpatialReferenceH hSRS, OGRErr *pnErr )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetInvFlattening( pnErr );
-}
-
-/************************************************************************/
-/* GetSemiMinor() */
-/************************************************************************/
-
-/**
- * Get spheroid semi minor axis.
- *
- * This method does the same thing as the C function OSRGetSemiMinor().
- *
- * @param pnErr if non-NULL set to OGRERR_FAILURE if semi minor axis
- * can be found.
- *
- * @return semi-minor axis, or WGS84 semi minor if it can't be found.
- */
-
-double OGRSpatialReference::GetSemiMinor( OGRErr * pnErr ) const
-
-{
- double dfInvFlattening, dfSemiMajor;
-
- dfSemiMajor = GetSemiMajor( pnErr );
- dfInvFlattening = GetInvFlattening( pnErr );
-
- if( ABS(dfInvFlattening) < 0.000000000001 )
- return dfSemiMajor;
- else
- return dfSemiMajor * (1.0 - 1.0/dfInvFlattening);
-}
-
-/************************************************************************/
-/* OSRGetSemiMinor() */
-/************************************************************************/
-
-double OSRGetSemiMinor( OGRSpatialReferenceH hSRS, OGRErr *pnErr )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetSemiMinor( pnErr );
-}
-
-/************************************************************************/
-/* SetLocalCS() */
-/************************************************************************/
-
-/**
- * Set the user visible LOCAL_CS name.
- *
- * This method is the same as the C function OSRSetLocalCS().
- *
- * This method is will ensure a LOCAL_CS node is created as the root,
- * and set the provided name on it. It must be used before SetLinearUnits().
- *
- * @param pszName the user visible name to assign. Not used as a key.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetLocalCS( const char * pszName )
-
-{
- OGR_SRSNode *poCS = GetAttrNode( "LOCAL_CS" );
-
- if( poCS == NULL && GetRoot() != NULL )
- {
- CPLDebug( "OGR",
- "OGRSpatialReference::SetLocalCS(%s) failed.\n"
- "It appears an incompatible root node (%s) already exists.\n",
- GetRoot()->GetValue() );
- return OGRERR_FAILURE;
- }
- else
- {
- SetNode( "LOCAL_CS", pszName );
- return OGRERR_NONE;
- }
-}
-
-/************************************************************************/
-/* OSRSetLocalCS() */
-/************************************************************************/
-
-OGRErr OSRSetLocalCS( OGRSpatialReferenceH hSRS, const char * pszName )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetLocalCS( pszName );
-}
-
-/************************************************************************/
-/* SetProjCS() */
-/************************************************************************/
-
-/**
- * Set the user visible PROJCS name.
- *
- * This method is the same as the C function OSRSetProjCS().
- *
- * This method is will ensure a PROJCS node is created as the root,
- * and set the provided name on it. If used on a GEOGCS coordinate system,
- * the GEOGCS node will be demoted to be a child of the new PROJCS root.
- *
- * @param pszName the user visible name to assign. Not used as a key.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetProjCS( const char * pszName )
-
-{
- OGR_SRSNode *poGeogCS = NULL;
- OGR_SRSNode *poProjCS = GetAttrNode( "PROJCS" );
-
- if( poRoot != NULL && EQUAL(poRoot->GetValue(),"GEOGCS") )
- {
- poGeogCS = poRoot;
- poRoot = NULL;
- }
-
- if( poProjCS == NULL && GetRoot() != NULL )
- {
- CPLDebug( "OGR",
- "OGRSpatialReference::SetProjCS(%s) failed.\n"
- "It appears an incompatible root node (%s) already exists.\n",
- GetRoot()->GetValue() );
- return OGRERR_FAILURE;
- }
-
- SetNode( "PROJCS", pszName );
-
- if( poGeogCS != NULL )
- poRoot->InsertChild( poGeogCS, 1 );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetProjCS() */
-/************************************************************************/
-
-OGRErr OSRSetProjCS( OGRSpatialReferenceH hSRS, const char * pszName )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetProjCS( pszName );
-}
-
-/************************************************************************/
-/* SetProjection() */
-/************************************************************************/
-
-/**
- * Set a projection name.
- *
- * This method is the same as the C function OSRSetProjection().
- *
- * @param pszProjection the projection name, which should be selected from
- * the macros in ogr_srs_api.h, such as SRS_PT_TRANSVERSE_MERCATOR.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetProjection( const char * pszProjection )
-
-{
- OGR_SRSNode *poGeogCS = NULL;
- OGRErr eErr;
-
- if( poRoot != NULL && EQUAL(poRoot->GetValue(),"GEOGCS") )
- {
- poGeogCS = poRoot;
- poRoot = NULL;
- }
-
- if( !GetAttrNode( "PROJCS" ) )
- {
- SetNode( "PROJCS", "unnamed" );
- }
-
- eErr = SetNode( "PROJCS|PROJECTION", pszProjection );
- if( eErr != OGRERR_NONE )
- return eErr;
-
- if( poGeogCS != NULL )
- poRoot->InsertChild( poGeogCS, 1 );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetProjection() */
-/************************************************************************/
-
-OGRErr OSRSetProjection( OGRSpatialReferenceH hSRS,
- const char * pszProjection )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetProjection( pszProjection );
-}
-
-/************************************************************************/
-/* SetProjParm() */
-/************************************************************************/
-
-/**
- * Set a projection parameter value.
- *
- * Adds a new PARAMETER under the PROJCS with the indicated name and value.
- *
- * This method is the same as the C function OSRSetProjParm().
- *
- * Please check http://www.remotesensing.org/geotiff/proj_list pages for
- * legal parameter names for specific projections.
- *
- *
- * @param pszParmName the parameter name, which should be selected from
- * the macros in ogr_srs_api.h, such as SRS_PP_CENTRAL_MERIDIAN.
- *
- * @param dfValue value to assign.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetProjParm( const char * pszParmName,
- double dfValue )
-
-{
- OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
- OGR_SRSNode *poParm;
- char szValue[64];
-
- if( poPROJCS == NULL )
- return OGRERR_FAILURE;
-
- OGRPrintDouble( szValue, dfValue );
-
-/* -------------------------------------------------------------------- */
-/* Try to find existing parameter with this name. */
-/* -------------------------------------------------------------------- */
- for( int iChild = 0; iChild < poPROJCS->GetChildCount(); iChild++ )
- {
- poParm = poPROJCS->GetChild( iChild );
-
- if( EQUAL(poParm->GetValue(),"PARAMETER")
- && poParm->GetChildCount() == 2
- && EQUAL(poParm->GetChild(0)->GetValue(),pszParmName) )
- {
- poParm->GetChild(1)->SetValue( szValue );
- return OGRERR_NONE;
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Otherwise create a new parameter and append. */
-/* -------------------------------------------------------------------- */
- poParm = new OGR_SRSNode( "PARAMETER" );
- poParm->AddChild( new OGR_SRSNode( pszParmName ) );
- poParm->AddChild( new OGR_SRSNode( szValue ) );
-
- poPROJCS->AddChild( poParm );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetProjParm() */
-/************************************************************************/
-
-OGRErr OSRSetProjParm( OGRSpatialReferenceH hSRS,
- const char * pszParmName, double dfValue )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetProjParm( pszParmName, dfValue );
-}
-
-/************************************************************************/
-/* GetProjParm() */
-/************************************************************************/
-
-/**
- * Fetch a projection parameter value.
- *
- * NOTE: This code should be modified to translate non degree angles into
- * degrees based on the GEOGCS unit. This has not yet been done.
- *
- * This method is the same as the C function OSRGetProjParm().
- *
- * @param pszName the name of the parameter to fetch, from the set of
- * SRS_PP codes in ogr_srs_api.h.
- *
- * @param dfDefaultValue the value to return if this parameter doesn't exist.
- *
- * @param pnErr place to put error code on failure. Ignored if NULL.
- *
- * @return value of parameter.
- */
-
-double OGRSpatialReference::GetProjParm( const char * pszName,
- double dfDefaultValue,
- OGRErr *pnErr ) const
-
-{
- const OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
- const OGR_SRSNode *poParameter = NULL;
-
- if( pnErr != NULL )
- *pnErr = OGRERR_NONE;
-
-/* -------------------------------------------------------------------- */
-/* Search for requested parameter. */
-/* -------------------------------------------------------------------- */
- if( poPROJCS != NULL )
- {
- for( int iChild = 0; iChild < poPROJCS->GetChildCount(); iChild++ )
- {
- poParameter = poPROJCS->GetChild(iChild);
-
- if( EQUAL(poParameter->GetValue(),"PARAMETER")
- && poParameter->GetChildCount() == 2
- && EQUAL(poPROJCS->GetChild(iChild)->GetChild(0)->GetValue(),
- pszName) )
- {
- return atof(poParameter->GetChild(1)->GetValue());
- }
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Try similar names, for selected parameters. */
-/* -------------------------------------------------------------------- */
- double dfValue;
- OGRErr nSubErr;
-
- if( EQUAL(pszName,SRS_PP_LATITUDE_OF_ORIGIN) )
- {
- dfValue = GetProjParm(SRS_PP_LATITUDE_OF_CENTER,0.0,&nSubErr);
-
- if( nSubErr == OGRERR_NONE )
- return dfValue;
- }
- else if( EQUAL(pszName,SRS_PP_CENTRAL_MERIDIAN) )
- {
- dfValue = GetProjParm(SRS_PP_LONGITUDE_OF_CENTER,0.0,&nSubErr);
- if( nSubErr != OGRERR_NONE )
- dfValue = GetProjParm(SRS_PP_LONGITUDE_OF_ORIGIN,0.0,&nSubErr);
-
- if( nSubErr == OGRERR_NONE )
- return dfValue;
- }
-
-/* -------------------------------------------------------------------- */
-/* Return default value on failure. */
-/* -------------------------------------------------------------------- */
- if( pnErr != NULL )
- *pnErr = OGRERR_FAILURE;
-
- return dfDefaultValue;
-}
-
-/************************************************************************/
-/* OSRGetProjParm() */
-/************************************************************************/
-
-double OSRGetProjParm( OGRSpatialReferenceH hSRS, const char *pszName,
- double dfDefaultValue, OGRErr *pnErr )
-
-{
- return ((OGRSpatialReference *) hSRS)->
- GetProjParm(pszName, dfDefaultValue, pnErr);
-}
-
-/************************************************************************/
-/* GetNormProjParm() */
-/************************************************************************/
-
-/**
- * Fetch a normalized projection parameter value.
- *
- * This method is the same as GetProjParm() except that the value of
- * the parameter is "normalized" into degrees or meters depending on
- * whether it is linear or angular.
- *
- * This method is the same as the C function OSRGetNormProjParm().
- *
- * @param pszName the name of the parameter to fetch, from the set of
- * SRS_PP codes in ogr_srs_api.h.
- *
- * @param dfDefaultValue the value to return if this parameter doesn't exist.
- *
- * @param pnErr place to put error code on failure. Ignored if NULL.
- *
- * @return value of parameter.
- */
-
-double OGRSpatialReference::GetNormProjParm( const char * pszName,
- double dfDefaultValue,
- OGRErr *pnErr ) const
-
-{
- double dfRawResult;
- OGRErr nError;
-
- if( pnErr == NULL )
- pnErr = &nError;
-
- GetNormInfo();
-
- dfRawResult = GetProjParm( pszName, dfDefaultValue, pnErr );
-
- // If we got the default just return it unadjusted.
- if( *pnErr != OGRERR_NONE )
- return dfRawResult;
-
- if( dfToDegrees != 1.0 && IsAngularParameter(pszName) )
- dfRawResult *= dfToDegrees;
-
- if( dfToMeter != 1.0 && IsLinearParameter( pszName ) )
- return dfRawResult * dfToMeter;
-#ifdef WKT_LONGITUDE_RELATIVE_TO_PM
- else if( dfFromGreenwich != 0.0 && IsLongitudeParameter( pszName ) )
- return dfRawResult + dfFromGreenwich;
-#endif
- else
- return dfRawResult;
-}
-
-/************************************************************************/
-/* OSRGetNormProjParm() */
-/************************************************************************/
-
-double OSRGetNormProjParm( OGRSpatialReferenceH hSRS, const char *pszName,
- double dfDefaultValue, OGRErr *pnErr )
-
-{
- return ((OGRSpatialReference *) hSRS)->
- GetNormProjParm(pszName, dfDefaultValue, pnErr);
-}
-
-/************************************************************************/
-/* SetNormProjParm() */
-/************************************************************************/
-
-/**
- * Set a projection parameter with a normalized value.
- *
- * This method is the same as SetProjParm() except that the value of
- * the parameter passed in is assumed to be in "normalized" form (decimal
- * degrees for angular values, meters for linear values. The values are
- * converted in a form suitable for the GEOGCS and linear units in effect.
- *
- * This method is the same as the C function OSRSetNormProjParm().
- *
- * @param pszName the parameter name, which should be selected from
- * the macros in ogr_srs_api.h, such as SRS_PP_CENTRAL_MERIDIAN.
- *
- * @param dfValue value to assign.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetNormProjParm( const char * pszName,
- double dfValue )
-
-{
- GetNormInfo();
-
- if( (dfToDegrees != 1.0 || dfFromGreenwich != 0.0)
- && IsAngularParameter(pszName) )
- {
-#ifdef WKT_LONGITUDE_RELATIVE_TO_PM
- if( dfFromGreenwich != 0.0 && IsLongitudeParameter( pszName ) )
- dfValue -= dfFromGreenwich;
-#endif
-
- dfValue /= dfToDegrees;
- }
- else if( dfToMeter != 1.0 && IsLinearParameter( pszName ) )
- dfValue /= dfToMeter;
-
- return SetProjParm( pszName, dfValue );
-}
-
-/************************************************************************/
-/* OSRSetNormProjParm() */
-/************************************************************************/
-
-OGRErr OSRSetNormProjParm( OGRSpatialReferenceH hSRS,
- const char * pszParmName, double dfValue )
-
-{
- return ((OGRSpatialReference *) hSRS)->
- SetNormProjParm( pszParmName, dfValue );
-}
-
-/************************************************************************/
-/* SetTM() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetTM( double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_TRANSVERSE_MERCATOR );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetTM() */
-/************************************************************************/
-
-OGRErr OSRSetTM( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetTM(
- dfCenterLat, dfCenterLong,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetTMVariant() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetTMVariant(
- const char *pszVariantName,
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( pszVariantName );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetTMVariant() */
-/************************************************************************/
-
-OGRErr OSRSetTMVariant( OGRSpatialReferenceH hSRS,
- const char *pszVariantName,
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetTMVariant(
- pszVariantName,
- dfCenterLat, dfCenterLong,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetTMSO() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetTMSO( double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* SetTPED() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetTPED( double dfLat1, double dfLong1,
- double dfLat2, double dfLong2,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_TWO_POINT_EQUIDISTANT );
- SetNormProjParm( SRS_PP_LATITUDE_OF_1ST_POINT, dfLat1 );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_1ST_POINT, dfLong1 );
- SetNormProjParm( SRS_PP_LATITUDE_OF_2ND_POINT, dfLat2 );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_2ND_POINT, dfLong2 );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetTMSO() */
-/************************************************************************/
-
-OGRErr OSRSetTMSO( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetTMSO(
- dfCenterLat, dfCenterLong,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetTMG() */
-/************************************************************************/
-
-OGRErr
-OGRSpatialReference::SetTMG( double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_TUNISIA_MINING_GRID );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetTMG() */
-/************************************************************************/
-
-OGRErr OSRSetTMG( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetTMG(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetACEA() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetACEA( double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_ALBERS_CONIC_EQUAL_AREA );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, dfStdP2 );
- SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetACEA() */
-/************************************************************************/
-
-OGRErr OSRSetACEA( OGRSpatialReferenceH hSRS,
- double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetACEA(
- dfStdP1, dfStdP2,
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetAE() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetAE( double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_AZIMUTHAL_EQUIDISTANT );
- SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetAE() */
-/************************************************************************/
-
-OGRErr OSRSetAE( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetAE(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetBonne() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetBonne(
- double dfStdP1, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_BONNE );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetBonne() */
-/************************************************************************/
-
-OGRErr OSRSetBonne( OGRSpatialReferenceH hSRS,
- double dfStandardParallel, double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetAE(
- dfStandardParallel, dfCentralMeridian,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetCEA() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetCEA( double dfStdP1, double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_CYLINDRICAL_EQUAL_AREA );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetCEA() */
-/************************************************************************/
-
-OGRErr OSRSetCEA( OGRSpatialReferenceH hSRS,
- double dfStdP1, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetCEA(
- dfStdP1, dfCentralMeridian,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetCS() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetCS( double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_CASSINI_SOLDNER );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetCS() */
-/************************************************************************/
-
-OGRErr OSRSetCS( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetCS(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetEC() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetEC( double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_EQUIDISTANT_CONIC );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, dfStdP2 );
- SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetEC() */
-/************************************************************************/
-
-OGRErr OSRSetEC( OGRSpatialReferenceH hSRS,
- double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetEC(
- dfStdP1, dfStdP2,
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetEckertIV() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetEckertIV( double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_ECKERT_IV );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetEckertIV() */
-/************************************************************************/
-
-OGRErr OSRSetEckertIV( OGRSpatialReferenceH hSRS,
- double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetEckertIV(
- dfCentralMeridian,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetEckertVI() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetEckertVI( double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_ECKERT_VI );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetEckertVI() */
-/************************************************************************/
-
-OGRErr OSRSetEckertVI( OGRSpatialReferenceH hSRS,
- double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetEckertVI(
- dfCentralMeridian,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetEquirectangular() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetEquirectangular(
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_EQUIRECTANGULAR );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetEquirectangular() */
-/************************************************************************/
-
-OGRErr OSRSetEquirectangular( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetEquirectangular(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetGS() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetGS( double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_GALL_STEREOGRAPHIC );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetGS() */
-/************************************************************************/
-
-OGRErr OSRSetGS( OGRSpatialReferenceH hSRS,
- double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetGS(
- dfCentralMeridian,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetGH() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetGH( double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_GOODE_HOMOLOSINE );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetGH() */
-/************************************************************************/
-
-OGRErr OSRSetGH( OGRSpatialReferenceH hSRS,
- double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetGH(
- dfCentralMeridian,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetGEOS() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetGEOS( double dfCentralMeridian,
- double dfSatelliteHeight,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_GEOSTATIONARY_SATELLITE );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
- SetNormProjParm( SRS_PP_SATELLITE_HEIGHT, dfSatelliteHeight );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetGEOS() */
-/************************************************************************/
-
-OGRErr OSRSetGEOS( OGRSpatialReferenceH hSRS,
- double dfCentralMeridian,
- double dfSatelliteHeight,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetGEOS(
- dfCentralMeridian, dfSatelliteHeight,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetGnomonic() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetGnomonic(
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_GNOMONIC );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetGnomonic() */
-/************************************************************************/
-
-OGRErr OSRSetGnomonic( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetGnomonic(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetHOM() */
-/************************************************************************/
-
-/**
- * Set a Hotine Oblique Mercator projection using azimuth angle.
- *
- * This method does the same thing as the C function OSRSetHOM().
- *
- * @param dfCenterLat Latitude of the projection origin.
- * @param dfCenterLong Longitude of the projection origin.
- * @param dfAzimuth Azimuth, measured clockwise from North, of the projection
- * centerline.
- * @param dfRectToSkew ?.
- * @param dfScale Scale factor applies to the projection origin.
- * @param dfFalseEasting False easting.
- * @param dfFalseNorthing False northing.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetHOM( double dfCenterLat, double dfCenterLong,
- double dfAzimuth, double dfRectToSkew,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_HOTINE_OBLIQUE_MERCATOR );
- SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
- SetNormProjParm( SRS_PP_AZIMUTH, dfAzimuth );
- SetNormProjParm( SRS_PP_RECTIFIED_GRID_ANGLE, dfRectToSkew );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetHOM() */
-/************************************************************************/
-
-OGRErr OSRSetHOM( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfAzimuth, double dfRectToSkew,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetHOM(
- dfCenterLat, dfCenterLong,
- dfAzimuth, dfRectToSkew,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetHOM2PNO() */
-/************************************************************************/
-
-/**
- * Set a Hotine Oblique Mercator projection using two points on projection
- * centerline.
- *
- * This method does the same thing as the C function OSRSetHOM2PNO().
- *
- * @param dfCenterLat Latitude of the projection origin.
- * @param dfLat1 Latitude of the first point on center line.
- * @param dfLong1 Longitude of the first point on center line.
- * @param dfLat2 Latitude of the second point on center line.
- * @param dfLong2 Longitude of the second point on center line.
- * @param dfScale Scale factor applies to the projection origin.
- * @param dfFalseEasting False easting.
- * @param dfFalseNorthing False northing.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetHOM2PNO( double dfCenterLat,
- double dfLat1, double dfLong1,
- double dfLat2, double dfLong2,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN );
- SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
- SetNormProjParm( SRS_PP_LATITUDE_OF_POINT_1, dfLat1 );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_POINT_1, dfLong1 );
- SetNormProjParm( SRS_PP_LATITUDE_OF_POINT_2, dfLat2 );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_POINT_2, dfLong2 );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetHOM2PNO() */
-/************************************************************************/
-
-OGRErr OSRSetHOM2PNO( OGRSpatialReferenceH hSRS,
- double dfCenterLat,
- double dfLat1, double dfLong1,
- double dfLat2, double dfLong2,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetHOM2PNO(
- dfCenterLat,
- dfLat1, dfLong1,
- dfLat2, dfLong2,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetKrovak() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetKrovak( double dfCenterLat, double dfCenterLong,
- double dfAzimuth,
- double dfPseudoStdParallel1,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_KROVAK );
- SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
- SetNormProjParm( SRS_PP_AZIMUTH, dfAzimuth );
- SetNormProjParm( SRS_PP_PSEUDO_STD_PARALLEL_1, dfPseudoStdParallel1 );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetKrovak() */
-/************************************************************************/
-
-OGRErr OSRSetKrovak( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfAzimuth, double dfPseudoStdParallel1,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetKrovak(
- dfCenterLat, dfCenterLong,
- dfAzimuth, dfPseudoStdParallel1,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetLAEA() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetLAEA( double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA );
- SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetLAEA() */
-/************************************************************************/
-
-OGRErr OSRSetLAEA( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetLAEA(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetLCC() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetLCC( double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, dfStdP2 );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetLCC() */
-/************************************************************************/
-
-OGRErr OSRSetLCC( OGRSpatialReferenceH hSRS,
- double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetLCC(
- dfStdP1, dfStdP2,
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetLCC1SP() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetLCC1SP( double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetLCC1SP() */
-/************************************************************************/
-
-OGRErr OSRSetLCC1SP( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetLCC1SP(
- dfCenterLat, dfCenterLong,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetLCCB() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetLCCB( double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, dfStdP2 );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetLCCB() */
-/************************************************************************/
-
-OGRErr OSRSetLCCB( OGRSpatialReferenceH hSRS,
- double dfStdP1, double dfStdP2,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetLCCB(
- dfStdP1, dfStdP2,
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetMC() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetMC( double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_MILLER_CYLINDRICAL );
- SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetMC() */
-/************************************************************************/
-
-OGRErr OSRSetMC( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetMC(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetMercator() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetMercator( double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_MERCATOR_1SP );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetMercator() */
-/************************************************************************/
-
-OGRErr OSRSetMercator( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetMercator(
- dfCenterLat, dfCenterLong,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetMercator2SP() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetMercator2SP(
- double dfStdP1,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_MERCATOR_2SP );
- SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetMercator2SP() */
-/************************************************************************/
-
-OGRErr OSRSetMercator2SP( OGRSpatialReferenceH hSRS,
- double dfStdP1,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetMercator2SP(
- dfStdP1,
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetMollweide() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetMollweide( double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_MOLLWEIDE );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetMollweide() */
-/************************************************************************/
-
-OGRErr OSRSetMollweide( OGRSpatialReferenceH hSRS,
- double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetMollweide(
- dfCentralMeridian,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetNZMG() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetNZMG( double dfCenterLat, double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_NEW_ZEALAND_MAP_GRID );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetNZMG() */
-/************************************************************************/
-
-OGRErr OSRSetNZMG( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetNZMG(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetOS() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetOS( double dfOriginLat, double dfCMeridian,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_OBLIQUE_STEREOGRAPHIC );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfOriginLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCMeridian );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetOS() */
-/************************************************************************/
-
-OGRErr OSRSetOS( OGRSpatialReferenceH hSRS,
- double dfOriginLat, double dfCMeridian,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetOS(
- dfOriginLat, dfCMeridian,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetOrthographic() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetOrthographic(
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_ORTHOGRAPHIC );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetOrthographic() */
-/************************************************************************/
-
-OGRErr OSRSetOrthographic( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetOrthographic(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetPolyconic() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetPolyconic(
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- // note: it seems that by some definitions this should include a
- // scale_factor parameter.
-
- SetProjection( SRS_PT_POLYCONIC );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetPolyconic() */
-/************************************************************************/
-
-OGRErr OSRSetPolyconic( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetPolyconic(
- dfCenterLat, dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetPS() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetPS(
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_POLAR_STEREOGRAPHIC );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetPS() */
-/************************************************************************/
-
-OGRErr OSRSetPS( OGRSpatialReferenceH hSRS,
- double dfCenterLat, double dfCenterLong,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetPS(
- dfCenterLat, dfCenterLong,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetRobinson() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetRobinson( double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_ROBINSON );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetRobinson() */
-/************************************************************************/
-
-OGRErr OSRSetRobinson( OGRSpatialReferenceH hSRS,
- double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetRobinson(
- dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetSinusoidal() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetSinusoidal( double dfCenterLong,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_SINUSOIDAL );
- SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetSinusoidal() */
-/************************************************************************/
-
-OGRErr OSRSetSinusoidal( OGRSpatialReferenceH hSRS,
- double dfCenterLong,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetSinusoidal(
- dfCenterLong,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetStereographic() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetStereographic(
- double dfOriginLat, double dfCMeridian,
- double dfScale,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_STEREOGRAPHIC );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfOriginLat );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCMeridian );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetStereographic() */
-/************************************************************************/
-
-OGRErr OSRSetStereographic( OGRSpatialReferenceH hSRS,
- double dfOriginLat, double dfCMeridian,
- double dfScale,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetStereographic(
- dfOriginLat, dfCMeridian,
- dfScale,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetSOC() */
-/* */
-/* NOTE: This definition isn't really used in practice any more */
-/* and should be considered deprecated. It seems that swiss */
-/* oblique mercator is now define as Hotine_Oblique_Mercator */
-/* with an azimuth of 90 and a rectified_grid_angle of 90. See */
-/* EPSG:2056 and Bug 423. */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetSOC( double dfLatitudeOfOrigin,
- double dfCentralMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_SWISS_OBLIQUE_CYLINDRICAL );
- SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfLatitudeOfOrigin );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetSOC() */
-/************************************************************************/
-
-OGRErr OSRSetSOC( OGRSpatialReferenceH hSRS,
- double dfLatitudeOfOrigin, double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetSOC(
- dfLatitudeOfOrigin, dfCentralMeridian,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetVDG() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetVDG( double dfCMeridian,
- double dfFalseEasting,
- double dfFalseNorthing )
-
-{
- SetProjection( SRS_PT_VANDERGRINTEN );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCMeridian );
- SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
- SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetVDG() */
-/************************************************************************/
-
-OGRErr OSRSetVDG( OGRSpatialReferenceH hSRS,
- double dfCentralMeridian,
- double dfFalseEasting, double dfFalseNorthing )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetVDG(
- dfCentralMeridian,
- dfFalseEasting, dfFalseNorthing );
-}
-
-/************************************************************************/
-/* SetUTM() */
-/************************************************************************/
-
-/**
- * Set UTM projection definition.
- *
- * This will generate a projection definition with the full set of
- * transverse mercator projection parameters for the given UTM zone.
- * If no PROJCS[] description is set yet, one will be set to look
- * like "UTM Zone %d, {Northern, Southern} Hemisphere".
- *
- * This method is the same as the C function OSRSetUTM().
- *
- * @param nZone UTM zone.
- *
- * @param bNorth TRUE for northern hemisphere, or FALSE for southern
- * hemisphere.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetUTM( int nZone, int bNorth )
-
-{
- SetProjection( SRS_PT_TRANSVERSE_MERCATOR );
- SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0 );
- SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, nZone * 6 - 183 );
- SetNormProjParm( SRS_PP_SCALE_FACTOR, 0.9996 );
- SetNormProjParm( SRS_PP_FALSE_EASTING, 500000.0 );
-
- if( bNorth )
- SetNormProjParm( SRS_PP_FALSE_NORTHING, 0 );
- else
- SetNormProjParm( SRS_PP_FALSE_NORTHING, 10000000 );
-
- if( EQUAL(GetAttrValue("PROJCS"),"unnamed") )
- {
- char szUTMName[128];
-
- if( bNorth )
- sprintf( szUTMName, "UTM Zone %d, Northern Hemisphere", nZone );
- else
- sprintf( szUTMName, "UTM Zone %d, Southern Hemisphere", nZone );
-
- SetNode( "PROJCS", szUTMName );
- }
-
- SetLinearUnits( SRS_UL_METER, 1.0 );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetUTM() */
-/************************************************************************/
-
-OGRErr OSRSetUTM( OGRSpatialReferenceH hSRS, int nZone, int bNorth )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetUTM( nZone, bNorth );
-}
-
-/************************************************************************/
-/* GetUTMZone() */
-/* */
-/* Returns zero if it isn't UTM. */
-/************************************************************************/
-
-/**
- * Get utm zone information.
- *
- * This is the same as the C function OSRGetUTMZone().
- *
- * @param pbNorth pointer to in to set to TRUE if northern hemisphere, or
- * FALSE if southern.
- *
- * @return UTM zone number or zero if this isn't a UTM definition.
- */
-
-int OGRSpatialReference::GetUTMZone( int * pbNorth ) const
-
-{
- const char *pszProjection = GetAttrValue( "PROJECTION" );
-
- if( pszProjection == NULL
- || !EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR) )
- return 0;
-
- if( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) != 0.0 )
- return 0;
-
- if( GetProjParm( SRS_PP_SCALE_FACTOR, 1.0 ) != 0.9996 )
- return 0;
-
- if( fabs(GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 )-500000.0) > 0.001 )
- return 0;
-
- double dfFalseNorthing = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0);
-
- if( dfFalseNorthing != 0.0
- && fabs(dfFalseNorthing-10000000.0) > 0.001 )
- return 0;
-
- if( pbNorth != NULL )
- *pbNorth = (dfFalseNorthing == 0);
-
- double dfCentralMeridian = GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN,
- 0.0);
- double dfZone = (dfCentralMeridian+183) / 6.0 + 0.000000001;
-
- if( ABS(dfZone - (int) dfZone) > 0.00001
- || dfCentralMeridian < -177.00001
- || dfCentralMeridian > 177.000001 )
- return 0;
- else
- return (int) dfZone;
-}
-
-/************************************************************************/
-/* OSRGetUTMZone() */
-/************************************************************************/
-
-int OSRGetUTMZone( OGRSpatialReferenceH hSRS, int *pbNorth )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetUTMZone( pbNorth );
-}
-
-/************************************************************************/
-/* SetAuthority() */
-/************************************************************************/
-
-/**
- * Set the authority for a node.
- *
- * This method is the same as the C function OSRSetAuthority().
- *
- * @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 "EPSG".
- *
- * @param nCode code for value with this authority.
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetAuthority( const char *pszTargetKey,
- const char * pszAuthority,
- int nCode )
-
-{
-/* -------------------------------------------------------------------- */
-/* Find the node below which the authority should be put. */
-/* -------------------------------------------------------------------- */
- OGR_SRSNode *poNode = 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 node. */
-/* -------------------------------------------------------------------- */
- char szCode[32];
- OGR_SRSNode *poAuthNode;
-
- sprintf( szCode, "%d", nCode );
-
- poAuthNode = new OGR_SRSNode( "AUTHORITY" );
- poAuthNode->AddChild( new OGR_SRSNode( pszAuthority ) );
- poAuthNode->AddChild( new OGR_SRSNode( szCode ) );
-
- poNode->AddChild( poAuthNode );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetAuthority() */
-/************************************************************************/
-
-OGRErr OSRSetAuthority( OGRSpatialReferenceH hSRS,
- const char *pszTargetKey,
- const char * pszAuthority,
- int nCode )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetAuthority( pszTargetKey,
- pszAuthority,
- nCode );
-}
-
-/************************************************************************/
-/* GetAuthorityCode() */
-/************************************************************************/
-
-/**
- * Get the authority code for a node.
- *
- * This method is used to query an AUTHORITY[] node from within the
- * WKT tree, and fetch the code value.
- *
- * While in theory values may be non-numeric, for the EPSG authority all
- * code values should be integral.
- *
- * This method is the same as the C function OSRGetAuthorityCode().
- *
- * @param pszTargetKey the partial or complete path to the node to
- * get an authority from. ie. "PROJCS", "GEOGCS", "GEOGCS|UNIT" or NULL to
- * search for an authority node on the root element.
- *
- * @return value code from authority node, or NULL on failure. The value
- * returned is internal and should not be freed or modified.
- */
-
-const char *
-OGRSpatialReference::GetAuthorityCode( const char *pszTargetKey ) const
-
-{
-/* -------------------------------------------------------------------- */
-/* Find the node below which the authority should be put. */
-/* -------------------------------------------------------------------- */
- const OGR_SRSNode *poNode;
-
- if( pszTargetKey == NULL )
- poNode = poRoot;
- else
- poNode= ((OGRSpatialReference *) this)->GetAttrNode( pszTargetKey );
-
- if( poNode == NULL )
- return NULL;
-
-/* -------------------------------------------------------------------- */
-/* Fetch AUTHORITY child if there is one. */
-/* -------------------------------------------------------------------- */
- if( poNode->FindChild("AUTHORITY") == -1 )
- return NULL;
-
- poNode = poNode->GetChild(poNode->FindChild("AUTHORITY"));
-
-/* -------------------------------------------------------------------- */
-/* Create a new authority node. */
-/* -------------------------------------------------------------------- */
- if( poNode->GetChildCount() < 2 )
- return NULL;
-
- return poNode->GetChild(1)->GetValue();
-}
-
-/************************************************************************/
-/* OSRGetAuthorityCode() */
-/************************************************************************/
-
-const char *OSRGetAuthorityCode( OGRSpatialReferenceH hSRS,
- const char *pszTargetKey )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetAuthorityCode( pszTargetKey );
-}
-
-/************************************************************************/
-/* GetAuthorityName() */
-/************************************************************************/
-
-/**
- * Get the authority name for a node.
- *
- * This method is used to query an AUTHORITY[] node from within the
- * WKT tree, and fetch the authority name value.
- *
- * The most common authority is "EPSG".
- *
- * This method is the same as the C function OSRGetAuthorityName().
- *
- * @param pszTargetKey the partial or complete path to the node to
- * get an authority from. ie. "PROJCS", "GEOGCS", "GEOGCS|UNIT" or NULL to
- * search for an authority node on the root element.
- *
- * @return value code from authority node, or NULL on failure. The value
- * returned is internal and should not be freed or modified.
- */
-
-const char *
-OGRSpatialReference::GetAuthorityName( const char *pszTargetKey ) const
-
-{
-/* -------------------------------------------------------------------- */
-/* Find the node below which the authority should be put. */
-/* -------------------------------------------------------------------- */
- const OGR_SRSNode *poNode;
-
- if( pszTargetKey == NULL )
- poNode = poRoot;
- else
- poNode= ((OGRSpatialReference *) this)->GetAttrNode( pszTargetKey );
-
- if( poNode == NULL )
- return NULL;
-
-/* -------------------------------------------------------------------- */
-/* Fetch AUTHORITY child if there is one. */
-/* -------------------------------------------------------------------- */
- if( poNode->FindChild("AUTHORITY") == -1 )
- return NULL;
-
- poNode = poNode->GetChild(poNode->FindChild("AUTHORITY"));
-
-/* -------------------------------------------------------------------- */
-/* Create a new authority node. */
-/* -------------------------------------------------------------------- */
- if( poNode->GetChildCount() < 2 )
- return NULL;
-
- return poNode->GetChild(0)->GetValue();
-}
-
-/************************************************************************/
-/* OSRGetAuthorityName() */
-/************************************************************************/
-
-const char *OSRGetAuthorityName( OGRSpatialReferenceH hSRS,
- const char *pszTargetKey )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetAuthorityName( pszTargetKey );
-}
-
-/************************************************************************/
-/* StripCTParms() */
-/************************************************************************/
-
-/**
- * Strip OGC CT Parameters.
- *
- * This method will remove all components of the coordinate system
- * that are specific to the OGC CT Specification. That is it will attempt
- * to strip it down to being compatible with the Simple Features 1.0
- * specification.
- *
- * This method is the same as the C function OSRStripCTParms().
- *
- * @param poCurrent node to operate on. NULL to operate on whole tree.
- *
- * @return OGRERR_NONE on success or an error code.
- */
-
-OGRErr OGRSpatialReference::StripCTParms( OGR_SRSNode * poCurrent )
-
-{
- if( poCurrent == NULL )
- poCurrent = GetRoot();
-
- if( poCurrent == NULL )
- return OGRERR_NONE;
-
- if( poCurrent == GetRoot() && EQUAL(poCurrent->GetValue(),"LOCAL_CS") )
- {
- delete poCurrent;
- poRoot = NULL;
-
- return OGRERR_NONE;
- }
-
- if( poCurrent == NULL )
- return OGRERR_NONE;
-
- poCurrent->StripNodes( "AUTHORITY" );
- poCurrent->StripNodes( "TOWGS84" );
- poCurrent->StripNodes( "AXIS" );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRStripCTParms() */
-/************************************************************************/
-
-OGRErr OSRStripCTParms( OGRSpatialReferenceH hSRS )
-
-{
- return ((OGRSpatialReference *) hSRS)->StripCTParms( NULL );
-}
-
-/************************************************************************/
-/* IsProjected() */
-/************************************************************************/
-
-/**
- * Check if projected coordinate system.
- *
- * This method is the same as the C function OSRIsProjected().
- *
- * @return TRUE if this contains a PROJCS node indicating a it is a
- * projected coordinate system.
- */
-
-int OGRSpatialReference::IsProjected() const
-
-{
- if( poRoot == NULL )
- return FALSE;
-
- // If we eventually support composite coordinate systems this will
- // need to improve.
-
- return EQUAL(poRoot->GetValue(),"PROJCS");
-}
-
-/************************************************************************/
-/* OSRIsProjected() */
-/************************************************************************/
-
-int OSRIsProjected( OGRSpatialReferenceH hSRS )
-
-{
- return ((OGRSpatialReference *) hSRS)->IsProjected();
-}
-
-/************************************************************************/
-/* IsGeographic() */
-/************************************************************************/
-
-/**
- * Check if geographic coordinate system.
- *
- * This method is the same as the C function OSRIsGeographic().
- *
- * @return TRUE if this spatial reference is geographic ... that is the
- * root is a GEOGCS node.
- */
-
-int OGRSpatialReference::IsGeographic() const
-
-{
- if( GetRoot() == NULL )
- return FALSE;
-
- return EQUAL(GetRoot()->GetValue(),"GEOGCS");
-}
-
-/************************************************************************/
-/* OSRIsGeographic() */
-/************************************************************************/
-
-int OSRIsGeographic( OGRSpatialReferenceH hSRS )
-
-{
- return ((OGRSpatialReference *) hSRS)->IsGeographic();
-}
-
-/************************************************************************/
-/* IsLocal() */
-/************************************************************************/
-
-/**
- * Check if local coordinate system.
- *
- * This method is the same as the C function OSRIsLocal().
- *
- * @return TRUE if this spatial reference is local ... that is the
- * root is a LOCAL_CS node.
- */
-
-int OGRSpatialReference::IsLocal() const
-
-{
- if( GetRoot() == NULL )
- return FALSE;
-
- return EQUAL(GetRoot()->GetValue(),"LOCAL_CS");
-}
-
-/************************************************************************/
-/* OSRIsLocal() */
-/************************************************************************/
-
-int OSRIsLocal( OGRSpatialReferenceH hSRS )
-
-{
- return ((OGRSpatialReference *) hSRS)->IsLocal();
-}
-
-/************************************************************************/
-/* CloneGeogCS() */
-/************************************************************************/
-
-OGRSpatialReference *OGRSpatialReference::CloneGeogCS() const
-
-{
- const OGR_SRSNode *poGeogCS;
- OGRSpatialReference * poNewSRS;
-
- poGeogCS = GetAttrNode( "GEOGCS" );
- if( poGeogCS == NULL )
- return NULL;
-
- poNewSRS = new OGRSpatialReference();
- poNewSRS->SetRoot( poGeogCS->Clone() );
-
- return poNewSRS;
-}
-
-/************************************************************************/
-/* OSRCloneGeogCS() */
-/************************************************************************/
-
-OGRSpatialReferenceH CPL_STDCALL OSRCloneGeogCS( OGRSpatialReferenceH hSource )
-
-{
- return (OGRSpatialReferenceH)
- ((OGRSpatialReference *) hSource)->CloneGeogCS();
-}
-
-/************************************************************************/
-/* IsSameGeogCS() */
-/************************************************************************/
-
-/**
- * Do the GeogCS'es match?
- *
- * This method is the same as the C function OSRIsSameGeogCS().
- *
- * @param poOther the SRS being compared against.
- *
- * @return TRUE if they are the same or FALSE otherwise.
- */
-
-int OGRSpatialReference::IsSameGeogCS( const OGRSpatialReference *poOther ) const
-
-{
- const char *pszThisValue, *pszOtherValue;
-
-/* -------------------------------------------------------------------- */
-/* Does the datum name match? Note that we assume */
-/* compatibility if either is missing a datum. */
-/* -------------------------------------------------------------------- */
- pszThisValue = this->GetAttrValue( "DATUM" );
- pszOtherValue = poOther->GetAttrValue( "DATUM" );
-
- if( pszThisValue != NULL && pszOtherValue != NULL
- && !EQUAL(pszThisValue,pszOtherValue) )
- return FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Do the prime meridians match? If missing assume a value of zero.*/
-/* -------------------------------------------------------------------- */
- pszThisValue = this->GetAttrValue( "PRIMEM", 1 );
- if( pszThisValue == NULL )
- pszThisValue = "0.0";
-
- pszOtherValue = poOther->GetAttrValue( "PRIMEM", 1 );
- if( pszOtherValue == NULL )
- pszOtherValue = "0.0";
-
- if( atof(pszOtherValue) != atof(pszThisValue) )
- return FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Do the units match? */
-/* -------------------------------------------------------------------- */
- pszThisValue = this->GetAttrValue( "GEOGCS|UNITS", 1 );
- if( pszThisValue == NULL )
- pszThisValue = SRS_UA_DEGREE_CONV;
-
- pszOtherValue = poOther->GetAttrValue( "GEOGCS|UNITS", 1 );
- if( pszOtherValue == NULL )
- pszOtherValue = SRS_UA_DEGREE_CONV;
-
- if( ABS(atof(pszOtherValue) - atof(pszThisValue)) > 0.00000001 )
- return FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Does the spheroid match. Check semi major, and inverse */
-/* flattening. */
-/* -------------------------------------------------------------------- */
- pszThisValue = this->GetAttrValue( "SPHEROID", 1 );
- pszOtherValue = poOther->GetAttrValue( "SPHEROID", 1 );
- if( pszThisValue != NULL && pszOtherValue != NULL
- && ABS(atof(pszThisValue) - atof(pszOtherValue)) > 0.01 )
- return FALSE;
-
- pszThisValue = this->GetAttrValue( "SPHEROID", 2 );
- pszOtherValue = poOther->GetAttrValue( "SPHEROID", 2 );
- if( pszThisValue != NULL && pszOtherValue != NULL
- && ABS(atof(pszThisValue) - atof(pszOtherValue)) > 0.0001 )
- return FALSE;
-
- return TRUE;
-}
-
-/************************************************************************/
-/* OSRIsSameGeogCS() */
-/************************************************************************/
-
-int OSRIsSameGeogCS( OGRSpatialReferenceH hSRS1, OGRSpatialReferenceH hSRS2 )
-
-{
- return ((OGRSpatialReference *) hSRS1)->IsSameGeogCS(
- (OGRSpatialReference *) hSRS2 );
-}
-
-/************************************************************************/
-/* IsSame() */
-/************************************************************************/
-
-/**
- * These two spatial references describe the same system.
- *
- * @param poOtherSRS the SRS being compared to.
- *
- * @return TRUE if equivelent or FALSE otherwise.
- */
-
-int OGRSpatialReference::IsSame( const OGRSpatialReference * poOtherSRS ) const
-
-{
- if( GetRoot() == NULL && poOtherSRS->GetRoot() == NULL )
- return TRUE;
- else if( GetRoot() == NULL || poOtherSRS->GetRoot() == NULL )
- return FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Compare geographic coordinate system. */
-/* -------------------------------------------------------------------- */
- if( !IsSameGeogCS( poOtherSRS ) )
- return FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Do the have the same root types? Ie. is one PROJCS and one */
-/* GEOGCS or perhaps LOCALCS? */
-/* -------------------------------------------------------------------- */
- if( !EQUAL(GetRoot()->GetValue(),poOtherSRS->GetRoot()->GetValue()) )
- return FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Compare projected coordinate system. */
-/* -------------------------------------------------------------------- */
- if( IsProjected() )
- {
- const char *pszValue1, *pszValue2;
- const OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
-
- pszValue1 = this->GetAttrValue( "PROJECTION" );
- pszValue2 = poOtherSRS->GetAttrValue( "PROJECTION" );
- if( pszValue1 == NULL || pszValue2 == NULL
- || !EQUAL(pszValue1,pszValue2) )
- return FALSE;
-
- for( int iChild = 0; iChild < poPROJCS->GetChildCount(); iChild++ )
- {
- const OGR_SRSNode *poNode;
-
- poNode = poPROJCS->GetChild( iChild );
- if( !EQUAL(poNode->GetValue(),"PARAMETER")
- || poNode->GetChildCount() != 2 )
- continue;
-
- /* this this eventually test within some epsilon? */
- if( this->GetProjParm( poNode->GetChild(0)->GetValue() )
- != poOtherSRS->GetProjParm( poNode->GetChild(0)->GetValue() ) )
- return FALSE;
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* If they are LOCALCS/PROJCS, do they have the same units? */
-/* -------------------------------------------------------------------- */
- if( EQUAL(GetRoot()->GetValue(),"LOCALCS") || IsProjected() )
- {
- if( GetLinearUnits() != 0.0 )
- {
- double dfRatio;
-
- dfRatio = poOtherSRS->GetLinearUnits() / GetLinearUnits();
- if( dfRatio < 0.9999999999 || dfRatio > 1.000000001 )
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/************************************************************************/
-/* OSRIsSame() */
-/************************************************************************/
-
-int OSRIsSame( OGRSpatialReferenceH hSRS1, OGRSpatialReferenceH hSRS2 )
-
-{
- return ((OGRSpatialReference *) hSRS1)->IsSame(
- (OGRSpatialReference *) hSRS2 );
-}
-
-/************************************************************************/
-/* SetTOWGS84() */
-/************************************************************************/
-
-/**
- * Set the Bursa-Wolf conversion to WGS84.
- *
- * This will create the TOWGS84 node as a child of the DATUM. It will fail
- * if there is no existing DATUM node. Unlike most OGRSpatialReference
- * methods it will insert itself in the appropriate order, and will replace
- * an existing TOWGS84 node if there is one.
- *
- * The parameters have the same meaning as EPSG transformation 9606
- * (Position Vector 7-param. transformation).
- *
- * This method is the same as the C function OSRSetTOWGS84().
- *
- * @param dfDX X child in meters.
- * @param dfDY Y child in meters.
- * @param dfDZ Z child in meters.
- * @param dfEX X rotation in arc seconds (optional, defaults to zero).
- * @param dfEY Y rotation in arc seconds (optional, defaults to zero).
- * @param dfEZ Z rotation in arc seconds (optional, defaults to zero).
- * @param dfPPM scaling factor (parts per million).
- *
- * @return OGRERR_NONE on success.
- */
-
-OGRErr OGRSpatialReference::SetTOWGS84( double dfDX, double dfDY, double dfDZ,
- double dfEX, double dfEY, double dfEZ,
- double dfPPM )
-
-{
- OGR_SRSNode *poDatum, *poTOWGS84;
- int iPosition;
- char szValue[64];
-
- poDatum = GetAttrNode( "DATUM" );
- if( poDatum == NULL )
- return OGRERR_FAILURE;
-
- if( poDatum->FindChild( "TOWGS84" ) != -1 )
- poDatum->DestroyChild( poDatum->FindChild( "TOWGS84" ) );
-
- iPosition = poDatum->GetChildCount();
- if( poDatum->FindChild("AUTHORITY") != -1 )
- {
- iPosition = poDatum->FindChild("AUTHORITY");
- }
-
- poTOWGS84 = new OGR_SRSNode("TOWGS84");
-
- OGRPrintDouble( szValue, dfDX );
- poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
-
- OGRPrintDouble( szValue, dfDY );
- poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
-
- OGRPrintDouble( szValue, dfDZ );
- poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
-
- OGRPrintDouble( szValue, dfEX );
- poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
-
- OGRPrintDouble( szValue, dfEY );
- poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
-
- OGRPrintDouble( szValue, dfEZ );
- poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
-
- OGRPrintDouble( szValue, dfPPM );
- poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
-
- poDatum->InsertChild( poTOWGS84, iPosition );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRSetTOWGS84() */
-/************************************************************************/
-
-OGRErr OSRSetTOWGS84( OGRSpatialReferenceH hSRS,
- double dfDX, double dfDY, double dfDZ,
- double dfEX, double dfEY, double dfEZ,
- double dfPPM )
-
-{
- return ((OGRSpatialReference *) hSRS)->SetTOWGS84( dfDX, dfDY, dfDZ,
- dfEX, dfEY, dfEZ,
- dfPPM );
-}
-
-/************************************************************************/
-/* GetTOWGS84() */
-/************************************************************************/
-
-/**
- * Fetch TOWGS84 parameters, if available.
- *
- * @param padfCoeff array into which up to 7 coefficients are placed.
- * @param nCoeffCount size of padfCoeff - defaults to 7.
- *
- * @return OGRERR_NONE on success, or OGRERR_FAILURE if there is no
- * TOWGS84 node available.
- */
-
-OGRErr OGRSpatialReference::GetTOWGS84( double * padfCoeff,
- int nCoeffCount ) const
-
-{
- const OGR_SRSNode *poNode = GetAttrNode( "TOWGS84" );
-
- memset( padfCoeff, 0, sizeof(double) * nCoeffCount );
-
- if( poNode == NULL )
- return OGRERR_FAILURE;
-
- for( int i = 0; i < nCoeffCount && i < poNode->GetChildCount(); i++ )
- {
- padfCoeff[i] = atof(poNode->GetChild(i)->GetValue());
- }
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRGetTOWGS84() */
-/************************************************************************/
-
-OGRErr OSRGetTOWGS84( OGRSpatialReferenceH hSRS,
- double * padfCoeff, int nCoeffCount )
-
-{
- return ((OGRSpatialReference *) hSRS)->GetTOWGS84( padfCoeff, nCoeffCount);
-}
-
-/************************************************************************/
-/* IsAngularParameter() */
-/* */
-/* Is the passed projection parameter an angular one? */
-/************************************************************************/
-
-int OGRSpatialReference::IsAngularParameter( const char *pszParameterName )
-
-{
- if( EQUALN(pszParameterName,"long",4)
- || EQUALN(pszParameterName,"lati",4)
- || EQUAL(pszParameterName,SRS_PP_CENTRAL_MERIDIAN)
- || EQUALN(pszParameterName,"standard_parallel",17)
- || EQUAL(pszParameterName,SRS_PP_AZIMUTH)
- || EQUAL(pszParameterName,SRS_PP_RECTIFIED_GRID_ANGLE) )
- return TRUE;
- else
- return FALSE;
-}
-
-/************************************************************************/
-/* IsLongitudeParameter() */
-/* */
-/* Is the passed projection parameter an angular longitude */
-/* (relative to a prime meridian)? */
-/************************************************************************/
-
-int OGRSpatialReference::IsLongitudeParameter( const char *pszParameterName )
-
-{
- if( EQUALN(pszParameterName,"long",4)
- || EQUAL(pszParameterName,SRS_PP_CENTRAL_MERIDIAN) )
- return TRUE;
- else
- return FALSE;
-}
-
-/************************************************************************/
-/* IsLinearParameter() */
-/* */
-/* Is the passed projection parameter an linear one measured in */
-/* meters or some similar linear measure. */
-/************************************************************************/
-
-int OGRSpatialReference::IsLinearParameter( const char *pszParameterName )
-
-{
- if( EQUALN(pszParameterName,"false_",6)
- || EQUAL(pszParameterName,SRS_PP_SATELLITE_HEIGHT) )
- return TRUE;
- else
- return FALSE;
-}
-
-/************************************************************************/
-/* GetNormInfo() */
-/* */
-/* Set the internal information for normalizing linear, and */
-/* angular values. */
-/************************************************************************/
-
-void OGRSpatialReference::GetNormInfo(void) const
-
-{
- if( bNormInfoSet )
- return;
-
-/* -------------------------------------------------------------------- */
-/* Initialize values. */
-/* -------------------------------------------------------------------- */
- OGRSpatialReference *poThis = (OGRSpatialReference *) this;
-
- poThis->bNormInfoSet = TRUE;
-
- poThis->dfFromGreenwich = GetPrimeMeridian(NULL);
- poThis->dfToMeter = GetLinearUnits(NULL);
- poThis->dfToDegrees = GetAngularUnits(NULL) / atof(SRS_UA_DEGREE_CONV);
- if( fabs(poThis->dfToDegrees-1.0) < 0.000000001 )
- poThis->dfToDegrees = 1.0;
-}
-
-/************************************************************************/
-/* FixupOrdering() */
-/************************************************************************/
-
-/**
- * Correct parameter ordering to match CT Specification.
- *
- * Some mechanisms to create WKT using OGRSpatialReference, and some
- * imported WKT fail to maintain the order of parameters required according
- * to the BNF definitions in the OpenGIS SF-SQL and CT Specifications. This
- * method attempts to massage things back into the required order.
- *
- * This method is the same as the C function OSRFixupOrdering().
- *
- * @return OGRERR_NONE on success or an error code if something goes
- * wrong.
- */
-
-OGRErr OGRSpatialReference::FixupOrdering()
-
-{
- if( GetRoot() != NULL )
- return GetRoot()->FixupOrdering();
- else
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRFixupOrdering() */
-/************************************************************************/
-
-OGRErr OSRFixupOrdering( OGRSpatialReferenceH hSRS )
-
-{
- return ((OGRSpatialReference *) hSRS)->FixupOrdering();
-}
-
-/************************************************************************/
-/* Fixup() */
-/************************************************************************/
-
-/**
- * Fixup as needed.
- *
- * Some mechanisms to create WKT using OGRSpatialReference, and some
- * imported WKT, are not valid according to the OGC CT specification. This
- * method attempts to fill in any missing defaults that are required, and
- * fixup ordering problems (using OSRFixupOrdering()) so that the resulting
- * WKT is valid.
- *
- * This method should be expected to evolve over time to as problems are
- * discovered. The following are amoung the fixup actions this method will
- * take:
- *
- * - Fixup the ordering of nodes to match the BNF WKT ordering, using
- * the FixupOrdering() method.
- *
- * - Add missing linear or angular units nodes.
- *
- * This method is the same as the C function OSRFixup().
- *
- * @return OGRERR_NONE on success or an error code if something goes
- * wrong.
- */
-
-OGRErr OGRSpatialReference::Fixup()
-
-{
-/* -------------------------------------------------------------------- */
-/* Ensure linear units defaulted to METER if missing for PROJCS */
-/* or LOCAL_CS. */
-/* -------------------------------------------------------------------- */
- const OGR_SRSNode *poCS = GetAttrNode( "PROJCS" );
-
- if( poCS == NULL )
- poCS = GetAttrNode( "LOCAL_CS" );
-
- if( poCS != NULL && poCS->FindChild( "UNIT" ) == -1 )
- SetLinearUnits( SRS_UL_METER, 1.0 );
-
-/* -------------------------------------------------------------------- */
-/* Ensure angular units defaulted to degrees on the GEOGCS. */
-/* -------------------------------------------------------------------- */
- poCS = GetAttrNode( "GEOGCS" );
- if( poCS != NULL && poCS->FindChild( "UNIT" ) == -1 )
- SetAngularUnits( SRS_UA_DEGREE, atof(SRS_UA_DEGREE_CONV) );
-
- return FixupOrdering();
-}
-
-/************************************************************************/
-/* OSRFixup() */
-/************************************************************************/
-
-OGRErr OSRFixup( OGRSpatialReferenceH hSRS )
-
-{
- return ((OGRSpatialReference *) hSRS)->Fixup();
-}
-
-/************************************************************************/
-/* GetExtension() */
-/************************************************************************/
-
-/**
- * Fetch extension value.
- *
- * Fetch the value of the named EXTENSION item for the identified
- * target node.
- *
- * @param pszTargetKey the name or path to the parent node of the EXTENSION.
- * @param pszName the name of the extension being fetched.
- * @param pszDefault the value to return if the extension is not found.
- *
- * @return node value if successful or pszDefault on failure.
- */
-
-const char *OGRSpatialReference::GetExtension( const char *pszTargetKey,
- const char *pszName,
- const char *pszDefault ) const
-
-{
-/* -------------------------------------------------------------------- */
-/* Find the target node. */
-/* -------------------------------------------------------------------- */
- const OGR_SRSNode *poNode;
-
- if( pszTargetKey == NULL )
- poNode = poRoot;
- else
- poNode= ((OGRSpatialReference *) this)->GetAttrNode( pszTargetKey );
-
- if( poNode == NULL )
- return NULL;
-
-/* -------------------------------------------------------------------- */
-/* Fetch matching EXTENSION if there is one. */
-/* -------------------------------------------------------------------- */
- for( int i = poNode->GetChildCount()-1; i >= 0; i-- )
- {
- const OGR_SRSNode *poChild = poNode->GetChild(i);
-
- if( EQUAL(poChild->GetValue(),"EXTENSION")
- && poChild->GetChildCount() >= 2 )
- {
- if( EQUAL(poChild->GetChild(0)->GetValue(),pszName) )
- return poChild->GetChild(1)->GetValue();
- }
- }
-
- return pszDefault;
-}
-
-/************************************************************************/
-/* SetExtension() */
-/************************************************************************/
-
-OGRErr OGRSpatialReference::SetExtension( const char *pszTargetKey,
- const char *pszName,
- const char *pszValue )
-
-{
-/* -------------------------------------------------------------------- */
-/* Find the target node. */
-/* -------------------------------------------------------------------- */
- OGR_SRSNode *poNode;
-
- if( pszTargetKey == NULL )
- poNode = poRoot;
- else
- poNode= ((OGRSpatialReference *) this)->GetAttrNode( pszTargetKey );
-
- if( poNode == NULL )
- return OGRERR_FAILURE;
-
-/* -------------------------------------------------------------------- */
-/* Fetch matching EXTENSION if there is one. */
-/* -------------------------------------------------------------------- */
- for( int i = poNode->GetChildCount()-1; i >= 0; i-- )
- {
- OGR_SRSNode *poChild = poNode->GetChild(i);
-
- if( EQUAL(poChild->GetValue(),"EXTENSION")
- && poChild->GetChildCount() >= 2 )
- {
- if( EQUAL(poChild->GetChild(0)->GetValue(),pszName) )
- {
- poChild->GetChild(1)->SetValue( pszValue );
- return OGRERR_NONE;
- }
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Create a new EXTENSION node. */
-/* -------------------------------------------------------------------- */
- OGR_SRSNode *poAuthNode;
-
- poAuthNode = new OGR_SRSNode( "EXTENSION" );
- poAuthNode->AddChild( new OGR_SRSNode( pszName ) );
- poAuthNode->AddChild( new OGR_SRSNode( pszValue ) );
-
- poNode->AddChild( poAuthNode );
-
- return OGRERR_NONE;
-}
-
-/************************************************************************/
-/* OSRCleanup() */
-/************************************************************************/
-
-/**
- * Cleanup cached SRS related memory.
- *
- * This function will attempt to cleanup any cache spatial reference
- * related information, such as cached tables of coordinate systems.
- */
-
-CPL_C_START
-void CleanupESRIDatumMappingTable();
-CPL_C_END
-
-
-void OSRCleanup( void )
-
-{
- CleanupESRIDatumMappingTable();
- CSVDeaccess( NULL );
-}
+/******************************************************************************
+ * $Id: ogrspatialreference.cpp,v 1.104 2006/12/18 16:22:51 fwarmerdam Exp $
+ *
+ * Project: OpenGIS Simple Features Reference Implementation
+ * Purpose: The OGRSpatialReference class.
+ * Author: Frank Warmerdam, warmerdam at pobox.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Les Technologies SoftMap 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: ogrspatialreference.cpp,v $
+ * Revision 1.104 2006/12/18 16:22:51 fwarmerdam
+ * added support for x-ogc as well as ogc namespace
+ *
+ * Revision 1.103 2006/11/30 17:48:32 fwarmerdam
+ * Avoid uninitialized variable warning.
+ *
+ * Revision 1.102 2006/11/24 17:58:15 fwarmerdam
+ * added extension management methods
+ *
+ * Revision 1.101 2006/11/21 21:25:27 fwarmerdam
+ * Applied ESRI:: modifier to dictionary lookups if requested.
+ *
+ * Revision 1.100 2006/11/07 18:55:07 fwarmerdam
+ * added OGC importFromURN()
+ *
+ * Revision 1.99 2006/10/14 01:31:14 fwarmerdam
+ * NULL target for GetAuthorityName/Code now returns for the root node.
+ *
+ * Revision 1.98 2005/12/20 02:08:07 fwarmerdam
+ * UTM should default to a linear units of meter.
+ *
+ * Revision 1.97 2005/12/01 04:59:46 fwarmerdam
+ * added two point equidistant support
+ *
+ * Revision 1.96 2005/10/16 01:32:41 fwarmerdam
+ * Apply epsilon testing to UTM zone false easting and northing.
+ *
+ * Revision 1.95 2005/09/21 03:00:42 fwarmerdam
+ * fixed return for Release
+ *
+ * Revision 1.94 2005/09/21 00:51:27 fwarmerdam
+ * added Release
+ *
+ * Revision 1.93 2005/04/06 00:02:05 fwarmerdam
+ * various osr and oct functions now stdcall
+ *
+ * Revision 1.92 2005/03/03 04:55:42 fwarmerdam
+ * make exportToWkt() const
+ *
+ * Revision 1.91 2005/02/11 14:21:28 fwarmerdam
+ * added GEOS projection support
+ *
+ * Revision 1.90 2005/01/13 05:17:37 fwarmerdam
+ * added SetLinearUnitsAndUpdateParameters
+ *
+ * Revision 1.89 2005/01/05 21:02:33 fwarmerdam
+ * added Goode Homolosine
+ *
+ * Revision 1.88 2004/11/11 18:28:45 fwarmerdam
+ * added Bonne projection support
+ *
+ * Revision 1.87 2004/09/23 16:20:13 fwarmerdam
+ * added OSRCleanup
+ *
+ * Revision 1.86 2004/09/10 20:59:06 fwarmerdam
+ * Added note on SetSOC() being deprecated.
+ *
+ * Revision 1.85 2004/05/06 19:26:04 dron
+ * Added OSRSetProjection() function.
+ *
+ * Revision 1.84 2004/05/04 17:54:45 warmerda
+ * internal longitude format is greenwich relative - no adjustments needed
+ *
+ * Revision 1.83 2004/03/04 18:04:45 warmerda
+ * added importFromDict() support
+ *
+ * Revision 1.82 2004/02/05 17:07:59 dron
+ * Support for HOM projection, specified by two points on centerline.
+ *
+ * Revision 1.81 2003/12/05 16:22:49 warmerda
+ * optimized IsProjected
+ *
+ * Revision 1.80 2003/10/07 04:20:50 warmerda
+ * added WMS AUTO: support
+ *
+ * Revision 1.79 2003/09/18 14:43:40 warmerda
+ * Ensure that SetAuthority() clears old nodes.
+ * Don't crash on NULL root in exportToPrettyWkt().
+ *
+ * Revision 1.78 2003/08/18 13:26:01 warmerda
+ * added SetTMVariant() and related definitions
+ *
+ * Revision 1.77 2003/06/19 17:10:26 warmerda
+ * a couple fixes in last commit
+ *
+ * Revision 1.76 2003/06/18 18:24:17 warmerda
+ * added projection specific set methods to C API
+ *
+ * Revision 1.75 2003/05/30 18:34:41 warmerda
+ * clear existing authority node in SetLinearUnits if one exists
+ *
+ * Revision 1.74 2003/05/28 19:16:43 warmerda
+ * fixed up argument names and stuff for docs
+ *
+ * Revision 1.73 2003/04/01 14:34:45 warmerda
+ * Clarify SetUTM() documentation.
+ *
+ * Revision 1.72 2003/03/28 17:42:05 warmerda
+ * fixed reference/dereference problem
+ *
+ * Revision 1.71 2003/02/25 04:55:41 warmerda
+ * Added SetGeogCSFrom() method. Modified SetWellKnownGeogCS() to use it.
+ * Modfied SetGeogCS() to replace an existing GEOGCS node if there is one.
+ *
+ * Revision 1.70 2003/02/14 22:15:04 warmerda
+ * expand tabs
+ *
+ * Revision 1.69 2003/02/08 00:37:15 warmerda
+ * try to improve documentation
+ *
+ * Revision 1.68 2003/02/06 04:53:12 warmerda
+ * added Fixup() method
+ *
+ * Revision 1.67 2003/01/31 02:27:08 warmerda
+ * modified SetFromUserInput() to avoid large buffer on stack
+ *
+ * Revision 1.66 2003/01/08 18:14:28 warmerda
+ * added FixupOrdering()
+ */
+
+#include "ogr_spatialref.h"
+#include "ogr_p.h"
+#include "cpl_csv.h"
+
+CPL_CVSID("$Id: ogrspatialreference.cpp,v 1.104 2006/12/18 16:22:51 fwarmerdam Exp $");
+
+// The current opinion is that WKT longitudes like central meridian
+// should be relative to greenwich, not the prime meridian in use.
+// Define the following if they should be relative to the prime meridian
+// of then geogcs.
+#undef WKT_LONGITUDE_RELATIVE_TO_PM
+
+/************************************************************************/
+/* OGRPrintDouble() */
+/************************************************************************/
+
+static void OGRPrintDouble( char * pszStrBuf, double dfValue )
+
+{
+ sprintf( pszStrBuf, "%.16g", dfValue );
+
+ int nLen = strlen(pszStrBuf);
+
+ // The following hack is intended to truncate some "precision" in cases
+ // that appear to be roundoff error.
+ if( nLen > 15
+ && (strcmp(pszStrBuf+nLen-6,"999999") == 0
+ || strcmp(pszStrBuf+nLen-6,"000001") == 0) )
+ {
+ sprintf( pszStrBuf, "%.15g", dfValue );
+ }
+}
+
+/************************************************************************/
+/* OGRSpatialReference() */
+/************************************************************************/
+
+/**
+ * Constructor.
+ *
+ * This constructor takes an optional string argument which if passed
+ * should be a WKT representation of an SRS. Passing this is equivelent
+ * to not passing it, and then calling importFromWkt() with the WKT string.
+ *
+ * Note that newly created objects are given a reference count of one.
+ *
+ * The C function OSRNewSpatialReference() does the same thing as this
+ * constructor.
+ *
+ * @param pszWKT well known text definition to which the object should
+ * be initialized, or NULL (the default).
+ */
+
+OGRSpatialReference::OGRSpatialReference( const char * pszWKT )
+
+{
+ bNormInfoSet = FALSE;
+ nRefCount = 1;
+ poRoot = NULL;
+
+ if( pszWKT != NULL )
+ importFromWkt( (char **) &pszWKT );
+}
+
+/************************************************************************/
+/* OSRNewSpatialReference() */
+/************************************************************************/
+
+OGRSpatialReferenceH CPL_STDCALL OSRNewSpatialReference( const char *pszWKT )
+
+{
+ OGRSpatialReference * poSRS;
+
+ poSRS = new OGRSpatialReference();
+
+ if( pszWKT != NULL && strlen(pszWKT) > 0 )
+ {
+ if( poSRS->importFromWkt( (char **) (&pszWKT) ) != OGRERR_NONE )
+ {
+ delete poSRS;
+ poSRS = NULL;
+ }
+ }
+
+ return poSRS;
+}
+
+/************************************************************************/
+/* OGRSpatialReference() */
+/* */
+/* Simple copy constructor. See also Clone(). */
+/************************************************************************/
+
+OGRSpatialReference::OGRSpatialReference(const OGRSpatialReference &oOther)
+
+{
+ bNormInfoSet = FALSE;
+ nRefCount = 1;
+ poRoot = NULL;
+
+ if( oOther.poRoot != NULL )
+ poRoot = oOther.poRoot->Clone();
+}
+
+/************************************************************************/
+/* ~OGRSpatialReference() */
+/************************************************************************/
+
+/**
+ * OGRSpatialReference destructor.
+ *
+ * The C function OSRDestroySpatialReference() does the same thing as this
+ * method.
+ */
+
+OGRSpatialReference::~OGRSpatialReference()
+
+{
+ if( poRoot != NULL )
+ delete poRoot;
+}
+
+/************************************************************************/
+/* OSRDestroySpatialReference() */
+/************************************************************************/
+
+void CPL_STDCALL OSRDestroySpatialReference( OGRSpatialReferenceH hSRS )
+
+{
+ delete ((OGRSpatialReference *) hSRS);
+}
+
+/************************************************************************/
+/* Clear() */
+/************************************************************************/
+
+/**
+ * Wipe current definition.
+ *
+ * Returns OGRSpatialReference to a state with no definition, as it
+ * exists when first created. It does not affect reference counts.
+ */
+
+void OGRSpatialReference::Clear()
+
+{
+ if( poRoot )
+ delete poRoot;
+
+ poRoot = NULL;
+}
+
+/************************************************************************/
+/* operator=() */
+/************************************************************************/
+
+OGRSpatialReference &
+OGRSpatialReference::operator=(const OGRSpatialReference &oSource)
+
+{
+ if( poRoot != NULL )
+ {
+ delete poRoot;
+ poRoot = NULL;
+ }
+
+ if( oSource.poRoot != NULL )
+ poRoot = oSource.poRoot->Clone();
+
+ return *this;
+}
+
+/************************************************************************/
+/* Reference() */
+/************************************************************************/
+
+/**
+ * Increments the reference count by one.
+ *
+ * The reference count is used keep track of the number of OGRGeometry objects
+ * referencing this SRS.
+ *
+ * The method does the same thing as the C function OSRReference().
+ *
+ * @return the updated reference count.
+ */
+
+int OGRSpatialReference::Reference()
+
+{
+ return ++nRefCount;
+}
+
+/************************************************************************/
+/* OSRReference() */
+/************************************************************************/
+
+int OSRReference( OGRSpatialReferenceH hSRS )
+
+{
+ return ((OGRSpatialReference *) hSRS)->Reference();
+}
+
+/************************************************************************/
+/* Dereference() */
+/************************************************************************/
+
+/**
+ * Decrements the reference count by one.
+ *
+ * The method does the same thing as the C function OSRDereference().
+ *
+ * @return the updated reference count.
+ */
+
+int OGRSpatialReference::Dereference()
+
+{
+ return --nRefCount;
+}
+
+/************************************************************************/
+/* OSRDereference() */
+/************************************************************************/
+
+int OSRDereference( OGRSpatialReferenceH hSRS )
+
+{
+ return ((OGRSpatialReference *) hSRS)->Dereference();
+}
+
+/************************************************************************/
+/* GetReferenceCount() */
+/************************************************************************/
+
+/**
+ * \fn int OGRSpatialReference::GetReferenceCount() const;
+ *
+ * Fetch current reference count.
+ *
+ * @return the current reference count.
+ */
+
+/************************************************************************/
+/* Release() */
+/************************************************************************/
+
+/**
+ * Decrements the reference count by one, and destroy if zero.
+ *
+ * The method does the same thing as the C function OSRRelease().
+ */
+
+void OGRSpatialReference::Release()
+
+{
+ if( this && Dereference() == 0 )
+ delete this;
+}
+
+/************************************************************************/
+/* OSRRelease() */
+/************************************************************************/
+
+void OSRRelease( OGRSpatialReferenceH hSRS )
+
+{
+ ((OGRSpatialReference *) hSRS)->Release();
+}
+
+/************************************************************************/
+/* SetRoot() */
+/************************************************************************/
+
+/**
+ * Set the root SRS node.
+ *
+ * If the object has an existing tree of OGR_SRSNodes, they are destroyed
+ * as part of assigning the new root. Ownership of the passed OGR_SRSNode is
+ * is assumed by the OGRSpatialReference.
+ *
+ * @param poNewRoot object to assign as root.
+ */
+
+void OGRSpatialReference::SetRoot( OGR_SRSNode * poNewRoot )
+
+{
+ if( poRoot != NULL )
+ delete poRoot;
+
+ poRoot = poNewRoot;
+}
+
+/************************************************************************/
+/* GetAttrNode() */
+/************************************************************************/
+
+/**
+ * Find named node in tree.
+ *
+ * This method does a pre-order traversal of the node tree searching for
+ * a node with this exact value (case insensitive), and returns it. Leaf
+ * nodes are not considered, under the assumption that they are just
+ * attribute value nodes.
+ *
+ * If a node appears more than once in the tree (such as UNIT for instance),
+ * the first encountered will be returned. Use GetNode() on a subtree to be
+ * more specific.
+ *
+ * @param pszNodePath the name of the node to search for. May contain multiple
+ * components such as "GEOGCS|UNITS".
+ *
+ * @return a pointer to the node found, or NULL if none.
+ */
+
+OGR_SRSNode *OGRSpatialReference::GetAttrNode( const char * pszNodePath )
+
+{
+ char **papszPathTokens;
+ OGR_SRSNode *poNode;
+
+ papszPathTokens = CSLTokenizeStringComplex(pszNodePath, "|", TRUE, FALSE);
+
+ if( CSLCount( papszPathTokens ) < 1 )
+ return NULL;
+
+ poNode = GetRoot();
+ for( int i = 0; poNode != NULL && papszPathTokens[i] != NULL; i++ )
+ {
+ poNode = poNode->GetNode( papszPathTokens[i] );
+ }
+
+ CSLDestroy( papszPathTokens );
+
+ return poNode;
+}
+
+const OGR_SRSNode *
+OGRSpatialReference::GetAttrNode( const char * pszNodePath ) const
+
+{
+ OGR_SRSNode *poNode;
+
+ poNode = ((OGRSpatialReference *) this)->GetAttrNode(pszNodePath);
+
+ return poNode;
+}
+
+/************************************************************************/
+/* GetAttrValue() */
+/************************************************************************/
+
+/**
+ * Fetch indicated attribute of named node.
+ *
+ * This method uses GetAttrNode() to find the named node, and then extracts
+ * the value of the indicated child. Thus a call to GetAttrValue("UNIT",1)
+ * would return the second child of the UNIT node, which is normally the
+ * length of the linear unit in meters.
+ *
+ * This method does the same thing as the C function OSRGetAttrValue().
+ *
+ * @param pszNodeName the tree node to look for (case insensitive).
+ * @param iAttr the child of the node to fetch (zero based).
+ *
+ * @return the requested value, or NULL if it fails for any reason.
+ */
+
+const char *OGRSpatialReference::GetAttrValue( const char * pszNodeName,
+ int iAttr ) const
+
+{
+ const OGR_SRSNode *poNode;
+
+ poNode = GetAttrNode( pszNodeName );
+ if( poNode == NULL )
+ return NULL;
+
+ if( iAttr < 0 || iAttr >= poNode->GetChildCount() )
+ return NULL;
+
+ return poNode->GetChild(iAttr)->GetValue();
+}
+
+/************************************************************************/
+/* OSRGetAttrValue() */
+/************************************************************************/
+
+const char * CPL_STDCALL OSRGetAttrValue( OGRSpatialReferenceH hSRS,
+ const char * pszKey, int iChild )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetAttrValue( pszKey, iChild );
+}
+
+/************************************************************************/
+/* Clone() */
+/************************************************************************/
+
+/**
+ * Make a duplicate of this OGRSpatialReference.
+ *
+ * This method is the same as the C function OSRClone().
+ *
+ * @return a new SRS, which becomes the responsibility of the caller.
+ */
+
+OGRSpatialReference *OGRSpatialReference::Clone() const
+
+{
+ OGRSpatialReference *poNewRef;
+
+ poNewRef = new OGRSpatialReference();
+
+ if( poRoot != NULL )
+ poNewRef->poRoot = poRoot->Clone();
+
+ return poNewRef;
+}
+
+/************************************************************************/
+/* OSRClone() */
+/************************************************************************/
+
+OGRSpatialReferenceH CPL_STDCALL OSRClone( OGRSpatialReferenceH hSRS )
+
+{
+ return (OGRSpatialReferenceH) ((OGRSpatialReference *) hSRS)->Clone();
+}
+
+/************************************************************************/
+/* exportToPrettyWkt() */
+/* */
+/* Translate into a nicely formatted string for display to a */
+/* person. */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::exportToPrettyWkt( char ** ppszResult,
+ int bSimplify ) const
+
+{
+ if( poRoot == NULL )
+ {
+ *ppszResult = CPLStrdup("");
+ return OGRERR_NONE;
+ }
+
+ if( bSimplify )
+ {
+ OGRSpatialReference *poSimpleClone = Clone();
+ OGRErr eErr;
+
+ poSimpleClone->GetRoot()->StripNodes( "AXIS" );
+ poSimpleClone->GetRoot()->StripNodes( "AUTHORITY" );
+ poSimpleClone->GetRoot()->StripNodes( "EXTENSION" );
+ eErr = poSimpleClone->GetRoot()->exportToPrettyWkt( ppszResult, 1 );
+ delete poSimpleClone;
+ return eErr;
+ }
+ else
+ return poRoot->exportToPrettyWkt( ppszResult, 1 );
+}
+
+/************************************************************************/
+/* OSRExportToPrettyWkt() */
+/************************************************************************/
+
+OGRErr CPL_STDCALL OSRExportToPrettyWkt( OGRSpatialReferenceH hSRS, char ** ppszReturn,
+ int bSimplify)
+
+{
+ *ppszReturn = NULL;
+
+ return ((OGRSpatialReference *) hSRS)->exportToPrettyWkt( ppszReturn,
+ bSimplify );
+}
+
+/************************************************************************/
+/* exportToWkt() */
+/************************************************************************/
+
+/**
+ * Convert this SRS into WKT format.
+ *
+ * Note that the returned WKT string should be freed with OGRFree() or
+ * CPLFree() when no longer needed. It is the responsibility of the caller.
+ *
+ * This method is the same as the C function OSRExportToWkt().
+ *
+ * @param ppszResult the resulting string is returned in this pointer.
+ *
+ * @return currently OGRERR_NONE is always returned, but the future it
+ * is possible error conditions will develop.
+ */
+
+OGRErr OGRSpatialReference::exportToWkt( char ** ppszResult ) const
+
+{
+ if( poRoot == NULL )
+ {
+ *ppszResult = CPLStrdup("");
+ return OGRERR_NONE;
+ }
+ else
+ {
+ return poRoot->exportToWkt(ppszResult);
+ }
+}
+
+/************************************************************************/
+/* OSRExportToWkt() */
+/************************************************************************/
+
+OGRErr CPL_STDCALL OSRExportToWkt( OGRSpatialReferenceH hSRS, char ** ppszReturn )
+
+{
+ *ppszReturn = NULL;
+
+ return ((OGRSpatialReference *) hSRS)->exportToWkt( ppszReturn );
+}
+
+/************************************************************************/
+/* importFromWkt() */
+/************************************************************************/
+
+/**
+ * Import from WKT string.
+ *
+ * This method will wipe the existing SRS definition, and
+ * reassign it based on the contents of the passed WKT string. Only as
+ * much of the input string as needed to construct this SRS is consumed from
+ * the input string, and the input string pointer
+ * is then updated to point to the remaining (unused) input.
+ *
+ * This method is the same as the C function OSRImportFromWkt().
+ *
+ * @param ppszInput Pointer to pointer to input. The pointer is updated to
+ * point to remaining unused input text.
+ *
+ * @return OGRERR_NONE if import succeeds, or OGRERR_CORRUPT_DATA if it
+ * fails for any reason.
+ */
+
+OGRErr OGRSpatialReference::importFromWkt( char ** ppszInput )
+
+{
+ if( poRoot != NULL )
+ delete poRoot;
+
+ bNormInfoSet = FALSE;
+
+ poRoot = new OGR_SRSNode();
+
+ return poRoot->importFromWkt( ppszInput );
+}
+
+/************************************************************************/
+/* OSRImportFromWkt() */
+/************************************************************************/
+
+OGRErr OSRImportFromWkt( OGRSpatialReferenceH hSRS, char **ppszInput )
+
+{
+ return ((OGRSpatialReference *) hSRS)->importFromWkt( ppszInput );
+}
+
+/************************************************************************/
+/* SetNode() */
+/************************************************************************/
+
+/**
+ * Set attribute value in spatial reference.
+ *
+ * Missing intermediate nodes in the path will be created if not already
+ * in existance. If the attribute has no children one will be created and
+ * assigned the value otherwise the zeroth child will be assigned the value.
+ *
+ * This method does the same as the C function OSRSetAttrValue().
+ *
+ * @param pszNodePath full path to attribute to be set. For instance
+ * "PROJCS|GEOGCS|UNITS".
+ *
+ * @param pszNewNodeValue value to be assigned to node, such as "meter".
+ * This may be NULL if you just want to force creation of the intermediate
+ * path.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetNode( const char * pszNodePath,
+ const char * pszNewNodeValue )
+
+{
+ char **papszPathTokens;
+ int i;
+ OGR_SRSNode *poNode;
+
+ papszPathTokens = CSLTokenizeStringComplex(pszNodePath, "|", TRUE, FALSE);
+
+ if( CSLCount( papszPathTokens ) < 1 )
+ return OGRERR_FAILURE;
+
+ if( GetRoot() == NULL || !EQUAL(papszPathTokens[0],GetRoot()->GetValue()) )
+ {
+ SetRoot( new OGR_SRSNode( papszPathTokens[0] ) );
+ }
+
+ poNode = GetRoot();
+ for( i = 1; papszPathTokens[i] != NULL; i++ )
+ {
+ int j;
+
+ for( j = 0; j < poNode->GetChildCount(); j++ )
+ {
+ if( EQUAL(poNode->GetChild( j )->GetValue(),papszPathTokens[i]) )
+ {
+ poNode = poNode->GetChild(j);
+ j = -1;
+ break;
+ }
+ }
+
+ if( j != -1 )
+ {
+ OGR_SRSNode *poNewNode = new OGR_SRSNode( papszPathTokens[i] );
+ poNode->AddChild( poNewNode );
+ poNode = poNewNode;
+ }
+ }
+
+ CSLDestroy( papszPathTokens );
+
+ if( pszNewNodeValue != NULL )
+ {
+ if( poNode->GetChildCount() > 0 )
+ poNode->GetChild(0)->SetValue( pszNewNodeValue );
+ else
+ poNode->AddChild( new OGR_SRSNode( pszNewNodeValue ) );
+ }
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetAttrValue() */
+/************************************************************************/
+
+OGRErr CPL_STDCALL OSRSetAttrValue( OGRSpatialReferenceH hSRS,
+ const char * pszPath, const char * pszValue )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetNode( pszPath, pszValue );
+}
+
+/************************************************************************/
+/* SetNode() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetNode( const char *pszNodePath,
+ double dfValue )
+
+{
+ char szValue[64];
+
+ if( ABS(dfValue - (int) dfValue) == 0.0 )
+ sprintf( szValue, "%d", (int) dfValue );
+ else
+ // notdef: sprintf( szValue, "%.16g", dfValue );
+ OGRPrintDouble( szValue, dfValue );
+
+ return SetNode( pszNodePath, szValue );
+}
+
+/************************************************************************/
+/* SetAngularUnits() */
+/************************************************************************/
+
+/**
+ * Set the angular units for the geographic coordinate system.
+ *
+ * This method creates a UNITS subnode with the specified values as a
+ * child of the GEOGCS node.
+ *
+ * This method does the same as the C function OSRSetAngularUnits().
+ *
+ * @param pszUnitsName the units name to be used. Some preferred units
+ * names can be found in ogr_srs_api.h such as SRS_UA_DEGREE.
+ *
+ * @param dfInRadians the value to multiple by an angle in the indicated
+ * units to transform to radians. Some standard conversion factors can
+ * be found in ogr_srs_api.h.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetAngularUnits( const char * pszUnitsName,
+ double dfInRadians )
+
+{
+ OGR_SRSNode *poCS;
+ OGR_SRSNode *poUnits;
+ char szValue[128];
+
+ bNormInfoSet = FALSE;
+
+ poCS = GetAttrNode( "GEOGCS" );
+
+ if( poCS == NULL )
+ return OGRERR_FAILURE;
+
+ OGRPrintDouble( szValue, dfInRadians );
+
+ if( poCS->FindChild( "UNIT" ) >= 0 )
+ {
+ poUnits = poCS->GetChild( poCS->FindChild( "UNIT" ) );
+ poUnits->GetChild(0)->SetValue( pszUnitsName );
+ poUnits->GetChild(1)->SetValue( szValue );
+ }
+ else
+ {
+ poUnits = new OGR_SRSNode( "UNIT" );
+ poUnits->AddChild( new OGR_SRSNode( pszUnitsName ) );
+ poUnits->AddChild( new OGR_SRSNode( szValue ) );
+
+ poCS->AddChild( poUnits );
+ }
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetAngularUnits() */
+/************************************************************************/
+
+OGRErr OSRSetAngularUnits( OGRSpatialReferenceH hSRS,
+ const char * pszUnits, double dfInRadians )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetAngularUnits( pszUnits,
+ dfInRadians );
+}
+
+/************************************************************************/
+/* GetAngularUnits() */
+/************************************************************************/
+
+/**
+ * Fetch angular geographic coordinate system units.
+ *
+ * If no units are available, a value of "degree" and SRS_UA_DEGREE_CONV
+ * will be assumed. This method only checks directly under the GEOGCS node
+ * for units.
+ *
+ * This method does the same thing as the C function OSRGetAngularUnits().
+ *
+ * @param ppszName a pointer to be updated with the pointer to the
+ * units name. The returned value remains internal to the OGRSpatialReference
+ * and shouldn't be freed, or modified. It may be invalidated on the next
+ * OGRSpatialReference call.
+ *
+ * @return the value to multiply by angular distances to transform them to
+ * radians.
+ */
+
+double OGRSpatialReference::GetAngularUnits( char ** ppszName ) const
+
+{
+ const OGR_SRSNode *poCS = GetAttrNode( "GEOGCS" );
+
+ if( ppszName != NULL )
+ *ppszName = "degree";
+
+ if( poCS == NULL )
+ return atof(SRS_UA_DEGREE_CONV);
+
+ for( int iChild = 0; iChild < poCS->GetChildCount(); iChild++ )
+ {
+ const OGR_SRSNode *poChild = poCS->GetChild(iChild);
+
+ if( EQUAL(poChild->GetValue(),"UNIT")
+ && poChild->GetChildCount() >= 2 )
+ {
+ if( ppszName != NULL )
+ *ppszName = (char *) poChild->GetChild(0)->GetValue();
+
+ return atof( poChild->GetChild(1)->GetValue() );
+ }
+ }
+
+ return 1.0;
+}
+
+/************************************************************************/
+/* OSRGetAngularUnits() */
+/************************************************************************/
+
+double OSRGetAngularUnits( OGRSpatialReferenceH hSRS, char ** ppszName )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetAngularUnits( ppszName );
+}
+
+/************************************************************************/
+/* SetLinearUnitsAndUpdateParameters() */
+/************************************************************************/
+
+/**
+ * Set the linear units for the projection.
+ *
+ * This method creates a UNITS subnode with the specified values as a
+ * child of the PROJCS or LOCAL_CS node. It works the same as the
+ * SetLinearUnits() method, but it also updates all existing linear
+ * projection parameter values from the old units to the new units.
+ *
+ * @param pszUnitsName the units name to be used. Some preferred units
+ * names can be found in ogr_srs_api.h such as SRS_UL_METER, SRS_UL_FOOT
+ * and SRS_UL_US_FOOT.
+ *
+ * @param dfInMeters the value to multiple by a length in the indicated
+ * units to transform to meters. Some standard conversion factors can
+ * be found in ogr_srs_api.h.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetLinearUnitsAndUpdateParameters(
+ const char *pszName, double dfInMeters )
+
+{
+ double dfOldInMeters = GetLinearUnits();
+ OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
+
+ if( dfInMeters == 0.0 )
+ return OGRERR_FAILURE;
+
+ if( dfInMeters == dfOldInMeters || poPROJCS == NULL )
+ return SetLinearUnits( pszName, dfInMeters );
+
+ for( int iChild = 0; iChild < poPROJCS->GetChildCount(); iChild++ )
+ {
+ const OGR_SRSNode *poChild = poPROJCS->GetChild(iChild);
+
+ if( EQUAL(poChild->GetValue(),"PARAMETER")
+ && poChild->GetChildCount() > 1 )
+ {
+ char *pszParmName = CPLStrdup(poChild->GetChild(0)->GetValue());
+
+ if( IsLinearParameter( pszParmName ) )
+ {
+ double dfOldValue = GetProjParm( pszParmName );
+
+ SetProjParm( pszParmName,
+ dfOldValue * dfOldInMeters / dfInMeters );
+ }
+
+ CPLFree( pszParmName );
+ }
+ }
+
+ return SetLinearUnits( pszName, dfInMeters );
+}
+
+/************************************************************************/
+/* SetLinearUnits() */
+/************************************************************************/
+
+/**
+ * Set the linear units for the projection.
+ *
+ * This method creates a UNITS subnode with the specified values as a
+ * child of the PROJCS or LOCAL_CS node.
+ *
+ * This method does the same as the C function OSRSetLinearUnits().
+ *
+ * @param pszUnitsName the units name to be used. Some preferred units
+ * names can be found in ogr_srs_api.h such as SRS_UL_METER, SRS_UL_FOOT
+ * and SRS_UL_US_FOOT.
+ *
+ * @param dfInMeters the value to multiple by a length in the indicated
+ * units to transform to meters. Some standard conversion factors can
+ * be found in ogr_srs_api.h.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetLinearUnits( const char * pszUnitsName,
+ double dfInMeters )
+
+{
+ OGR_SRSNode *poCS;
+ OGR_SRSNode *poUnits;
+ char szValue[128];
+
+ bNormInfoSet = FALSE;
+
+ poCS = GetAttrNode( "PROJCS" );
+ if( poCS == NULL )
+ poCS = GetAttrNode( "LOCAL_CS" );
+
+ if( poCS == NULL )
+ return OGRERR_FAILURE;
+
+ if( dfInMeters == (int) dfInMeters )
+ sprintf( szValue, "%d", (int) dfInMeters );
+ else
+ //notdef: sprintf( szValue, "%.16g", dfInMeters );
+ OGRPrintDouble( szValue, dfInMeters );
+
+ if( poCS->FindChild( "UNIT" ) >= 0 )
+ {
+ poUnits = poCS->GetChild( poCS->FindChild( "UNIT" ) );
+ poUnits->GetChild(0)->SetValue( pszUnitsName );
+ poUnits->GetChild(1)->SetValue( szValue );
+ if( poUnits->FindChild( "AUTHORITY" ) != -1 )
+ poUnits->DestroyChild( poUnits->FindChild( "AUTHORITY" ) );
+ }
+ else
+ {
+ poUnits = new OGR_SRSNode( "UNIT" );
+ poUnits->AddChild( new OGR_SRSNode( pszUnitsName ) );
+ poUnits->AddChild( new OGR_SRSNode( szValue ) );
+
+ poCS->AddChild( poUnits );
+ }
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetLinearUnits() */
+/************************************************************************/
+
+OGRErr OSRSetLinearUnits( OGRSpatialReferenceH hSRS,
+ const char * pszUnits, double dfInMeters )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetLinearUnits( pszUnits,
+ dfInMeters );
+}
+
+/************************************************************************/
+/* GetLinearUnits() */
+/************************************************************************/
+
+/**
+ * Fetch linear projection units.
+ *
+ * If no units are available, a value of "Meters" and 1.0 will be assumed.
+ * This method only checks directly under the PROJCS or LOCAL_CS node for
+ * units.
+ *
+ * This method does the same thing as the C function OSRGetLinearUnits()/
+ *
+ * @param ppszName a pointer to be updated with the pointer to the
+ * units name. The returned value remains internal to the OGRSpatialReference
+ * and shouldn't be freed, or modified. It may be invalidated on the next
+ * OGRSpatialReference call.
+ *
+ * @return the value to multiply by linear distances to transform them to
+ * meters.
+ */
+
+double OGRSpatialReference::GetLinearUnits( char ** ppszName ) const
+
+{
+ const OGR_SRSNode *poCS = GetAttrNode( "PROJCS" );
+
+ if( poCS == NULL )
+ poCS = GetAttrNode( "LOCAL_CS" );
+
+ if( ppszName != NULL )
+ *ppszName = "unknown";
+
+ if( poCS == NULL )
+ return 1.0;
+
+ for( int iChild = 0; iChild < poCS->GetChildCount(); iChild++ )
+ {
+ const OGR_SRSNode *poChild = poCS->GetChild(iChild);
+
+ if( EQUAL(poChild->GetValue(),"UNIT")
+ && poChild->GetChildCount() >= 2 )
+ {
+ if( ppszName != NULL )
+ *ppszName = (char *) poChild->GetChild(0)->GetValue();
+
+ return atof( poChild->GetChild(1)->GetValue() );
+ }
+ }
+
+ return 1.0;
+}
+
+/************************************************************************/
+/* OSRGetLinearUnits() */
+/************************************************************************/
+
+double OSRGetLinearUnits( OGRSpatialReferenceH hSRS, char ** ppszName )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetLinearUnits( ppszName );
+}
+
+/************************************************************************/
+/* GetPrimeMeridian() */
+/************************************************************************/
+
+/**
+ * Fetch prime meridian info.
+ *
+ * Returns the offset of the prime meridian from greenwich in degrees,
+ * and the prime meridian name (if requested). If no PRIMEM value exists
+ * in the coordinate system definition a value of "Greenwich" and an
+ * offset of 0.0 is assumed.
+ *
+ * If the prime meridian name is returned, the pointer is to an internal
+ * copy of the name. It should not be freed, altered or depended on after
+ * the next OGR call.
+ *
+ * This method is the same as the C function OSRGetPrimeMeridian().
+ *
+ * @param ppszName return location for prime meridian name. If NULL, name
+ * is not returned.
+ *
+ * @return the offset to the GEOGCS prime meridian from greenwich in decimal
+ * degrees.
+ */
+
+double OGRSpatialReference::GetPrimeMeridian( char **ppszName ) const
+
+{
+ const OGR_SRSNode *poPRIMEM = GetAttrNode( "PRIMEM" );
+
+ if( poPRIMEM != NULL && poPRIMEM->GetChildCount() >= 2
+ && atof(poPRIMEM->GetChild(1)->GetValue()) != 0.0 )
+ {
+ if( ppszName != NULL )
+ *ppszName = (char *) poPRIMEM->GetChild(0)->GetValue();
+ return atof(poPRIMEM->GetChild(1)->GetValue());
+ }
+
+ if( ppszName != NULL )
+ *ppszName = SRS_PM_GREENWICH;
+
+ return 0.0;
+}
+
+/************************************************************************/
+/* OSRGetPrimeMeridian() */
+/************************************************************************/
+
+double OSRGetPrimeMeridian( OGRSpatialReferenceH hSRS, char **ppszName )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetPrimeMeridian( ppszName );
+}
+
+/************************************************************************/
+/* SetGeogCS() */
+/************************************************************************/
+
+/**
+ * Set geographic coordinate system.
+ *
+ * This method is used to set the datum, ellipsoid, prime meridian and
+ * angular units for a geographic coordinate system. It can be used on it's
+ * own to establish a geographic spatial reference, or applied to a
+ * projected coordinate system to establish the underlying geographic
+ * coordinate system.
+ *
+ * This method does the same as the C function OSRSetGeogCS().
+ *
+ * @param pszGeogName user visible name for the geographic coordinate system
+ * (not to serve as a key).
+ *
+ * @param pszDatumName key name for this datum. The OpenGIS specification
+ * lists some known values, and otherwise EPSG datum names with a standard
+ * transformation are considered legal keys.
+ *
+ * @param pszSpheroidName user visible spheroid name (not to serve as a key)
+ *
+ * @param dfSemiMajor the semi major axis of the spheroid.
+ *
+ * @param dfInvFlattening the inverse flattening for the spheroid.
+ * This can be computed from the semi minor axis as
+ * 1/f = 1.0 / (1.0 - semiminor/semimajor).
+ *
+ * @param pszPMName the name of the prime merdidian (not to serve as a key)
+ * If this is NULL a default value of "Greenwich" will be used.
+ *
+ * @param dfPMOffset the longitude of greenwich relative to this prime
+ * meridian.
+ *
+ * @param pszAngularUnits the angular units name (see ogr_srs_api.h for some
+ * standard names). If NULL a value of "degrees" will be assumed.
+ *
+ * @param dfConvertToRadians value to multiply angular units by to transform
+ * them to radians. A value of SRS_UL_DEGREE_CONV will be used if
+ * pszAngularUnits is NULL.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr
+OGRSpatialReference::SetGeogCS( const char * pszGeogName,
+ const char * pszDatumName,
+ const char * pszSpheroidName,
+ double dfSemiMajor, double dfInvFlattening,
+ const char * pszPMName, double dfPMOffset,
+ const char * pszAngularUnits,
+ double dfConvertToRadians )
+
+{
+ bNormInfoSet = FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Do we already have a GEOGCS? If so, blow it away so it can */
+/* be properly replaced. */
+/* -------------------------------------------------------------------- */
+ if( GetAttrNode( "GEOGCS" ) != NULL )
+ {
+ OGR_SRSNode *poPROJCS;
+
+ if( EQUAL(GetRoot()->GetValue(),"GEOGCS") )
+ Clear();
+ else if( (poPROJCS = GetAttrNode( "PROJCS" )) != NULL
+ && poPROJCS->FindChild( "GEOGCS" ) != -1 )
+ poPROJCS->DestroyChild( poPROJCS->FindChild( "GEOGCS" ) );
+ else
+ return OGRERR_FAILURE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Set defaults for various parameters. */
+/* -------------------------------------------------------------------- */
+ if( pszGeogName == NULL )
+ pszGeogName = "unnamed";
+
+ if( pszPMName == NULL )
+ pszPMName = SRS_PM_GREENWICH;
+
+ if( pszDatumName == NULL )
+ pszDatumName = "unknown";
+
+ if( pszSpheroidName == NULL )
+ pszSpheroidName = "unnamed";
+
+ if( pszAngularUnits == NULL )
+ {
+ pszAngularUnits = SRS_UA_DEGREE;
+ dfConvertToRadians = atof(SRS_UA_DEGREE_CONV);
+ }
+
+/* -------------------------------------------------------------------- */
+/* Build the GEOGCS object. */
+/* -------------------------------------------------------------------- */
+ char szValue[128];
+ OGR_SRSNode *poGeogCS, *poSpheroid, *poDatum, *poPM, *poUnits;
+
+ poGeogCS = new OGR_SRSNode( "GEOGCS" );
+ poGeogCS->AddChild( new OGR_SRSNode( pszGeogName ) );
+
+/* -------------------------------------------------------------------- */
+/* Setup the spheroid. */
+/* -------------------------------------------------------------------- */
+ poSpheroid = new OGR_SRSNode( "SPHEROID" );
+ poSpheroid->AddChild( new OGR_SRSNode( pszSpheroidName ) );
+
+ OGRPrintDouble( szValue, dfSemiMajor );
+ poSpheroid->AddChild( new OGR_SRSNode(szValue) );
+
+ OGRPrintDouble( szValue, dfInvFlattening );
+ poSpheroid->AddChild( new OGR_SRSNode(szValue) );
+
+/* -------------------------------------------------------------------- */
+/* Setup the Datum. */
+/* -------------------------------------------------------------------- */
+ poDatum = new OGR_SRSNode( "DATUM" );
+ poDatum->AddChild( new OGR_SRSNode(pszDatumName) );
+ poDatum->AddChild( poSpheroid );
+
+/* -------------------------------------------------------------------- */
+/* Setup the prime meridian. */
+/* -------------------------------------------------------------------- */
+ if( dfPMOffset == 0.0 )
+ strcpy( szValue, "0" );
+ else
+ OGRPrintDouble( szValue, dfPMOffset );
+
+ poPM = new OGR_SRSNode( "PRIMEM" );
+ poPM->AddChild( new OGR_SRSNode( pszPMName ) );
+ poPM->AddChild( new OGR_SRSNode( szValue ) );
+
+/* -------------------------------------------------------------------- */
+/* Setup the rotational units. */
+/* -------------------------------------------------------------------- */
+ OGRPrintDouble( szValue, dfConvertToRadians );
+
+ poUnits = new OGR_SRSNode( "UNIT" );
+ poUnits->AddChild( new OGR_SRSNode(pszAngularUnits) );
+ poUnits->AddChild( new OGR_SRSNode(szValue) );
+
+/* -------------------------------------------------------------------- */
+/* Complete the GeogCS */
+/* -------------------------------------------------------------------- */
+ poGeogCS->AddChild( poDatum );
+ poGeogCS->AddChild( poPM );
+ poGeogCS->AddChild( poUnits );
+
+/* -------------------------------------------------------------------- */
+/* Attach below the PROJCS if there is one, or make this the root. */
+/* -------------------------------------------------------------------- */
+ if( GetRoot() != NULL && EQUAL(GetRoot()->GetValue(),"PROJCS") )
+ poRoot->InsertChild( poGeogCS, 1 );
+ else
+ SetRoot( poGeogCS );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetGeogCS() */
+/************************************************************************/
+
+OGRErr OSRSetGeogCS( OGRSpatialReferenceH hSRS,
+ const char * pszGeogName,
+ const char * pszDatumName,
+ const char * pszSpheroidName,
+ double dfSemiMajor, double dfInvFlattening,
+ const char * pszPMName, double dfPMOffset,
+ const char * pszAngularUnits,
+ double dfConvertToRadians )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetGeogCS(
+ pszGeogName, pszDatumName,
+ pszSpheroidName, dfSemiMajor, dfInvFlattening,
+ pszPMName, dfPMOffset, pszAngularUnits, dfConvertToRadians );
+
+}
+
+/************************************************************************/
+/* SetWellKnownGeogCS() */
+/************************************************************************/
+
+/**
+ * Set a GeogCS based on well known name.
+ *
+ * This may be called on an empty OGRSpatialReference to make a geographic
+ * coordinate system, or on something with an existing PROJCS node to
+ * set the underlying geographic coordinate system of a projected coordinate
+ * system.
+ *
+ * The following well known text values are currently supported:
+ * <ul>
+ * <li> "WGS84": same as "EPSG:4326" but has no dependence on EPSG data files.
+ * <li> "WGS72": same as "EPSG:4322" but has no dependence on EPSG data files.
+ * <li> "NAD27": same as "EPSG:4267" but has no dependence on EPSG data files.
+ * <li> "NAD83": same as "EPSG:4269" but has no dependence on EPSG data files.
+ * <li> "EPSG:n": same as doing an ImportFromEPSG(n).
+ * </ul>
+ *
+ * @param pszName name of well known geographic coordinate system.
+ * @return OGRERR_NONE on success, or OGRERR_FAILURE if the name isn't
+ * recognised, the target object is already initialized, or an EPSG value
+ * can't be successfully looked up.
+ */
+
+OGRErr OGRSpatialReference::SetWellKnownGeogCS( const char * pszName )
+
+{
+ OGRSpatialReference oSRS2;
+ OGRErr eErr;
+
+/* -------------------------------------------------------------------- */
+/* Check for EPSG authority numbers. */
+/* -------------------------------------------------------------------- */
+ if( EQUALN(pszName, "EPSG:",5) )
+ {
+ eErr = oSRS2.importFromEPSG( atoi(pszName+5) );
+ if( eErr != OGRERR_NONE )
+ return eErr;
+
+ if( !oSRS2.IsGeographic() )
+ return OGRERR_FAILURE;
+
+ return CopyGeogCSFrom( &oSRS2 );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Check for simple names. */
+/* -------------------------------------------------------------------- */
+ char *pszWKT = NULL;
+
+ if( EQUAL(pszName, "WGS84") || EQUAL(pszName,"CRS84") )
+ pszWKT = "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( EQUAL(pszName, "WGS72") )
+ pszWKT = "GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\",SPHEROID[\"WGS 72\",6378135,298.26,AUTHORITY[\"EPSG\",\"7043\"]],TOWGS84[0,0,4.5,0,0,0.554,0.2263],AUTHORITY[\"EPSG\",\"6322\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4322\"]]";
+
+ else if( EQUAL(pszName, "NAD27") || EQUAL(pszName, "CRS27") )
+ pszWKT = "GEOGCS[\"NAD27\",DATUM[\"North_American_Datum_1927\",SPHEROID[\"Clarke 1866\",6378206.4,294.978698213898,AUTHORITY[\"EPSG\",\"7008\"]],TOWGS84[-3,142,183,0,0,0,0],AUTHORITY[\"EPSG\",\"6267\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4267\"]]";
+
+ else if( EQUAL(pszName, "NAD83") || EQUAL(pszName,"CRS83") )
+ pszWKT = "GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6269\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4269\"]]";
+
+ else
+ return OGRERR_FAILURE;
+
+/* -------------------------------------------------------------------- */
+/* Import the WKT */
+/* -------------------------------------------------------------------- */
+ eErr = oSRS2.importFromWkt( &pszWKT );
+ if( eErr != OGRERR_NONE )
+ return eErr;
+
+/* -------------------------------------------------------------------- */
+/* Copy over. */
+/* -------------------------------------------------------------------- */
+ return CopyGeogCSFrom( &oSRS2 );
+}
+
+/************************************************************************/
+/* OSRSetWellKnownGeogCS() */
+/************************************************************************/
+
+OGRErr OSRSetWellKnownGeogCS( OGRSpatialReferenceH hSRS, const char *pszName )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetWellKnownGeogCS( pszName );
+}
+
+/************************************************************************/
+/* CopyGeogCSFrom() */
+/************************************************************************/
+
+/**
+ * Copy GEOGCS from another OGRSpatialReference.
+ *
+ * The GEOGCS information is copied into this OGRSpatialReference from another.
+ * If this object has a PROJCS root already, the GEOGCS is installed within
+ * it, otherwise it is installed as the root.
+ *
+ * @param poSrcSRS the spatial reference to copy the GEOGCS information from.
+ *
+ * @return OGRERR_NONE on success or an error code.
+ */
+
+
+OGRErr OGRSpatialReference::CopyGeogCSFrom(
+ const OGRSpatialReference * poSrcSRS )
+
+{
+ const OGR_SRSNode *poGeogCS = NULL;
+
+ bNormInfoSet = FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Do we already have a GEOGCS? If so, blow it away so it can */
+/* be properly replaced. */
+/* -------------------------------------------------------------------- */
+ if( GetAttrNode( "GEOGCS" ) != NULL )
+ {
+ OGR_SRSNode *poPROJCS;
+
+ if( EQUAL(GetRoot()->GetValue(),"GEOGCS") )
+ Clear();
+ else if( (poPROJCS = GetAttrNode( "PROJCS" )) != NULL
+ && poPROJCS->FindChild( "GEOGCS" ) != -1 )
+ poPROJCS->DestroyChild( poPROJCS->FindChild( "GEOGCS" ) );
+ else
+ return OGRERR_FAILURE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Find the GEOGCS node on the source. */
+/* -------------------------------------------------------------------- */
+ poGeogCS = poSrcSRS->GetAttrNode( "GEOGCS" );
+ if( poGeogCS == NULL )
+ return OGRERR_FAILURE;
+
+/* -------------------------------------------------------------------- */
+/* Attach below the PROJCS if there is one, or make this the root. */
+/* -------------------------------------------------------------------- */
+ if( GetRoot() != NULL && EQUAL(GetRoot()->GetValue(),"PROJCS") )
+ poRoot->InsertChild( poGeogCS->Clone(), 1 );
+ else
+ SetRoot( poGeogCS->Clone() );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRCopyGeogCSFrom() */
+/************************************************************************/
+
+OGRErr OSRCopyGeogCSFrom( OGRSpatialReferenceH hSRS,
+ OGRSpatialReferenceH hSrcSRS )
+
+{
+ return ((OGRSpatialReference *) hSRS)->CopyGeogCSFrom(
+ (const OGRSpatialReference *) hSrcSRS );
+}
+
+/************************************************************************/
+/* SetFromUserInput() */
+/************************************************************************/
+
+/**
+ * Set spatial reference from various text formats.
+ *
+ * This method will examine the provided input, and try to deduce the
+ * format, and then use it to initialize the spatial reference system. It
+ * may take the following forms:
+ *
+ * <ol>
+ * <li> Well Known Text definition - passed on to importFromWkt().
+ * <li> "EPSG:n" - number passed on to importFromEPSG().
+ * <li> "AUTO:proj_id,unit_id,lon0,lat0" - WMS auto projections.
+ * <li> "urn:ogc:def:crs:EPSG::n" - ogc urns
+ * <li> PROJ.4 definitions - passed on to importFromProj4().
+ * <li> filename - file read for WKT, XML or PROJ.4 definition.
+ * <li> well known name accepted by SetWellKnownGeogCS(), such as NAD27, NAD83,
+ * WGS84 or WGS72.
+ * </ol>
+ *
+ * It is expected that this method will be extended in the future to support
+ * XML and perhaps a simplified "minilanguage" for indicating common UTM and
+ * State Plane definitions.
+ *
+ * This method is intended to be flexible, but by it's nature it is
+ * imprecise as it must guess information about the format intended. When
+ * possible applications should call the specific method appropriate if the
+ * input is known to be in a particular format.
+ *
+ * This method does the same thing as the OSRSetFromUserInput() function.
+ *
+ * @param pszDefinition text definition to try to deduce SRS from.
+ *
+ * @return OGRERR_NONE on success, or an error code if the name isn't
+ * recognised, the definition is corrupt, or an EPSG value can't be
+ * successfully looked up.
+ */
+
+OGRErr OGRSpatialReference::SetFromUserInput( const char * pszDefinition )
+
+{
+ int bESRI = FALSE;
+ OGRErr err;
+
+ if( EQUALN(pszDefinition,"ESRI::",6) )
+ {
+ bESRI = TRUE;
+ pszDefinition += 6;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Is it a recognised syntax? */
+/* -------------------------------------------------------------------- */
+ if( EQUALN(pszDefinition,"PROJCS",6)
+ || EQUALN(pszDefinition,"GEOGCS",6)
+ || EQUALN(pszDefinition,"LOCAL_CS",8) )
+ {
+ err = importFromWkt( (char **) &pszDefinition );
+ if( err == OGRERR_NONE && bESRI )
+ err = morphFromESRI();
+
+ return err;
+ }
+
+ if( EQUALN(pszDefinition,"EPSG:",5) )
+ return importFromEPSG( atoi(pszDefinition+5) );
+
+ if( EQUALN(pszDefinition,"urn:ogc:def:crs:",16)
+ || EQUALN(pszDefinition,"urn:x-ogc:def:crs:",18) )
+ return importFromURN( pszDefinition );
+
+ if( EQUALN(pszDefinition,"AUTO:",5) )
+ return importFromWMSAUTO( pszDefinition );
+
+ if( EQUALN(pszDefinition,"DICT:",5)
+ && strstr(pszDefinition,",") )
+ {
+ char *pszFile = CPLStrdup(pszDefinition+5);
+ char *pszCode = strstr(pszFile,",") + 1;
+
+ pszCode[-1] = '\0';
+
+ err = importFromDict( pszFile, pszCode );
+ CPLFree( pszFile );
+
+ if( err == OGRERR_NONE && bESRI )
+ err = morphFromESRI();
+
+ return err;
+ }
+
+ if( EQUAL(pszDefinition,"NAD27")
+ || EQUAL(pszDefinition,"NAD83")
+ || EQUAL(pszDefinition,"WGS84")
+ || EQUAL(pszDefinition,"WGS72") )
+ {
+ Clear();
+ return SetWellKnownGeogCS( pszDefinition );
+ }
+
+ if( strstr(pszDefinition,"+proj") != NULL
+ || strstr(pszDefinition,"+init") != NULL )
+ return importFromProj4( pszDefinition );
+
+/* -------------------------------------------------------------------- */
+/* Try to open it as a file. */
+/* -------------------------------------------------------------------- */
+ FILE *fp;
+ int nBufMax = 100000;
+ char *pszBufPtr, *pszBuffer;
+ int nBytes;
+
+ fp = VSIFOpen( pszDefinition, "rt" );
+ if( fp == NULL )
+ return OGRERR_CORRUPT_DATA;
+
+ pszBuffer = (char *) CPLMalloc(nBufMax);
+ nBytes = VSIFRead( pszBuffer, 1, nBufMax-1, fp );
+ VSIFClose( fp );
+
+ if( nBytes == nBufMax-1 )
+ {
+ CPLDebug( "OGR",
+ "OGRSpatialReference::SetFromUserInput(%s), opened file\n"
+ "but it is to large for our generous buffer. Is it really\n"
+ "just a WKT definition?" );
+ CPLFree( pszBuffer );
+ return OGRERR_FAILURE;
+ }
+
+ pszBuffer[nBytes] = '\0';
+
+ pszBufPtr = pszBuffer;
+ while( pszBufPtr[0] == ' ' || pszBufPtr[0] == '\n' )
+ pszBufPtr++;
+
+ if( pszBufPtr[0] == '<' )
+ err = importFromXML( pszBufPtr );
+ else if( strstr(pszBuffer,"+proj") != NULL
+ || strstr(pszBuffer,"+init") != NULL )
+ err = importFromProj4( pszBufPtr );
+ else
+ {
+ err = importFromWkt( &pszBufPtr );
+ if( err == OGRERR_NONE && bESRI )
+ err = morphFromESRI();
+ }
+
+ CPLFree( pszBuffer );
+
+ return err;
+}
+
+/************************************************************************/
+/* OSRSetFromUserInput() */
+/************************************************************************/
+
+OGRErr CPL_STDCALL OSRSetFromUserInput( OGRSpatialReferenceH hSRS,
+ const char *pszDef )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetFromUserInput( pszDef );
+}
+
+/************************************************************************/
+/* importFromURN() */
+/* */
+/* See OGC recommendation paper 06-023r1 or later for details. */
+/************************************************************************/
+
+/**
+ * Initialize from OGC URN.
+ *
+ * Initializes this spatial reference from a coordinate system defined
+ * by an OGC URN prefixed with "urn:ogc:def:crs:" per recommendation
+ * paper 06-023r1. Currently EPSG and OGC authority values are supported,
+ * including OGC auto codes, but not including CRS1 or CRS88 (NAVD88).
+ *
+ * This method is also support through SetFromUserInput() which can
+ * normally be used for URNs.
+ *
+ * @param pszURN the urn string.
+ *
+ * @return OGRERR_NONE on success or an error code.
+ */
+
+OGRErr OGRSpatialReference::importFromURN( const char *pszURN )
+
+{
+ const char *pszCur = pszURN + 16;
+
+ if( EQUALN(pszURN,"urn:ogc:def:crs:",16) )
+ pszCur = pszURN + 16;
+ else if( EQUALN(pszURN,"urn:x-ogc:def:crs:",18) )
+ pszCur = pszURN + 18;
+ else
+ {
+ CPLError( CE_Failure, CPLE_AppDefined,
+ "URN %s not a supported format.", pszURN );
+ return OGRERR_FAILURE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Find code (ignoring version) out of string like: */
+/* */
+/* authority:version:code */
+/* -------------------------------------------------------------------- */
+ const char *pszAuthority = pszCur;
+
+ // skip authority
+ while( *pszCur != ':' && *pszCur )
+ pszCur++;
+ if( *pszCur == ':' )
+ pszCur++;
+
+ // skip version
+ while( *pszCur != ':' && *pszCur )
+ pszCur++;
+ if( *pszCur == ':' )
+ pszCur++;
+
+ const char *pszCode = pszCur;
+
+/* -------------------------------------------------------------------- */
+/* Is this an EPSG code? */
+/* -------------------------------------------------------------------- */
+ if( EQUALN(pszAuthority,"EPSG:",5) )
+ return importFromEPSG( atoi(pszCode) );
+
+/* -------------------------------------------------------------------- */
+/* Is this an OGC code? */
+/* -------------------------------------------------------------------- */
+ if( !EQUALN(pszAuthority,"OGC:",4) )
+ {
+ CPLError( CE_Failure, CPLE_AppDefined,
+ "URN %s has unrecognised authority.",
+ pszURN );
+ return OGRERR_FAILURE;
+ }
+
+ if( EQUALN(pszCode,"CRS84",5) )
+ return SetWellKnownGeogCS( pszCode );
+ else if( EQUALN(pszCode,"CRS83",5) )
+ return SetWellKnownGeogCS( pszCode );
+ else if( EQUALN(pszCode,"CRS27",5) )
+ return SetWellKnownGeogCS( pszCode );
+
+/* -------------------------------------------------------------------- */
+/* Handle auto codes. We need to convert from format */
+/* AUTO42001:99:8888 to format AUTO:42001,99,8888. */
+/* -------------------------------------------------------------------- */
+ else if( EQUALN(pszCode,"AUTO",4) )
+ {
+ char szWMSAuto[100];
+ int i;
+
+ if( strlen(pszCode) > sizeof(szWMSAuto)-2 )
+ return OGRERR_FAILURE;
+
+ strcpy( szWMSAuto, "AUTO:" );
+ strcpy( szWMSAuto + 5, pszCode + 4 );
+ for( i = 5; szWMSAuto[i] != '\0'; i++ )
+ {
+ if( szWMSAuto[i] == ':' )
+ szWMSAuto[i] = ',';
+ }
+
+ return importFromWMSAUTO( szWMSAuto );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Not a recognise OGC item. */
+/* -------------------------------------------------------------------- */
+ CPLError( CE_Failure, CPLE_AppDefined,
+ "URN %s value not supported.",
+ pszURN );
+
+ return OGRERR_FAILURE;
+}
+
+/************************************************************************/
+/* importFromWMSAUTO() */
+/* */
+/* Note that the WMS 1.3 specification does not include the */
+/* units code, while apparently earlier specs do. We try to */
+/* guess around this. */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::importFromWMSAUTO( const char * pszDefinition )
+
+{
+ char **papszTokens;
+ int nProjId, nUnitsId;
+ double dfRefLong, dfRefLat = 0.0;
+
+/* -------------------------------------------------------------------- */
+/* Tokenize */
+/* -------------------------------------------------------------------- */
+ if( EQUALN(pszDefinition,"AUTO:",5) )
+ pszDefinition += 5;
+
+ papszTokens = CSLTokenizeStringComplex( pszDefinition, ",", FALSE, TRUE );
+
+ if( CSLCount(papszTokens) == 4 )
+ {
+ nProjId = atoi(papszTokens[0]);
+ nUnitsId = atoi(papszTokens[1]);
+ dfRefLong = atof(papszTokens[2]);
+ dfRefLat = atof(papszTokens[3]);
+ }
+ else if( CSLCount(papszTokens) == 3 && atoi(papszTokens[0]) == 42005 )
+ {
+ nProjId = atoi(papszTokens[0]);
+ nUnitsId = atoi(papszTokens[1]);
+ dfRefLong = atof(papszTokens[2]);
+ dfRefLat = 0.0;
+ }
+ else if( CSLCount(papszTokens) == 3 )
+ {
+ nProjId = atoi(papszTokens[0]);
+ nUnitsId = 9001;
+ dfRefLong = atof(papszTokens[1]);
+ dfRefLat = atof(papszTokens[2]);
+
+ }
+ else if( CSLCount(papszTokens) == 2 && atoi(papszTokens[0]) == 42005 )
+ {
+ nProjId = atoi(papszTokens[0]);
+ nUnitsId = 9001;
+ dfRefLong = atof(papszTokens[1]);
+ }
+ else
+ {
+ CSLDestroy( papszTokens );
+ CPLError( CE_Failure, CPLE_AppDefined,
+ "AUTO projection has wrong number of arguments, expected\n"
+ "AUTO:proj_id,units_id,ref_long,ref_lat or"
+ "AUTO:proj_id,ref_long,ref_lat" );
+ return OGRERR_FAILURE;
+ }
+
+ CSLDestroy( papszTokens );
+
+/* -------------------------------------------------------------------- */
+/* Build coordsys. */
+/* -------------------------------------------------------------------- */
+ Clear();
+
+ switch( nProjId )
+ {
+ case 42001: // Auto UTM
+ SetUTM( (int) floor( (dfRefLong + 180.0) / 6.0 ) + 1,
+ dfRefLat >= 0.0 );
+ break;
+
+ case 42002: // Auto TM (strangely very UTM-like).
+ SetTM( 0, dfRefLong, 0.9996,
+ 500000.0, (dfRefLat >= 0.0) ? 0.0 : 10000000.0 );
+ break;
+
+ case 42003: // Auto Orthographic.
+ SetOrthographic( dfRefLat, dfRefLong, 0.0, 0.0 );
+ break;
+
+ case 42004: // Auto Equirectangular
+ SetEquirectangular( dfRefLat, dfRefLong, 0.0, 0.0 );
+ break;
+
+ case 42005:
+ SetMollweide( dfRefLong, 0.0, 0.0 );
+ break;
+
+ default:
+ CPLError( CE_Failure, CPLE_AppDefined,
+ "Unsupported projection id in importFromWMSAUTO(): %d",
+ nProjId );
+ return OGRERR_FAILURE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Set units. */
+/* -------------------------------------------------------------------- */
+
+ switch( nUnitsId )
+ {
+ case 9001:
+ SetLinearUnits( SRS_UL_METER, 1.0 );
+ break;
+
+ case 9002:
+ SetLinearUnits( "Foot", 0.3048 );
+ break;
+
+ case 9003:
+ SetLinearUnits( "US survey foot", 0.304800609601 );
+ break;
+
+ default:
+ CPLError( CE_Failure, CPLE_AppDefined,
+ "Unsupported units code (%d).",
+ nUnitsId );
+ return OGRERR_FAILURE;
+ break;
+ }
+
+ SetAuthority( "PROJCS|UNIT", "EPSG", nUnitsId );
+
+/* -------------------------------------------------------------------- */
+/* Set WGS84. */
+/* -------------------------------------------------------------------- */
+ SetWellKnownGeogCS( "WGS84" );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* GetSemiMajor() */
+/************************************************************************/
+
+/**
+ * Get spheroid semi major axis.
+ *
+ * This method does the same thing as the C function OSRGetSemiMajor().
+ *
+ * @param pnErr if non-NULL set to OGRERR_FAILURE if semi major axis
+ * can be found.
+ *
+ * @return semi-major axis, or SRS_WGS84_SEMIMAJOR if it can't be found.
+ */
+
+double OGRSpatialReference::GetSemiMajor( OGRErr * pnErr ) const
+
+{
+ const OGR_SRSNode *poSpheroid = GetAttrNode( "SPHEROID" );
+
+ if( pnErr != NULL )
+ *pnErr = OGRERR_NONE;
+
+ if( poSpheroid != NULL && poSpheroid->GetChildCount() >= 3 )
+ {
+ return atof( poSpheroid->GetChild(1)->GetValue() );
+ }
+ else
+ {
+ if( pnErr != NULL )
+ *pnErr = OGRERR_FAILURE;
+
+ return SRS_WGS84_SEMIMAJOR;
+ }
+}
+
+/************************************************************************/
+/* OSRGetSemiMajor() */
+/************************************************************************/
+
+double OSRGetSemiMajor( OGRSpatialReferenceH hSRS, OGRErr *pnErr )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetSemiMajor( pnErr );
+}
+
+/************************************************************************/
+/* GetInvFlattening() */
+/************************************************************************/
+
+/**
+ * Get spheroid inverse flattening.
+ *
+ * This method does the same thing as the C function OSRGetInvFlattening().
+ *
+ * @param pnErr if non-NULL set to OGRERR_FAILURE if no inverse flattening
+ * can be found.
+ *
+ * @return inverse flattening, or SRS_WGS84_INVFLATTENING if it can't be found.
+ */
+
+double OGRSpatialReference::GetInvFlattening( OGRErr * pnErr ) const
+
+{
+ const OGR_SRSNode *poSpheroid = GetAttrNode( "SPHEROID" );
+
+ if( pnErr != NULL )
+ *pnErr = OGRERR_NONE;
+
+ if( poSpheroid != NULL && poSpheroid->GetChildCount() >= 3 )
+ {
+ return atof( poSpheroid->GetChild(2)->GetValue() );
+ }
+ else
+ {
+ if( pnErr != NULL )
+ *pnErr = OGRERR_FAILURE;
+
+ return SRS_WGS84_INVFLATTENING;
+ }
+}
+
+/************************************************************************/
+/* OSRGetInvFlattening() */
+/************************************************************************/
+
+double OSRGetInvFlattening( OGRSpatialReferenceH hSRS, OGRErr *pnErr )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetInvFlattening( pnErr );
+}
+
+/************************************************************************/
+/* GetSemiMinor() */
+/************************************************************************/
+
+/**
+ * Get spheroid semi minor axis.
+ *
+ * This method does the same thing as the C function OSRGetSemiMinor().
+ *
+ * @param pnErr if non-NULL set to OGRERR_FAILURE if semi minor axis
+ * can be found.
+ *
+ * @return semi-minor axis, or WGS84 semi minor if it can't be found.
+ */
+
+double OGRSpatialReference::GetSemiMinor( OGRErr * pnErr ) const
+
+{
+ double dfInvFlattening, dfSemiMajor;
+
+ dfSemiMajor = GetSemiMajor( pnErr );
+ dfInvFlattening = GetInvFlattening( pnErr );
+
+ if( ABS(dfInvFlattening) < 0.000000000001 )
+ return dfSemiMajor;
+ else
+ return dfSemiMajor * (1.0 - 1.0/dfInvFlattening);
+}
+
+/************************************************************************/
+/* OSRGetSemiMinor() */
+/************************************************************************/
+
+double OSRGetSemiMinor( OGRSpatialReferenceH hSRS, OGRErr *pnErr )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetSemiMinor( pnErr );
+}
+
+/************************************************************************/
+/* SetLocalCS() */
+/************************************************************************/
+
+/**
+ * Set the user visible LOCAL_CS name.
+ *
+ * This method is the same as the C function OSRSetLocalCS().
+ *
+ * This method is will ensure a LOCAL_CS node is created as the root,
+ * and set the provided name on it. It must be used before SetLinearUnits().
+ *
+ * @param pszName the user visible name to assign. Not used as a key.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetLocalCS( const char * pszName )
+
+{
+ OGR_SRSNode *poCS = GetAttrNode( "LOCAL_CS" );
+
+ if( poCS == NULL && GetRoot() != NULL )
+ {
+ CPLDebug( "OGR",
+ "OGRSpatialReference::SetLocalCS(%s) failed.\n"
+ "It appears an incompatible root node (%s) already exists.\n",
+ GetRoot()->GetValue() );
+ return OGRERR_FAILURE;
+ }
+ else
+ {
+ SetNode( "LOCAL_CS", pszName );
+ return OGRERR_NONE;
+ }
+}
+
+/************************************************************************/
+/* OSRSetLocalCS() */
+/************************************************************************/
+
+OGRErr OSRSetLocalCS( OGRSpatialReferenceH hSRS, const char * pszName )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetLocalCS( pszName );
+}
+
+/************************************************************************/
+/* SetProjCS() */
+/************************************************************************/
+
+/**
+ * Set the user visible PROJCS name.
+ *
+ * This method is the same as the C function OSRSetProjCS().
+ *
+ * This method is will ensure a PROJCS node is created as the root,
+ * and set the provided name on it. If used on a GEOGCS coordinate system,
+ * the GEOGCS node will be demoted to be a child of the new PROJCS root.
+ *
+ * @param pszName the user visible name to assign. Not used as a key.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetProjCS( const char * pszName )
+
+{
+ OGR_SRSNode *poGeogCS = NULL;
+ OGR_SRSNode *poProjCS = GetAttrNode( "PROJCS" );
+
+ if( poRoot != NULL && EQUAL(poRoot->GetValue(),"GEOGCS") )
+ {
+ poGeogCS = poRoot;
+ poRoot = NULL;
+ }
+
+ if( poProjCS == NULL && GetRoot() != NULL )
+ {
+ CPLDebug( "OGR",
+ "OGRSpatialReference::SetProjCS(%s) failed.\n"
+ "It appears an incompatible root node (%s) already exists.\n",
+ GetRoot()->GetValue() );
+ return OGRERR_FAILURE;
+ }
+
+ SetNode( "PROJCS", pszName );
+
+ if( poGeogCS != NULL )
+ poRoot->InsertChild( poGeogCS, 1 );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetProjCS() */
+/************************************************************************/
+
+OGRErr OSRSetProjCS( OGRSpatialReferenceH hSRS, const char * pszName )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetProjCS( pszName );
+}
+
+/************************************************************************/
+/* SetProjection() */
+/************************************************************************/
+
+/**
+ * Set a projection name.
+ *
+ * This method is the same as the C function OSRSetProjection().
+ *
+ * @param pszProjection the projection name, which should be selected from
+ * the macros in ogr_srs_api.h, such as SRS_PT_TRANSVERSE_MERCATOR.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetProjection( const char * pszProjection )
+
+{
+ OGR_SRSNode *poGeogCS = NULL;
+ OGRErr eErr;
+
+ if( poRoot != NULL && EQUAL(poRoot->GetValue(),"GEOGCS") )
+ {
+ poGeogCS = poRoot;
+ poRoot = NULL;
+ }
+
+ if( !GetAttrNode( "PROJCS" ) )
+ {
+ SetNode( "PROJCS", "unnamed" );
+ }
+
+ eErr = SetNode( "PROJCS|PROJECTION", pszProjection );
+ if( eErr != OGRERR_NONE )
+ return eErr;
+
+ if( poGeogCS != NULL )
+ poRoot->InsertChild( poGeogCS, 1 );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetProjection() */
+/************************************************************************/
+
+OGRErr OSRSetProjection( OGRSpatialReferenceH hSRS,
+ const char * pszProjection )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetProjection( pszProjection );
+}
+
+/************************************************************************/
+/* SetProjParm() */
+/************************************************************************/
+
+/**
+ * Set a projection parameter value.
+ *
+ * Adds a new PARAMETER under the PROJCS with the indicated name and value.
+ *
+ * This method is the same as the C function OSRSetProjParm().
+ *
+ * Please check http://www.remotesensing.org/geotiff/proj_list pages for
+ * legal parameter names for specific projections.
+ *
+ *
+ * @param pszParmName the parameter name, which should be selected from
+ * the macros in ogr_srs_api.h, such as SRS_PP_CENTRAL_MERIDIAN.
+ *
+ * @param dfValue value to assign.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetProjParm( const char * pszParmName,
+ double dfValue )
+
+{
+ OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
+ OGR_SRSNode *poParm;
+ char szValue[64];
+
+ if( poPROJCS == NULL )
+ return OGRERR_FAILURE;
+
+ OGRPrintDouble( szValue, dfValue );
+
+/* -------------------------------------------------------------------- */
+/* Try to find existing parameter with this name. */
+/* -------------------------------------------------------------------- */
+ for( int iChild = 0; iChild < poPROJCS->GetChildCount(); iChild++ )
+ {
+ poParm = poPROJCS->GetChild( iChild );
+
+ if( EQUAL(poParm->GetValue(),"PARAMETER")
+ && poParm->GetChildCount() == 2
+ && EQUAL(poParm->GetChild(0)->GetValue(),pszParmName) )
+ {
+ poParm->GetChild(1)->SetValue( szValue );
+ return OGRERR_NONE;
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Otherwise create a new parameter and append. */
+/* -------------------------------------------------------------------- */
+ poParm = new OGR_SRSNode( "PARAMETER" );
+ poParm->AddChild( new OGR_SRSNode( pszParmName ) );
+ poParm->AddChild( new OGR_SRSNode( szValue ) );
+
+ poPROJCS->AddChild( poParm );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetProjParm() */
+/************************************************************************/
+
+OGRErr OSRSetProjParm( OGRSpatialReferenceH hSRS,
+ const char * pszParmName, double dfValue )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetProjParm( pszParmName, dfValue );
+}
+
+/************************************************************************/
+/* GetProjParm() */
+/************************************************************************/
+
+/**
+ * Fetch a projection parameter value.
+ *
+ * NOTE: This code should be modified to translate non degree angles into
+ * degrees based on the GEOGCS unit. This has not yet been done.
+ *
+ * This method is the same as the C function OSRGetProjParm().
+ *
+ * @param pszName the name of the parameter to fetch, from the set of
+ * SRS_PP codes in ogr_srs_api.h.
+ *
+ * @param dfDefaultValue the value to return if this parameter doesn't exist.
+ *
+ * @param pnErr place to put error code on failure. Ignored if NULL.
+ *
+ * @return value of parameter.
+ */
+
+double OGRSpatialReference::GetProjParm( const char * pszName,
+ double dfDefaultValue,
+ OGRErr *pnErr ) const
+
+{
+ const OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
+ const OGR_SRSNode *poParameter = NULL;
+
+ if( pnErr != NULL )
+ *pnErr = OGRERR_NONE;
+
+/* -------------------------------------------------------------------- */
+/* Search for requested parameter. */
+/* -------------------------------------------------------------------- */
+ if( poPROJCS != NULL )
+ {
+ for( int iChild = 0; iChild < poPROJCS->GetChildCount(); iChild++ )
+ {
+ poParameter = poPROJCS->GetChild(iChild);
+
+ if( EQUAL(poParameter->GetValue(),"PARAMETER")
+ && poParameter->GetChildCount() == 2
+ && EQUAL(poPROJCS->GetChild(iChild)->GetChild(0)->GetValue(),
+ pszName) )
+ {
+ return atof(poParameter->GetChild(1)->GetValue());
+ }
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Try similar names, for selected parameters. */
+/* -------------------------------------------------------------------- */
+ double dfValue;
+ OGRErr nSubErr;
+
+ if( EQUAL(pszName,SRS_PP_LATITUDE_OF_ORIGIN) )
+ {
+ dfValue = GetProjParm(SRS_PP_LATITUDE_OF_CENTER,0.0,&nSubErr);
+
+ if( nSubErr == OGRERR_NONE )
+ return dfValue;
+ }
+ else if( EQUAL(pszName,SRS_PP_CENTRAL_MERIDIAN) )
+ {
+ dfValue = GetProjParm(SRS_PP_LONGITUDE_OF_CENTER,0.0,&nSubErr);
+ if( nSubErr != OGRERR_NONE )
+ dfValue = GetProjParm(SRS_PP_LONGITUDE_OF_ORIGIN,0.0,&nSubErr);
+
+ if( nSubErr == OGRERR_NONE )
+ return dfValue;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Return default value on failure. */
+/* -------------------------------------------------------------------- */
+ if( pnErr != NULL )
+ *pnErr = OGRERR_FAILURE;
+
+ return dfDefaultValue;
+}
+
+/************************************************************************/
+/* OSRGetProjParm() */
+/************************************************************************/
+
+double OSRGetProjParm( OGRSpatialReferenceH hSRS, const char *pszName,
+ double dfDefaultValue, OGRErr *pnErr )
+
+{
+ return ((OGRSpatialReference *) hSRS)->
+ GetProjParm(pszName, dfDefaultValue, pnErr);
+}
+
+/************************************************************************/
+/* GetNormProjParm() */
+/************************************************************************/
+
+/**
+ * Fetch a normalized projection parameter value.
+ *
+ * This method is the same as GetProjParm() except that the value of
+ * the parameter is "normalized" into degrees or meters depending on
+ * whether it is linear or angular.
+ *
+ * This method is the same as the C function OSRGetNormProjParm().
+ *
+ * @param pszName the name of the parameter to fetch, from the set of
+ * SRS_PP codes in ogr_srs_api.h.
+ *
+ * @param dfDefaultValue the value to return if this parameter doesn't exist.
+ *
+ * @param pnErr place to put error code on failure. Ignored if NULL.
+ *
+ * @return value of parameter.
+ */
+
+double OGRSpatialReference::GetNormProjParm( const char * pszName,
+ double dfDefaultValue,
+ OGRErr *pnErr ) const
+
+{
+ double dfRawResult;
+ OGRErr nError;
+
+ if( pnErr == NULL )
+ pnErr = &nError;
+
+ GetNormInfo();
+
+ dfRawResult = GetProjParm( pszName, dfDefaultValue, pnErr );
+
+ // If we got the default just return it unadjusted.
+ if( *pnErr != OGRERR_NONE )
+ return dfRawResult;
+
+ if( dfToDegrees != 1.0 && IsAngularParameter(pszName) )
+ dfRawResult *= dfToDegrees;
+
+ if( dfToMeter != 1.0 && IsLinearParameter( pszName ) )
+ return dfRawResult * dfToMeter;
+#ifdef WKT_LONGITUDE_RELATIVE_TO_PM
+ else if( dfFromGreenwich != 0.0 && IsLongitudeParameter( pszName ) )
+ return dfRawResult + dfFromGreenwich;
+#endif
+ else
+ return dfRawResult;
+}
+
+/************************************************************************/
+/* OSRGetNormProjParm() */
+/************************************************************************/
+
+double OSRGetNormProjParm( OGRSpatialReferenceH hSRS, const char *pszName,
+ double dfDefaultValue, OGRErr *pnErr )
+
+{
+ return ((OGRSpatialReference *) hSRS)->
+ GetNormProjParm(pszName, dfDefaultValue, pnErr);
+}
+
+/************************************************************************/
+/* SetNormProjParm() */
+/************************************************************************/
+
+/**
+ * Set a projection parameter with a normalized value.
+ *
+ * This method is the same as SetProjParm() except that the value of
+ * the parameter passed in is assumed to be in "normalized" form (decimal
+ * degrees for angular values, meters for linear values. The values are
+ * converted in a form suitable for the GEOGCS and linear units in effect.
+ *
+ * This method is the same as the C function OSRSetNormProjParm().
+ *
+ * @param pszName the parameter name, which should be selected from
+ * the macros in ogr_srs_api.h, such as SRS_PP_CENTRAL_MERIDIAN.
+ *
+ * @param dfValue value to assign.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetNormProjParm( const char * pszName,
+ double dfValue )
+
+{
+ GetNormInfo();
+
+ if( (dfToDegrees != 1.0 || dfFromGreenwich != 0.0)
+ && IsAngularParameter(pszName) )
+ {
+#ifdef WKT_LONGITUDE_RELATIVE_TO_PM
+ if( dfFromGreenwich != 0.0 && IsLongitudeParameter( pszName ) )
+ dfValue -= dfFromGreenwich;
+#endif
+
+ dfValue /= dfToDegrees;
+ }
+ else if( dfToMeter != 1.0 && IsLinearParameter( pszName ) )
+ dfValue /= dfToMeter;
+
+ return SetProjParm( pszName, dfValue );
+}
+
+/************************************************************************/
+/* OSRSetNormProjParm() */
+/************************************************************************/
+
+OGRErr OSRSetNormProjParm( OGRSpatialReferenceH hSRS,
+ const char * pszParmName, double dfValue )
+
+{
+ return ((OGRSpatialReference *) hSRS)->
+ SetNormProjParm( pszParmName, dfValue );
+}
+
+/************************************************************************/
+/* SetTM() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetTM( double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_TRANSVERSE_MERCATOR );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetTM() */
+/************************************************************************/
+
+OGRErr OSRSetTM( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetTM(
+ dfCenterLat, dfCenterLong,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetTMVariant() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetTMVariant(
+ const char *pszVariantName,
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( pszVariantName );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetTMVariant() */
+/************************************************************************/
+
+OGRErr OSRSetTMVariant( OGRSpatialReferenceH hSRS,
+ const char *pszVariantName,
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetTMVariant(
+ pszVariantName,
+ dfCenterLat, dfCenterLong,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetTMSO() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetTMSO( double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* SetTPED() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetTPED( double dfLat1, double dfLong1,
+ double dfLat2, double dfLong2,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_TWO_POINT_EQUIDISTANT );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_1ST_POINT, dfLat1 );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_1ST_POINT, dfLong1 );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_2ND_POINT, dfLat2 );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_2ND_POINT, dfLong2 );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetTMSO() */
+/************************************************************************/
+
+OGRErr OSRSetTMSO( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetTMSO(
+ dfCenterLat, dfCenterLong,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetTMG() */
+/************************************************************************/
+
+OGRErr
+OGRSpatialReference::SetTMG( double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_TUNISIA_MINING_GRID );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetTMG() */
+/************************************************************************/
+
+OGRErr OSRSetTMG( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetTMG(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetACEA() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetACEA( double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_ALBERS_CONIC_EQUAL_AREA );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, dfStdP2 );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetACEA() */
+/************************************************************************/
+
+OGRErr OSRSetACEA( OGRSpatialReferenceH hSRS,
+ double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetACEA(
+ dfStdP1, dfStdP2,
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetAE() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetAE( double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_AZIMUTHAL_EQUIDISTANT );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetAE() */
+/************************************************************************/
+
+OGRErr OSRSetAE( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetAE(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetBonne() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetBonne(
+ double dfStdP1, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_BONNE );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetBonne() */
+/************************************************************************/
+
+OGRErr OSRSetBonne( OGRSpatialReferenceH hSRS,
+ double dfStandardParallel, double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetAE(
+ dfStandardParallel, dfCentralMeridian,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetCEA() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetCEA( double dfStdP1, double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_CYLINDRICAL_EQUAL_AREA );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetCEA() */
+/************************************************************************/
+
+OGRErr OSRSetCEA( OGRSpatialReferenceH hSRS,
+ double dfStdP1, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetCEA(
+ dfStdP1, dfCentralMeridian,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetCS() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetCS( double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_CASSINI_SOLDNER );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetCS() */
+/************************************************************************/
+
+OGRErr OSRSetCS( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetCS(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetEC() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetEC( double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_EQUIDISTANT_CONIC );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, dfStdP2 );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetEC() */
+/************************************************************************/
+
+OGRErr OSRSetEC( OGRSpatialReferenceH hSRS,
+ double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetEC(
+ dfStdP1, dfStdP2,
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetEckertIV() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetEckertIV( double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_ECKERT_IV );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetEckertIV() */
+/************************************************************************/
+
+OGRErr OSRSetEckertIV( OGRSpatialReferenceH hSRS,
+ double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetEckertIV(
+ dfCentralMeridian,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetEckertVI() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetEckertVI( double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_ECKERT_VI );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetEckertVI() */
+/************************************************************************/
+
+OGRErr OSRSetEckertVI( OGRSpatialReferenceH hSRS,
+ double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetEckertVI(
+ dfCentralMeridian,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetEquirectangular() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetEquirectangular(
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_EQUIRECTANGULAR );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetEquirectangular() */
+/************************************************************************/
+
+OGRErr OSRSetEquirectangular( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetEquirectangular(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetGS() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetGS( double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_GALL_STEREOGRAPHIC );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetGS() */
+/************************************************************************/
+
+OGRErr OSRSetGS( OGRSpatialReferenceH hSRS,
+ double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetGS(
+ dfCentralMeridian,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetGH() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetGH( double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_GOODE_HOMOLOSINE );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetGH() */
+/************************************************************************/
+
+OGRErr OSRSetGH( OGRSpatialReferenceH hSRS,
+ double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetGH(
+ dfCentralMeridian,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetGEOS() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetGEOS( double dfCentralMeridian,
+ double dfSatelliteHeight,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_GEOSTATIONARY_SATELLITE );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
+ SetNormProjParm( SRS_PP_SATELLITE_HEIGHT, dfSatelliteHeight );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetGEOS() */
+/************************************************************************/
+
+OGRErr OSRSetGEOS( OGRSpatialReferenceH hSRS,
+ double dfCentralMeridian,
+ double dfSatelliteHeight,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetGEOS(
+ dfCentralMeridian, dfSatelliteHeight,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetGnomonic() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetGnomonic(
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_GNOMONIC );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetGnomonic() */
+/************************************************************************/
+
+OGRErr OSRSetGnomonic( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetGnomonic(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetHOM() */
+/************************************************************************/
+
+/**
+ * Set a Hotine Oblique Mercator projection using azimuth angle.
+ *
+ * This method does the same thing as the C function OSRSetHOM().
+ *
+ * @param dfCenterLat Latitude of the projection origin.
+ * @param dfCenterLong Longitude of the projection origin.
+ * @param dfAzimuth Azimuth, measured clockwise from North, of the projection
+ * centerline.
+ * @param dfRectToSkew ?.
+ * @param dfScale Scale factor applies to the projection origin.
+ * @param dfFalseEasting False easting.
+ * @param dfFalseNorthing False northing.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetHOM( double dfCenterLat, double dfCenterLong,
+ double dfAzimuth, double dfRectToSkew,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_HOTINE_OBLIQUE_MERCATOR );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
+ SetNormProjParm( SRS_PP_AZIMUTH, dfAzimuth );
+ SetNormProjParm( SRS_PP_RECTIFIED_GRID_ANGLE, dfRectToSkew );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetHOM() */
+/************************************************************************/
+
+OGRErr OSRSetHOM( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfAzimuth, double dfRectToSkew,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetHOM(
+ dfCenterLat, dfCenterLong,
+ dfAzimuth, dfRectToSkew,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetHOM2PNO() */
+/************************************************************************/
+
+/**
+ * Set a Hotine Oblique Mercator projection using two points on projection
+ * centerline.
+ *
+ * This method does the same thing as the C function OSRSetHOM2PNO().
+ *
+ * @param dfCenterLat Latitude of the projection origin.
+ * @param dfLat1 Latitude of the first point on center line.
+ * @param dfLong1 Longitude of the first point on center line.
+ * @param dfLat2 Latitude of the second point on center line.
+ * @param dfLong2 Longitude of the second point on center line.
+ * @param dfScale Scale factor applies to the projection origin.
+ * @param dfFalseEasting False easting.
+ * @param dfFalseNorthing False northing.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetHOM2PNO( double dfCenterLat,
+ double dfLat1, double dfLong1,
+ double dfLat2, double dfLong2,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_POINT_1, dfLat1 );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_POINT_1, dfLong1 );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_POINT_2, dfLat2 );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_POINT_2, dfLong2 );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetHOM2PNO() */
+/************************************************************************/
+
+OGRErr OSRSetHOM2PNO( OGRSpatialReferenceH hSRS,
+ double dfCenterLat,
+ double dfLat1, double dfLong1,
+ double dfLat2, double dfLong2,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetHOM2PNO(
+ dfCenterLat,
+ dfLat1, dfLong1,
+ dfLat2, dfLong2,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetKrovak() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetKrovak( double dfCenterLat, double dfCenterLong,
+ double dfAzimuth,
+ double dfPseudoStdParallel1,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_KROVAK );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
+ SetNormProjParm( SRS_PP_AZIMUTH, dfAzimuth );
+ SetNormProjParm( SRS_PP_PSEUDO_STD_PARALLEL_1, dfPseudoStdParallel1 );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetKrovak() */
+/************************************************************************/
+
+OGRErr OSRSetKrovak( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfAzimuth, double dfPseudoStdParallel1,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetKrovak(
+ dfCenterLat, dfCenterLong,
+ dfAzimuth, dfPseudoStdParallel1,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetLAEA() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetLAEA( double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetLAEA() */
+/************************************************************************/
+
+OGRErr OSRSetLAEA( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetLAEA(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetLCC() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetLCC( double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, dfStdP2 );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetLCC() */
+/************************************************************************/
+
+OGRErr OSRSetLCC( OGRSpatialReferenceH hSRS,
+ double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetLCC(
+ dfStdP1, dfStdP2,
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetLCC1SP() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetLCC1SP( double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetLCC1SP() */
+/************************************************************************/
+
+OGRErr OSRSetLCC1SP( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetLCC1SP(
+ dfCenterLat, dfCenterLong,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetLCCB() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetLCCB( double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, dfStdP2 );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetLCCB() */
+/************************************************************************/
+
+OGRErr OSRSetLCCB( OGRSpatialReferenceH hSRS,
+ double dfStdP1, double dfStdP2,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetLCCB(
+ dfStdP1, dfStdP2,
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetMC() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetMC( double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_MILLER_CYLINDRICAL );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfCenterLat );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetMC() */
+/************************************************************************/
+
+OGRErr OSRSetMC( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetMC(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetMercator() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetMercator( double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_MERCATOR_1SP );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetMercator() */
+/************************************************************************/
+
+OGRErr OSRSetMercator( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetMercator(
+ dfCenterLat, dfCenterLong,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetMercator2SP() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetMercator2SP(
+ double dfStdP1,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_MERCATOR_2SP );
+ SetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, dfStdP1 );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetMercator2SP() */
+/************************************************************************/
+
+OGRErr OSRSetMercator2SP( OGRSpatialReferenceH hSRS,
+ double dfStdP1,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetMercator2SP(
+ dfStdP1,
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetMollweide() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetMollweide( double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_MOLLWEIDE );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetMollweide() */
+/************************************************************************/
+
+OGRErr OSRSetMollweide( OGRSpatialReferenceH hSRS,
+ double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetMollweide(
+ dfCentralMeridian,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetNZMG() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetNZMG( double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_NEW_ZEALAND_MAP_GRID );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetNZMG() */
+/************************************************************************/
+
+OGRErr OSRSetNZMG( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetNZMG(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetOS() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetOS( double dfOriginLat, double dfCMeridian,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_OBLIQUE_STEREOGRAPHIC );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfOriginLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCMeridian );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetOS() */
+/************************************************************************/
+
+OGRErr OSRSetOS( OGRSpatialReferenceH hSRS,
+ double dfOriginLat, double dfCMeridian,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetOS(
+ dfOriginLat, dfCMeridian,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetOrthographic() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetOrthographic(
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_ORTHOGRAPHIC );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetOrthographic() */
+/************************************************************************/
+
+OGRErr OSRSetOrthographic( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetOrthographic(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetPolyconic() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetPolyconic(
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ // note: it seems that by some definitions this should include a
+ // scale_factor parameter.
+
+ SetProjection( SRS_PT_POLYCONIC );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetPolyconic() */
+/************************************************************************/
+
+OGRErr OSRSetPolyconic( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetPolyconic(
+ dfCenterLat, dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetPS() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetPS(
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_POLAR_STEREOGRAPHIC );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetPS() */
+/************************************************************************/
+
+OGRErr OSRSetPS( OGRSpatialReferenceH hSRS,
+ double dfCenterLat, double dfCenterLong,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetPS(
+ dfCenterLat, dfCenterLong,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetRobinson() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetRobinson( double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_ROBINSON );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetRobinson() */
+/************************************************************************/
+
+OGRErr OSRSetRobinson( OGRSpatialReferenceH hSRS,
+ double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetRobinson(
+ dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetSinusoidal() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetSinusoidal( double dfCenterLong,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_SINUSOIDAL );
+ SetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, dfCenterLong );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetSinusoidal() */
+/************************************************************************/
+
+OGRErr OSRSetSinusoidal( OGRSpatialReferenceH hSRS,
+ double dfCenterLong,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetSinusoidal(
+ dfCenterLong,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetStereographic() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetStereographic(
+ double dfOriginLat, double dfCMeridian,
+ double dfScale,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_STEREOGRAPHIC );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfOriginLat );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCMeridian );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetStereographic() */
+/************************************************************************/
+
+OGRErr OSRSetStereographic( OGRSpatialReferenceH hSRS,
+ double dfOriginLat, double dfCMeridian,
+ double dfScale,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetStereographic(
+ dfOriginLat, dfCMeridian,
+ dfScale,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetSOC() */
+/* */
+/* NOTE: This definition isn't really used in practice any more */
+/* and should be considered deprecated. It seems that swiss */
+/* oblique mercator is now define as Hotine_Oblique_Mercator */
+/* with an azimuth of 90 and a rectified_grid_angle of 90. See */
+/* EPSG:2056 and Bug 423. */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetSOC( double dfLatitudeOfOrigin,
+ double dfCentralMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_SWISS_OBLIQUE_CYLINDRICAL );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, dfLatitudeOfOrigin );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCentralMeridian );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetSOC() */
+/************************************************************************/
+
+OGRErr OSRSetSOC( OGRSpatialReferenceH hSRS,
+ double dfLatitudeOfOrigin, double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetSOC(
+ dfLatitudeOfOrigin, dfCentralMeridian,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetVDG() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetVDG( double dfCMeridian,
+ double dfFalseEasting,
+ double dfFalseNorthing )
+
+{
+ SetProjection( SRS_PT_VANDERGRINTEN );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCMeridian );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetVDG() */
+/************************************************************************/
+
+OGRErr OSRSetVDG( OGRSpatialReferenceH hSRS,
+ double dfCentralMeridian,
+ double dfFalseEasting, double dfFalseNorthing )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetVDG(
+ dfCentralMeridian,
+ dfFalseEasting, dfFalseNorthing );
+}
+
+/************************************************************************/
+/* SetUTM() */
+/************************************************************************/
+
+/**
+ * Set UTM projection definition.
+ *
+ * This will generate a projection definition with the full set of
+ * transverse mercator projection parameters for the given UTM zone.
+ * If no PROJCS[] description is set yet, one will be set to look
+ * like "UTM Zone %d, {Northern, Southern} Hemisphere".
+ *
+ * This method is the same as the C function OSRSetUTM().
+ *
+ * @param nZone UTM zone.
+ *
+ * @param bNorth TRUE for northern hemisphere, or FALSE for southern
+ * hemisphere.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetUTM( int nZone, int bNorth )
+
+{
+ SetProjection( SRS_PT_TRANSVERSE_MERCATOR );
+ SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0 );
+ SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, nZone * 6 - 183 );
+ SetNormProjParm( SRS_PP_SCALE_FACTOR, 0.9996 );
+ SetNormProjParm( SRS_PP_FALSE_EASTING, 500000.0 );
+
+ if( bNorth )
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, 0 );
+ else
+ SetNormProjParm( SRS_PP_FALSE_NORTHING, 10000000 );
+
+ if( EQUAL(GetAttrValue("PROJCS"),"unnamed") )
+ {
+ char szUTMName[128];
+
+ if( bNorth )
+ sprintf( szUTMName, "UTM Zone %d, Northern Hemisphere", nZone );
+ else
+ sprintf( szUTMName, "UTM Zone %d, Southern Hemisphere", nZone );
+
+ SetNode( "PROJCS", szUTMName );
+ }
+
+ SetLinearUnits( SRS_UL_METER, 1.0 );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetUTM() */
+/************************************************************************/
+
+OGRErr OSRSetUTM( OGRSpatialReferenceH hSRS, int nZone, int bNorth )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetUTM( nZone, bNorth );
+}
+
+/************************************************************************/
+/* GetUTMZone() */
+/* */
+/* Returns zero if it isn't UTM. */
+/************************************************************************/
+
+/**
+ * Get utm zone information.
+ *
+ * This is the same as the C function OSRGetUTMZone().
+ *
+ * @param pbNorth pointer to in to set to TRUE if northern hemisphere, or
+ * FALSE if southern.
+ *
+ * @return UTM zone number or zero if this isn't a UTM definition.
+ */
+
+int OGRSpatialReference::GetUTMZone( int * pbNorth ) const
+
+{
+ const char *pszProjection = GetAttrValue( "PROJECTION" );
+
+ if( pszProjection == NULL )
+ return 0;
+
+ if( !EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR) &&
+ !EQUAL(pszProjection,SRS_PT_TM) )
+ return 0;
+
+ if( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) != 0.0 )
+ return 0;
+
+ if( GetProjParm( SRS_PP_SCALE_FACTOR, 1.0 ) != 0.9996 )
+ return 0;
+
+ if( fabs(GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 )-500000.0) > 0.001 )
+ return 0;
+
+ double dfFalseNorthing = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0);
+
+ if( dfFalseNorthing != 0.0
+ && fabs(dfFalseNorthing-10000000.0) > 0.001 )
+ return 0;
+
+ if( pbNorth != NULL )
+ *pbNorth = (dfFalseNorthing == 0);
+
+ double dfCentralMeridian = GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN,
+ 0.0);
+ double dfZone = (dfCentralMeridian+183) / 6.0 + 0.000000001;
+
+ if( ABS(dfZone - (int) dfZone) > 0.00001
+ || dfCentralMeridian < -177.00001
+ || dfCentralMeridian > 177.000001 )
+ return 0;
+ else
+ return (int) dfZone;
+}
+
+/************************************************************************/
+/* OSRGetUTMZone() */
+/************************************************************************/
+
+int OSRGetUTMZone( OGRSpatialReferenceH hSRS, int *pbNorth )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetUTMZone( pbNorth );
+}
+
+/************************************************************************/
+/* SetAuthority() */
+/************************************************************************/
+
+/**
+ * Set the authority for a node.
+ *
+ * This method is the same as the C function OSRSetAuthority().
+ *
+ * @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 "EPSG".
+ *
+ * @param nCode code for value with this authority.
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetAuthority( const char *pszTargetKey,
+ const char * pszAuthority,
+ int nCode )
+
+{
+/* -------------------------------------------------------------------- */
+/* Find the node below which the authority should be put. */
+/* -------------------------------------------------------------------- */
+ OGR_SRSNode *poNode = 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 node. */
+/* -------------------------------------------------------------------- */
+ char szCode[32];
+ OGR_SRSNode *poAuthNode;
+
+ sprintf( szCode, "%d", nCode );
+
+ poAuthNode = new OGR_SRSNode( "AUTHORITY" );
+ poAuthNode->AddChild( new OGR_SRSNode( pszAuthority ) );
+ poAuthNode->AddChild( new OGR_SRSNode( szCode ) );
+
+ poNode->AddChild( poAuthNode );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetAuthority() */
+/************************************************************************/
+
+OGRErr OSRSetAuthority( OGRSpatialReferenceH hSRS,
+ const char *pszTargetKey,
+ const char * pszAuthority,
+ int nCode )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetAuthority( pszTargetKey,
+ pszAuthority,
+ nCode );
+}
+
+/************************************************************************/
+/* GetAuthorityCode() */
+/************************************************************************/
+
+/**
+ * Get the authority code for a node.
+ *
+ * This method is used to query an AUTHORITY[] node from within the
+ * WKT tree, and fetch the code value.
+ *
+ * While in theory values may be non-numeric, for the EPSG authority all
+ * code values should be integral.
+ *
+ * This method is the same as the C function OSRGetAuthorityCode().
+ *
+ * @param pszTargetKey the partial or complete path to the node to
+ * get an authority from. ie. "PROJCS", "GEOGCS", "GEOGCS|UNIT" or NULL to
+ * search for an authority node on the root element.
+ *
+ * @return value code from authority node, or NULL on failure. The value
+ * returned is internal and should not be freed or modified.
+ */
+
+const char *
+OGRSpatialReference::GetAuthorityCode( const char *pszTargetKey ) const
+
+{
+/* -------------------------------------------------------------------- */
+/* Find the node below which the authority should be put. */
+/* -------------------------------------------------------------------- */
+ const OGR_SRSNode *poNode;
+
+ if( pszTargetKey == NULL )
+ poNode = poRoot;
+ else
+ poNode= ((OGRSpatialReference *) this)->GetAttrNode( pszTargetKey );
+
+ if( poNode == NULL )
+ return NULL;
+
+/* -------------------------------------------------------------------- */
+/* Fetch AUTHORITY child if there is one. */
+/* -------------------------------------------------------------------- */
+ if( poNode->FindChild("AUTHORITY") == -1 )
+ return NULL;
+
+ poNode = poNode->GetChild(poNode->FindChild("AUTHORITY"));
+
+/* -------------------------------------------------------------------- */
+/* Create a new authority node. */
+/* -------------------------------------------------------------------- */
+ if( poNode->GetChildCount() < 2 )
+ return NULL;
+
+ return poNode->GetChild(1)->GetValue();
+}
+
+/************************************************************************/
+/* OSRGetAuthorityCode() */
+/************************************************************************/
+
+const char *OSRGetAuthorityCode( OGRSpatialReferenceH hSRS,
+ const char *pszTargetKey )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetAuthorityCode( pszTargetKey );
+}
+
+/************************************************************************/
+/* GetAuthorityName() */
+/************************************************************************/
+
+/**
+ * Get the authority name for a node.
+ *
+ * This method is used to query an AUTHORITY[] node from within the
+ * WKT tree, and fetch the authority name value.
+ *
+ * The most common authority is "EPSG".
+ *
+ * This method is the same as the C function OSRGetAuthorityName().
+ *
+ * @param pszTargetKey the partial or complete path to the node to
+ * get an authority from. ie. "PROJCS", "GEOGCS", "GEOGCS|UNIT" or NULL to
+ * search for an authority node on the root element.
+ *
+ * @return value code from authority node, or NULL on failure. The value
+ * returned is internal and should not be freed or modified.
+ */
+
+const char *
+OGRSpatialReference::GetAuthorityName( const char *pszTargetKey ) const
+
+{
+/* -------------------------------------------------------------------- */
+/* Find the node below which the authority should be put. */
+/* -------------------------------------------------------------------- */
+ const OGR_SRSNode *poNode;
+
+ if( pszTargetKey == NULL )
+ poNode = poRoot;
+ else
+ poNode= ((OGRSpatialReference *) this)->GetAttrNode( pszTargetKey );
+
+ if( poNode == NULL )
+ return NULL;
+
+/* -------------------------------------------------------------------- */
+/* Fetch AUTHORITY child if there is one. */
+/* -------------------------------------------------------------------- */
+ if( poNode->FindChild("AUTHORITY") == -1 )
+ return NULL;
+
+ poNode = poNode->GetChild(poNode->FindChild("AUTHORITY"));
+
+/* -------------------------------------------------------------------- */
+/* Create a new authority node. */
+/* -------------------------------------------------------------------- */
+ if( poNode->GetChildCount() < 2 )
+ return NULL;
+
+ return poNode->GetChild(0)->GetValue();
+}
+
+/************************************************************************/
+/* OSRGetAuthorityName() */
+/************************************************************************/
+
+const char *OSRGetAuthorityName( OGRSpatialReferenceH hSRS,
+ const char *pszTargetKey )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetAuthorityName( pszTargetKey );
+}
+
+/************************************************************************/
+/* StripCTParms() */
+/************************************************************************/
+
+/**
+ * Strip OGC CT Parameters.
+ *
+ * This method will remove all components of the coordinate system
+ * that are specific to the OGC CT Specification. That is it will attempt
+ * to strip it down to being compatible with the Simple Features 1.0
+ * specification.
+ *
+ * This method is the same as the C function OSRStripCTParms().
+ *
+ * @param poCurrent node to operate on. NULL to operate on whole tree.
+ *
+ * @return OGRERR_NONE on success or an error code.
+ */
+
+OGRErr OGRSpatialReference::StripCTParms( OGR_SRSNode * poCurrent )
+
+{
+ if( poCurrent == NULL )
+ poCurrent = GetRoot();
+
+ if( poCurrent == NULL )
+ return OGRERR_NONE;
+
+ if( poCurrent == GetRoot() && EQUAL(poCurrent->GetValue(),"LOCAL_CS") )
+ {
+ delete poCurrent;
+ poRoot = NULL;
+
+ return OGRERR_NONE;
+ }
+
+ if( poCurrent == NULL )
+ return OGRERR_NONE;
+
+ poCurrent->StripNodes( "AUTHORITY" );
+ poCurrent->StripNodes( "TOWGS84" );
+ poCurrent->StripNodes( "AXIS" );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRStripCTParms() */
+/************************************************************************/
+
+OGRErr OSRStripCTParms( OGRSpatialReferenceH hSRS )
+
+{
+ return ((OGRSpatialReference *) hSRS)->StripCTParms( NULL );
+}
+
+/************************************************************************/
+/* IsProjected() */
+/************************************************************************/
+
+/**
+ * Check if projected coordinate system.
+ *
+ * This method is the same as the C function OSRIsProjected().
+ *
+ * @return TRUE if this contains a PROJCS node indicating a it is a
+ * projected coordinate system.
+ */
+
+int OGRSpatialReference::IsProjected() const
+
+{
+ if( poRoot == NULL )
+ return FALSE;
+
+ // If we eventually support composite coordinate systems this will
+ // need to improve.
+
+ return EQUAL(poRoot->GetValue(),"PROJCS");
+}
+
+/************************************************************************/
+/* OSRIsProjected() */
+/************************************************************************/
+
+int OSRIsProjected( OGRSpatialReferenceH hSRS )
+
+{
+ return ((OGRSpatialReference *) hSRS)->IsProjected();
+}
+
+/************************************************************************/
+/* IsGeographic() */
+/************************************************************************/
+
+/**
+ * Check if geographic coordinate system.
+ *
+ * This method is the same as the C function OSRIsGeographic().
+ *
+ * @return TRUE if this spatial reference is geographic ... that is the
+ * root is a GEOGCS node.
+ */
+
+int OGRSpatialReference::IsGeographic() const
+
+{
+ if( GetRoot() == NULL )
+ return FALSE;
+
+ return EQUAL(GetRoot()->GetValue(),"GEOGCS");
+}
+
+/************************************************************************/
+/* OSRIsGeographic() */
+/************************************************************************/
+
+int OSRIsGeographic( OGRSpatialReferenceH hSRS )
+
+{
+ return ((OGRSpatialReference *) hSRS)->IsGeographic();
+}
+
+/************************************************************************/
+/* IsLocal() */
+/************************************************************************/
+
+/**
+ * Check if local coordinate system.
+ *
+ * This method is the same as the C function OSRIsLocal().
+ *
+ * @return TRUE if this spatial reference is local ... that is the
+ * root is a LOCAL_CS node.
+ */
+
+int OGRSpatialReference::IsLocal() const
+
+{
+ if( GetRoot() == NULL )
+ return FALSE;
+
+ return EQUAL(GetRoot()->GetValue(),"LOCAL_CS");
+}
+
+/************************************************************************/
+/* OSRIsLocal() */
+/************************************************************************/
+
+int OSRIsLocal( OGRSpatialReferenceH hSRS )
+
+{
+ return ((OGRSpatialReference *) hSRS)->IsLocal();
+}
+
+/************************************************************************/
+/* CloneGeogCS() */
+/************************************************************************/
+
+OGRSpatialReference *OGRSpatialReference::CloneGeogCS() const
+
+{
+ const OGR_SRSNode *poGeogCS;
+ OGRSpatialReference * poNewSRS;
+
+ poGeogCS = GetAttrNode( "GEOGCS" );
+ if( poGeogCS == NULL )
+ return NULL;
+
+ poNewSRS = new OGRSpatialReference();
+ poNewSRS->SetRoot( poGeogCS->Clone() );
+
+ return poNewSRS;
+}
+
+/************************************************************************/
+/* OSRCloneGeogCS() */
+/************************************************************************/
+
+OGRSpatialReferenceH CPL_STDCALL OSRCloneGeogCS( OGRSpatialReferenceH hSource )
+
+{
+ return (OGRSpatialReferenceH)
+ ((OGRSpatialReference *) hSource)->CloneGeogCS();
+}
+
+/************************************************************************/
+/* IsSameGeogCS() */
+/************************************************************************/
+
+/**
+ * Do the GeogCS'es match?
+ *
+ * This method is the same as the C function OSRIsSameGeogCS().
+ *
+ * @param poOther the SRS being compared against.
+ *
+ * @return TRUE if they are the same or FALSE otherwise.
+ */
+
+int OGRSpatialReference::IsSameGeogCS( const OGRSpatialReference *poOther ) const
+
+{
+ const char *pszThisValue, *pszOtherValue;
+
+/* -------------------------------------------------------------------- */
+/* Does the datum name match? Note that we assume */
+/* compatibility if either is missing a datum. */
+/* -------------------------------------------------------------------- */
+ pszThisValue = this->GetAttrValue( "DATUM" );
+ pszOtherValue = poOther->GetAttrValue( "DATUM" );
+
+ if( pszThisValue != NULL && pszOtherValue != NULL
+ && !EQUAL(pszThisValue,pszOtherValue) )
+ return FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Do the prime meridians match? If missing assume a value of zero.*/
+/* -------------------------------------------------------------------- */
+ pszThisValue = this->GetAttrValue( "PRIMEM", 1 );
+ if( pszThisValue == NULL )
+ pszThisValue = "0.0";
+
+ pszOtherValue = poOther->GetAttrValue( "PRIMEM", 1 );
+ if( pszOtherValue == NULL )
+ pszOtherValue = "0.0";
+
+ if( atof(pszOtherValue) != atof(pszThisValue) )
+ return FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Do the units match? */
+/* -------------------------------------------------------------------- */
+ pszThisValue = this->GetAttrValue( "GEOGCS|UNITS", 1 );
+ if( pszThisValue == NULL )
+ pszThisValue = SRS_UA_DEGREE_CONV;
+
+ pszOtherValue = poOther->GetAttrValue( "GEOGCS|UNITS", 1 );
+ if( pszOtherValue == NULL )
+ pszOtherValue = SRS_UA_DEGREE_CONV;
+
+ if( ABS(atof(pszOtherValue) - atof(pszThisValue)) > 0.00000001 )
+ return FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Does the spheroid match. Check semi major, and inverse */
+/* flattening. */
+/* -------------------------------------------------------------------- */
+ pszThisValue = this->GetAttrValue( "SPHEROID", 1 );
+ pszOtherValue = poOther->GetAttrValue( "SPHEROID", 1 );
+ if( pszThisValue != NULL && pszOtherValue != NULL
+ && ABS(atof(pszThisValue) - atof(pszOtherValue)) > 0.01 )
+ return FALSE;
+
+ pszThisValue = this->GetAttrValue( "SPHEROID", 2 );
+ pszOtherValue = poOther->GetAttrValue( "SPHEROID", 2 );
+ if( pszThisValue != NULL && pszOtherValue != NULL
+ && ABS(atof(pszThisValue) - atof(pszOtherValue)) > 0.0001 )
+ return FALSE;
+
+ return TRUE;
+}
+
+/************************************************************************/
+/* OSRIsSameGeogCS() */
+/************************************************************************/
+
+int OSRIsSameGeogCS( OGRSpatialReferenceH hSRS1, OGRSpatialReferenceH hSRS2 )
+
+{
+ return ((OGRSpatialReference *) hSRS1)->IsSameGeogCS(
+ (OGRSpatialReference *) hSRS2 );
+}
+
+/************************************************************************/
+/* IsSame() */
+/************************************************************************/
+
+/**
+ * These two spatial references describe the same system.
+ *
+ * @param poOtherSRS the SRS being compared to.
+ *
+ * @return TRUE if equivelent or FALSE otherwise.
+ */
+
+int OGRSpatialReference::IsSame( const OGRSpatialReference * poOtherSRS ) const
+
+{
+ if( GetRoot() == NULL && poOtherSRS->GetRoot() == NULL )
+ return TRUE;
+ else if( GetRoot() == NULL || poOtherSRS->GetRoot() == NULL )
+ return FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Compare geographic coordinate system. */
+/* -------------------------------------------------------------------- */
+ if( !IsSameGeogCS( poOtherSRS ) )
+ return FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Do the have the same root types? Ie. is one PROJCS and one */
+/* GEOGCS or perhaps LOCALCS? */
+/* -------------------------------------------------------------------- */
+ if( !EQUAL(GetRoot()->GetValue(),poOtherSRS->GetRoot()->GetValue()) )
+ return FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Compare projected coordinate system. */
+/* -------------------------------------------------------------------- */
+ if( IsProjected() )
+ {
+ const char *pszValue1, *pszValue2;
+ const OGR_SRSNode *poPROJCS = GetAttrNode( "PROJCS" );
+
+ pszValue1 = this->GetAttrValue( "PROJECTION" );
+ pszValue2 = poOtherSRS->GetAttrValue( "PROJECTION" );
+ if( pszValue1 == NULL || pszValue2 == NULL
+ || !EQUAL(pszValue1,pszValue2) )
+ return FALSE;
+
+ for( int iChild = 0; iChild < poPROJCS->GetChildCount(); iChild++ )
+ {
+ const OGR_SRSNode *poNode;
+
+ poNode = poPROJCS->GetChild( iChild );
+ if( !EQUAL(poNode->GetValue(),"PARAMETER")
+ || poNode->GetChildCount() != 2 )
+ continue;
+
+ /* this this eventually test within some epsilon? */
+ if( this->GetProjParm( poNode->GetChild(0)->GetValue() )
+ != poOtherSRS->GetProjParm( poNode->GetChild(0)->GetValue() ) )
+ return FALSE;
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* If they are LOCALCS/PROJCS, do they have the same units? */
+/* -------------------------------------------------------------------- */
+ if( EQUAL(GetRoot()->GetValue(),"LOCALCS") || IsProjected() )
+ {
+ if( GetLinearUnits() != 0.0 )
+ {
+ double dfRatio;
+
+ dfRatio = poOtherSRS->GetLinearUnits() / GetLinearUnits();
+ if( dfRatio < 0.9999999999 || dfRatio > 1.000000001 )
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+/************************************************************************/
+/* OSRIsSame() */
+/************************************************************************/
+
+int OSRIsSame( OGRSpatialReferenceH hSRS1, OGRSpatialReferenceH hSRS2 )
+
+{
+ return ((OGRSpatialReference *) hSRS1)->IsSame(
+ (OGRSpatialReference *) hSRS2 );
+}
+
+/************************************************************************/
+/* SetTOWGS84() */
+/************************************************************************/
+
+/**
+ * Set the Bursa-Wolf conversion to WGS84.
+ *
+ * This will create the TOWGS84 node as a child of the DATUM. It will fail
+ * if there is no existing DATUM node. Unlike most OGRSpatialReference
+ * methods it will insert itself in the appropriate order, and will replace
+ * an existing TOWGS84 node if there is one.
+ *
+ * The parameters have the same meaning as EPSG transformation 9606
+ * (Position Vector 7-param. transformation).
+ *
+ * This method is the same as the C function OSRSetTOWGS84().
+ *
+ * @param dfDX X child in meters.
+ * @param dfDY Y child in meters.
+ * @param dfDZ Z child in meters.
+ * @param dfEX X rotation in arc seconds (optional, defaults to zero).
+ * @param dfEY Y rotation in arc seconds (optional, defaults to zero).
+ * @param dfEZ Z rotation in arc seconds (optional, defaults to zero).
+ * @param dfPPM scaling factor (parts per million).
+ *
+ * @return OGRERR_NONE on success.
+ */
+
+OGRErr OGRSpatialReference::SetTOWGS84( double dfDX, double dfDY, double dfDZ,
+ double dfEX, double dfEY, double dfEZ,
+ double dfPPM )
+
+{
+ OGR_SRSNode *poDatum, *poTOWGS84;
+ int iPosition;
+ char szValue[64];
+
+ poDatum = GetAttrNode( "DATUM" );
+ if( poDatum == NULL )
+ return OGRERR_FAILURE;
+
+ if( poDatum->FindChild( "TOWGS84" ) != -1 )
+ poDatum->DestroyChild( poDatum->FindChild( "TOWGS84" ) );
+
+ iPosition = poDatum->GetChildCount();
+ if( poDatum->FindChild("AUTHORITY") != -1 )
+ {
+ iPosition = poDatum->FindChild("AUTHORITY");
+ }
+
+ poTOWGS84 = new OGR_SRSNode("TOWGS84");
+
+ OGRPrintDouble( szValue, dfDX );
+ poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
+
+ OGRPrintDouble( szValue, dfDY );
+ poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
+
+ OGRPrintDouble( szValue, dfDZ );
+ poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
+
+ OGRPrintDouble( szValue, dfEX );
+ poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
+
+ OGRPrintDouble( szValue, dfEY );
+ poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
+
+ OGRPrintDouble( szValue, dfEZ );
+ poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
+
+ OGRPrintDouble( szValue, dfPPM );
+ poTOWGS84->AddChild( new OGR_SRSNode( szValue ) );
+
+ poDatum->InsertChild( poTOWGS84, iPosition );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRSetTOWGS84() */
+/************************************************************************/
+
+OGRErr OSRSetTOWGS84( OGRSpatialReferenceH hSRS,
+ double dfDX, double dfDY, double dfDZ,
+ double dfEX, double dfEY, double dfEZ,
+ double dfPPM )
+
+{
+ return ((OGRSpatialReference *) hSRS)->SetTOWGS84( dfDX, dfDY, dfDZ,
+ dfEX, dfEY, dfEZ,
+ dfPPM );
+}
+
+/************************************************************************/
+/* GetTOWGS84() */
+/************************************************************************/
+
+/**
+ * Fetch TOWGS84 parameters, if available.
+ *
+ * @param padfCoeff array into which up to 7 coefficients are placed.
+ * @param nCoeffCount size of padfCoeff - defaults to 7.
+ *
+ * @return OGRERR_NONE on success, or OGRERR_FAILURE if there is no
+ * TOWGS84 node available.
+ */
+
+OGRErr OGRSpatialReference::GetTOWGS84( double * padfCoeff,
+ int nCoeffCount ) const
+
+{
+ const OGR_SRSNode *poNode = GetAttrNode( "TOWGS84" );
+
+ memset( padfCoeff, 0, sizeof(double) * nCoeffCount );
+
+ if( poNode == NULL )
+ return OGRERR_FAILURE;
+
+ for( int i = 0; i < nCoeffCount && i < poNode->GetChildCount(); i++ )
+ {
+ padfCoeff[i] = atof(poNode->GetChild(i)->GetValue());
+ }
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRGetTOWGS84() */
+/************************************************************************/
+
+OGRErr OSRGetTOWGS84( OGRSpatialReferenceH hSRS,
+ double * padfCoeff, int nCoeffCount )
+
+{
+ return ((OGRSpatialReference *) hSRS)->GetTOWGS84( padfCoeff, nCoeffCount);
+}
+
+/************************************************************************/
+/* IsAngularParameter() */
+/* */
+/* Is the passed projection parameter an angular one? */
+/************************************************************************/
+
+int OGRSpatialReference::IsAngularParameter( const char *pszParameterName )
+
+{
+ if( EQUALN(pszParameterName,"long",4)
+ || EQUALN(pszParameterName,"lati",4)
+ || EQUAL(pszParameterName,SRS_PP_CENTRAL_MERIDIAN)
+ || EQUALN(pszParameterName,"standard_parallel",17)
+ || EQUAL(pszParameterName,SRS_PP_AZIMUTH)
+ || EQUAL(pszParameterName,SRS_PP_RECTIFIED_GRID_ANGLE) )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+/************************************************************************/
+/* IsLongitudeParameter() */
+/* */
+/* Is the passed projection parameter an angular longitude */
+/* (relative to a prime meridian)? */
+/************************************************************************/
+
+int OGRSpatialReference::IsLongitudeParameter( const char *pszParameterName )
+
+{
+ if( EQUALN(pszParameterName,"long",4)
+ || EQUAL(pszParameterName,SRS_PP_CENTRAL_MERIDIAN) )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+/************************************************************************/
+/* IsLinearParameter() */
+/* */
+/* Is the passed projection parameter an linear one measured in */
+/* meters or some similar linear measure. */
+/************************************************************************/
+
+int OGRSpatialReference::IsLinearParameter( const char *pszParameterName )
+
+{
+ if( EQUALN(pszParameterName,"false_",6)
+ || EQUAL(pszParameterName,SRS_PP_SATELLITE_HEIGHT) )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+/************************************************************************/
+/* GetNormInfo() */
+/* */
+/* Set the internal information for normalizing linear, and */
+/* angular values. */
+/************************************************************************/
+
+void OGRSpatialReference::GetNormInfo(void) const
+
+{
+ if( bNormInfoSet )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Initialize values. */
+/* -------------------------------------------------------------------- */
+ OGRSpatialReference *poThis = (OGRSpatialReference *) this;
+
+ poThis->bNormInfoSet = TRUE;
+
+ poThis->dfFromGreenwich = GetPrimeMeridian(NULL);
+ poThis->dfToMeter = GetLinearUnits(NULL);
+ poThis->dfToDegrees = GetAngularUnits(NULL) / atof(SRS_UA_DEGREE_CONV);
+ if( fabs(poThis->dfToDegrees-1.0) < 0.000000001 )
+ poThis->dfToDegrees = 1.0;
+}
+
+/************************************************************************/
+/* FixupOrdering() */
+/************************************************************************/
+
+/**
+ * Correct parameter ordering to match CT Specification.
+ *
+ * Some mechanisms to create WKT using OGRSpatialReference, and some
+ * imported WKT fail to maintain the order of parameters required according
+ * to the BNF definitions in the OpenGIS SF-SQL and CT Specifications. This
+ * method attempts to massage things back into the required order.
+ *
+ * This method is the same as the C function OSRFixupOrdering().
+ *
+ * @return OGRERR_NONE on success or an error code if something goes
+ * wrong.
+ */
+
+OGRErr OGRSpatialReference::FixupOrdering()
+
+{
+ if( GetRoot() != NULL )
+ return GetRoot()->FixupOrdering();
+ else
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRFixupOrdering() */
+/************************************************************************/
+
+OGRErr OSRFixupOrdering( OGRSpatialReferenceH hSRS )
+
+{
+ return ((OGRSpatialReference *) hSRS)->FixupOrdering();
+}
+
+/************************************************************************/
+/* Fixup() */
+/************************************************************************/
+
+/**
+ * Fixup as needed.
+ *
+ * Some mechanisms to create WKT using OGRSpatialReference, and some
+ * imported WKT, are not valid according to the OGC CT specification. This
+ * method attempts to fill in any missing defaults that are required, and
+ * fixup ordering problems (using OSRFixupOrdering()) so that the resulting
+ * WKT is valid.
+ *
+ * This method should be expected to evolve over time to as problems are
+ * discovered. The following are amoung the fixup actions this method will
+ * take:
+ *
+ * - Fixup the ordering of nodes to match the BNF WKT ordering, using
+ * the FixupOrdering() method.
+ *
+ * - Add missing linear or angular units nodes.
+ *
+ * This method is the same as the C function OSRFixup().
+ *
+ * @return OGRERR_NONE on success or an error code if something goes
+ * wrong.
+ */
+
+OGRErr OGRSpatialReference::Fixup()
+
+{
+/* -------------------------------------------------------------------- */
+/* Ensure linear units defaulted to METER if missing for PROJCS */
+/* or LOCAL_CS. */
+/* -------------------------------------------------------------------- */
+ const OGR_SRSNode *poCS = GetAttrNode( "PROJCS" );
+
+ if( poCS == NULL )
+ poCS = GetAttrNode( "LOCAL_CS" );
+
+ if( poCS != NULL && poCS->FindChild( "UNIT" ) == -1 )
+ SetLinearUnits( SRS_UL_METER, 1.0 );
+
+/* -------------------------------------------------------------------- */
+/* Ensure angular units defaulted to degrees on the GEOGCS. */
+/* -------------------------------------------------------------------- */
+ poCS = GetAttrNode( "GEOGCS" );
+ if( poCS != NULL && poCS->FindChild( "UNIT" ) == -1 )
+ SetAngularUnits( SRS_UA_DEGREE, atof(SRS_UA_DEGREE_CONV) );
+
+ return FixupOrdering();
+}
+
+/************************************************************************/
+/* OSRFixup() */
+/************************************************************************/
+
+OGRErr OSRFixup( OGRSpatialReferenceH hSRS )
+
+{
+ return ((OGRSpatialReference *) hSRS)->Fixup();
+}
+
+/************************************************************************/
+/* GetExtension() */
+/************************************************************************/
+
+/**
+ * Fetch extension value.
+ *
+ * Fetch the value of the named EXTENSION item for the identified
+ * target node.
+ *
+ * @param pszTargetKey the name or path to the parent node of the EXTENSION.
+ * @param pszName the name of the extension being fetched.
+ * @param pszDefault the value to return if the extension is not found.
+ *
+ * @return node value if successful or pszDefault on failure.
+ */
+
+const char *OGRSpatialReference::GetExtension( const char *pszTargetKey,
+ const char *pszName,
+ const char *pszDefault ) const
+
+{
+/* -------------------------------------------------------------------- */
+/* Find the target node. */
+/* -------------------------------------------------------------------- */
+ const OGR_SRSNode *poNode;
+
+ if( pszTargetKey == NULL )
+ poNode = poRoot;
+ else
+ poNode= ((OGRSpatialReference *) this)->GetAttrNode( pszTargetKey );
+
+ if( poNode == NULL )
+ return NULL;
+
+/* -------------------------------------------------------------------- */
+/* Fetch matching EXTENSION if there is one. */
+/* -------------------------------------------------------------------- */
+ for( int i = poNode->GetChildCount()-1; i >= 0; i-- )
+ {
+ const OGR_SRSNode *poChild = poNode->GetChild(i);
+
+ if( EQUAL(poChild->GetValue(),"EXTENSION")
+ && poChild->GetChildCount() >= 2 )
+ {
+ if( EQUAL(poChild->GetChild(0)->GetValue(),pszName) )
+ return poChild->GetChild(1)->GetValue();
+ }
+ }
+
+ return pszDefault;
+}
+
+/************************************************************************/
+/* SetExtension() */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetExtension( const char *pszTargetKey,
+ const char *pszName,
+ const char *pszValue )
+
+{
+/* -------------------------------------------------------------------- */
+/* Find the target node. */
+/* -------------------------------------------------------------------- */
+ OGR_SRSNode *poNode;
+
+ if( pszTargetKey == NULL )
+ poNode = poRoot;
+ else
+ poNode= ((OGRSpatialReference *) this)->GetAttrNode( pszTargetKey );
+
+ if( poNode == NULL )
+ return OGRERR_FAILURE;
+
+/* -------------------------------------------------------------------- */
+/* Fetch matching EXTENSION if there is one. */
+/* -------------------------------------------------------------------- */
+ for( int i = poNode->GetChildCount()-1; i >= 0; i-- )
+ {
+ OGR_SRSNode *poChild = poNode->GetChild(i);
+
+ if( EQUAL(poChild->GetValue(),"EXTENSION")
+ && poChild->GetChildCount() >= 2 )
+ {
+ if( EQUAL(poChild->GetChild(0)->GetValue(),pszName) )
+ {
+ poChild->GetChild(1)->SetValue( pszValue );
+ return OGRERR_NONE;
+ }
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Create a new EXTENSION node. */
+/* -------------------------------------------------------------------- */
+ OGR_SRSNode *poAuthNode;
+
+ poAuthNode = new OGR_SRSNode( "EXTENSION" );
+ poAuthNode->AddChild( new OGR_SRSNode( pszName ) );
+ poAuthNode->AddChild( new OGR_SRSNode( pszValue ) );
+
+ poNode->AddChild( poAuthNode );
+
+ return OGRERR_NONE;
+}
+
+/************************************************************************/
+/* OSRCleanup() */
+/************************************************************************/
+
+/**
+ * Cleanup cached SRS related memory.
+ *
+ * This function will attempt to cleanup any cache spatial reference
+ * related information, such as cached tables of coordinate systems.
+ */
+
+CPL_C_START
+void CleanupESRIDatumMappingTable();
+CPL_C_END
+
+
+void OSRCleanup( void )
+
+{
+ CleanupESRIDatumMappingTable();
+ CSVDeaccess( NULL );
+}
Added: trunk/MgDev/Oem/gdal-1.4.0/port/cpl.vcproj
===================================================================
--- trunk/MgDev/Oem/gdal-1.4.0/port/cpl.vcproj (rev 0)
+++ trunk/MgDev/Oem/gdal-1.4.0/port/cpl.vcproj 2007-03-21 00:50:25 UTC (rev 1309)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="CPL"
+ ProjectGUID="{E8F6DBAE-C078-4826-D996-01EFA74219F6}"
+ RootNamespace="CPL"
+ Keyword="MakeFileProj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="0"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ >
+ <Tool
+ Name="VCNMakeTool"
+ BuildCommandLine="nmake /f makefile.vc"
+ ReBuildCommandLine="nmake /f makefile.vc clean default"
+ CleanCommandLine="nmake /f makefile.vc clean"
+ Output=""
+ PreprocessorDefinitions=""
+ IncludeSearchPath=""
+ ForcedIncludes=""
+ AssemblySearchPath=""
+ ForcedUsingAssemblies=""
+ CompileAsManaged=""
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="0"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ >
+ <Tool
+ Name="VCNMakeTool"
+ BuildCommandLine="nmake /f makefile.vc"
+ ReBuildCommandLine="nmake /f makefile.vc clean default"
+ CleanCommandLine="nmake /f makefile.vc clean"
+ Output=""
+ PreprocessorDefinitions=""
+ IncludeSearchPath=""
+ ForcedIncludes=""
+ AssemblySearchPath=""
+ ForcedUsingAssemblies=""
+ CompileAsManaged=""
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\makefile.vc"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Property changes on: trunk/MgDev/Oem/gdal-1.4.0/port/cpl.vcproj
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/MgDev/Oem/gdal-1.4.0/port/cpl_findfile.cpp
===================================================================
--- trunk/MgDev/Oem/gdal-1.4.0/port/cpl_findfile.cpp 2007-03-21 00:47:37 UTC (rev 1308)
+++ trunk/MgDev/Oem/gdal-1.4.0/port/cpl_findfile.cpp 2007-03-21 00:50:25 UTC (rev 1309)
@@ -1,258 +1,261 @@
-/******************************************************************************
- * $Id: cpl_findfile.cpp,v 1.13 2006/11/05 19:43:18 hobu Exp $
- *
- * Project: CPL - Common Portability Library
- * Purpose: Generic data file location finder, with application hooking.
- * Author: Frank Warmerdam, warmerdam at 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: cpl_findfile.cpp,v $
- * Revision 1.13 2006/11/05 19:43:18 hobu
- * OSX Framework location
- *
- * Revision 1.12 2006/09/23 23:05:22 fwarmerdam
- * Honour GDAL_DATA when initializing finder.
- *
- * Revision 1.11 2006/03/21 20:11:54 fwarmerdam
- * fixup headers a bit
- *
- * Revision 1.10 2005/09/13 23:56:06 fwarmerdam
- * improved cleanup logic
- *
- * Revision 1.9 2005/05/23 03:59:07 fwarmerdam
- * make finder stuff threadlocal
- *
- * Revision 1.8 2005/01/15 07:46:20 fwarmerdam
- * make cplpopfinderlocation safer for final cleanup
- *
- * Revision 1.7 2004/11/22 16:01:05 fwarmerdam
- * added GDAL_PREFIX
- *
- * Revision 1.6 2003/10/24 16:41:16 warmerda
- * Added /usr/local/share/gdal (not /usr/local/share) to default locations.
- *
- * Revision 1.5 2003/10/24 16:30:10 warmerda
- * fixed serious bug in default finder ... only last location used
- *
- * Revision 1.4 2002/12/03 04:42:02 warmerda
- * improved finder cleanup support
- *
- * Revision 1.3 2001/07/18 04:00:49 warmerda
- * added CPL_CVSID
- *
- * Revision 1.2 2001/01/19 21:16:41 warmerda
- * expanded tabs
- *
- * Revision 1.1 2000/08/29 21:06:25 warmerda
- * New
- *
- */
-
-#include "cpl_conv.h"
-#include "cpl_string.h"
-
-CPL_CVSID("$Id: cpl_findfile.cpp,v 1.13 2006/11/05 19:43:18 hobu Exp $");
-
-static CPL_THREADLOCAL int bFinderInitialized = FALSE;
-static CPL_THREADLOCAL int nFileFinders = 0;
-static CPL_THREADLOCAL CPLFileFinder *papfnFinders = NULL;
-static CPL_THREADLOCAL char **papszFinderLocations = NULL;
-
-/************************************************************************/
-/* CPLFinderInit() */
-/************************************************************************/
-
-static void CPLFinderInit()
-
-{
- if( !bFinderInitialized )
- {
- bFinderInitialized = TRUE;
- CPLPushFileFinder( CPLDefaultFindFile );
-
- CPLPushFinderLocation( "." );
-
- if( CPLGetConfigOption( "GDAL_DATA", NULL ) != NULL )
- {
- CPLPushFinderLocation( CPLGetConfigOption( "GDAL_DATA", NULL ) );
- }
- else
- {
-#ifdef GDAL_PREFIX
- #ifdef MACOSX_FRAMEWORK
- CPLPushFinderLocation( GDAL_PREFIX "/Resources/gdal" );
- #else
- CPLPushFinderLocation( GDAL_PREFIX "/share/gdal" );
- #endif
-#else
- CPLPushFinderLocation( "/usr/local/share/gdal" );
-#endif
- }
- }
-}
-
-/************************************************************************/
-/* CPLFinderClean() */
-/************************************************************************/
-
-void CPLFinderClean()
-
-{
- while( papszFinderLocations != NULL )
- CPLPopFinderLocation();
- while( CPLPopFileFinder() != NULL ) {}
-
- bFinderInitialized = FALSE;
-}
-
-/************************************************************************/
-/* CPLDefaultFileFind() */
-/************************************************************************/
-
-const char *CPLDefaultFindFile( const char *pszClass,
- const char *pszBasename )
-
-{
- int i, nLocations = CSLCount( papszFinderLocations );
-
- (void) pszClass;
-
- for( i = nLocations-1; i >= 0; i-- )
- {
- const char *pszResult;
- VSIStatBuf sStat;
-
- pszResult = CPLFormFilename( papszFinderLocations[i], pszBasename,
- NULL );
-
- if( VSIStat( pszResult, &sStat ) == 0 )
- return pszResult;
- }
-
- return NULL;
-}
-
-/************************************************************************/
-/* CPLFindFile() */
-/************************************************************************/
-
-const char *CPLFindFile( const char *pszClass, const char *pszBasename )
-
-{
- int i;
-
- CPLFinderInit();
-
- for( i = nFileFinders-1; i >= 0; i-- )
- {
- const char * pszResult;
-
- pszResult = (papfnFinders[i])( pszClass, pszBasename );
- if( pszResult != NULL )
- return pszResult;
- }
-
- return NULL;
-}
-
-/************************************************************************/
-/* CPLPushFileFinder() */
-/************************************************************************/
-
-void CPLPushFileFinder( CPLFileFinder pfnFinder )
-
-{
- CPLFinderInit();
-
- papfnFinders = (CPLFileFinder *)
- CPLRealloc(papfnFinders, sizeof(void*) * ++nFileFinders);
- papfnFinders[nFileFinders-1] = pfnFinder;
-}
-
-/************************************************************************/
-/* CPLPopFileFinder() */
-/************************************************************************/
-
-CPLFileFinder CPLPopFileFinder()
-
-{
- CPLFileFinder pfnReturn;
-
-// CPLFinderInit();
-
- if( nFileFinders == 0 )
- return NULL;
-
- pfnReturn = papfnFinders[--nFileFinders];
-
- if( nFileFinders == 0)
- {
- CPLFree( papfnFinders );
- papfnFinders = NULL;
- }
-
- return pfnReturn;
-}
-
-/************************************************************************/
-/* CPLPushFinderLocation() */
-/************************************************************************/
-
-void CPLPushFinderLocation( const char *pszLocation )
-
-{
- CPLFinderInit();
-
- papszFinderLocations = CSLAddString( papszFinderLocations,
- pszLocation );
-}
-
-
-/************************************************************************/
-/* CPLPopFinderLocation() */
-/************************************************************************/
-
-void CPLPopFinderLocation()
-
-{
- int nCount;
-
- if( papszFinderLocations == NULL )
- return;
-
- CPLFinderInit();
-
- nCount = CSLCount(papszFinderLocations);
- if( nCount == 0 )
- return;
-
- CPLFree( papszFinderLocations[nCount-1] );
- papszFinderLocations[nCount-1] = NULL;
-
- if( nCount == 1 )
- {
- CPLFree( papszFinderLocations );
- papszFinderLocations = NULL;
- }
-}
+/******************************************************************************
+ * $Id: cpl_findfile.cpp,v 1.13 2006/11/05 19:43:18 hobu Exp $
+ *
+ * Project: CPL - Common Portability Library
+ * Purpose: Generic data file location finder, with application hooking.
+ * Author: Frank Warmerdam, warmerdam at 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: cpl_findfile.cpp,v $
+ * Revision 1.13 2006/11/05 19:43:18 hobu
+ * OSX Framework location
+ *
+ * Revision 1.12 2006/09/23 23:05:22 fwarmerdam
+ * Honour GDAL_DATA when initializing finder.
+ *
+ * Revision 1.11 2006/03/21 20:11:54 fwarmerdam
+ * fixup headers a bit
+ *
+ * Revision 1.10 2005/09/13 23:56:06 fwarmerdam
+ * improved cleanup logic
+ *
+ * Revision 1.9 2005/05/23 03:59:07 fwarmerdam
+ * make finder stuff threadlocal
+ *
+ * Revision 1.8 2005/01/15 07:46:20 fwarmerdam
+ * make cplpopfinderlocation safer for final cleanup
+ *
+ * Revision 1.7 2004/11/22 16:01:05 fwarmerdam
+ * added GDAL_PREFIX
+ *
+ * Revision 1.6 2003/10/24 16:41:16 warmerda
+ * Added /usr/local/share/gdal (not /usr/local/share) to default locations.
+ *
+ * Revision 1.5 2003/10/24 16:30:10 warmerda
+ * fixed serious bug in default finder ... only last location used
+ *
+ * Revision 1.4 2002/12/03 04:42:02 warmerda
+ * improved finder cleanup support
+ *
+ * Revision 1.3 2001/07/18 04:00:49 warmerda
+ * added CPL_CVSID
+ *
+ * Revision 1.2 2001/01/19 21:16:41 warmerda
+ * expanded tabs
+ *
+ * Revision 1.1 2000/08/29 21:06:25 warmerda
+ * New
+ *
+ */
+
+#include "cpl_conv.h"
+#include "cpl_string.h"
+
+CPL_CVSID("$Id: cpl_findfile.cpp,v 1.13 2006/11/05 19:43:18 hobu Exp $");
+
+static CPL_THREADLOCAL int bFinderInitialized = FALSE;
+static CPL_THREADLOCAL int nFileFinders = 0;
+static CPL_THREADLOCAL CPLFileFinder *papfnFinders = NULL;
+static CPL_THREADLOCAL char **papszFinderLocations = NULL;
+
+/************************************************************************/
+/* CPLFinderInit() */
+/************************************************************************/
+
+static void CPLFinderInit()
+
+{
+ if( !bFinderInitialized )
+ {
+ bFinderInitialized = TRUE;
+ CPLPushFileFinder( CPLDefaultFindFile );
+
+ CPLPushFinderLocation( "." );
+
+ if( CPLGetConfigOption( "GDAL_DATA", NULL ) != NULL )
+ {
+ CPLPushFinderLocation( CPLGetConfigOption( "GDAL_DATA", NULL ) );
+ }
+ else
+ {
+#ifdef GDAL_PREFIX
+ #ifdef MACOSX_FRAMEWORK
+ CPLPushFinderLocation( GDAL_PREFIX "/Resources/gdal" );
+ #else
+ CPLPushFinderLocation( GDAL_PREFIX "/share/gdal" );
+ #endif
+#else
+ CPLPushFinderLocation( "/usr/local/share/gdal" );
+#endif
+ }
+ }
+}
+
+/************************************************************************/
+/* CPLFinderClean() */
+/************************************************************************/
+
+void CPLFinderClean()
+
+{
+ if( bFinderInitialized )
+ {
+ while( papszFinderLocations != NULL )
+ CPLPopFinderLocation();
+ while( CPLPopFileFinder() != NULL ) {}
+
+ bFinderInitialized = FALSE;
+ }
+}
+
+/************************************************************************/
+/* CPLDefaultFileFind() */
+/************************************************************************/
+
+const char *CPLDefaultFindFile( const char *pszClass,
+ const char *pszBasename )
+
+{
+ int i, nLocations = CSLCount( papszFinderLocations );
+
+ (void) pszClass;
+
+ for( i = nLocations-1; i >= 0; i-- )
+ {
+ const char *pszResult;
+ VSIStatBuf sStat;
+
+ pszResult = CPLFormFilename( papszFinderLocations[i], pszBasename,
+ NULL );
+
+ if( VSIStat( pszResult, &sStat ) == 0 )
+ return pszResult;
+ }
+
+ return NULL;
+}
+
+/************************************************************************/
+/* CPLFindFile() */
+/************************************************************************/
+
+const char *CPLFindFile( const char *pszClass, const char *pszBasename )
+
+{
+ int i;
+
+ CPLFinderInit();
+
+ for( i = nFileFinders-1; i >= 0; i-- )
+ {
+ const char * pszResult;
+
+ pszResult = (papfnFinders[i])( pszClass, pszBasename );
+ if( pszResult != NULL )
+ return pszResult;
+ }
+
+ return NULL;
+}
+
+/************************************************************************/
+/* CPLPushFileFinder() */
+/************************************************************************/
+
+void CPLPushFileFinder( CPLFileFinder pfnFinder )
+
+{
+ CPLFinderInit();
+
+ papfnFinders = (CPLFileFinder *)
+ CPLRealloc(papfnFinders, sizeof(void*) * ++nFileFinders);
+ papfnFinders[nFileFinders-1] = pfnFinder;
+}
+
+/************************************************************************/
+/* CPLPopFileFinder() */
+/************************************************************************/
+
+CPLFileFinder CPLPopFileFinder()
+
+{
+ CPLFileFinder pfnReturn;
+
+// CPLFinderInit();
+
+ if( nFileFinders == 0 )
+ return NULL;
+
+ pfnReturn = papfnFinders[--nFileFinders];
+
+ if( nFileFinders == 0)
+ {
+ CPLFree( papfnFinders );
+ papfnFinders = NULL;
+ }
+
+ return pfnReturn;
+}
+
+/************************************************************************/
+/* CPLPushFinderLocation() */
+/************************************************************************/
+
+void CPLPushFinderLocation( const char *pszLocation )
+
+{
+ CPLFinderInit();
+
+ papszFinderLocations = CSLAddString( papszFinderLocations,
+ pszLocation );
+}
+
+
+/************************************************************************/
+/* CPLPopFinderLocation() */
+/************************************************************************/
+
+void CPLPopFinderLocation()
+
+{
+ int nCount;
+
+ if( papszFinderLocations == NULL )
+ return;
+
+ CPLFinderInit();
+
+ nCount = CSLCount(papszFinderLocations);
+ if( nCount == 0 )
+ return;
+
+ CPLFree( papszFinderLocations[nCount-1] );
+ papszFinderLocations[nCount-1] = NULL;
+
+ if( nCount == 1 )
+ {
+ CPLFree( papszFinderLocations );
+ papszFinderLocations = NULL;
+ }
+}
Modified: trunk/MgDev/Oem/gdal-1.4.0/port/makefile.vc
===================================================================
--- trunk/MgDev/Oem/gdal-1.4.0/port/makefile.vc 2007-03-21 00:47:37 UTC (rev 1308)
+++ trunk/MgDev/Oem/gdal-1.4.0/port/makefile.vc 2007-03-21 00:50:25 UTC (rev 1309)
@@ -1,46 +1,47 @@
-#
-# CPL (Common Portability Library) makefile
-#
-
-OBJ = cpl_conv.obj \
- cpl_error.obj \
- cpl_string.obj \
- cplstring.obj \
- cpl_strtod.obj \
- cpl_vsisimple.obj \
- cplgetsymbol.obj \
- cpl_dir.obj \
- cpl_path.obj \
- cpl_csv.obj \
- cpl_findfile.obj \
- cpl_vsil_win32.obj \
- cpl_minixml.obj \
- cpl_multiproc.obj \
- cpl_list.obj \
- cpl_getexecpath.obj \
- cpl_vsil.obj \
- cpl_vsi_mem.obj \
- $(ODBC_OBJ)
-
-LIB = cpl.lib
-
-GDAL_ROOT = ..
-
-!INCLUDE ..\nmake.opt
-
-!IFDEF ODBC_SUPPORTED
-ODBC_OBJ = cpl_odbc.obj
-!ENDIF
-
-default: cpl_config.h $(LIB)
-
-$(LIB): $(OBJ)
- lib /out:cpl.lib *.obj
-
-clean:
- -del *.obj *.lib
-
-cpl_config.h: cpl_config.h.vc
- copy cpl_config.h.vc cpl_config.h
-
-
+#
+# CPL (Common Portability Library) makefile
+#
+
+OBJ = cpl_conv.obj \
+ cpl_error.obj \
+ cpl_string.obj \
+ cplstring.obj \
+ cpl_strtod.obj \
+ cpl_vsisimple.obj \
+ cplgetsymbol.obj \
+ cpl_dir.obj \
+ cpl_path.obj \
+ cpl_csv.obj \
+ cpl_findfile.obj \
+ cpl_vsil_win32.obj \
+ cpl_minixml.obj \
+ cpl_multiproc.obj \
+ cpl_list.obj \
+ cpl_getexecpath.obj \
+ cpl_vsil.obj \
+ cpl_vsi_mem.obj \
+ $(ODBC_OBJ)
+
+LIB = cpl.lib
+
+GDAL_ROOT = ..
+PDB_NAME = cpl.pdb
+
+!INCLUDE ..\nmake.opt
+
+!IFDEF ODBC_SUPPORTED
+ODBC_OBJ = cpl_odbc.obj
+!ENDIF
+
+default: cpl_config.h $(LIB)
+
+$(LIB): $(OBJ)
+ lib /out:cpl.lib *.obj
+
+clean:
+ -del *.obj *.lib
+
+cpl_config.h: cpl_config.h.vc
+ copy cpl_config.h.vc cpl_config.h
+
+
More information about the mapguide-commits
mailing list