[DebianGIS-dev] r650 - in packages: . ogdi-dfsg ogdi-dfsg/branches
ogdi-dfsg/branches/upstream ogdi-dfsg/branches/upstream/current
ogdi-dfsg/branches/upstream/current/config
ogdi-dfsg/branches/upstream/current/contrib
ogdi-dfsg/branches/upstream/current/contrib/gdal
ogdi-dfsg/branches/upstream/current/contrib/ogdi_import
ogdi-dfsg/branches/upstream/current/contrib/ogdi_info
ogdi-dfsg/branches/upstream/current/include
ogdi-dfsg/branches/upstream/current/include/Linux
ogdi-dfsg/branches/upstream/current/ogdi
ogdi-dfsg/branches/upstream/current/ogdi/attr_driver
ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc
ogdi-dfsg/branches/upstream/current/ogdi/c-api
ogdi-dfsg/branches/upstream/current/ogdi/datum_driver
ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada
ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa
ogdi-dfsg/branches/upstream/current/ogdi/driver
ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg
ogdi-dfsg/branches/upstream/current/ogdi/driver/dted
ogdi-dfsg/branches/upstream/current/ogdi/driver/network
ogdi-dfsg/branches/upstream/current/ogdi/driver/network/sun
ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf
ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton
ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf
ogdi-dfsg/branches/upstream/current/ogdi/examples
ogdi-dfsg/branches/upstream/current/ogdi/examples/example1
ogdi-dfsg/branches/upstream/current/ogdi/examples/example2
ogdi-dfsg/branches/upstream/current/ogdi/gltpd
ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun
ogdi-dfsg/branches/upstream/current/ogdi/glutil
ogdi-dfsg/branches/upstream/current/ogdi/include
ogdi-dfsg/branches/upstream/current/ogdi/include/sun
ogdi-dfsg/branches/upstream/current/ogdi/scripts
ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface
ogdi-dfsg/branches/upstream/current/vpflib
ogdi-dfsg/branches/upstream/current/vpflib/include
Francesco Lovergine
frankie at alioth.debian.org
Mon Mar 26 17:00:52 CET 2007
Author: frankie
Date: 2007-03-26 16:00:49 +0000 (Mon, 26 Mar 2007)
New Revision: 650
Added:
packages/ogdi-dfsg/
packages/ogdi-dfsg/branches/
packages/ogdi-dfsg/branches/upstream/
packages/ogdi-dfsg/branches/upstream/current/
packages/ogdi-dfsg/branches/upstream/current/ChangeLog
packages/ogdi-dfsg/branches/upstream/current/HOWTO-RELEASE
packages/ogdi-dfsg/branches/upstream/current/LICENSE
packages/ogdi-dfsg/branches/upstream/current/NEWS
packages/ogdi-dfsg/branches/upstream/current/README
packages/ogdi-dfsg/branches/upstream/current/README-BIN.TXT
packages/ogdi-dfsg/branches/upstream/current/VERSION
packages/ogdi-dfsg/branches/upstream/current/aclocal.m4
packages/ogdi-dfsg/branches/upstream/current/config.guess
packages/ogdi-dfsg/branches/upstream/current/config.log
packages/ogdi-dfsg/branches/upstream/current/config.sub
packages/ogdi-dfsg/branches/upstream/current/config/
packages/ogdi-dfsg/branches/upstream/current/config/Linux.mak
packages/ogdi-dfsg/branches/upstream/current/config/common.mak
packages/ogdi-dfsg/branches/upstream/current/config/common.mak.in
packages/ogdi-dfsg/branches/upstream/current/config/darwin.mak
packages/ogdi-dfsg/branches/upstream/current/config/generic.mak.in
packages/ogdi-dfsg/branches/upstream/current/config/linux.mak
packages/ogdi-dfsg/branches/upstream/current/config/mkinstalldirs
packages/ogdi-dfsg/branches/upstream/current/config/solaris.mak
packages/ogdi-dfsg/branches/upstream/current/config/unix.mak
packages/ogdi-dfsg/branches/upstream/current/config/win32.mak
packages/ogdi-dfsg/branches/upstream/current/configure
packages/ogdi-dfsg/branches/upstream/current/configure.in
packages/ogdi-dfsg/branches/upstream/current/contrib/
packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/
packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gbgetsymbol.c
packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal.def
packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal_serv.c
packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal_serv.h
packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdalbridge.c
packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdalbridge.h
packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/makefile
packages/ogdi-dfsg/branches/upstream/current/contrib/makefile
packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/
packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/dbfopen.c
packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/makefile
packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/ogdi_import.c
packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/shapefil.h
packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/shpopen.c
packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/
packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/makefile
packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/ogdi_info.c
packages/ogdi-dfsg/branches/upstream/current/include/
packages/ogdi-dfsg/branches/upstream/current/include/Linux/
packages/ogdi-dfsg/branches/upstream/current/include/Linux/ogdi_macro.h
packages/ogdi-dfsg/branches/upstream/current/makefile
packages/ogdi-dfsg/branches/upstream/current/mkbindist.sh
packages/ogdi-dfsg/branches/upstream/current/mkogdidist.sh
packages/ogdi-dfsg/branches/upstream/current/ogdi-config
packages/ogdi-dfsg/branches/upstream/current/ogdi-config.in
packages/ogdi-dfsg/branches/upstream/current/ogdi.pc
packages/ogdi-dfsg/branches/upstream/current/ogdi.pc.in
packages/ogdi-dfsg/branches/upstream/current/ogdi/
packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/
packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/
packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/lodbc.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/odbc.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/odbc.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/client.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_capabilities.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_dyna.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_xdr.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_xdrz.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsassoc.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsdist.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsgeo.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecshash.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsinfo.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecslist.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsregex.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecssplit.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecstile.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/gmath.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/gmath.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/matrix.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/matrix.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ogdi.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/opendir.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/opendir.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/server.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/dtcanada.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/dtcanada.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/nadconv.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/nadconv.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/sdms.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/testgrid.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/dtusa.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/dtusa.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/datadict.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/ddadrg.tcl
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/object.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/utils.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/datadict.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/object.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/utils.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/ecs_clnt.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/remote.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/remote.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/sun/
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/sun/ecs_clnt.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/datadict.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/object.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/utils.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/datadict.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/datainfo.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/object.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/open.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.mta
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeletonb.mta
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/utils.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/datadict.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/feature.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/object.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/open.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/swq.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/swq.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/utils.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrfswq.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/
packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example1/
packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example1/example1.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example1/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example2/
packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example2/example2.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example2/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/
packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/asyncsvr.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/ecs_sif.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/ecs_svc.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/
packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/asyncsvr.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/ecs_sif.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/ecs_svc.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/
packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/dirent.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/getglenv.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/glutil.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/iofile.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/status_d.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs.x
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs_util.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_clnt.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_svc.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_util.h
packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_xdr.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/makefile
packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/
packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/h_clean.pl
packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/svc_clean.pl
packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/xdr_clean.pl
packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/
packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/ecs_tcl.c
packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/ecs_tcl.def
packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/makefile
packages/ogdi-dfsg/branches/upstream/current/readme.w32
packages/ogdi-dfsg/branches/upstream/current/varwin32.bat
packages/ogdi-dfsg/branches/upstream/current/vpflib/
packages/ogdi-dfsg/branches/upstream/current/vpflib/coorgeom.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/coorgeom.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/get_feat.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/get_feat.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arcdef.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arcfunc.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/bmp.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cb_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cb_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cc1_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cli_sr_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cli_sr_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/color_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/color_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/coord_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/coord_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/datum_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/datum_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_dn.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_fn.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ellips_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ellips_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/help_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/i_stat.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ibrowse.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/inifunc.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/link.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/machine.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mapdoc_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mapdoc_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mgm_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mgm_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse1.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_ask.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_ipc.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_sql.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museapi.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museconv.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musedfun.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musedir.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musepacy.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museras.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musesys.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pnt_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pntappl.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pntgui_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/print_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/raster_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/raster_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/reduce2.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/setup.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sql_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sqllib_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sqllib_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunras_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunras_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrast.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrdef.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrfunc.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/system_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/system_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/tifffunc.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ts_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ts_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/unit_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/unit_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/units_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/units_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/valid_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vec_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vec_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vector.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vpf_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vpf_f.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/linklist.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/linklist.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/makefile
packages/ogdi-dfsg/branches/upstream/current/vpflib/musedir.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/musedir.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/reduce2.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/set.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/set.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/strfunc.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/strfunc.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vec_d.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf2vec.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf2vec.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfbrows.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfbrows.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfdproj.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfio.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprim.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprim.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfproj.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprop.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprop.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfquery.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfquery.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfread.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfrelat.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfrelat.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.i
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfspx.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfspx.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftable.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftable.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftidx.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftidx.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfview.h
packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfwrite.c
packages/ogdi-dfsg/branches/upstream/current/vpflib/xvt.h
packages/ogdi-dfsg/tags/
Log:
[svn-inject] Installing original source of ogdi-dfsg
Added: packages/ogdi-dfsg/branches/upstream/current/ChangeLog
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ChangeLog 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ChangeLog 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,827 @@
+============================================================================
+2007-02-24 Balint Cristian <cbalint at redhat.com>
+
+ * Prepare for 3.2.0beta1 release.
+
+2007-02-24 Balint Cristian <cbalint at redhat.com>
+
+ * Clear olso tilestruct while freeing memory in dyn_freelayerpriv().
+ glibc mtrace() reports zero malloc problems now.
+ Thanks to djdejohn for the report !
+
+============================================================================
+2007-02-12 Balint Cristian <cbalint at redhat.com>
+
+ * Prepare for 3.1.6 release.
+ * add ogdi.pc.in and ogdi-config scripts
+
+2007-02-12 Balint Cristian <cbalint at redhat.com>
+
+ Hide plugins from system libs path:
+
+ * move plugins to $LIB_INST/ogdi subfolder (this is std. now).
+
+ * add dlopen patch in c-api for run-time to be able find those
+ plugins for that case that we hided plugins from system wide.
+
+ * small typo in ChangeLog.
+
+ We shouldn't expose plugin libs to system wide lib search path,
+ this would break FHS, its better to keep them hidden, and only
+ ogdi binary handle those.
+
+ * use -soname and mark our exposed library, so exclude plugins.
+
+ * libogdi31.so is now libogdi.so.3.1 with libogdi.3 soname.
+ but should be findable now with -logdi.
+
+ Release versioning:
+
+ - MAJOR releases represents major ABI changes in the exposed shared lib.
+ This should not be so offen, only once with major code change wich due
+ to a change in how ogdi is called external by other applications.
+ - MINOR releases represents revisions or bugfixes over ogdi.
+
+2007-02-12 Balint Cristian <cbalint at redhat.com>
+
+ * fix some gcc warnings, uninited variables, and unused variables.
+
+=============================================================================
+
+
+2005-02-28 Frank Warmerdam <warmerdam at pobox.com>
+
+ * Prepare for 3.1.5 release.
+
+2004-10-26 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/vrf/utils.c: the path parsing regex was being freed,
+ but then not recompiled if needed again later. Was breaking some
+ efforts to open a second VRF datasource after the first was closed.
+
+ * README: slight improvements in build explanation.
+
+ * ogdi/contrib/ogdi_info/ogdi_info.c: minor improvements.
+
+2004-10-25 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf/vrfswq.c: fixed case of 1 character wide string
+
+ fields as per bug 809737.
+
+ * vpflib/vpfprim.c: Fixed bug in create_edge_rec() with getting
+ the left face id if it is in 'I' format, instead of 'K' format such
+ as occurs in the rference layer of VMAP0 products.
+
+ * ogdi/driver/vrf/utils.c: Use short for "buffint" variable. This is
+ the level number used in forming metadata. This corrects a complaint
+ noticed in valgrind. Likely to cause problems on big endian systems
+ as well (crazy level numbers).
+
+ * ogdi/driver/vrf/vrfswq.c: Fixed so that comparisons to string fields
+ longer than one character work. Fixed so that trailing spaces are
+ trimmed off string values read from disk before applying comparisons.
+
+2004-10-19 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/vrf/object.c: Fixed memory leak for line layers with
+ an attribute query in effect (primList) as reported by Jerome Waymel.
+
+2004-10-05 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/vrf/vrfswq.c: fixed memory leak.
+
+ * README: updated to reflect use of configure.
+
+=============================================================================
+
+2004-10-04 Frank Warmerdam <warmerdam at pobox.com>
+
+ * Release OGDI 3.1.3.
+
+2004-03-29 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/rpf/utils.c: Check for FSDEVG field is present in
+ TOC file. As per Bug 917678.
+
+2004-03-26 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/rpf/rpf.c: Fixed computation of nbfeature in
+ dyn_SelectRegion() as it is unduely sensitive to rounding error issues.
+ As per Bug 924250 from Mark Aubin.
+
+2004-02-19 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/vrf/vrf.c: fixed serious bug in releaseAllLayers().
+ Only every other layer was effectively being released resulting in
+ major leaks of file handles and other resources in application
+ accessing multiple layers at once and not explicitly releasing them.
+
+ * vpflib/musedir.c: added some include files to avoid warnings in
+ unix builds.
+
+ * ogdi/c-api/client.c: ecs_DestroyServer() now does an ecs_CleanUp() on
+ cln_dummy_result to avoid noisy memory leak.
+
+ * ogdi/drivers/vrf/feature.c: fixed leak of edge_rec.coords memory
+ in the bug 741854 fix in vrf_get_ring_coords().
+
+2004-02-18 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_info/ogdi_info.c: use ecs_CleanUp() to free contents
+ of result from cln_DestroyClient(). Minor memory leak.
+
+ * vpflib/strfunc.c: leftjust() - avoid use of strcpy() for overlapping
+ string moves. Reported by Craig Bruce, verified with valgrind.
+
+=============================================================================
+
+2003-12-15 Frank Warmerdam <warmerdam at pobox.com>
+
+ * Release OGDI 3.1.2.
+
+ * ogdi/include/ecs_util.h: updated version to 3.1.2.
+
+ * config/darwin.cfg: new configuration file for MacOS 10.3.
+
+ * vpflib/ coorgeom.c, vpfprim.c, vpftable.h, xvt.h:
+ Avoid use of obsolete values.h and malloc.h in order to compile
+ properly on MacOS 10.3. Submitted by Greg Allen.
+
+2003-08-27 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/c-api/ecssplit.c: Modififed ecs_SplitURL() to release
+ regular expression resources if called with a NULL url.
+
+ * ogdi/c-api/client.c: Modified cln_DestroyClient() to call
+ ecs_SplitURL(NULL) to free static resources.Well, go
+
+ * ogdi/drivers/adrg/utils.c: Fixed problem in _read_adrg(),
+ _read_overview(), and _initRegionWithDefault() such that the files
+ were never closed. As per bug 795612.
+
+ * ogdi/drivers/adrg/adrg.c: Fixed _releaseAllLayers() so it release
+ from the last layer to the first. It seems that ecs_FreeLayer()
+ now decrements the s->nblayers but didn't use to at some point in the
+ distant past. This bug was discovered while investigating the leaks
+ described in sourceforge bug 795612.
+
+2003-05-22 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf/feature.c, utils.c: Fixed several problems related
+ to bug 741854, primarily related to VITD area features causing hangs
+ and crashes.
+
+2003-01-29 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/include/ecs_util.h: fixed spelling of length in a few places.
+
+2002-12-18 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/include/ecs_util.h: If PI is undefined try to use M_PI. If
+ not available define with much more precision. As per bug report
+ from Craig Bruce.
+
+=============================================================================
+
+2002-03-28 Frank Warmerdam <warmerdam at pobox.com>
+
+ * OGDI 3.1.1 Release.
+
+ * external/zlib/*: Upgraded to zlib 1.1.4 to avoid widely publicized
+ security problem with zlib 1.1.3.
+
+2002-02-21 Frank Warmerdam <warmerdam at pobox.com>
+
+ * configure.in: Don't include /usr/local/lib in LIBS path, and
+ -I/usr/local/include in CFLAGS by default.
+
+ * contrib/mkbindist.sh: completed (also added README-BIN.TXT).
+
+ * contrib/ogdi_import/ogdi_import.c: fixed bug building with old
+ (included with OGDI) PROJ.4 library.
+
+ * ogdi/gltpd/{asyncsvr.c,ecs_svc.c}: Undefied svc_fdset if defined
+ to avoid dependence on recent libc on linux.
+
+2002-02-08 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_import/ogdi_import.c: Fixed serious bug importing
+ floating point fields with unknown precision.
+
+2001-12-14 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_info/ogdi_info.c: don't try to reproject to latlong
+ if already in latlong.
+
+2001-12-11 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_import/ogdi_import.c: fixed region handling if
+ GetLayerRegion() fails - default to global bounds.
+
+2001-11-13 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_import/ogdi_import.c: added -no-dict option.
+
+2001-10-17 Frank Warmerdam <warmerdam at pobox.com>
+
+ * README: Correct reference to devdir since it isn't normally
+ called that in a source release.
+
+2001-10-09 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_import/ogdi_import.c: added preliminary support for
+ setting the output (client) projection.
+
+2001-10-01 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_import/ogdi_import.c: various fixes related to region
+ overriding, and computing the size of the output raster.
+
+ * ogdi/c-api/client.c: fixed problems in cln_CalcCtlPoints() with
+ very small regions, equivelent to one pixel of data. Sometimes
+ produced a degenerate transformation.
+
+2001-09-28 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/include/ecs_util.h: Added the OGDI_VERSION and OGDI_RELEASEDATE
+ macros in ecs_util.h.
+
+2001-09-17 Frank Warmerdam <warmerdam at pobox.com>
+
+ * configure.in: don't add /usr/local/lib to LIBS by default. It
+ makes it hard to avoid using stuff from /usr/local.
+
+============================================================================
+
+2001-09-17 Frank Warmerdam <warmerdam at pobox.com>
+
+ * OGDI 3.0 Final Released
+
+2001-08-27 Frank Warmerdam <warmerdam at pobox.com>
+
+ * OGDI 3.1Beta2 Issued.
+
+ * ogdi/driver/rpf/rpf.c: Fixed computation of width and height in
+ GetRasterInfo(). Update test suite accordingly.
+
+ * vpflib/muse_dir.c: Fixed check for DOT_FOUND to only look in
+ the last component of the path, not the whole path, otherwise
+ directories with dots in them cause problems.
+
+ * external/expat/makefile: fixed declaration for WORDS_BIGENDIAN
+ macro.
+
+2001-08-16 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf: feature.c, vrf.h
+ Removed MAXRINGS and MAXSEGS limits. Arrays now dynamically grown.
+ See Bug 450045.
+
+ * ogdi/driver/vrf: vrf.c, vrf.h, object.c, feature.c:
+ added support for merging line features based on the relationship
+ implied by the join table (relating a set of primitive geometries
+ with one feature). This patch was submitted by Frank Warmerdam in
+ 1999. See bug 222422.
+
+ * ogdi/driver/vrf/utils.c: partially rewrite
+ vrf_build_coverage_capabilities() to avoid repeating entries and
+ to get rid of temp.
+
+ * ogdi/contrib/ogdi_import/ogdi_import.c: fixed roundoff
+ error in calcuation of xsize/ysize from region.
+
+ * ogdi/c-api/client.c: Modified cln_ConvRegion() to avoid roundoff
+ errors in initial computation of intwidth and intheight. As per
+ bug 450042.
+
+ * ogdi/driver/rpf/rpf.c: Ensure that only Image and Matrix types
+ are accepted by dyn_SelectLayer().
+
+2001-07-17 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/include/ecs_util.h: fixed case where DISABLE_CVSID is defined.
+
+ * contrib/ogdi_info/ogdi_info.c: fixed reporting of text layers.
+
+ * contrib/ogdi_import/ogdi_import.c: added support for writing
+ text, points and areas.
+
+2001-07-05 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf/utils.c: Fixed bug in vrf_GetMetadata() that resulted
+ in first layer of a class appearing twice in metadata. See SourceForge
+ bug 111181 originally reported by R.K.Beck at t-online.de to the
+ ogdi-dev list.
+
+
+2001-06-29 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf/utils.c: Fixed unterminated string.
+
+ * ogdi/driver/vrf/vrf.c: Fix memory leaks if FCS not found.
+
+2001-06-26 Frank Warmerdam <warmerdam at pobox.com>
+
+ * vpflib: musedir.h, musedir.c, vpfbrows.c, vpfspx.c, vpftable.c,
+ vpftidx.c - renamed file_open() to muse_file_open() to avoid conflicts
+ with FITS library.
+
+ * ogdi/driver/rpf/utils.c: implemented vrf_fopen_ci() for case
+ insensitive access to files.
+
+2001-06-25 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf: swq.c, vrfswq.c
+
+ Added WIN32 redifinition of strcasecmp() to stricmp().
+
+ * ogdi/driver/adrg/adrg.c:Made cleanup safer if verifyLocation() fails.
+
+2001-06-23 Frank Warmerdam <warmerdam at pobox.com>
+
+ * NEWS: added file.
+
+ * ogdi/driver/adrg: adrg.c, adrg.h
+
+ Added capabilities support. Cache layer list when opening datastore.
+
+2001-06-22 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_import/ogdi_import.c: enabled RGB support.
+
+ * ogdi/driver/adrg/ddadrg.tcl
+
+ new, came from DND.
+
+ * ogdi/driver/adrg: adrg.c, object.c, utils.c, adrg.h
+
+ Incorporated Image support from DND, added standard headers.
+
+ * ogdi/include/ecs_util.h: Fixed typo in ECS_SETGEOMIMAGEVALUE().
+
+2001-06-21 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf: added ECS_CVSID to all source files.
+
+2001-06-20 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf: vrf.c, swq.c, swq.h, vrf.h, makefile
+
+ Added full implementation of restricted_where support based on SWQ.
+ This adds brackets to expressions.
+
+2001-06-13 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf/*: Updated source headers.
+
+ * ogdi/c-api/ecs_capabililties.c, ogdi/driver/dted/dted.c,
+ ogdi/driver/vrf/util.c, ogdi/driver/rpf/rpf.c: Fixed capabilities
+ to match 6.2 spec (BoundingBox, resx, resy, LatLongBoundingBox).
+
+2001-05-30 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_import/ogdi_import.c: utilize layer capabitilies if
+ available to set region and resolution.
+
+ * ogdi/drivers/rpf/rpf.c: Modified capabilities returned to have real
+ information about each layer instead of just dummy global bounds info.
+
+2001-05-04 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/gdal: added contributed GDAL raster server.
+
+ * ogdi/c-api/client.c: clear autoCache in cln_SelectRegion().
+
+2001-04-19 Frank Warmerdam <warmerdam at pobox.com>
+
+ * contrib/ogdi_info/ogdi_info.c: improve region bounds reporting.
+
+ * external/expat: config.h, makefile: make portable
+
+ * external/expat/makefile, external/zlib/makefile: only create
+ a dynamic library, not a static one.
+
+ * external/expat/expat_ogdi.def: created.
+
+ * config/common.mak: make soft link from libogdi.so to libogdi31.so
+ during install.
+
+ * Updated test suite for dted/ecstile.c changes.
+
+ Collectively the following fix DTED bug 233252.
+
+ * ogdi/c-api/ecstile.c: fixed round off errors in calculation
+ of t->linelength, and placed coord.x/y at center of pixel instead of
+ the corner.
+
+ * ogdi/drvers/dted/object.c: moved pos_y to the middle of the
+ desired row. Generated errors in unsupported functions.
+
+ * ogdi/drivers/dted/dted.c: fixed bugs with computing nbfeature.
+
+2001-04-16 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/rpf/rpf.c: added capabilities support.
+
+ * makefile, ogdi/include/makefile: added special non-local install
+ rules for include files and creating target directories.
+
+ * config/common.mak, config/generic.mak.in: added non-local install
+ support (normally into /usr/local).
+
+2001-04-12 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/c-api/ogdi.def: added various capabilities related entry points.
+
+ * ogdi/c-api/ecsdist.c, ogdi/include/ecs_util.h:
+ Added ecs_GetPixelFromRGB() and ecs_GetRGBFromPixel().
+
+ * test_suite/scripts/rpf: added test for Image support.
+
+ * ogdi/drivers/rpf: rpf.c, rpf.h, object.c, utils.c
+
+ Applied DND Image support patches, and added source headers.
+
+ * ogdi/c-api: ecs_capabilities.c client.c
+ ogdi/include/ecs_util.h
+
+ Completed initial capabilities implemention in client.
+
+ * contrib/ogdi_info/ogdi_info.c: added capabilities and extension
+ dumping support.
+
+ * test_suite/scripts/dted, test_suite/scripts/vpf: added capture
+ of capabilities documents.
+
+ * configure, configure.in, config/generic.mak.in: added the ability
+ to substitute for zlib using configure options.
+
+ * ogdi/c-api/ecs_capabilities.c: initial implementation of
+ _ecs_ParseCapabilities(), still incomplete.
+
+ * ogdi/c-api/makefile: added ecs_capabilities.c
+
+ * ogdi/c-api/client.c: added support for initializing and freeing
+ new capabilities related fields in ecs_Client.
+
+ * ogdi/include/ecs_utils.h: added ecs_LayerCapabilities, and additions
+ to ecs_util.h.
+
+ * configure.in, configure, config/common.mak, config/generic.mak.in:
+
+ Added a support for linking in Expat, and controlling whether it is
+ internal, external or disabled from configure.
+
+ * external/expat/*: added using Expat release 1.95.1.
+
+ * external/makefile: optionally add expat to subdirs.
+
+2001-04-11 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/vrf: vrf.c, utils.c, vrf.h
+ Added ogdi_capabilities support.
+
+2001-04-10 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/dted/dted.c: add ogdi_capabilities support.
+
+ * contrib/ogdi_info/ogdi_info.c: added support for reporting Image
+ values.
+
+ * testsuite/scripts/dted: added Image test (test 3).
+
+ * ogdi/drivers/dted: dted.c, dted.h, object.c, utils.c
+
+ Upgraded with changes from DND to support Image layers. Patch
+ also includes change to exclude zero elevations when computing
+ mincat/maxcat. New style headers also applied.
+
+2001-04-09 Frank Warmerdam <warmerdam at pobox.com>
+
+ * config/win32.mak: Strip down DLL name to get .def name without
+ version.
+
+ * config/common.mak: added OGDI_VERSION declaration.
+
+ * external/zlib/makefile, ogdi/c-api/makefile:
+ Added OGDI_VERISION to .so / .dll filename.
+
+ * external/zlib: upgraded zlib to 1.1.3. Added OGDI_ZLIB.TXT to
+ describe issues about ZLIB use within OGDI.
+
+ * contrib/ogdi_info/ogdi_info.c: added -no-proj option. Fixed up
+ test suite to use this to avoid projection availability differences
+ on Unix and Windows.
+
+ * ogdi/c-api: client.c, ecs_dyna.c, ecs_xdrz.c, ecsdist.c, ecsgeo.c,
+ ecshash.c, ecsinfo.c, ecslist.c, ecsregex.c, ecssplit.c, ecstile.c,
+ gmath.c, gmath.h, opendir.c, opendir.h, server.c
+ ogdi/gltpd: asyncsvr.c, ecs_sif.c
+ ogdi/include/ecs_utils.h, ogdi/tcl_interface/ecs_tcl.c
+
+ Applied new source headers.
+
+2001-03-22 Frank Warmerdam <warmerdam at pobox.com>
+
+ * mkbindist.sh: frist attempt at binary distribution script.
+
+2001-03-11 Frank Warmerdam <warmerdam at pobox.com>
+
+ * include/win32: removed heapagnt.h, shmalloc.h, smrtheap.h,
+ AVDEFS.H, PAN.H, TARGET.H, avtypes.h, pafs.h, edat.h, portable.h,
+ product.h, proto.h, status_d.h. They were not used, and contained
+ problematic licenses.
+
+2001-02-20 Frank Warmerdam <warmerdam at pobox.com>
+
+ * proj/biveval.c: upgraded to code from PROJ.4.4.2 to avoid
+ bug in SGI compiler.
+
+ * ogdi/c-api/client.c: fixed cln_ConvRegion() bug, which was
+ screwing up region resolutions. Updated test_suite accordingly.
+
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=133190&group_id=11181
+
+2001-02-19 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/glutil/iofile.c: added stdlib.h to avoid warnings.
+
+ * vpflib/vpfprop.c, vpflib/vpftable.c: avoid unnecessary definition
+ of MAXINT or MAXSHORT.
+
+ * ogdi/c-api/ecs_dyna.c: use MISSING_DLFCN_H instead of _LINUX.
+
+ * vpflib/coorgeom.c: use MISSING_FLOAT_H flag.
+
+ * vpflib/include/machine.h: make unix platforms more generic.
+
+ * vpflib/makefile: pass BIG_ENDIAN flag into compiles.
+
+ * win32.mak: switch to BIG_ENDIAN, and add /DMISSING_DLFCN_H.
+
+ * Added configure, configure.in, aclocal, and config/generic.mak.in
+ as part of implementing "GNU configure" support for OGDI.
+
+ * config/common.mak: default TARGET based on $(shell uname).
+
+ * makefile: make compilation of proj conditional on PROJ_SETTING.
+
+ * restored compilation of ogdi/glutil, still used in some places.
+
+ * testsuite: added RPF test data, and script.
+
+ * ogdi/makefile: removed glutil from subdirs, it doesn't seem to
+ play a role in normal OGDI.
+
+ * mkogdidist.sh: added new file for making source distributions.
+
+2001-02-18 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/drivers/adrg: adrg.c adrg.h object.c utils.c
+ ogdi/drivers/dted: dted.c, object.c
+ ogdi/drivers/skeleton: skeleton.c, skeleton.h, open.c, object.c
+ ogdi/drivers/network/remote.c
+ ogdi/drivers/vrf: feature.c, object.c, open.c, vrf.c
+ ogdi/drivers/rpf: object.c, rpf.c, rpf.h, utils.c
+
+ Avoid unused argument and other warnings.
+
+ * ogdi/datum_driver/canada/dtcanada.c, ogdi/datum_driver/usa/dtusa.c
+ ogdi/c-api: client.c ecsgeo.c, ogdi/include/ecs_util.h
+ contrib/ogdi_info/ogdi_info.c
+
+ Fixed so that PROJ.4.4.x with projUV instead of UV will also work.
+
+ * */makefile: include explicit clean targets, and get rid of test
+ targets alltogether to avoid override messages from GNUmake.
+
+ * readme.sun: removed, adequately addressed in build.html.
+
+ * modif.txt: removed, and incorporated into ChangeLog.
+
+ * ogdi/gltpd: ecs_sif.c, asyncsvr.c
+ Cleanup lots of compiler warnings.
+
+2001-02-17 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/c-api: ecs_xdrz.c, ecshash.c ecstile.c server.c
+ Avoid compiler warnings about unused variables, and signed/unsigned
+ stuff.
+
+ * ogdi/c-api/makefile, ogdi/gltpd/makefile:
+ Disable running rpcgen unless explicitly requested due to problems.
+
+2001-02-07 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/vrf: vrf.c, utils.c
+ Fixed a variety of memory leak problems, partly based on contributions
+ from PCI, and Intergraph.
+
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=122434&group_id=11181
+
+ * vpflib/vpftable.c: Avoid problem in vpf_open_table() with mixture
+ of unix and dos style separators.
+
+ * ogdi/driver/dted/utils.c, dted.c: Fixed various memory leaks.
+
+ * ogdi/c-api/server.c: Modified svr_DestroyServer() to free
+ rasterconversion.coef.coef_val if non-null to fix memory leak.
+
+2001-02-02 Frank Warmerdam <warmerdam at pobox.com>
+
+ * ogdi/driver/rpf/utils.c: Fixed bug with lpriv->ff being freed
+ multiple times when it wasn't reinitialized to NULL in case of error.
+
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=130944&group_id=11181
+
+ * ogdi/driver/rpf/rpf.c: Fixed dyn_GetRasterInfo() to return proper
+ row/column values for current region. As per:
+
+ http://sourceforge.net/bugs/?func=detailbug&group_id=11181&bug_id=130943
+
+ * config/win32.mak: don't force debugtype to be coff.
+
+2001-01-09 Frank Warmerdam <warmerdam at pobox.com>
+
+ * Updated test scripts to support operating against a server
+ (OGDI_HOST), and updated to reflect the VRF bug fix.
+
+ * Fixed bug in reading and display of VALUE DESCRRIPTION TABLE's
+ in the vrf_Getmetadata() call of the vrf driver. See
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=128211&group_id=11181
+
+ * Renamed MAKEFILE to Makefile in external/rpc_win32/TEST, SERVICE,
+ and TEST.
+
+2000-11-23 Frank Warmerdam <warmerdam at pobox.com>
+
+ * Added DTED test scripts in test_suite/scripts/dted.
+
+ * Added contrib section with ogdi_info, and ogdi_import.
+
+2000-11-22 Frank Warmerdam <warmerdam at pobox.com>
+
+ * Fixed devdir/ogdi/drivers/dted/utils.c so that:
+ - closedir() is not called on dirlist2 if it was never opened.
+ - Removed a big chunk of #ifdef'ed out code.
+ - Ignore CVS directories.
+
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=123178&group_id=11181
+
+ * Modify the ECSRESULTTYPE, ECSRESULT, ECSGEOMTYPE, ECSGEOM,
+ ECSAREARING, ECSERROR, ECSSUCCESS, ECSEOF, ECSPROJ, ECSMESSAGE,
+ ECSREGION, ECSTEXT, ECSRASTERINFO, ECSRASTERINFONB, ECSRASTERINFOCAT,
+ ECSOBJECT, ECSOBJECTID, ECSOBJECTATTR, ECSRASTER,
+ ECS_SETGEOMBOUNDINGBOX, ECS_SETGEOMLINECOORD, ECS_SETGEOMMATRIXVALUE,
+ and ECS_SETGEOMIMAGEVALUE macros so they "protect" complex arguments.
+ The ECS_SET* macros were converted to subscoped statements.
+
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=122425&group_id=11181
+
+ * Added test_suite tree including some test data to CVS repository.
+ Note, this from the root, not under devdir.
+
+ * Added .cvsignore files marking off OBJ.* directories.
+
+2000-11-21 Frank Warmerdam <warmerdam at pobox.com>
+
+ * vpflib/vpftable.c: vpf_open_table() - memset() the table
+ structure to zero to ensure no fields are uninitialized thereby
+ causing problems in vpf_close_table()
+
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=123132&group_id=11181
+
+ * vpflib/vpftable.c: vpf_close_table() ... don't fclose(table->fp)
+ if it is NULL. This can occur if no features are selected (for
+ instance the wrong family type is used for a layer).
+
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=123132&group_id=11181
+
+ * Query strings passed to VRF driver with double quoted strings
+ wouldn't work properly (ie. contourl at elev(hqc="1")) because
+ one extra character was being eaten by code in vpflib/vpfquery.c.
+ Applied fix suggested by Duncan Chaundy (PCI).
+
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=122597&group_id=11181
+
+ * Added Ecs_tcl_Init() entry point in ecs_tcl.c. This
+ appears to be needed for Tcl8.x dynamic loading on Unix.
+
+ http://sourceforge.net/bugs/?func=detailbug&bug_id=123077&group_id=11181
+
+2000-11-10 Frank Warmerdam <warmerdam at pobox.com>
+
+ * Change Crown copyrigh back to LAS copyright, but with the same
+ rights of use and distributions as the crown copyright code.
+ ogdi/c-api: client.c, ecsdist.c, server.c
+ ogdi/attr_driver/odbc: odbc.c, makefile, odbc.h
+ ogdi/attr_drier: makefile
+ datum_driver: makefile
+ datum_driver/canada: dtcanada.c, makefile, nadconv.c, navconv.h,
+ sdms.c
+ datum_driver/usa: dtusa.c, makefile
+ external/rpc_win32/makefile
+ external/rpc_win32/LIBRPC/makefile
+ external/rpc_win32/RPCGEN/makefile
+ external/zlib/makefile
+ ogdi/driver/adrg: adrg.c, adrg.h, utils.c, object.c, makefile
+ ogdi/driver/dted: dted.c, dted.h, object.c, utils.c, makefile
+ ogdi/driver/network: makefile
+ ogdi/driver/rpf: makefile, rpf.c, utils.c, rpf.h
+ ogdi/driver/skeleton: makefile, skeleton.c, object.c, open.c,
+ skeleton.h, utils.c
+ ogdi/driver/vrf: feature.c, object.c, vrf.c, utils.c, open.c, vrf.h,
+ makefile
+ ogdi/gltp: makefile
+ ogdi/glutil: makefile
+ ogdi/include: ecs.x, ecs_util.h, makefile, ecs.h
+ ogdi/include/sun: ecs.h
+ ogdi/tcl_interface: ecs_tcl.c, makefile
+
+2000-11-09 Frank Warmerdam <warmerdam at pobox.com>
+
+ * remove files in the devdir/ogdi/doc directory. They are out of
+ date (ogdi.ps), and available from other places (proj.4). They also
+ add alot of heft to an ogdi cvs checkout.
+
+2000-11-02 Frank Warmerdam <warmerdam at pobox.com>
+
+ * Added LICENSE file summarizing licenses in effect in source tree.
+
+ * Change LAS copyright message to crown copyright on the following
+ files:
+ ogdi/c-api: client.c, ecsdist.c, server.c
+ ogdi/attr_driver/odbc: odbc.c, makefile, odbc.h
+ ogdi/attr_drier: makefile
+ datum_driver: makefile
+ datum_driver/canada: dtcanada.c, makefile, nadconv.c, navconv.h,
+ sdms.c
+ datum_driver/usa: dtusa.c, makefile
+ external/rpc_win32/makefile
+ external/rpc_win32/LIBRPC/makefile
+ external/rpc_win32/RPCGEN/makefile
+ external/zlib/makefile
+ ogdi/driver/adrg: adrg.c, adrg.h, utils.c, object.c, makefile
+ ogdi/driver/dted: dted.c, dted.h, object.c, utils.c, makefile
+ ogdi/driver/network: makefile
+ ogdi/driver/rpf: makefile, rpf.c, utils.c, rpf.h
+ ogdi/driver/skeleton: makefile, skeleton.c, object.c, open.c,
+ skeleton.h, utils.c
+ ogdi/driver/vrf: feature.c, object.c, vrf.c, utils.c, open.c, vrf.h,
+ makefile
+ ogdi/gltp: makefile
+ ogdi/glutil: makefile
+ ogdi/include: ecs.x, ecs_util.h, makefile, ecs.h
+ ogdi/include/sun: ecs.h
+ ogdi/tcl_interface: ecs_tcl.c, makefile
+
+2000-10-29 Frank Warmerdam <warmerdam at pobox.com>
+
+ * Made config/mkinstalldirs executable.
+
+ * Added config/linux.mak.
+
+ * Added ChangeLog file.
+
+ * Imported OGDI 3.0 Beta into CVS.
+
+------------------------------------------------------------------------------
+
+OGDI 3.0 beta
+
+Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+Files changed: devdir\ogdi\c-api\client.c
+ devdir\ogdi\c-api\server.c
+ devdir\ogdi\driver\skeleton\skeleton.c
+ devdir\ogdi\driver\skeleton\skeleton.h
+ devdir\ogdi\include\ecs_util.h
+ devdir\ogdi\makefile
+ devdir\ogdi\driver\makefile
+ devdir\ogdi\examples\example2\example2.c
+ devdir\ogdi\examples\example2\makefile
+
+Files removed: devdir\ogdi\ogdi.def
+ devdir\ogdi\c-api\ecs.def
+ devdir\ogdi\driver\network\libremote.def
+
+Files added: devdir\ogdi\examples\example2\example2.c
+ devdir\ogdi\examples\example2\makefile
+ devdir\ogdi\ogdi\driver\skeleton\datadict.h
+
+
+Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+Remarks: -The function svr_BroadCloseLayers() in server.c seems to be useless and
+ it contains the following errors:
+ The argument to ecs_OpenDynamicLib should be "ogdi" instead of "ecs".
+ The argument passed to ecs_CloseDynamicLib() should be "handle" instead of "func".
+ Also, this function does nat have to load the cln_BroadCloseLayer because both
+ svr_BroadCloseLayers() and cln_BroadCloseLayers() are in the same library.
+ -The function cln_BroadCloseLayers() in client.c seems to be useless.
+ -To conclude, I suggest to remove svr_BroadCloseLayers() and cln_BroadCloseLayers() from the core.
+
+ -Both example1 and example2 directories contain example1.c and the makefile to build this example.
+ To correct the error, I took the makefile and the example2.c file from the previous core and I copied
+ them in the example2 directory of the present core.
+
+ -The file datadict.h was missing to build the skeleton driver. I took the one from the previous core.
Added: packages/ogdi-dfsg/branches/upstream/current/HOWTO-RELEASE
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/HOWTO-RELEASE 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/HOWTO-RELEASE 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,43 @@
+ Notes on Preparing an OGDI Source Release
+ =========================================
+
+1) Ensure the OGDI_VERSION and OGDI_RELEASEDATE values are up to date in
+ ogdi/include/ecs_utils.h.
+
+2) Update OGDI_MINOR OGDI_MAJOR and OGDI_VERSION in configure.in for
+ proper soname versioning of libraries. Run autoconf to regenerate
+ configure script.
+
+3) Do complete test builds on several platforms - at least Linux,
+ Solaris, and Windows NT.
+
+4) Run testsuite on these platforms.
+
+5) Add release notice in devdir/ChangeLog.
+
+6) Update the NEWS file based on a digested form of the ChangeLog file.
+
+7) If this is a major public release, apply a tag to the source for
+ the release. Normally tags are not incorporated for alpha and beta
+ releases to avoid tag pollution.
+
+ ie.
+
+ cd devdir
+ cvs tag ogdi_3_1_0
+
+8) Create the source distributions using the mkogdidist.sh script. The
+ version name should include subrelease name components as appropriate.
+ Hit enter when prompted for a CVS password.
+
+ ie.
+ cd devdir
+ mkogdidist.sh 3.1beta2
+
+9) Publish the resulting files. For public (ie. final) releases they should
+ be put up on the SourceForge file download manager area.
+
+ <fill in details>
+
+10) Announce release. For public releases announce to ogdidev mailing list,
+ and on Freshmeat.net.
Added: packages/ogdi-dfsg/branches/upstream/current/LICENSE
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/LICENSE 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/LICENSE 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,288 @@
+
+
+Much of OGDI is implicitly or explicitly under the following
+two licenses (year varies a bit):
+
+ Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+or
+
+ Copyright (C) 1997 Her Majesty the Queen in Right of Canada.
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of Her Majesty the Queen
+ in Right of Canada not be used in advertising or publicity pertaining
+ to distribution of the software without specific, written prior
+ permission. Her Majesty the Queen in Right of Canada makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+New files written by 3i are under this copyright:
+
+ Copyright (C) 2001 Information Interoperability Institute (3i)
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of 3i not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. 3i makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+
+===============================================================================
+
+ogdi/c-api/ecshash.c is:
+
+ * Copyright (c) 1991-1993 The Regents of the University of California.
+ * Copyright (c) 1994 Sun Microsystems, Inc.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+===============================================================================
+
+ogdi/c-api/ecsregex.c is:
+
+ * Copyright (c) 1986 by University of Toronto.
+ * Written by Henry Spencer. Not derived from licensed software.
+ *
+ * Permission is granted to anyone to use this software for any
+ * purpose on any computer system, and to redistribute it freely,
+ * subject to the following restrictions:
+ *
+ * 1. The author is not responsible for the consequences of use of
+ * this software, no matter how awful, even if they arise
+ * from defects in it.
+ *
+ * 2. The origin of this software must not be misrepresented, either
+ * by explicit claim or by omission.
+ *
+ * 3. Altered versions must be plainly marked as such, and must not
+ * be misrepresented as being the original software.
+
+===============================================================================
+
+ogdi/c-api/marix.c is:
+
+ * A public domain implementation.
+ *
+ * Author: Balint Cristian <cbalint at redhat.com>
+ *
+ * matrix invert code derivate from GRASS project (< 4.0 version):
+ * http://grass.itc.it/
+ * http://en.wikipedia.org/wiki/Invertible_matrix
+ *
+ * * matrix multiply algorithm:
+ * http://en.wikipedia.org/wiki/Matrix_multiplication
+ *
+ * * matrix transpose algorithm:
+ * http://en.wikipedia.org/wiki/Transpose
+
+===============================================================================
+
+ogdi/c-api/opendir.c/h is:
+ * @(#)dir.c 1.4 87/11/06 Public Domain.
+ *
+ * A public domain implementation of BSD directory routines for
+ * MS-DOS. Written by Michael Rendell ({uunet,utai}michael at garfield),
+
+===============================================================================
+
+include/win32/unistd.h:
+ * Copyright (c) 1994 Software Research Associates, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Software Research Associates not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Software Research
+ * Associates makes no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+
+===============================================================================
+
+include/win32/rpc/auth.h (and others):
+/*********************************************************************
+ * RPC for the Windows NT Operating System
+ * 1993 by Martin F. Gergeleit
+ * Users may use, copy or modify Sun RPC for the Windows NT Operating
+ * System according to the Sun copyright below.
+ *
+ * RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
+ * WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
+ * USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
+ *********************************************************************/
+
+/* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part. Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+
+===============================================================================
+
+proj/*:
+
+Public Domain.
+
+===============================================================================
+
+vpflib/*:
+
+ The vpflib library contains the public domain VPFVIEW C code included
+with the Digital Chart of the World, Edition 1, which was pruned and ported
+to work on "POSIX"-like systems.
+
+NIMA's LICENSE Disclaimer of VPFVIEW C source code:
+
+/**********************************************************************************
+/* U.S. National Imagery and Mapping Agency -- UNCLASSIFIED --
+ *
+ * VPFView 2.1 Distribution - Source Code Disclaimer:
+ *
+ * 1. The VPFView source code ("the software") is provided free of charge via the
+ * Internet by the National Imagery and Mapping Agency (NIMA) of the United States
+ * Department of Defense. Although NIMA makes no copyright claim under Title 17
+ * U.S.C.,NIMA claims copyrights in the source code under other legal regimes. NIMA
+ * hereby grants to each user of the software a license to use and distribute the
+ * software, and develop derivative works.
+ *
+ * 2. Warranty Disclaimer: The software was developed to meet only the internal
+ * requirements of the U.S. National Imagery and Mapping Agency. The software
+ * is provided "as is," and no warranty, express or implied, including but not
+ * limited to the implied warranties of merchantability and fitness for particular
+ * purpose or arising by statute or otherwise in law or from a course of dealing
+ * or usage in trade, is made by NIMA as to the accuracy and functioning of the
+ * software.
+ *
+ * 3. NIMA and its personnel are not required to provide technical support or general
+ * assistance with respect to the software.
+ *
+ * 4. Neither NIMA nor its personnel will be liable for any claims, losses, or
+ * damages arising from or connected with the use of the software. The user agrees
+ * to hold harmless the United States National Imagery and Mapping Agency. The user
+ * Is sole and exclusive remedy is to stop using the software.
+ *
+ * 5. NIMA requests that products developed using the software credit the source of
+ * the software with the following statement, "The product was developed using VPFView,
+ * a product of the National Imagery and Mapping Agency."
+ *
+ * 6. For any products developed using the software, NIMA requires a disclaimer that
+ * use of the software does not indicate endorsement or approval of the product by
+ * the Secretary of Defense or the National Imagery and Mapping Agency. Pursuant to
+ * the United States Code, 10 U.S.C. ß 2797, the name of the National Imagery and
+ * Mapping Agency, the initials "NIMA", the seal of the National Imagery and
+ * Mapping Agency, or any colorable imitation thereof shall not be used to imply
+ * approval, endorsement, or authorization of a product without prior written
+ * permission from United States Secretary of Defense.
+ *
+ */
+
+===============================================================================
+
+external/rpc_win32/*/*:
+
+/*********************************************************************
+ * RPC for the Windows NT Operating System
+ * 1993 by Martin F. Gergeleit
+ * Users may use, copy or modify Sun RPC for the Windows NT Operating
+ * System according to the Sun copyright below.
+ *
+ * RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
+ * WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
+ * USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
+ *********************************************************************/
+
+/* @(#)svc.c 2.4 88/08/11 4.0 RPCSRC; from 1.44 88/02/08 SMI */
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part. Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+ */
+
+===============================================================================
+
+external/zlib/*:
+
+ Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly Mark Adler
+ gzip at prep.ai.mit.edu madler at alumni.caltech.edu
Added: packages/ogdi-dfsg/branches/upstream/current/NEWS
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/NEWS 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/NEWS 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,139 @@
+ OGDI 3.x Core News
+ ==================
+
+View the ChangeLog file for detailed, file by file notes on changes. The
+NEWS file is just used to sumarize major changes, and new features.
+
+3.2.0beta1
+==========
+
+ o Fix 64 bit platforms.
+ o Fix malloc/free problem in rpf.c
+
+3.1.6
+=====
+
+ o Hide internal plugin objects from system libs path on unixes.
+
+ o Release versioning using soname of libogdi shared library.
+
+ o Clean up tons of compiler warnings over GCC.
+
+3.1.5
+=====
+
+ o Fixed serious bugs with untiled VPF products (like rference layer in VMAP0)
+
+ o Fixed a few minor memory leaks, and at least one major one in VPF driver
+ when using query expression.
+
+ o Fixed serious bug in VPF reader when reader is re-loaded after one use.
+
+ o Fixed several other issues in VPF driver.
+
+
+3.1.4
+=====
+
+ o Fixed bug in VRF driver when one client connection is closed and another
+ opened.
+
+ o Fixed severe problems with VRF driver and selection expressions for string
+ fields.
+
+ o Fixed severe problem composing area polygons from non-tiled VRF datastores
+ (such as VMAP0 rference layer).
+
+ o Fixed additional memory leaks.
+
+ o Improvements in README for how to build on Unix and windows.
+
+
+3.1.3
+=====
+
+ o Fixed major leak in VPF driver.
+
+ o Support TOC files without FSDEVG field.
+
+ o Fixed rounding error in computing "nbfeature" in RPF driver (rounding issue)
+
+ o Assorted other minor bug fixes, and memory leak cleanup.
+
+
+3.1.2
+=====
+
+ o Minor fixes for MacOS 10.3 support (older versions of MacOS won't work
+ easily)
+
+ o Fixed minor memory leaks in core.
+
+ o Fixed major file handle leak in ADRG driver.
+
+ o Fixed bugs in VPF driver, especially for VITD datasets.
+
+
+3.1.1
+=====
+
+ o Upgraded to ZLIB 1.1.4 to avoid buffer overflow security risk in zlib 1.1.3.
+
+ o Various bugs fixed, and improvements to ogdi_info, and ogdi_import
+ utilities.
+
+ o Fixed problems in cln_CalcCtlPoints() with very small regions, equivelent
+ to one pixel of data. Sometimes produced a degenerate transformation.
+
+ o Added OGDI_VERSION and OGDI_RELEASEDATE macros in ecs_util.h.
+
+
+3.1.0
+=====
+
+Essentially the same as 3.1Beta1.
+
+
+3.1Beta1
+========
+
+ o Implement support for XML Capabilities (as per Proposal 6: Capabilities
+ Metadata). This includes:
+
+ - Added support for reaturning correct capabilities to adrg, dted, rpf
+ and vpf drivers.
+
+ - Added support for parsing capabilities documents, in libogdi utilizing
+ Expat (incorporated into the source tree under devdir/external).
+
+ - Added public client side API for accessing capabilities and version
+ information (cln_GetLayerCapabilities(), cln_GetVersion()).
+
+ o Upgraded VPF driver to support brackets in query expression. Implemented
+ using generic "restricted_where" processor (swq.c).
+
+ o Upgraded ADRG, RPF and DTED drivers to support Image (as well as Matrix)
+ family support based on updates supplied by DND.
+
+ o Added contributed GDAL raster driver as contrib/gdal.
+
+ o Updated zlib in external/zlib to 1.1.3.
+
+ o Embed version number in OGDI shared libraries (eg. libogdi31.so).
+
+
+3.1Alpha
+========
+
+ o Incorporated contrib/ogdi_import, and contrib/ogdi_info sample applications.
+
+ o Updated build system to include configure script, install target, and
+ various cleanups and simplifications. RPCGEN is no longer run by default.
+ External versions of libz and PROJ.4 can be utilized.
+
+ o Updated licenses within source code to reflect the redistributable nature
+ of code written by LAS on contract to DND.
+
+ o Variety of bug fixes, primarily to drivers.
+
+ o Remove warnings during build from core code.
Added: packages/ogdi-dfsg/branches/upstream/current/README
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/README 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/README 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,95 @@
+
+ OGDI README
+ ===========
+
+
+OGDI developer and user resources can be found online at:
+
+ http://ogdi.sourceforge.net/
+
+
+Building
+========
+
+Detailed building instructions are available at:
+
+ http://ogdi.sourceforge.net/build.html
+
+Unix
+----
+
+1) Set TOPDIR to point to the home directory of the OGDI source tree.
+
+ eg.
+ TOPDIR=/usr/ogdi-3.1.3
+ export TOPDIR
+
+2) Run configure.
+
+ eg.
+ ./configure
+
+3) Build with make (GNUmake is required).
+
+ make
+
+ NOTE: on some platforms you will need to add the shared libraries to
+ your LD_LIBRARY_PATH for the link phase to complete.
+
+ eg.
+
+ LD_LIBRARY_PATH=$TOPDIR/bin/Linux
+ export LD_LIBRARY_PATH
+
+4) Install.
+
+ make install
+
+Windows
+-------
+
+Windows works similarly, but a preset configuration is used instead of
+building one with configure.
+
+Requirements:
+ o Cygwin (build shell) from http://www.cygwin.com/
+ o Microsoft Visual C++ 6.x (make sure it works at the commandline from bash,
+ run VCVARS32.BAT if not).
+
+1) Set TOPDIR to point to the home directory of the OGDI source tree.
+
+ eg.
+ TOPDIR=c:/ogdi-3.1.3
+ export TOPDIR
+
+2) Set the target build configuration
+
+ eg.
+ TARGET=win32
+ export TARGET
+
+3) Build with make.
+
+ make
+
+
+Running
+=======
+
+Briefly, ensure that $TOPDIR/bin/$TARGET is in the path. Ensure that
+$TOPDIR/bin/$TARGET is in the LD_LIBRARY_PATH on Unix.
+
+To use in local mode try a command like:
+
+ ogdi_info -u gltp:/dted/d:/toronto/dted -f Matrix -l 'DTED(DISK)' -dl
+
+To use via the server, run gltpd.exe first in the background. On windows, run
+portmap.exe before running gltpd.exe. Then use a command like:
+
+ ogdi_info -u gltp://localhost/dted/d:/toronto/dted -f Matrix -l 'DTED(DISK)' -dl
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/README-BIN.TXT
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/README-BIN.TXT 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/README-BIN.TXT 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,100 @@
+ OGDI README for Binary (Executable) Distribution
+ ================================================
+
+Source Version: @VERSION@
+Platform: @PLATFORM@
+
+Manifest
+--------
+
+This tree (ogdi- at PLATFORM@-bin. at VERSION@) contains a binary distribution
+of OGDI @VERSION@ for the @PLATFORM@ system (note that win32 includes Windows
+98, NT, 2000 and XP). This distribution includes ready to run executables
+along with shared libraries suitable for linking other applications against.
+On Windows it includes DLLs and stub libraries for linking against. As well,
+all include files required for development against the client are included.
+
+ogdi- at PLATFORM@-bin. at VERSION@/bin/*:
+ - shared libraries (unix) or DLLs (windows).
+ - executable for gltpd (OGDI gltp server).
+ - executables for portmapper daemon (windows only)
+ - executables for sample client programs including:
+ o ogdi_import: Translate OGDI vectors to shapefiles and rasters to
+ raw binary.
+ o ogdi_info: Dump information about, and contents of OGDI datastore
+ in text format to the terminal window.
+
+ogdi- at PLATFORM@-bin. at VERSION@/include/*:
+ - all include files needed for client development
+
+ogdi- at PLATFORM@-bin. at VERSION@/lib/*:
+ - client stub libraries for dlls (windows only)
+
+Setup on Unix
+-------------
+
+Generally speaking it is necessary to add the ogdi- at PLATFORM@-bin. at VERSION@/bin
+directory to the executable path, and the shared library path. This can
+often be accomplished with commands like this (assuming the distribution
+is unpacked under the users home directory):
+
+C-Shell:
+ % setenv PATH $PATH:$HOME/ogdi- at PLATFORM@-bin. at VERSION@/bin
+ % setenv LD_LIBRARY_PATH $HOME/ogdi- at PLATFORM@-bin. at VERSION@/bin
+
+Bourne Shell:
+ % PATH=${PATH}:$HOME/ogdi- at PLATFORM@-bin. at VERSION@/bin
+ % LD_LIBRARY_PATH=$HOME/ogdi- at PLATFORM@-bin. at VERSION@/bin
+ % export LD_LIBRARY_PATH
+
+If it is desirable to "install" the programs they can usually be copied
+to a central shared directory something like this:
+
+ % cp ogdi- at PLATFORM@-bin. at VERSION@/bin/*.so /usr/local/lib
+ % cp ogdi- at PLATFORM@-bin. at VERSION@/bin/{gltpd,ogdi_import,ogdi_info} /usr/local/lib
+
+To develop a client program it should be sufficient to add the
+include directory to the include path, and the bin directory to the link
+path along with the main client library.
+
+eg.
+ % gcc -I$HOME/ogdi- at PLATFORM@-bin. at VERSION@/include myclient.c \
+ -L$HOME/ogdi- at PLATFORM@-bin. at VERSION@/bin -logdi31 -ldl -lm
+
+
+Setup on Windows
+----------------
+
+OGDI Client programs can be run directly from the ogdi- at PLATFORM@-bin. at VERSION@/bin
+directory from a command window, or this directory can be added to the
+search path. At the DOS command prompt the directory can be added to the
+path using a statement like the following (assuming the distribution was
+unpacked under C:\):
+
+ C:\> SET PATH=%PATH%;C:\ogdi- at PLATFORM@-bin. at VERSION@\bin
+
+Before running gltpd.exe (the OGDI server) it is necessary to run portmap.exe.
+The portmap.exe program providers "port mapper" services necessary for the RPC
+protocol used by gltpd.
+
+To develop code it is generally necessary to add the
+C:\ogdi- at PLATFORM@-bin. at VERSION@\include directory to the include path. This
+can be accomplished with the -IC:\ogdi- at PLATFORM@-bin. at VERSION@/include
+directive in NMAKE files, or in the preprocessor tab of the Visual Studio
+options.
+
+On windows applications should be linked against the
+C:\ogdi- at PLATFORM@-bin. at VERSION@\lib\ogdi31.lib file.
+
+More Information
+----------------
+
+For more information on OGDI, access to the OGDI source visit:
+
+ http://ogdi.sourceforge.net/
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/VERSION
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/VERSION 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/VERSION 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1 @@
+3.2.0.beta1: Sat Feb 24 18:49:04 CET 2007
Added: packages/ogdi-dfsg/branches/upstream/current/aclocal.m4
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/aclocal.m4 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/aclocal.m4 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,95 @@
+AC_DEFUN(AC_COMPILER_WFLAGS,
+[
+ # Remove -g from compile flags, we will add via CFG variable if
+ # we need it.
+ CXXFLAGS=`echo "$CXXFLAGS " | sed "s/-g //"`
+ CFLAGS=`echo "$CFLAGS " | sed "s/-g //"`
+
+ # check for GNU compiler, and use -Wall
+ if test "$GCC" = "yes"; then
+ C_WFLAGS="-Wall"
+ AC_DEFINE(USE_GNUCC)
+ fi
+ if test "$GXX" = "yes"; then
+ CXX_WFLAGS="-Wall"
+ AC_DEFINE(USE_GNUCC)
+ fi
+ AC_SUBST(CXX_WFLAGS,$CXX_WFLAGS)
+ AC_SUBST(C_WFLAGS,$C_WFLAGS)
+])
+
+AC_DEFUN(AC_COMPILER_PIC,
+[
+ echo 'void f(){}' > conftest.c
+ if test -z "`${CC-cc} -fPIC -c conftest.c 2>&1`"; then
+ C_PIC=-fPIC
+ else
+ C_PIC=
+ fi
+ if test -z "`${CXX-g++} -fPIC -c conftest.c 2>&1`"; then
+ CXX_PIC=-fPIC
+ else
+ CXX_PIC=
+ fi
+ rm -f conftest*
+
+ AC_SUBST(CXX_PIC,$CXX_PIC)
+ AC_SUBST(C_PIC,$C_PIC)
+])
+
+dnl
+dnl Try to find something to link shared libraries with. Use "c++ -shared"
+dnl in preference to "ld -shared" because it will link in required c++
+dnl run time support for us.
+dnl
+AC_DEFUN(AC_LD_SHARED,
+[
+ echo 'void g(); int main(){ g(); return 0; }' > conftest1.c
+
+ echo 'void g(); void g(){}' > conftest2.c
+ ${CC} ${C_PIC} -c conftest2.c
+
+ LD_SHARED="/bin/true"
+ if test -z "`${CXX} -shared conftest2.o -o libconftest.so 2>&1`" ; then
+ if test -z "`${CC} conftest1.c libconftest.so -o conftest1 2>&1`"; then
+ LD_LIBRARY_PATH_OLD="$LD_LIBRARY_PATH"
+ LD_LIBRARY_PATH="`pwd`"
+ export LD_LIBRARY_PATH
+ if test -z "`./conftest1 2>&1`" ; then
+ echo "checking for ${CXX} -shared ... yes"
+ LD_SHARED="${CXX} -shared"
+ else
+ echo "checking for ${CXX} -shared ... no(3)"
+ fi
+ LD_LIBRARY_PATH="$LD_LIBRARY_PATH_OLD"
+ else
+ echo "checking for ${CXX} -shared ... no(2)"
+ fi
+ else
+ echo "checking for ${CXX} -shared ... no(1)"
+ fi
+
+ if test "$LD_SHARED" = "/bin/true" \
+ -a -z "`ld -shared conftest2.o -o libconftest.so 2>&1`" ; then
+ if test -z "`${CC} conftest1.c libconftest.so -o conftest1 2>&1`"; then
+ LD_LIBRARY_PATH_OLD="$LD_LIBRARY_PATH"
+ LD_LIBRARY_PATH="`pwd`"
+ export LD_LIBRARY_PATH
+ if test -z "`./conftest1 2>&1`" ; then
+ echo "checking for ld -shared ... yes"
+ LD_SHARED="ld -shared"
+ fi
+ LD_LIBRARY_PATH="$LD_LIBRARY_PATH_OLD"
+ fi
+ fi
+
+ if test "$LD_SHARED" = "/bin/true" ; then
+ echo "checking for ld -shared ... no"
+ fi
+ rm -f conftest* libconftest*
+
+ AC_SUBST(LD_SHARED,$LD_SHARED)
+])
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/config/Linux.mak
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/Linux.mak 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/Linux.mak 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,109 @@
+# Copyright (C) 2001 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+# Generic unix configuration file, processed by configure to make
+# platform specific.
+
+#
+# Read in the configuration common to all Unix
+#
+include $(TOPDIR)/config/unix.mak
+
+#
+# platform specific Symbols
+#
+PLATFORM = $(TARGET)
+_SOLARIS = 1
+USE_TERMIO = -DUSE_TERMIO
+
+#
+# platform specific tools
+#
+AR = ar cr
+
+
+#
+# Compilation and linking flags
+#
+SHLIB_CFLAGS = -fPIC
+COMMON_CFLAGS = $(OPTIMIZATION) -Wall -Wall -DUNIX=1
+
+SHLIB_LDFLAGS = -shared
+COMMON_LDFLAGS = $(OPTIMIZATION)
+
+RPC_INCLUDES = -DHAVE_STD_RPC_INCLUDES
+
+UCB_STATICLIB =
+
+TCL_INCLUDE = -I/usr/include/tcl8.3
+TCL_LINKLIB =
+
+#
+# Install Locations
+#
+prefix = /usr
+exec_prefix = ${prefix}
+INST_INCLUDE = ${prefix}/include
+INST_LIB = ${exec_prefix}/lib
+INST_BIN = ${exec_prefix}/bin
+
+#
+# platform specific file locations
+#
+#RPC_LINKLIB = -lrpcsvc -lnsl -lsocket
+#RPC_LINKLIB = -ldl -ldbmalloc
+RPC_LINKLIB = -ldl
+
+#
+# Endian definition, could be little or big
+#
+BIG_ENDIAN = 0
+
+#
+# Handle internal/external PROJ.4 library usage.
+#
+
+PROJ_SETTING=external
+
+ifeq ($(PROJ_SETTING),external)
+PROJ_INCLUDE := -I/usr/include
+PROJ_STATICLIB := -lproj
+endif
+
+#
+# Handle internal/external ZLIB library usage.
+#
+
+ZLIB_SETTING=external
+
+ifeq ($(ZLIB_SETTING),external)
+ZLIB_INCLUDE := -I/usr/include
+ZLIB_LINKLIB := -lz
+endif
+
+#
+# Handle internal/external/disabled "Expat" library handling.
+#
+
+EXPAT_SETTING=external
+
+ifeq ($(EXPAT_SETTING),external)
+EXPAT_INCLUDE := -I/usr/include
+EXPAT_LINKLIB := -lexpat
+endif
+
+ifeq ($(EXPAT_SETTING),disabled)
+EXPAT_INCLUDE := -DEXPAT_DISABLED
+EXPAT_LINKLIB :=
+endif
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/config/common.mak
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/common.mak 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/common.mak 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,277 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+# Release versioning.
+#
+# MAJOR releases represent major ABI changes in the exposed shared lib.
+# This should not be so offen, only once with major code change wich due
+# to a change in how ogdi is called external by other applications.
+#
+# MINOR releases represents revisions or bugfixes over ogdi.
+#
+# The exposed soname of lib is libogdi.so.($major) an lies in $(INST_LIB)
+# Plugins lies in $(INST_LIB)/ogdi/
+#
+
+OGDI_MAJOR = 3
+OGDI_MINOR = 2
+
+OGDI_VERSION = $(OGDI_MAJOR)$(OGDI_MINOR)
+
+# Common macros and symbols used by all platforms
+#
+#
+#
+# !!! IMPORTANT !!!
+#
+# $TARGET and $TOPDIR must be defined in the environment
+#
+# - $TARGET is the platform on which you compile;
+# it could be 'solaris' or 'win32'
+# - $TOPDIR is the root directory of OGDI source files
+#
+#
+
+
+#
+# Default definitions
+#
+
+ifndef CFG
+CFG = release
+endif
+
+ifndef TARGET
+TARGET = $(shell uname)
+endif
+
+#
+# Standard location of external components (not maintained
+# by LAS)
+#
+
+
+#
+# Standard location of compiled component libraries
+#
+
+BINDIR = $(TOPDIR)/bin/$(TARGET)
+LIBDIR = $(TOPDIR)/lib/$(TARGET)
+
+#
+# Final OS installation location.
+#
+prefix = /usr/local
+exec_prefix = ${prefix}
+INST_INCLUDE = ${prefix}/include
+INST_LIB = ${exec_prefix}/lib
+INST_BIN = ${exec_prefix}/bin
+
+#
+# A location named $(LINKDIR) will be defined in the system
+# specific configuration files. Under win32 this will point
+# to the location of the export libs $(LIBDIR), but under
+# Unix it is the location of the shared objects $(BINDIR).
+#
+
+#
+# Standard location of software components.
+#
+
+CURRENT_DIR = ./
+VPF_DIR = $(topdir)/vpflib
+
+#
+# The following can be internal or external depending on whether we
+# want to use the built-in versions of these libraries.
+#
+EXPAT_SETTING = internal
+ZLIB_SETTING = internal
+PROJ_SETTING = internal
+
+#
+# Standard location of include files.
+#
+
+CURRENT_INCLUDE = $(patsubst %,$(INCL_SW)%,$(subst :, ,$(VPATH)))
+GENERAL_INCLUDE = $(INCL_SW)$(TOPDIR)/include/$(TARGET)
+
+
+OGDI_INCLUDE = $(INCL_SW)$(TOPDIR)/ogdi/include
+VRF_INCLUDE = $(INCL_SW)$(TOPDIR)/ogdi/driver/vrf
+PROJ_INCLUDE = $(INCL_SW)$(TOPDIR)/proj
+VPF_INCLUDE = $(INCL_SW)$(TOPDIR)/vpflib/include $(INCL_SW)$(TOPDIR)/vpflib
+ZLIB_INCLUDE = $(INCL_SW)$(TOPDIR)/external/zlib
+GLUTIL_INCLUDE = $(INCL_SW)$(TOPDIR)/ogdi/glutil
+EXPAT_INCLUDE = $(INCL_SW)$(TOPDIR)/external/expat
+
+#
+# Dynamic libraries (shared objects)
+#
+
+ODBCEXT_LINKLIB = $(LINK_SW)$(LINKDIR)$(LIB_SW)odbcext$(LIB_SUFFIX)
+OGDI_LINKLIB = $(LINK_SW)$(LINKDIR)$(LIB_SW)ogdi$(LIB_SUFFIX)
+ZLIB_LINKLIB = $(LINK_SW)$(LINKDIR)$(LIB_SW)zlib_ogdi$(OGDI_VERSION)$(LIB_SUFFIX)
+EXPAT_LINKLIB = $(LINK_SW)$(LINKDIR)$(LIB_SW)expat_ogdi$(OGDI_VERSION)$(LIB_SUFFIX)
+
+#
+# Static libraries (archives)
+#
+
+PROJ_STATICLIB = $(LINK_SW)$(LIBDIR)/static$(LIB_SW)proj$(LIB_SUFFIX)
+VPF_STATICLIB = $(LINK_SW)$(LIBDIR)/static$(LIB_SW)vpf$(LIB_SUFFIX)
+REMOTE_STATICLIB = $(LINK_SW)$(LIBDIR)/static$(LIB_SW)remote$(LIB_SUFFIX)
+GLUTIL_STATICLIB = $(LINK_SW)$(LIBDIR)/static$(LIB_SW)glutil$(LIB_SUFFIX)
+
+
+#
+# Library aggregations
+#
+
+
+#
+# Location of resulting object files
+#
+
+OBJDIR =OBJ.$(TARGET)
+DEPENDFILE = depend.d
+OBJECTS = $(SOURCES:.c=.$(OBJ_EXT))
+
+#
+# When compiling in the OBJ.$(TARGET) directory, search for
+# the source code files in the parent directory.
+#
+
+VPATH = ..
+
+#
+# Standard target names. Do not redefine them if they have
+# already been set in the enclosing makefile.
+#
+
+TOBEGEN_STRIPPED=$(patsubst %$(OGDI_VERSION),%,$(TOBEGEN))
+
+ifndef ARCGEN
+ARCHGEN = $(TOPDIR)/lib/$(TARGET)/static/$(LIB_PREFIX)$(TOBEGEN).$(ARCH_EXT)
+endif
+ifndef DYNAGEN
+DYNAGEN = $(TOPDIR)/bin/$(TARGET)/$(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT)
+endif
+ifndef SHRDGEN
+SHRDGEN = $(TOPDIR)/bin/$(TARGET)/$(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR)
+endif
+ifndef PROGGEN
+PROGGEN = $(TOPDIR)/bin/$(TARGET)/$(TOBEGEN)$(APP_EXT)
+endif
+
+STANDARD_TARGETS = clean install
+
+#
+# Default target to be used if no others are specified.
+# This implies that all makefiles that include this configuration
+# must provide an 'all' target.
+#
+
+all:
+
+#
+# Include the platform specific configuration
+#
+
+include $(TOPDIR)/config/$(TARGET).mak
+
+
+#
+# Standard targets provided for all sub-makefiles
+#
+
+#
+# Create a platform-specific object directory
+#
+
+MKOBJECTDIR:
+ $(MKINSTALLDIR) $(OBJDIR)
+
+#
+# Build the dependency file using 'makedepend'
+#
+
+$(DEPENDFILE): $(SOURCES)
+ touch depend.tmp
+ makedepend -f depend.tmp -- $(subst /I,-I,$(subst /D,-D,$(SYSTEM_INCLUDE) $(CFLAGS))) -- $^
+ sed -e 's?^\.\./??g' -e 's?:/?:\\?g' depend.tmp > $@
+#
+# Clean all possible junk
+#
+
+default-clean:
+ -$(RMALL) $(OBJDIR) $(TOPDIR)/lib/$(TARGET)/static/$(LIB_PREFIX)$(TOBEGEN).* $(OBJDIR) $(TOPDIR)/lib/$(TARGET)/$(LIB_PREFIX)$(TOBEGEN).* $(TOPDIR)/bin/$(TARGET)/$(LIB_PREFIX)$(TOBEGEN).* $(PROGGEN)
+
+#
+# Default rule(s) to install stuff if appropriate.
+#
+
+ifeq ($(TARGETGEN),$(DYNAGEN))
+default-install:
+ mkdir -p $(INST_LIB)/ogdi
+ cp $(TARGETGEN) $(INST_LIB)/ogdi
+endif
+
+ifeq ($(TARGETGEN),$(SHRDGEN))
+default-install:
+ cp $(TARGETGEN) $(INST_LIB)
+ pushd $(INST_LIB); \
+ ln -s $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) \
+ $(LIB_PREFIX)$(TOBEGEN_STRIPPED).$(SHLIB_EXT).$(OGDI_MAJOR); \
+ ln -s $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) \
+ $(LIB_PREFIX)$(TOBEGEN_STRIPPED).$(SHLIB_EXT); \
+ popd
+endif
+
+ifeq ($(TARGETGEN),$(ARCHGEN))
+default-install:
+endif
+
+ifeq ($(TARGETGEN),$(PROGGEN))
+default-install:
+ cp $(TARGETGEN) $(INST_BIN)
+endif
+
+ifeq ($(TARGETGEN),)
+default-install:
+endif
+
+install-so-link:
+ mv -f $(INST_LIB)/$(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) $(INST_LIB)
+ mv -f $(INST_LIB)/$(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR) $(INST_LIB)
+ pushd $(INST_LIB); ln -s $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) \
+ $(LIB_PREFIX)$(TOBEGEN_STRIPPED).$(SHLIB_EXT) ; \
+ popd
+
+install: default-install $(EXTRA_INSTALL_TARGETS)
+
+#
+# Include the auto-generated dependency rules. Only include
+# this file if executing from within the OBJ.$(TARGET) directory.
+#
+
+# ifeq ($(PASS),depend)
+# include $(DEPENDFILE)
+# endif
+
+#
+# End of the common configuration
+#
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/config/common.mak.in
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/common.mak.in 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/common.mak.in 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,277 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+# Release versioning.
+#
+# MAJOR releases represent major ABI changes in the exposed shared lib.
+# This should not be so offen, only once with major code change wich due
+# to a change in how ogdi is called external by other applications.
+#
+# MINOR releases represents revisions or bugfixes over ogdi.
+#
+# The exposed soname of lib is libogdi.so.($major) an lies in $(INST_LIB)
+# Plugins lies in $(INST_LIB)/ogdi/
+#
+
+OGDI_MAJOR = @OGDI_MAJOR@
+OGDI_MINOR = @OGDI_MINOR@
+
+OGDI_VERSION = $(OGDI_MAJOR)$(OGDI_MINOR)
+
+# Common macros and symbols used by all platforms
+#
+#
+#
+# !!! IMPORTANT !!!
+#
+# $TARGET and $TOPDIR must be defined in the environment
+#
+# - $TARGET is the platform on which you compile;
+# it could be 'solaris' or 'win32'
+# - $TOPDIR is the root directory of OGDI source files
+#
+#
+
+
+#
+# Default definitions
+#
+
+ifndef CFG
+CFG = release
+endif
+
+ifndef TARGET
+TARGET = $(shell uname)
+endif
+
+#
+# Standard location of external components (not maintained
+# by LAS)
+#
+
+
+#
+# Standard location of compiled component libraries
+#
+
+BINDIR = $(TOPDIR)/bin/$(TARGET)
+LIBDIR = $(TOPDIR)/lib/$(TARGET)
+
+#
+# Final OS installation location.
+#
+prefix = /usr/local
+exec_prefix = ${prefix}
+INST_INCLUDE = ${prefix}/include
+INST_LIB = ${exec_prefix}/lib
+INST_BIN = ${exec_prefix}/bin
+
+#
+# A location named $(LINKDIR) will be defined in the system
+# specific configuration files. Under win32 this will point
+# to the location of the export libs $(LIBDIR), but under
+# Unix it is the location of the shared objects $(BINDIR).
+#
+
+#
+# Standard location of software components.
+#
+
+CURRENT_DIR = ./
+VPF_DIR = $(topdir)/vpflib
+
+#
+# The following can be internal or external depending on whether we
+# want to use the built-in versions of these libraries.
+#
+EXPAT_SETTING = internal
+ZLIB_SETTING = internal
+PROJ_SETTING = internal
+
+#
+# Standard location of include files.
+#
+
+CURRENT_INCLUDE = $(patsubst %,$(INCL_SW)%,$(subst :, ,$(VPATH)))
+GENERAL_INCLUDE = $(INCL_SW)$(TOPDIR)/include/$(TARGET)
+
+
+OGDI_INCLUDE = $(INCL_SW)$(TOPDIR)/ogdi/include
+VRF_INCLUDE = $(INCL_SW)$(TOPDIR)/ogdi/driver/vrf
+PROJ_INCLUDE = $(INCL_SW)$(TOPDIR)/proj
+VPF_INCLUDE = $(INCL_SW)$(TOPDIR)/vpflib/include $(INCL_SW)$(TOPDIR)/vpflib
+ZLIB_INCLUDE = $(INCL_SW)$(TOPDIR)/external/zlib
+GLUTIL_INCLUDE = $(INCL_SW)$(TOPDIR)/ogdi/glutil
+EXPAT_INCLUDE = $(INCL_SW)$(TOPDIR)/external/expat
+
+#
+# Dynamic libraries (shared objects)
+#
+
+ODBCEXT_LINKLIB = $(LINK_SW)$(LINKDIR)$(LIB_SW)odbcext$(LIB_SUFFIX)
+OGDI_LINKLIB = $(LINK_SW)$(LINKDIR)$(LIB_SW)ogdi$(LIB_SUFFIX)
+ZLIB_LINKLIB = $(LINK_SW)$(LINKDIR)$(LIB_SW)zlib_ogdi$(OGDI_VERSION)$(LIB_SUFFIX)
+EXPAT_LINKLIB = $(LINK_SW)$(LINKDIR)$(LIB_SW)expat_ogdi$(OGDI_VERSION)$(LIB_SUFFIX)
+
+#
+# Static libraries (archives)
+#
+
+PROJ_STATICLIB = $(LINK_SW)$(LIBDIR)/static$(LIB_SW)proj$(LIB_SUFFIX)
+VPF_STATICLIB = $(LINK_SW)$(LIBDIR)/static$(LIB_SW)vpf$(LIB_SUFFIX)
+REMOTE_STATICLIB = $(LINK_SW)$(LIBDIR)/static$(LIB_SW)remote$(LIB_SUFFIX)
+GLUTIL_STATICLIB = $(LINK_SW)$(LIBDIR)/static$(LIB_SW)glutil$(LIB_SUFFIX)
+
+
+#
+# Library aggregations
+#
+
+
+#
+# Location of resulting object files
+#
+
+OBJDIR =OBJ.$(TARGET)
+DEPENDFILE = depend.d
+OBJECTS = $(SOURCES:.c=.$(OBJ_EXT))
+
+#
+# When compiling in the OBJ.$(TARGET) directory, search for
+# the source code files in the parent directory.
+#
+
+VPATH = ..
+
+#
+# Standard target names. Do not redefine them if they have
+# already been set in the enclosing makefile.
+#
+
+TOBEGEN_STRIPPED=$(patsubst %$(OGDI_VERSION),%,$(TOBEGEN))
+
+ifndef ARCGEN
+ARCHGEN = $(TOPDIR)/lib/$(TARGET)/static/$(LIB_PREFIX)$(TOBEGEN).$(ARCH_EXT)
+endif
+ifndef DYNAGEN
+DYNAGEN = $(TOPDIR)/bin/$(TARGET)/$(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT)
+endif
+ifndef SHRDGEN
+SHRDGEN = $(TOPDIR)/bin/$(TARGET)/$(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR)
+endif
+ifndef PROGGEN
+PROGGEN = $(TOPDIR)/bin/$(TARGET)/$(TOBEGEN)$(APP_EXT)
+endif
+
+STANDARD_TARGETS = clean install
+
+#
+# Default target to be used if no others are specified.
+# This implies that all makefiles that include this configuration
+# must provide an 'all' target.
+#
+
+all:
+
+#
+# Include the platform specific configuration
+#
+
+include $(TOPDIR)/config/$(TARGET).mak
+
+
+#
+# Standard targets provided for all sub-makefiles
+#
+
+#
+# Create a platform-specific object directory
+#
+
+MKOBJECTDIR:
+ $(MKINSTALLDIR) $(OBJDIR)
+
+#
+# Build the dependency file using 'makedepend'
+#
+
+$(DEPENDFILE): $(SOURCES)
+ touch depend.tmp
+ makedepend -f depend.tmp -- $(subst /I,-I,$(subst /D,-D,$(SYSTEM_INCLUDE) $(CFLAGS))) -- $^
+ sed -e 's?^\.\./??g' -e 's?:/?:\\?g' depend.tmp > $@
+#
+# Clean all possible junk
+#
+
+default-clean:
+ -$(RMALL) $(OBJDIR) $(TOPDIR)/lib/$(TARGET)/static/$(LIB_PREFIX)$(TOBEGEN).* $(OBJDIR) $(TOPDIR)/lib/$(TARGET)/$(LIB_PREFIX)$(TOBEGEN).* $(TOPDIR)/bin/$(TARGET)/$(LIB_PREFIX)$(TOBEGEN).* $(PROGGEN)
+
+#
+# Default rule(s) to install stuff if appropriate.
+#
+
+ifeq ($(TARGETGEN),$(DYNAGEN))
+default-install:
+ mkdir -p $(INST_LIB)/ogdi
+ cp $(TARGETGEN) $(INST_LIB)/ogdi
+endif
+
+ifeq ($(TARGETGEN),$(SHRDGEN))
+default-install:
+ cp $(TARGETGEN) $(INST_LIB)
+ pushd $(INST_LIB); \
+ ln -s $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) \
+ $(LIB_PREFIX)$(TOBEGEN_STRIPPED).$(SHLIB_EXT).$(OGDI_MAJOR); \
+ ln -s $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) \
+ $(LIB_PREFIX)$(TOBEGEN_STRIPPED).$(SHLIB_EXT); \
+ popd
+endif
+
+ifeq ($(TARGETGEN),$(ARCHGEN))
+default-install:
+endif
+
+ifeq ($(TARGETGEN),$(PROGGEN))
+default-install:
+ cp $(TARGETGEN) $(INST_BIN)
+endif
+
+ifeq ($(TARGETGEN),)
+default-install:
+endif
+
+install-so-link:
+ mv -f $(INST_LIB)/$(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) $(INST_LIB)
+ mv -f $(INST_LIB)/$(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR) $(INST_LIB)
+ pushd $(INST_LIB); ln -s $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) \
+ $(LIB_PREFIX)$(TOBEGEN_STRIPPED).$(SHLIB_EXT) ; \
+ popd
+
+install: default-install $(EXTRA_INSTALL_TARGETS)
+
+#
+# Include the auto-generated dependency rules. Only include
+# this file if executing from within the OBJ.$(TARGET) directory.
+#
+
+# ifeq ($(PASS),depend)
+# include $(DEPENDFILE)
+# endif
+
+#
+# End of the common configuration
+#
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/config/darwin.mak
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/darwin.mak 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/darwin.mak 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,66 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+# Darwin (MacOS X) configuration file
+
+#
+# Read in the configuration common to all Unix
+#
+include $(TOPDIR)/config/unix.mak
+
+#
+# platform specific Symbols
+#
+PLATFORM = darwin
+
+#
+# platform specific tools
+#
+AR = ar cr
+
+#
+# Compilation and linking flags
+#
+SHLIB_CFLAGS = -fno-common
+COMMON_CFLAGS = $(OPTIMIZATION) -fno-common
+
+SHLIB_LDFLAGS = -dynamiclib
+COMMON_LDFLAGS = $(OPTIMIZATION)
+
+
+#
+# File name extensions
+#
+SHLIB_EXT = dylib
+
+UCB_STATICLIB =
+
+#
+# Endian definition
+#
+
+BIG_ENDIAN = 1
+
+
+#
+# make rules
+#
+$(ARCHGEN): $(OBJECTS)
+ @echo Making archive file: $@
+ $(AR) $@ $^
+ ranlib $@
+ @echo $@ made successfully ...
+
+$(DYNAGEN): $(OBJECTS)
+ @echo Making shared library: $@
+ $(SHLIB_LD) $(SHLIB_LDFLAGS) $(COMMON_LDFLAGS) -o $@ $^ $(LINK_LIBS)
+ @echo $@ made successfully ...
Added: packages/ogdi-dfsg/branches/upstream/current/config/generic.mak.in
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/generic.mak.in 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/generic.mak.in 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,109 @@
+# Copyright (C) 2001 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+# Generic unix configuration file, processed by configure to make
+# platform specific.
+
+#
+# Read in the configuration common to all Unix
+#
+include $(TOPDIR)/config/unix.mak
+
+#
+# platform specific Symbols
+#
+PLATFORM = $(TARGET)
+_SOLARIS = 1
+USE_TERMIO = -DUSE_TERMIO
+
+#
+# platform specific tools
+#
+AR = ar cr
+
+
+#
+# Compilation and linking flags
+#
+SHLIB_CFLAGS = @C_PIC@
+COMMON_CFLAGS = $(OPTIMIZATION) @CFLAGS@ @C_WFLAGS@ -DUNIX=1
+
+SHLIB_LDFLAGS = -shared
+COMMON_LDFLAGS = $(OPTIMIZATION)
+
+RPC_INCLUDES = @RPC_INCLUDES@
+
+UCB_STATICLIB =
+
+TCL_INCLUDE = -I/usr/include/tcl8.3
+TCL_LINKLIB =
+
+#
+# Install Locations
+#
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+INST_INCLUDE = ${prefix}/include
+INST_LIB = @libdir@
+INST_BIN = @bindir@
+
+#
+# platform specific file locations
+#
+#RPC_LINKLIB = -lrpcsvc -lnsl -lsocket
+#RPC_LINKLIB = -ldl -ldbmalloc
+RPC_LINKLIB = @LIBS@
+
+#
+# Endian definition, could be little or big
+#
+BIG_ENDIAN = @BIG_ENDIAN@
+
+#
+# Handle internal/external PROJ.4 library usage.
+#
+
+PROJ_SETTING=@PROJ_SETTING@
+
+ifeq ($(PROJ_SETTING),external)
+PROJ_INCLUDE := @PROJ_INCLUDE@
+PROJ_STATICLIB := @PROJ_LIB@
+endif
+
+#
+# Handle internal/external ZLIB library usage.
+#
+
+ZLIB_SETTING=@ZLIB_SETTING@
+
+ifeq ($(ZLIB_SETTING),external)
+ZLIB_INCLUDE := @ZLIB_INCLUDE@
+ZLIB_LINKLIB := @ZLIB_LIB@
+endif
+
+#
+# Handle internal/external/disabled "Expat" library handling.
+#
+
+EXPAT_SETTING=@EXPAT_SETTING@
+
+ifeq ($(EXPAT_SETTING),external)
+EXPAT_INCLUDE := @EXPAT_INCLUDE@
+EXPAT_LINKLIB := @EXPAT_LIB@
+endif
+
+ifeq ($(EXPAT_SETTING),disabled)
+EXPAT_INCLUDE := -DEXPAT_DISABLED
+EXPAT_LINKLIB :=
+endif
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/config/linux.mak
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/linux.mak 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/linux.mak 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,68 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+# Solaris configuration file
+
+#
+# Read in the configuration common to all Unix
+#
+include $(TOPDIR)/config/unix.mak
+
+#
+# platform specific Symbols
+#
+PLATFORM = linux
+_SOLARIS = 1
+USE_TERMIO = -DUSE_TERMIO
+
+#
+# platform specific tools
+#
+AR = ar cr
+
+
+#
+# Compilation and linking flags
+#
+SHLIB_CFLAGS = -fPIC
+COMMON_CFLAGS = $(OPTIMIZATION) -W -Wall -ansi -fPIC -DUNIX=1 \
+ -D_BSD_SOURCE -D_LINUX
+
+SHLIB_LDFLAGS = -shared
+COMMON_LDFLAGS = $(OPTIMIZATION)
+
+RPC_INCLUDES = -DHAVE_STD_RPC_INCLUDES
+
+
+UCB_STATICLIB =
+
+TCL_INCLUDE = -I/usr/include/tcl8.3
+TCL_LINKLIB =
+
+#
+# platform specific file locations
+#
+#RPC_LINKLIB = -lrpcsvc -lnsl -lsocket
+#RPC_LINKLIB = -ldl -ldbmalloc
+RPC_LINKLIB = -ldl
+
+#
+# Endian definition, could be little or big
+#
+
+BIG_ENDIAN = 0
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/config/mkinstalldirs
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/mkinstalldirs 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/mkinstalldirs 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,40 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman at prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+# $Id: mkinstalldirs,v 1.1.1.1 2000/10/29 20:54:55 warmerda Exp $
+
+errstatus=0
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case "$pathcomp" in
+ -* ) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp" 1>&2
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
Property changes on: packages/ogdi-dfsg/branches/upstream/current/config/mkinstalldirs
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/config/solaris.mak
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/solaris.mak 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/solaris.mak 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,61 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+# Solaris configuration file
+
+#
+# Read in the configuration common to all Unix
+#
+include $(TOPDIR)/config/unix.mak
+
+#
+# platform specific Symbols
+#
+PLATFORM = solaris
+_SOLARIS = 1
+USE_TERMIO = -DUSE_TERMIO
+
+#
+# platform specific tools
+#
+AR = /usr/ccs/bin/ar cr
+
+
+#
+# Compilation and linking flags
+#
+SHLIB_CFLAGS = -fPIC
+COMMON_CFLAGS = $(OPTIMIZATION) -W -Wall -ansi -fPIC -D_SOLARIS=1 -DUNIX=1
+
+SHLIB_LDFLAGS = -shared -h $(@F)
+COMMON_LDFLAGS = $(OPTIMIZATION)
+
+
+UCB_STATICLIB = /usr/ucblib/libucb.a
+
+#
+# platform specific file locations
+#
+RPC_LINKLIB = -lrpcsvc -lnsl -lsocket
+
+
+#
+# Endian definition, could be little or big
+#
+
+BIG_ENDIAN = 1
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/config/unix.mak
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/unix.mak 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/unix.mak 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,108 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+
+
+# Unix configuration file. Symbols and macros common
+# all Unix platforms.
+#
+
+UNIX = 1
+UNIX_DEFINE = -Dunix
+
+#
+# Standard tools
+#
+CC = gcc
+LD = gcc
+SHLIB_LD = gcc
+AR = ar cr
+RM = rm
+RMALL = rm -rf
+FILECOPY = cp
+MKDIR = mkdir
+DIRCOPY = cp -r
+SHELL = /bin/sh
+MKINSTALLDIR = $(TOPDIR)/config/mkinstalldirs
+
+#
+# File name extensions
+#
+APP_EXT =
+ARCH_EXT = a
+LIB_PREFIX = lib
+LIB_SUFFIX =
+OBJ_EXT = o
+SHLIB_EXT = so
+
+#
+# Command switches
+#
+DEFINE_SW = -D
+INCL_SW = -I
+LIB_SW = $(subst :, -l,:)
+LINK_SW = -L
+
+ifeq ($(CFG),debug)
+OPTIMIZATION = -g
+else
+OPTIMIZATION = -O
+endif
+
+#
+# Standard location of compiled component libraries
+#
+LINKDIR = $(BINDIR)
+
+#
+# Includes
+#
+SYSTEM_INCLUDE = $(patsubst %,$(INCL_SW)%,$(subst \,/,$(subst :, ,$(INCLUDE))))
+
+#
+# Library locations for link command
+#
+
+RPC_LINKLIB =
+MATH_LINKLIB = $(LIB_SW)m
+DL_LINKLIB =
+
+LIBC_LINKLIB = -lc
+
+#
+# make rules
+#
+$(ARCHGEN): $(OBJECTS)
+ @echo Making archive file: $@
+ $(AR) $@ $^
+ @echo $@ made successfully ...
+
+$(PROGGEN): $(OBJECTS)
+ @echo Making executable: $@
+ $(LD) $(COMMON_LDFLAGS) $(COMMON_CFLAGS) -o $@ $^ $(LINK_LIBS)
+ @echo $@ made successfully ...
+
+$(SHRDGEN): $(OBJECTS)
+ @echo Making shared library: $@
+ $(SHLIB_LD) $(SHLIB_LDFLAGS) $(COMMON_LDFLAGS) $(COMMON_CFLAGS) -Wl,-soname,$(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR) -o $@ $^ $(LINK_LIBS)
+ pushd $(TOPDIR)/bin/$(TARGET); ln -s $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT); \
+ ln -s $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR).$(OGDI_MINOR) $(LIB_PREFIX)$(TOBEGEN).$(SHLIB_EXT).$(OGDI_MAJOR); popd
+ @echo $@ made successfully ...
+
+$(DYNAGEN): $(OBJECTS)
+ @echo Making dynamic library: $@
+ $(SHLIB_LD) $(SHLIB_LDFLAGS) $(COMMON_LDFLAGS) $(COMMON_CFLAGS) -o $@ $^ $(LINK_LIBS)
+ @echo $@ made successfully ...
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/config/win32.mak
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config/win32.mak 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config/win32.mak 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,193 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+#
+#
+# win32 configuration file
+#
+
+MAKE = $(MAKE_COMMAND) $(MAKEOVERRIDES)
+
+
+#
+# Platform specific symbols
+#
+
+Platform = win32
+
+#
+# Standard tools
+#
+
+CC = cl.exe /nologo
+LD = link.exe /nologo
+SHLIB_LD = link.exe /nologo
+AR = lib.exe /nologo
+FILECOPY = cp
+MKDIR = mkdir
+DIRCOPY = cp -rf
+ifndef SHELL
+SHELL = /bin/sh
+endif
+MKINSTALLDIR = $(TOPDIR)/config/mkinstalldirs
+RSC = rc.exe
+RM = rm
+RMALL = rm -rf
+RMDIR = rmdir
+
+
+REVERSETOPDIR = $(subst /,\,$(TOPDIR))
+
+#
+# File name extensions
+#
+
+APP_EXT = .exe
+ARCH_EXT = lib
+LIB_PREFIX =
+LIB_SUFFIX = .lib
+OBJ_EXT = obj
+SHLIB_EXT = dll
+
+#
+# Command switches
+#
+
+DEFINE_SW = /D
+INCL_SW = /I
+LIB_SW = /
+LINK_SW =
+
+
+#
+# Endian definition, could be little or big
+#
+
+BIG_ENDIAN = 0
+
+#
+#Compilation and linking flags
+#
+
+# These flags are appropriate for a compiling with Visual C++ 5.0
+# With these flags, you could run purify.
+#
+
+WINCPP_DEBUG = /GX /D_DEBUG /Zi $(CPP_DEBUG)
+WINCPP_RELEASE = /GX /Gi- /Gy /Od /DNDEBUG $(CPP_RELEASE)
+LINK_DEBUG = /DEBUG /INCREMENTAL:no /FIXED:NO
+LINK_RELEASE = /INCREMENTAL:no /OPT:REF
+
+#flags
+
+# These flags are appropriate for a compiling with Visual C++ 4.0
+# With these flags, you could run purify.
+#
+
+#LINK_DEBUG = /DEBUG /INCREMENTAL:no /debugtype:cv
+#WINCPP_RELEASE = /GX /Gi- /Gy /O2 /DNDEBUG $(CPP_RELEASE)
+
+
+SMARTHEAP_LIB =
+
+ifneq ($(CFG),release)
+OPTIMIZATION = $(WINCPP_DEBUG)
+LINK_OPTIMIZATION = $(LINK_DEBUG)
+else
+OPTIMIZATION = $(WINCPP_RELEASE)
+LINK_OPTIMIZATION = $(LINK_RELEASE)
+endif
+
+SHLIB_CFLAGS =
+SHLIB_LDFLAGS = /DLL
+COMMON_LDFLAGS = /DEBUG
+
+#
+# Standard location of compiled component libraries
+#
+
+LINKDIR = $(LIBDIR)
+
+#
+# INCLUDE locations for include command
+#
+
+SYSTEM_INCLUDE = $(patsubst %,$(INCL_SW)%,$(subst \,/,$(subst ;, ,$(INCLUDE))))
+COMPAT_INCLUDE = $(INCL_SW)$(TOPDIR)/include/win32/compat
+
+RPC_INCLUDE = $(INCL_SW)$(TOPDIR)/external/rpc_win32/rpc
+SYS_INCLUDE = $(INCL_SW)$(TOPDIR)/include/win32/sys
+
+# Library locations for link command
+
+WIN_LINKLIB = user32.lib gdi32.lib wsock32.lib advapi32.lib kernel32.lib
+LXLIB_LINKLIB = $(LIBDIR)/lxlib.lib
+ODBC_LINKLIB = odbc32.lib odbccp32.lib
+RPC_LINKLIB = $(LIBDIR)/static/rpc.lib
+
+
+#
+# rules
+#
+
+COMMON_CFLAGS = /D_WINDOWS /DWIN32 /D_MBCS \
+ /Dhypot=_hypot /DNO_DIRENT_H \
+ /DSIGQUIT=SIGBREAK /Dioctl=Ioctl /DSIGPIPE=SIGTERM \
+ /DSIGHUP=SIGTERM /DSIGALRM=SIGTERM /Dpopen=_popen \
+ /Dpclose=_pclose \
+ /DMISSING_DLFCN_H \
+ $(OPTIMIZATION) \
+ /W3 /YX /MD /c /Fpheaders.pch
+
+FLAGS_X86DEF = /D_X86_
+
+$(subst :,\:,$(ARCHGEN)): $(OBJECTS)
+ @echo Making archive file: $@
+ $(AR) /OUT:$@ $^
+ @echo $@ made successfully ...
+
+DEF_FILE=$(TOBEGEN_STRIPPED).def
+RES_FILE=$(TOBEGEN).res
+RC_FILE=$(TOBEGEN).rc
+
+$(subst :,\:,$(DYNAGEN)): $(DEF_FILE) $(OBJECTS)
+ @echo Making dynamic file: $@
+ @echo
+ $(SHLIB_LD) /DLL $(LINK_OPTIMIZATION) \
+ $(filter %.$(OBJ_EXT),$^) $(LINK_LIBS) /DEF:$(filter %.def,$^) \
+ /OUT:$(TOBEGEN).dll \
+ /IMPLIB:$(TOPDIR)/lib/$(TARGET)/$(LIB_PREFIX)$(TOBEGEN).$(ARCH_EXT) \
+ /OUT:$@
+
+ifndef WITHICON
+$(subst :,\:,$(PROGGEN)): $(OBJECTS)
+ @echo Making executable file: $@
+ $(LD) $^ $(LINK_LIBS) \
+ $(LINK_OPTIMIZATION) $(SMARTHEAP_LINKLIB) \
+ /OUT:$@
+
+else
+$(subst :,\:,$(PROGGEN)): $(RES_FILE) $(OBJECTS)
+ @echo Making executable file: $@
+ $(LD) $(filter %.$(OBJ_EXT),$^) $(LINK_LIBS) \
+ $(filter %.res,$^) \
+ $(LINK_OPTIMIZATION) $(SMARTHEAP_LINKLIB) \
+ /OUT:$@
+endif
+
+
+%.obj: %.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) $<
+
+$(subst :,\:,$(RES_FILE)): $(RC_FILE)
+ $(RSC) /fo"$@" $(GENERAL_INCLUDE) $(TCLTK_INCLUDE) $^
+
Added: packages/ogdi-dfsg/branches/upstream/current/config.guess
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config.guess 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config.guess 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1500 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2006-07-02'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per at bothner.com>.
+# Please send patches to <config-patches at gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi at noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ x86:Interix*:[3456]*)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T:Interix*:[3456]*)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^LIBC/{
+ s: ::g
+ p
+ }'`"
+ test x"${LIBC}" != x && {
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit
+ }
+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel at ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes at openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf at swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green at stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green at stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches at gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
Property changes on: packages/ogdi-dfsg/branches/upstream/current/config.guess
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/config.log
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config.log 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config.log 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,600 @@
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by configure, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ $ ./configure --host=i486-linux-gnu --build=i486-linux-gnu --prefix=/usr --mandir=${prefix}/share/man --infodir=${prefix}/share/info CFLAGS=-Wall -g -O2 LDFLAGS=-Wl,-z,defs --with-projinc=/usr/include --with-projlib=-lproj --with-proj=yes --with-zliblib=-lz --with-zlibinc=/usr/include --with-zlib=yes --with-expatlib=-lexpat --with-expatinc=/usr/include --with-expat=yes --with-pkgconfigdir=/usr/lib/pkgconfig
+
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = klecker
+uname -m = i686
+uname -r = 2.6.18-3-686
+uname -s = Linux
+uname -v = #1 SMP Sun Dec 10 19:37:06 UTC 2006
+
+/usr/bin/uname -p = unknown
+/bin/uname -X = unknown
+
+/bin/arch = i686
+/usr/bin/arch -k = unknown
+/usr/convex/getsysinfo = unknown
+hostinfo = unknown
+/bin/machine = unknown
+/usr/bin/oslevel = unknown
+/bin/universe = unknown
+
+PATH: /usr/local/sbin
+PATH: /usr/local/bin
+PATH: /usr/sbin
+PATH: /usr/bin
+PATH: /sbin
+PATH: /bin
+PATH: /usr/bin/X11
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+configure:1334: checking for i486-linux-gnu-gcc
+configure:1350: found /usr/bin/i486-linux-gnu-gcc
+configure:1360: result: i486-linux-gnu-gcc
+configure:1642: checking for C compiler version
+configure:1645: i486-linux-gnu-gcc --version </dev/null >&5
+i486-linux-gnu-gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
+Copyright (C) 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+configure:1648: $? = 0
+configure:1650: i486-linux-gnu-gcc -v </dev/null >&5
+Using built-in specs.
+Target: i486-linux-gnu
+Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
+Thread model: posix
+gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
+configure:1653: $? = 0
+configure:1655: i486-linux-gnu-gcc -V </dev/null >&5
+i486-linux-gnu-gcc: '-V' option must have argument
+configure:1658: $? = 1
+configure:1681: checking for C compiler default output file name
+configure:1684: i486-linux-gnu-gcc -Wall -g -O2 -Wl,-z,defs conftest.c >&5
+configure:1687: $? = 0
+configure:1733: result: a.out
+configure:1738: checking whether the C compiler works
+configure:1744: ./a.out
+configure:1747: $? = 0
+configure:1764: result: yes
+configure:1771: checking whether we are cross compiling
+configure:1773: result: no
+configure:1776: checking for suffix of executables
+configure:1778: i486-linux-gnu-gcc -o conftest -Wall -g -O2 -Wl,-z,defs conftest.c >&5
+configure:1781: $? = 0
+configure:1806: result:
+configure:1812: checking for suffix of object files
+configure:1833: i486-linux-gnu-gcc -c -Wall -g -O2 conftest.c >&5
+configure:1836: $? = 0
+configure:1858: result: o
+configure:1862: checking whether we are using the GNU C compiler
+configure:1886: i486-linux-gnu-gcc -c -Wall -g -O2 conftest.c >&5
+configure:1892: $? = 0
+configure:1896: test -z
+ || test ! -s conftest.err
+configure:1899: $? = 0
+configure:1902: test -s conftest.o
+configure:1905: $? = 0
+configure:1918: result: yes
+configure:1924: checking whether i486-linux-gnu-gcc accepts -g
+configure:1945: i486-linux-gnu-gcc -c -g conftest.c >&5
+configure:1951: $? = 0
+configure:1955: test -z
+ || test ! -s conftest.err
+configure:1958: $? = 0
+configure:1961: test -s conftest.o
+configure:1964: $? = 0
+configure:1975: result: yes
+configure:1992: checking for i486-linux-gnu-gcc option to accept ANSI C
+configure:2062: i486-linux-gnu-gcc -c -Wall -g -O2 conftest.c >&5
+configure:2068: $? = 0
+configure:2072: test -z
+ || test ! -s conftest.err
+configure:2075: $? = 0
+configure:2078: test -s conftest.o
+configure:2081: $? = 0
+configure:2099: result: none needed
+configure:2117: i486-linux-gnu-gcc -c -Wall -g -O2 conftest.c >&5
+conftest.c:2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'me'
+configure:2123: $? = 1
+configure: failed program was:
+| #ifndef __cplusplus
+| choke me
+| #endif
+configure:2260: checking for dlopen in -ldl
+configure:2290: i486-linux-gnu-gcc -o conftest -Wall -g -O2 -Wl,-z,defs conftest.c -ldl >&5
+configure:2296: $? = 0
+configure:2300: test -z
+ || test ! -s conftest.err
+configure:2303: $? = 0
+configure:2306: test -s conftest
+configure:2309: $? = 0
+configure:2322: result: yes
+configure:2435: checking how to run the C preprocessor
+configure:2470: i486-linux-gnu-gcc -E conftest.c
+configure:2476: $? = 0
+configure:2508: i486-linux-gnu-gcc -E conftest.c
+conftest.c:11:28: error: ac_nonexistent.h: No such file or directory
+configure:2514: $? = 1
+configure: failed program was:
+| /* confdefs.h. */
+|
+| #define PACKAGE_NAME ""
+| #define PACKAGE_TARNAME ""
+| #define PACKAGE_VERSION ""
+| #define PACKAGE_STRING ""
+| #define PACKAGE_BUGREPORT ""
+| #define HAVE_LIBDL 1
+| #define USE_GNUCC 1
+| /* end confdefs.h. */
+| #include <ac_nonexistent.h>
+configure:2553: result: i486-linux-gnu-gcc -E
+configure:2577: i486-linux-gnu-gcc -E conftest.c
+configure:2583: $? = 0
+configure:2615: i486-linux-gnu-gcc -E conftest.c
+conftest.c:11:28: error: ac_nonexistent.h: No such file or directory
+configure:2621: $? = 1
+configure: failed program was:
+| /* confdefs.h. */
+|
+| #define PACKAGE_NAME ""
+| #define PACKAGE_TARNAME ""
+| #define PACKAGE_VERSION ""
+| #define PACKAGE_STRING ""
+| #define PACKAGE_BUGREPORT ""
+| #define HAVE_LIBDL 1
+| #define USE_GNUCC 1
+| /* end confdefs.h. */
+| #include <ac_nonexistent.h>
+configure:2665: checking for egrep
+configure:2675: result: grep -E
+configure:2680: checking for ANSI C header files
+configure:2705: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2711: $? = 0
+configure:2715: test -z
+ || test ! -s conftest.err
+configure:2718: $? = 0
+configure:2721: test -s conftest.o
+configure:2724: $? = 0
+configure:2813: i486-linux-gnu-gcc -o conftest -Wall -Wl,-z,defs conftest.c -ldl >&5
+conftest.c: In function 'main':
+conftest.c:28: warning: implicit declaration of function 'exit'
+conftest.c:28: warning: incompatible implicit declaration of built-in function 'exit'
+configure:2816: $? = 0
+configure:2818: ./conftest
+configure:2821: $? = 0
+configure:2836: result: yes
+configure:2860: checking for sys/types.h
+configure:2876: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2882: $? = 0
+configure:2886: test -z
+ || test ! -s conftest.err
+configure:2889: $? = 0
+configure:2892: test -s conftest.o
+configure:2895: $? = 0
+configure:2906: result: yes
+configure:2860: checking for sys/stat.h
+configure:2876: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2882: $? = 0
+configure:2886: test -z
+ || test ! -s conftest.err
+configure:2889: $? = 0
+configure:2892: test -s conftest.o
+configure:2895: $? = 0
+configure:2906: result: yes
+configure:2860: checking for stdlib.h
+configure:2876: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2882: $? = 0
+configure:2886: test -z
+ || test ! -s conftest.err
+configure:2889: $? = 0
+configure:2892: test -s conftest.o
+configure:2895: $? = 0
+configure:2906: result: yes
+configure:2860: checking for string.h
+configure:2876: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2882: $? = 0
+configure:2886: test -z
+ || test ! -s conftest.err
+configure:2889: $? = 0
+configure:2892: test -s conftest.o
+configure:2895: $? = 0
+configure:2906: result: yes
+configure:2860: checking for memory.h
+configure:2876: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2882: $? = 0
+configure:2886: test -z
+ || test ! -s conftest.err
+configure:2889: $? = 0
+configure:2892: test -s conftest.o
+configure:2895: $? = 0
+configure:2906: result: yes
+configure:2860: checking for strings.h
+configure:2876: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2882: $? = 0
+configure:2886: test -z
+ || test ! -s conftest.err
+configure:2889: $? = 0
+configure:2892: test -s conftest.o
+configure:2895: $? = 0
+configure:2906: result: yes
+configure:2860: checking for inttypes.h
+configure:2876: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2882: $? = 0
+configure:2886: test -z
+ || test ! -s conftest.err
+configure:2889: $? = 0
+configure:2892: test -s conftest.o
+configure:2895: $? = 0
+configure:2906: result: yes
+configure:2860: checking for stdint.h
+configure:2876: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2882: $? = 0
+configure:2886: test -z
+ || test ! -s conftest.err
+configure:2889: $? = 0
+configure:2892: test -s conftest.o
+configure:2895: $? = 0
+configure:2906: result: yes
+configure:2860: checking for unistd.h
+configure:2876: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2882: $? = 0
+configure:2886: test -z
+ || test ! -s conftest.err
+configure:2889: $? = 0
+configure:2892: test -s conftest.o
+configure:2895: $? = 0
+configure:2906: result: yes
+configure:2934: checking rpc/pmap_clnt.h usability
+configure:2946: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2952: $? = 0
+configure:2956: test -z
+ || test ! -s conftest.err
+configure:2959: $? = 0
+configure:2962: test -s conftest.o
+configure:2965: $? = 0
+configure:2975: result: yes
+configure:2979: checking rpc/pmap_clnt.h presence
+configure:2989: i486-linux-gnu-gcc -E conftest.c
+configure:2995: $? = 0
+configure:3015: result: yes
+configure:3050: checking for rpc/pmap_clnt.h
+configure:3057: result: yes
+configure:2934: checking float.h usability
+configure:2946: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2952: $? = 0
+configure:2956: test -z
+ || test ! -s conftest.err
+configure:2959: $? = 0
+configure:2962: test -s conftest.o
+configure:2965: $? = 0
+configure:2975: result: yes
+configure:2979: checking float.h presence
+configure:2989: i486-linux-gnu-gcc -E conftest.c
+configure:2995: $? = 0
+configure:3015: result: yes
+configure:3050: checking for float.h
+configure:3057: result: yes
+configure:2934: checking dlfcn.h usability
+configure:2946: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:2952: $? = 0
+configure:2956: test -z
+ || test ! -s conftest.err
+configure:2959: $? = 0
+configure:2962: test -s conftest.o
+configure:2965: $? = 0
+configure:2975: result: yes
+configure:2979: checking dlfcn.h presence
+configure:2989: i486-linux-gnu-gcc -E conftest.c
+configure:2995: $? = 0
+configure:3015: result: yes
+configure:3050: checking for dlfcn.h
+configure:3057: result: yes
+configure:3086: checking whether byte ordering is bigendian
+configure:3113: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:3119: $? = 0
+configure:3123: test -z
+ || test ! -s conftest.err
+configure:3126: $? = 0
+configure:3129: test -s conftest.o
+configure:3132: $? = 0
+configure:3156: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+conftest.c: In function 'main':
+conftest.c:31: error: 'not' undeclared (first use in this function)
+conftest.c:31: error: (Each undeclared identifier is reported only once
+conftest.c:31: error: for each function it appears in.)
+conftest.c:31: error: expected ';' before 'big'
+configure:3162: $? = 1
+configure: failed program was:
+| /* confdefs.h. */
+|
+| #define PACKAGE_NAME ""
+| #define PACKAGE_TARNAME ""
+| #define PACKAGE_VERSION ""
+| #define PACKAGE_STRING ""
+| #define PACKAGE_BUGREPORT ""
+| #define HAVE_LIBDL 1
+| #define USE_GNUCC 1
+| #define STDC_HEADERS 1
+| #define HAVE_SYS_TYPES_H 1
+| #define HAVE_SYS_STAT_H 1
+| #define HAVE_STDLIB_H 1
+| #define HAVE_STRING_H 1
+| #define HAVE_MEMORY_H 1
+| #define HAVE_STRINGS_H 1
+| #define HAVE_INTTYPES_H 1
+| #define HAVE_STDINT_H 1
+| #define HAVE_UNISTD_H 1
+| #define HAVE_RPC_PMAP_CLNT_H 1
+| #define HAVE_FLOAT_H 1
+| #define HAVE_DLFCN_H 1
+| /* end confdefs.h. */
+| #include <sys/types.h>
+| #include <sys/param.h>
+|
+| int
+| main ()
+| {
+| #if BYTE_ORDER != BIG_ENDIAN
+| not big endian
+| #endif
+|
+| ;
+| return 0;
+| }
+configure:3297: result: no
+configure:3339: checking for pj_init in -lproj
+configure:3369: i486-linux-gnu-gcc -o conftest -Wall -Wl,-z,defs conftest.c -lproj -ldl >&5
+configure:3375: $? = 0
+configure:3379: test -z
+ || test ! -s conftest.err
+configure:3382: $? = 0
+configure:3385: test -s conftest
+configure:3388: $? = 0
+configure:3401: result: yes
+configure:3423: checking projects.h usability
+configure:3435: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:3441: $? = 0
+configure:3445: test -z
+ || test ! -s conftest.err
+configure:3448: $? = 0
+configure:3451: test -s conftest.o
+configure:3454: $? = 0
+configure:3464: result: yes
+configure:3468: checking projects.h presence
+configure:3478: i486-linux-gnu-gcc -E conftest.c
+configure:3484: $? = 0
+configure:3504: result: yes
+configure:3539: checking for projects.h
+configure:3546: result: yes
+configure:3655: checking for deflateInit_ in -lz
+configure:3685: i486-linux-gnu-gcc -o conftest -Wall -Wl,-z,defs conftest.c -lz -ldl >&5
+configure:3691: $? = 0
+configure:3695: test -z
+ || test ! -s conftest.err
+configure:3698: $? = 0
+configure:3701: test -s conftest
+configure:3704: $? = 0
+configure:3717: result: yes
+configure:3739: checking zlib.h usability
+configure:3751: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:3757: $? = 0
+configure:3761: test -z
+ || test ! -s conftest.err
+configure:3764: $? = 0
+configure:3767: test -s conftest.o
+configure:3770: $? = 0
+configure:3780: result: yes
+configure:3784: checking zlib.h presence
+configure:3794: i486-linux-gnu-gcc -E conftest.c
+configure:3800: $? = 0
+configure:3820: result: yes
+configure:3855: checking for zlib.h
+configure:3862: result: yes
+configure:3946: result: Using ZLIB_LIB=-lz for ZLIB library.
+configure:3960: result: Using ZLIB_INCLUDE=-I/usr/include for ZLIB includes.
+configure:3991: checking for XML_ParserCreate in -lexpat
+configure:4021: i486-linux-gnu-gcc -o conftest -Wall -Wl,-z,defs conftest.c -lexpat -ldl >&5
+configure:4027: $? = 0
+configure:4031: test -z
+ || test ! -s conftest.err
+configure:4034: $? = 0
+configure:4037: test -s conftest
+configure:4040: $? = 0
+configure:4053: result: yes
+configure:4075: checking expat.h usability
+configure:4087: i486-linux-gnu-gcc -c -Wall conftest.c >&5
+configure:4093: $? = 0
+configure:4097: test -z
+ || test ! -s conftest.err
+configure:4100: $? = 0
+configure:4103: test -s conftest.o
+configure:4106: $? = 0
+configure:4116: result: yes
+configure:4120: checking expat.h presence
+configure:4130: i486-linux-gnu-gcc -E conftest.c
+configure:4136: $? = 0
+configure:4156: result: yes
+configure:4191: checking for expat.h
+configure:4198: result: yes
+configure:4316: pkgconfig directory is /usr/lib/pkgconfig
+configure:4471: creating ./config.status
+
+## ---------------------- ##
+## Running config.status. ##
+## ---------------------- ##
+
+This file was extended by config.status, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ CONFIG_FILES =
+ CONFIG_HEADERS =
+ CONFIG_LINKS =
+ CONFIG_COMMANDS =
+ $ ./config.status
+
+on klecker
+
+config.status:657: creating config/common.mak
+config.status:657: creating ogdi.pc
+config.status:657: creating ogdi-config
+config.status:657: creating config/generic.mak
+
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+
+ac_cv_c_bigendian=no
+ac_cv_c_compiler_gnu=yes
+ac_cv_env_CC_set=
+ac_cv_env_CC_value=
+ac_cv_env_CFLAGS_set=set
+ac_cv_env_CFLAGS_value='-Wall -g -O2'
+ac_cv_env_CPPFLAGS_set=
+ac_cv_env_CPPFLAGS_value=
+ac_cv_env_CPP_set=
+ac_cv_env_CPP_value=
+ac_cv_env_LDFLAGS_set=set
+ac_cv_env_LDFLAGS_value=-Wl,-z,defs
+ac_cv_env_build_alias_set=set
+ac_cv_env_build_alias_value=i486-linux-gnu
+ac_cv_env_host_alias_set=set
+ac_cv_env_host_alias_value=i486-linux-gnu
+ac_cv_env_target_alias_set=
+ac_cv_env_target_alias_value=
+ac_cv_exeext=
+ac_cv_header_dlfcn_h=yes
+ac_cv_header_expat_h=yes
+ac_cv_header_float_h=yes
+ac_cv_header_inttypes_h=yes
+ac_cv_header_memory_h=yes
+ac_cv_header_projects_h=yes
+ac_cv_header_rpc_pmap_clnt_h=yes
+ac_cv_header_stdc=yes
+ac_cv_header_stdint_h=yes
+ac_cv_header_stdlib_h=yes
+ac_cv_header_string_h=yes
+ac_cv_header_strings_h=yes
+ac_cv_header_sys_stat_h=yes
+ac_cv_header_sys_types_h=yes
+ac_cv_header_unistd_h=yes
+ac_cv_header_zlib_h=yes
+ac_cv_lib_dl_dlopen=yes
+ac_cv_lib_expat_XML_ParserCreate=yes
+ac_cv_lib_proj_pj_init=yes
+ac_cv_lib_z_deflateInit_=yes
+ac_cv_objext=o
+ac_cv_prog_CC=i486-linux-gnu-gcc
+ac_cv_prog_CPP='i486-linux-gnu-gcc -E'
+ac_cv_prog_cc_g=yes
+ac_cv_prog_cc_stdc=
+ac_cv_prog_egrep='grep -E'
+
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+
+BIG_ENDIAN='0'
+CC='i486-linux-gnu-gcc'
+CFLAGS='-Wall '
+CPP='i486-linux-gnu-gcc -E'
+CPPFLAGS=''
+CXX_PIC='-fPIC'
+CXX_WFLAGS=''
+C_PIC='-fPIC'
+C_WFLAGS='-Wall'
+DEFS='-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBDL=1 -DUSE_GNUCC=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_RPC_PMAP_CLNT_H=1 -DHAVE_FLOAT_H=1 -DHAVE_DLFCN_H=1 -DHAVE_PROJECTS_H=1 -DHAVE_ZLIB_H=1 -DHAVE_EXPAT_H=1 '
+ECHO_C=''
+ECHO_N='-n'
+ECHO_T=''
+EGREP='grep -E'
+EXEEXT=''
+EXPAT_INCLUDE='-I/usr/include'
+EXPAT_LIB='-lexpat'
+EXPAT_SETTING='external'
+LDFLAGS='-Wl,-z,defs'
+LD_SHARED='ld -shared'
+LIBOBJS=''
+LIBS='-ldl '
+LTLIBOBJS=''
+OBJEXT='o'
+OGDI_MAJOR='3'
+OGDI_MINOR='2'
+OGDI_VERSION='3.2.0beta1'
+PACKAGE_BUGREPORT=''
+PACKAGE_NAME=''
+PACKAGE_STRING=''
+PACKAGE_TARNAME=''
+PACKAGE_VERSION=''
+PATH_SEPARATOR=':'
+PROJ_INCLUDE='-I/usr/include'
+PROJ_LIB='-lproj'
+PROJ_SETTING='external'
+RPC_INCLUDES='-DHAVE_STD_RPC_INCLUDES'
+SHELL='/bin/sh'
+ZLIB_INCLUDE='-I/usr/include'
+ZLIB_LIB='-lz'
+ZLIB_SETTING='external'
+ac_ct_CC=''
+binconfigs='${binconfigs}'
+bindir='${exec_prefix}/bin'
+build_alias='i486-linux-gnu'
+datadir='${prefix}/share'
+exec_prefix='${prefix}'
+host_alias='i486-linux-gnu'
+includedir='${prefix}/include'
+infodir='${prefix}/share/info'
+libdir='${exec_prefix}/lib'
+libexecdir='${exec_prefix}/libexec'
+localstatedir='${prefix}/var'
+mandir='${prefix}/share/man'
+oldincludedir='/usr/include'
+pkgconfigdir='/usr/lib/pkgconfig'
+prefix='/usr'
+program_transform_name='s,x,x,'
+sbindir='${exec_prefix}/sbin'
+sharedstatedir='${prefix}/com'
+sysconfdir='${prefix}/etc'
+target_alias=''
+
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+
+#define HAVE_DLFCN_H 1
+#define HAVE_EXPAT_H 1
+#define HAVE_FLOAT_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_LIBDL 1
+#define HAVE_MEMORY_H 1
+#define HAVE_PROJECTS_H 1
+#define HAVE_RPC_PMAP_CLNT_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_ZLIB_H 1
+#define PACKAGE_BUGREPORT ""
+#define PACKAGE_NAME ""
+#define PACKAGE_STRING ""
+#define PACKAGE_TARNAME ""
+#define PACKAGE_VERSION ""
+#define STDC_HEADERS 1
+#define USE_GNUCC 1
+
+configure: exit 0
Added: packages/ogdi-dfsg/branches/upstream/current/config.sub
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/config.sub 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/config.sub 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1616 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2006-09-20'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches at gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | mt \
+ | msp430 \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16c)
+ basic_machine=cr16c-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
Property changes on: packages/ogdi-dfsg/branches/upstream/current/config.sub
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/configure
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/configure 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/configure 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,5282 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.59.
+#
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete. It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
+ac_unique_file="config/unix.mak"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS OGDI_VERSION OGDI_MAJOR OGDI_MINOR CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX_WFLAGS C_WFLAGS CXX_PIC C_PIC LD_SHARED CPP EGREP RPC_INCLUDES BIG_ENDIAN PROJ_SETTING PROJ_INCLUDE PROJ_LIB ZLIB_SETTING ZLIB_INCLUDE ZLIB_LIB EXPAT_SETTING EXPAT_INCLUDE EXPAT_LIB pkgconfigdir binconfigs LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+ac_prev=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_option in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ eval "enable_$ac_feature=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_$ac_feature='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_$ac_package='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/-/_/g'`
+ eval "with_$ac_package=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+ eval "$ac_envvar='$ac_optarg'"
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+ localstatedir libdir includedir oldincludedir infodir mandir
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$0" : 'X\(//\)[^/]' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+ { (exit 1); exit 1; }; }
+ else
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+ fi
+fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+ { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+_ACEOF
+
+ cat <<_ACEOF
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --infodir=DIR info documentation [PREFIX/info]
+ --mandir=DIR man documentation [PREFIX/man]
+_ACEOF
+
+ cat <<\_ACEOF
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+ cat <<\_ACEOF
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-proj=ARG Utilize external PROJ.4 support
+ --with-projlib=path Select PROJ.4 library
+ --with-projinc=path Select PROJ.4 include directory
+ --with-zlib=ARG Utilize external ZLIB support
+ --with-zliblib=path Select ZLIB library
+ --with-zlibinc=path Select ZLIB include directory
+ --with-expat=ARG Utilize external Expat library, or disable Expat.
+ --with-expatlib=path Select Expat library
+ --with-expatinc=path Select Expat include directory
+ --with-pkgconfigdir Use the specified pkgconfig dir (default is
+ libdir/pkgconfig)
+ --with-binconfigs Generate shell ogdi-config scripts as well as
+ pkg-config data [default=yes]
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
+ headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+_ACEOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ ac_popdir=`pwd`
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d $ac_dir || continue
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+ cd $ac_dir
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f $ac_srcdir/configure.gnu; then
+ echo
+ $SHELL $ac_srcdir/configure.gnu --help=recursive
+ elif test -f $ac_srcdir/configure; then
+ echo
+ $SHELL $ac_srcdir/configure --help=recursive
+ elif test -f $ac_srcdir/configure.ac ||
+ test -f $ac_srcdir/configure.in; then
+ echo
+ $ac_configure --help
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi
+ cd $ac_popdir
+ done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+ cat <<\_ACEOF
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit 0
+fi
+exec 5>config.log
+cat >&5 <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ echo "PATH: $as_dir"
+done
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_sep=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+ # Get rid of the leading space.
+ ac_sep=" "
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+{
+ (set) 2>&1 |
+ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ sed -n \
+ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+ ;;
+ *)
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+}
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ sed "/^$/d" confdefs.h | sort
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal"
+ echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core &&
+ rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+ ' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . $cache_file;;
+ *) . ./$cache_file;;
+ esac
+ fi
+else
+ { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+ eval ac_new_val="\$ac_env_${ac_var}_value"
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+OGDI_VERSION=3.2.0beta1
+OGDI_MAJOR=3
+OGDI_MINOR=2
+
+
+
+
+
+
+if test "$TOPDIR" = "" ; then
+ { { echo "$as_me:$LINENO: error: Required TOPDIR environment variable not set, see README." >&5
+echo "$as_me: error: Required TOPDIR environment variable not set, see README." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+if test "$OS" = "Windows_NT" ; then
+ { { echo "$as_me:$LINENO: error: Please don't use configure for Windows, see README." >&5
+echo "$as_me: error: Please don't use configure for Windows, see README." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_CC" && break
+done
+
+ CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+ "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+ (eval $ac_link_default) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Find the output, starting from the most likely. This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+ ;;
+ conftest.$ac_ext )
+ # This is the source file.
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ # FIXME: I believe we export ac_cv_exeext for Libtool,
+ # but it would be cool to find out if it's true. Does anybody
+ # maintain Libtool? --akim.
+ export ac_cv_exeext
+ break;;
+ * )
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ export ac_cv_exeext
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std1 is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std1. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX 10.20 and later -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+ x|xno)
+ echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+ *)
+ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+ CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+ choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ for ac_declaration in \
+ '' \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);'
+do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+#include <stdlib.h>
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+ echo '#ifdef __cplusplus' >>confdefs.h
+ echo $ac_declaration >>confdefs.h
+ echo '#endif' >>confdefs.h
+fi
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+ LIBS="-ldl $LIBS"
+
+fi
+
+
+
+ # Remove -g from compile flags, we will add via CFG variable if
+ # we need it.
+ CXXFLAGS=`echo "$CXXFLAGS " | sed "s/-g //"`
+ CFLAGS=`echo "$CFLAGS " | sed "s/-g //"`
+
+ # check for GNU compiler, and use -Wall
+ if test "$GCC" = "yes"; then
+ C_WFLAGS="-Wall"
+ cat >>confdefs.h <<\_ACEOF
+#define USE_GNUCC 1
+_ACEOF
+
+ fi
+ if test "$GXX" = "yes"; then
+ CXX_WFLAGS="-Wall"
+ cat >>confdefs.h <<\_ACEOF
+#define USE_GNUCC 1
+_ACEOF
+
+ fi
+ CXX_WFLAGS=$CXX_WFLAGS
+
+ C_WFLAGS=$C_WFLAGS
+
+
+
+ echo 'void f(){}' > conftest.c
+ if test -z "`${CC-cc} -fPIC -c conftest.c 2>&1`"; then
+ C_PIC=-fPIC
+ else
+ C_PIC=
+ fi
+ if test -z "`${CXX-g++} -fPIC -c conftest.c 2>&1`"; then
+ CXX_PIC=-fPIC
+ else
+ CXX_PIC=
+ fi
+ rm -f conftest*
+
+ CXX_PIC=$CXX_PIC
+
+ C_PIC=$C_PIC
+
+
+
+ echo 'void g(); int main(){ g(); return 0; }' > conftest1.c
+
+ echo 'void g(); void g(){}' > conftest2.c
+ ${CC} ${C_PIC} -c conftest2.c
+
+ LD_SHARED="/bin/true"
+ if test -z "`${CXX} -shared conftest2.o -o libconftest.so 2>&1`" ; then
+ if test -z "`${CC} conftest1.c libconftest.so -o conftest1 2>&1`"; then
+ LD_LIBRARY_PATH_OLD="$LD_LIBRARY_PATH"
+ LD_LIBRARY_PATH="`pwd`"
+ export LD_LIBRARY_PATH
+ if test -z "`./conftest1 2>&1`" ; then
+ echo "checking for ${CXX} -shared ... yes"
+ LD_SHARED="${CXX} -shared"
+ else
+ echo "checking for ${CXX} -shared ... no(3)"
+ fi
+ LD_LIBRARY_PATH="$LD_LIBRARY_PATH_OLD"
+ else
+ echo "checking for ${CXX} -shared ... no(2)"
+ fi
+ else
+ echo "checking for ${CXX} -shared ... no(1)"
+ fi
+
+ if test "$LD_SHARED" = "/bin/true" \
+ -a -z "`ld -shared conftest2.o -o libconftest.so 2>&1`" ; then
+ if test -z "`${CC} conftest1.c libconftest.so -o conftest1 2>&1`"; then
+ LD_LIBRARY_PATH_OLD="$LD_LIBRARY_PATH"
+ LD_LIBRARY_PATH="`pwd`"
+ export LD_LIBRARY_PATH
+ if test -z "`./conftest1 2>&1`" ; then
+ echo "checking for ld -shared ... yes"
+ LD_SHARED="ld -shared"
+ fi
+ LD_LIBRARY_PATH="$LD_LIBRARY_PATH_OLD"
+ fi
+ fi
+
+ if test "$LD_SHARED" = "/bin/true" ; then
+ echo "checking for ld -shared ... no"
+ fi
+ rm -f conftest* libconftest*
+
+ LD_SHARED=$LD_SHARED
+
+
+
+CFLAGS=`echo "$CFLAGS " | sed "s/-O2 //"`
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then ac_cv_prog_egrep='grep -E'
+ else ac_cv_prog_egrep='egrep'
+ fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+for ac_header in rpc/pmap_clnt.h float.h dlfcn.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists. ##
+## ------------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+if test "$ac_cv_header_rpc_pmap_clnt_h" = yes ; then
+ RPC_INCLUDES=-DHAVE_STD_RPC_INCLUDES
+else
+ RPC_INCLUDES=
+fi
+RPC_INCLUDES=$RPC_INCLUDES
+
+
+if test "$ac_cv_header_float_h" = no ; then
+ CFLAGS="$CFLAGS -DMISSING_FLOAT_H"
+fi
+if test "$ac_cv_header_dlfcn_h" = no ; then
+ CFLAGS="$CFLAGS -DMISSING_DLFCN_H"
+fi
+
+echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
+echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6
+if test "${ac_cv_c_bigendian+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # See if sys/param.h defines the BYTE_ORDER macro.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/param.h>
+
+int
+main ()
+{
+#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ # It does; now see whether it defined to BIG_ENDIAN or not.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/param.h>
+
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_c_bigendian=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_bigendian=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+# It does not; compile a test program.
+if test "$cross_compiling" = yes; then
+ # try to guess the endianness by grepping values into an object file
+ ac_cv_c_bigendian=unknown
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
+short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }
+int
+main ()
+{
+ _ascii (); _ebcdic ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
+ ac_cv_c_bigendian=yes
+fi
+if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+ if test "$ac_cv_c_bigendian" = unknown; then
+ ac_cv_c_bigendian=no
+ else
+ # finding both strings is unlikely to happen, but who knows?
+ ac_cv_c_bigendian=unknown
+ fi
+fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+int
+main ()
+{
+ /* Are we little or big endian? From Harbison&Steele. */
+ union
+ {
+ long l;
+ char c[sizeof (long)];
+ } u;
+ u.l = 1;
+ exit (u.c[sizeof (long) - 1] == 1);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_c_bigendian=no
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_c_bigendian=yes
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
+echo "${ECHO_T}$ac_cv_c_bigendian" >&6
+case $ac_cv_c_bigendian in
+ yes)
+
+cat >>confdefs.h <<\_ACEOF
+#define WORDS_BIGENDIAN 1
+_ACEOF
+ ;;
+ no)
+ ;;
+ *)
+ { { echo "$as_me:$LINENO: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&5
+echo "$as_me: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
+ { (exit 1); exit 1; }; } ;;
+esac
+
+if test $ac_cv_c_bigendian = yes ; then
+ BIG_ENDIAN=1
+else
+ BIG_ENDIAN=0
+fi
+BIG_ENDIAN=$BIG_ENDIAN
+
+
+
+PROJ_SETTING=internal
+PROJ_INCLUDE=
+PROJ_LIB=
+export PROJ_LIB PROJ_INCLUDE PROJ_SETTING
+
+
+# Check whether --with-proj or --without-proj was given.
+if test "${with_proj+set}" = set; then
+ withval="$with_proj"
+
+fi;
+
+if test "$with_proj" = "yes" ; then
+
+ echo "$as_me:$LINENO: checking for pj_init in -lproj" >&5
+echo $ECHO_N "checking for pj_init in -lproj... $ECHO_C" >&6
+if test "${ac_cv_lib_proj_pj_init+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lproj $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char pj_init ();
+int
+main ()
+{
+pj_init ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_proj_pj_init=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_proj_pj_init=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_proj_pj_init" >&5
+echo "${ECHO_T}$ac_cv_lib_proj_pj_init" >&6
+if test $ac_cv_lib_proj_pj_init = yes; then
+ PROJ_SETTING=external
+else
+ PROJ_SETTING=missing
+fi
+
+
+for ac_header in projects.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists. ##
+## ------------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+ if test $PROJ_SETTING = missing ; then
+ { { echo "$as_me:$LINENO: error: Unable to find external PROJ.4 library, give path or use default internal library." >&5
+echo "$as_me: error: Unable to find external PROJ.4 library, give path or use default internal library." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ if test "$ac_cv_header_projects_h" = no ; then
+ { { echo "$as_me:$LINENO: error: Unable to find external PROJ.4 projects.h file, give path or use default internal library." >&5
+echo "$as_me: error: Unable to find external PROJ.4 projects.h file, give path or use default internal library." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ PROJ_SETTING=external
+ PROJ_LIB=-lproj
+
+elif test "$with_proj" != "no" -a "$with_proj" != "" ; then
+
+ if test -r $with_proj/include/projects.h ; then
+ echo "checking for $with_proj/include/projects.h ... found"
+ PROJ_INCLUDE=-I$with_proj/include
+ else
+ { { echo "$as_me:$LINENO: error: Unable to find $with_proj/include/projects.h" >&5
+echo "$as_me: error: Unable to find $with_proj/include/projects.h" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ if test -r $with_proj/lib/libproj.so ; then
+ PROJ_LIB=$with_proj/lib/libproj.so
+ echo "checking for $PROJ_LIB ... found"
+
+ elif test -r $with_proj/lib/libproj.a ; then
+ PROJ_LIB=$with_proj/lib/libproj.a
+ echo "checking for $PROJ_LIB ... found"
+
+ else
+ { { echo "$as_me:$LINENO: error: Unable to find $with_proj/lib/libproj.{so,a}" >&5
+echo "$as_me: error: Unable to find $with_proj/lib/libproj.{so,a}" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ PROJ_SETTING=external
+
+fi
+
+
+# Check whether --with-projlib or --without-projlib was given.
+if test "${with_projlib+set}" = set; then
+ withval="$with_projlib"
+
+fi;
+
+if test "$with_projlib" != "" ; then
+ PROJ_LIB=$with_projlib
+ PROJ_SETTING=external
+ echo "Using PROJ_LIB=$PROJ_LIB for PROJ.4 library."
+fi
+
+
+# Check whether --with-projinc or --without-projinc was given.
+if test "${with_projinc+set}" = set; then
+ withval="$with_projinc"
+
+fi;
+
+if test "$with_projinc" != "" ; then
+ PROJ_INCLUDE=-I${with_projinc}
+ PROJ_SETTING=external
+ echo "Using PROJ_INCLUDE=$PROJ_INCLUDE for PROJ.4 includes."
+fi
+
+if test "$PROJ_SETTING" = "internal" ; then
+ echo "Using internal PROJ.4 implementation."
+fi
+
+PROJ_SETTING=$PROJ_SETTING
+
+PROJ_INCLUDE=$PROJ_INCLUDE
+
+PROJ_LIB=$PROJ_LIB
+
+
+
+ZLIB_SETTING=internal
+ZLIB_INCLUDE=
+ZLIB_LIB=
+export ZLIB_LIB ZLIB_INCLUDE ZLIB_SETTING
+
+
+# Check whether --with-zlib or --without-zlib was given.
+if test "${with_zlib+set}" = set; then
+ withval="$with_zlib"
+
+fi;
+
+if test "$with_zlib" = "yes" ; then
+
+ echo "$as_me:$LINENO: checking for deflateInit_ in -lz" >&5
+echo $ECHO_N "checking for deflateInit_ in -lz... $ECHO_C" >&6
+if test "${ac_cv_lib_z_deflateInit_+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lz $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char deflateInit_ ();
+int
+main ()
+{
+deflateInit_ ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_z_deflateInit_=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_z_deflateInit_=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_z_deflateInit_" >&5
+echo "${ECHO_T}$ac_cv_lib_z_deflateInit_" >&6
+if test $ac_cv_lib_z_deflateInit_ = yes; then
+ ZLIB_SETTING=external
+else
+ ZLIB_SETTING=missing
+fi
+
+
+for ac_header in zlib.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists. ##
+## ------------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+ if test $ZLIB_SETTING = missing ; then
+ { { echo "$as_me:$LINENO: error: Unable to find external ZLIB library, give path or use default internal library." >&5
+echo "$as_me: error: Unable to find external ZLIB library, give path or use default internal library." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ if test "$ac_cv_header_zlib_h" = no ; then
+ { { echo "$as_me:$LINENO: error: Unable to find external ZLIB zlib.h file, give path or use default internal library." >&5
+echo "$as_me: error: Unable to find external ZLIB zlib.h file, give path or use default internal library." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ ZLIB_SETTING=external
+ ZLIB_LIB=-lz
+
+elif test "$with_zlib" != "no" -a "$with_zlib" != "" ; then
+
+ if test -r $with_zlib/include/zlib.h ; then
+ echo "$as_me:$LINENO: result: checking for $with_zlib/include/zlib.h ... found" >&5
+echo "${ECHO_T}checking for $with_zlib/include/zlib.h ... found" >&6
+ ZLIB_INCLUDE=-I$with_zlib/include
+ elif test -r $with_zlib/zlib.h ; then
+ echo "$as_me:$LINENO: result: checking for $with_zlib/zlib.h ... found" >&5
+echo "${ECHO_T}checking for $with_zlib/zlib.h ... found" >&6
+ ZLIB_INCLUDE=-I$with_zlib
+ else
+ { { echo "$as_me:$LINENO: error: Unable to find $with_zlib/include/zlib.h" >&5
+echo "$as_me: error: Unable to find $with_zlib/include/zlib.h" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ if test -r $with_zlib/lib/libz.so ; then
+ ZLIB_LIB=$with_zlib/lib/libz.so
+ echo "$as_me:$LINENO: result: checking for $ZLIB_LIB ... found" >&5
+echo "${ECHO_T}checking for $ZLIB_LIB ... found" >&6
+
+ elif test -r $with_zlib/lib/libz.a ; then
+ ZLIB_LIB=$with_zlib/lib/libz.a
+ echo "$as_me:$LINENO: result: checking for $ZLIB_LIB ... found" >&5
+echo "${ECHO_T}checking for $ZLIB_LIB ... found" >&6
+
+ elif test -r $with_zlib/libz.so ; then
+ ZLIB_LIB=$with_zlib/libz.so
+ echo "$as_me:$LINENO: result: checking for $ZLIB_LIB ... found" >&5
+echo "${ECHO_T}checking for $ZLIB_LIB ... found" >&6
+
+ elif test -r $with_zlib/libz.a ; then
+ ZLIB_LIB=$with_zlib/libz.a
+ echo "$as_me:$LINENO: result: checking for $ZLIB_LIB ... found" >&5
+echo "${ECHO_T}checking for $ZLIB_LIB ... found" >&6
+
+ else
+ { { echo "$as_me:$LINENO: error: Unable to find $with_zlib/{lib/,}libz.{so,a}" >&5
+echo "$as_me: error: Unable to find $with_zlib/{lib/,}libz.{so,a}" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ ZLIB_SETTING=external
+
+fi
+
+
+# Check whether --with-zliblib or --without-zliblib was given.
+if test "${with_zliblib+set}" = set; then
+ withval="$with_zliblib"
+
+fi;
+
+if test "$with_zliblib" != "" ; then
+ ZLIB_LIB=$with_zliblib
+ ZLIB_SETTING=external
+ echo "$as_me:$LINENO: result: Using ZLIB_LIB=$ZLIB_LIB for ZLIB library." >&5
+echo "${ECHO_T}Using ZLIB_LIB=$ZLIB_LIB for ZLIB library." >&6
+fi
+
+
+# Check whether --with-zlibinc or --without-zlibinc was given.
+if test "${with_zlibinc+set}" = set; then
+ withval="$with_zlibinc"
+
+fi;
+
+if test "$with_zlibinc" != "" ; then
+ ZLIB_INCLUDE=-I${with_zlibinc}
+ ZLIB_SETTING=external
+ echo "$as_me:$LINENO: result: Using ZLIB_INCLUDE=$ZLIB_INCLUDE for ZLIB includes." >&5
+echo "${ECHO_T}Using ZLIB_INCLUDE=$ZLIB_INCLUDE for ZLIB includes." >&6
+fi
+
+if test "$ZLIB_SETTING" = "internal" ; then
+ echo "$as_me:$LINENO: result: Using internal ZLIB implementation." >&5
+echo "${ECHO_T}Using internal ZLIB implementation." >&6
+fi
+
+ZLIB_SETTING=$ZLIB_SETTING
+
+ZLIB_INCLUDE=$ZLIB_INCLUDE
+
+ZLIB_LIB=$ZLIB_LIB
+
+
+
+EXPAT_SETTING=internal
+EXPAT_INCLUDE=
+EXPAT_LIB=
+export EXPAT_LIB EXPAT_INCLUDE EXPAT_SETTING
+
+
+# Check whether --with-expat or --without-expat was given.
+if test "${with_expat+set}" = set; then
+ withval="$with_expat"
+
+fi;
+
+if test "$with_expat" = "yes" ; then
+
+ echo "$as_me:$LINENO: checking for XML_ParserCreate in -lexpat" >&5
+echo $ECHO_N "checking for XML_ParserCreate in -lexpat... $ECHO_C" >&6
+if test "${ac_cv_lib_expat_XML_ParserCreate+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lexpat $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char XML_ParserCreate ();
+int
+main ()
+{
+XML_ParserCreate ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_expat_XML_ParserCreate=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_expat_XML_ParserCreate=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_expat_XML_ParserCreate" >&5
+echo "${ECHO_T}$ac_cv_lib_expat_XML_ParserCreate" >&6
+if test $ac_cv_lib_expat_XML_ParserCreate = yes; then
+ EXPAT_SETTING=external
+else
+ EXPAT_SETTING=missing
+fi
+
+
+for ac_header in expat.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists. ##
+## ------------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+ if test $EXPAT_SETTING = missing ; then
+ { { echo "$as_me:$LINENO: error: Unable to find external Expat library, give path or use default internal library." >&5
+echo "$as_me: error: Unable to find external Expat library, give path or use default internal library." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ if test "$ac_cv_header_expat_h" = no ; then
+ { { echo "$as_me:$LINENO: error: Unable to find external expat.h file, give path or use default internal library." >&5
+echo "$as_me: error: Unable to find external expat.h file, give path or use default internal library." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ EXPAT_SETTING=external
+ EXPAT_LIB=-lexpat
+
+elif test "$with_expat" = "no" ; then
+ echo "Disabled use of Expat library, and XML capabilities parsing."
+ EXPAT_SETTING=disabled
+
+elif test "$with_expat" != "" ; then
+
+ if test -r $with_expat/include/expat.h ; then
+ echo "checking for $with_expat/include/expat.h ... found"
+ EXPAT_INCLUDE=-I$with_expat/include
+ elif test -r $with_expat/expat.h ; then
+ echo "checking for $with_expat/expat.h ... found"
+ EXPAT_INCLUDE=-I$with_expat
+ else
+ { { echo "$as_me:$LINENO: error: Unable to find $with_expat/include/expat.h" >&5
+echo "$as_me: error: Unable to find $with_expat/include/expat.h" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ if test -r $with_expat/lib/libexpat.so ; then
+ EXPAT_LIB=$with_expat/lib/libexpat.so
+ echo "checking for $EXPAT_LIB ... found"
+
+ elif test -r $with_expat/lib/libexpat.a ; then
+ EXPAT_LIB=$with_expat/lib/libexpat.a
+ echo "checking for $EXPAT_LIB ... found"
+
+ elif test -r $with_expat/libexpat.so ; then
+ EXPAT_LIB=$with_expat/libexpat.so
+ echo "checking for $EXPAT_LIB ... found"
+
+ elif test -r $with_expat/libexpat.a ; then
+ EXPAT_LIB=$with_expat/libexpat.a
+ echo "checking for $EXPAT_LIB ... found"
+
+ else
+ { { echo "$as_me:$LINENO: error: Unable to find $with_expat/{lib/,}libexpat.{so,a}" >&5
+echo "$as_me: error: Unable to find $with_expat/{lib/,}libexpat.{so,a}" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ EXPAT_SETTING=external
+fi
+
+
+# Check whether --with-expatlib or --without-expatlib was given.
+if test "${with_expatlib+set}" = set; then
+ withval="$with_expatlib"
+
+fi;
+
+if test "$with_expatlib" != "" ; then
+ EXPAT_LIB=$with_expatlib
+ EXPAT_SETTING=external
+ echo "Using EXPAT_LIB=$EXPAT_LIB for Expat library."
+fi
+
+
+# Check whether --with-expatinc or --without-expatinc was given.
+if test "${with_expatinc+set}" = set; then
+ withval="$with_expatinc"
+
+fi;
+
+if test "$with_expatinc" != "" ; then
+ EXPAT_INCLUDE=-I${with_expatinc}
+ EXPAT_SETTING=external
+ echo "Using EXPAT_INCLUDE=$EXPAT_INCLUDE for Expat includes."
+fi
+
+if test "$EXPAT_SETTING" = "internal" ; then
+ echo "Using internal Expat implementation."
+fi
+
+EXPAT_SETTING=$EXPAT_SETTING
+
+EXPAT_INCLUDE=$EXPAT_INCLUDE
+
+EXPAT_LIB=$EXPAT_LIB
+
+
+# Allow the pkg-config directory to be set
+
+# Check whether --with-pkgconfigdir or --without-pkgconfigdir was given.
+if test "${with_pkgconfigdir+set}" = set; then
+ withval="$with_pkgconfigdir"
+ pkgconfigdir=${withval}
+else
+ pkgconfigdir='${libdir}/pkgconfig'
+fi;
+
+{ echo "$as_me:$LINENO: pkgconfig directory is ${pkgconfigdir}" >&5
+echo "$as_me: pkgconfig directory is ${pkgconfigdir}" >&6;}
+
+# Make the *-config binary config scripts optional
+
+# Check whether --with-binconfigs or --without-binconfigs was given.
+if test "${with_binconfigs+set}" = set; then
+ withval="$with_binconfigs"
+ if test "${withval}" = no; then
+ binconfigs=
+ { echo "$as_me:$LINENO: ogdi-config scripts will not be built" >&5
+echo "$as_me: ogdi-config scripts will not be built" >&6;}
+ else
+ binconfigs='${binconfigs}'
+ fi
+else
+ binconfigs='${binconfigs}'
+fi;
+
+
+# Config files, substituting as above
+ ac_config_files="$ac_config_files config/common.mak:config/common.mak.in"
+
+ ac_config_files="$ac_config_files ogdi.pc:ogdi.pc.in"
+
+ ac_config_files="$ac_config_files ogdi-config:ogdi-config.in"
+
+
+ ac_config_files="$ac_config_files config/generic.mak"
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+ (set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+} |
+ sed '
+ t clear
+ : clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
+ if test -w $cache_file; then
+ test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+ cat confcache >$cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ ]*$//;
+}'
+fi
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+#
+# If the first sed substitution is executed (which looks for macros that
+# take arguments), then we branch to the quote section. Otherwise,
+# look for a macro that doesn't take arguments.
+cat >confdef2opt.sed <<\_ACEOF
+t clear
+: clear
+s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g
+t quote
+s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g
+t quote
+d
+: quote
+s,[ `~#$^&*(){}\\|;'"<>?],\\&,g
+s,\[,\\&,g
+s,\],\\&,g
+s,\$,$$,g
+p
+_ACEOF
+# We use echo to avoid assuming a particular line-breaking character.
+# The extra dot is to prevent the shell from consuming trailing
+# line-breaks from the sub-command output. A line-break within
+# single-quotes doesn't work because, if this script is created in a
+# platform that uses two characters for line-breaks (e.g., DOS), tr
+# would break.
+ac_LF_and_DOT=`echo; echo .`
+DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'`
+rm -f confdef2opt.sed
+
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_i=`echo "$ac_i" |
+ sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+ # 2. Add them.
+ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling. Logging --version etc. is OK.
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+ echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+ echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+ echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+ echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+
+Configuration files:
+$config_files
+
+Report bugs to <bug-autoconf at gnu.org>."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.59,
+ with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value. By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "x$1" : 'x\([^=]*\)='`
+ ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ -*)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ *) # This is not an option, so the user has probably given explicit
+ # arguments.
+ ac_option=$1
+ ac_need_defaults=false;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --vers* | -V )
+ echo "$ac_cs_version"; exit 0 ;;
+ --he | --h)
+ # Conflict between --help and --header
+ { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ echo "$ac_cs_usage"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+ ac_need_defaults=false;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1" ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+
+
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+ case "$ac_config_target" in
+ # Handling of arguments.
+ "config/common.mak" ) CONFIG_FILES="$CONFIG_FILES config/common.mak:config/common.mak.in" ;;
+ "ogdi.pc" ) CONFIG_FILES="$CONFIG_FILES ogdi.pc:ogdi.pc.in" ;;
+ "ogdi-config" ) CONFIG_FILES="$CONFIG_FILES ogdi-config:ogdi-config.in" ;;
+ "config/generic.mak" ) CONFIG_FILES="$CONFIG_FILES config/generic.mak" ;;
+ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./confstat$$-$RANDOM
+ (umask 077 && mkdir $tmp)
+} ||
+{
+ echo "$me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+ # Protect against being on the right side of a sed subst in config.status.
+ sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+ s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s, at SHELL@,$SHELL,;t t
+s, at PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s, at PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s, at PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s, at PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s, at PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s, at PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s, at exec_prefix@,$exec_prefix,;t t
+s, at prefix@,$prefix,;t t
+s, at program_transform_name@,$program_transform_name,;t t
+s, at bindir@,$bindir,;t t
+s, at sbindir@,$sbindir,;t t
+s, at libexecdir@,$libexecdir,;t t
+s, at datadir@,$datadir,;t t
+s, at sysconfdir@,$sysconfdir,;t t
+s, at sharedstatedir@,$sharedstatedir,;t t
+s, at localstatedir@,$localstatedir,;t t
+s, at libdir@,$libdir,;t t
+s, at includedir@,$includedir,;t t
+s, at oldincludedir@,$oldincludedir,;t t
+s, at infodir@,$infodir,;t t
+s, at mandir@,$mandir,;t t
+s, at build_alias@,$build_alias,;t t
+s, at host_alias@,$host_alias,;t t
+s, at target_alias@,$target_alias,;t t
+s, at DEFS@,$DEFS,;t t
+s, at ECHO_C@,$ECHO_C,;t t
+s, at ECHO_N@,$ECHO_N,;t t
+s, at ECHO_T@,$ECHO_T,;t t
+s, at LIBS@,$LIBS,;t t
+s, at OGDI_VERSION@,$OGDI_VERSION,;t t
+s, at OGDI_MAJOR@,$OGDI_MAJOR,;t t
+s, at OGDI_MINOR@,$OGDI_MINOR,;t t
+s, at CC@,$CC,;t t
+s, at CFLAGS@,$CFLAGS,;t t
+s, at LDFLAGS@,$LDFLAGS,;t t
+s, at CPPFLAGS@,$CPPFLAGS,;t t
+s, at ac_ct_CC@,$ac_ct_CC,;t t
+s, at EXEEXT@,$EXEEXT,;t t
+s, at OBJEXT@,$OBJEXT,;t t
+s, at CXX_WFLAGS@,$CXX_WFLAGS,;t t
+s, at C_WFLAGS@,$C_WFLAGS,;t t
+s, at CXX_PIC@,$CXX_PIC,;t t
+s, at C_PIC@,$C_PIC,;t t
+s, at LD_SHARED@,$LD_SHARED,;t t
+s, at CPP@,$CPP,;t t
+s, at EGREP@,$EGREP,;t t
+s, at RPC_INCLUDES@,$RPC_INCLUDES,;t t
+s, at BIG_ENDIAN@,$BIG_ENDIAN,;t t
+s, at PROJ_SETTING@,$PROJ_SETTING,;t t
+s, at PROJ_INCLUDE@,$PROJ_INCLUDE,;t t
+s, at PROJ_LIB@,$PROJ_LIB,;t t
+s, at ZLIB_SETTING@,$ZLIB_SETTING,;t t
+s, at ZLIB_INCLUDE@,$ZLIB_INCLUDE,;t t
+s, at ZLIB_LIB@,$ZLIB_LIB,;t t
+s, at EXPAT_SETTING@,$EXPAT_SETTING,;t t
+s, at EXPAT_INCLUDE@,$EXPAT_INCLUDE,;t t
+s, at EXPAT_LIB@,$EXPAT_LIB,;t t
+s, at pkgconfigdir@,$pkgconfigdir,;t t
+s, at binconfigs@,$binconfigs,;t t
+s, at LIBOBJS@,$LIBOBJS,;t t
+s, at LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+ cat >>$CONFIG_STATUS <<\_ACEOF
+ # Split the substitutions into bite-sized pieces for seds with
+ # small command number limits, like on Digital OSF/1 and HP-UX.
+ ac_max_sed_lines=48
+ ac_sed_frag=1 # Number of current file.
+ ac_beg=1 # First line for current file.
+ ac_end=$ac_max_sed_lines # Line after last line for current file.
+ ac_more_lines=:
+ ac_sed_cmds=
+ while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ else
+ sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ fi
+ if test ! -s $tmp/subs.frag; then
+ ac_more_lines=false
+ else
+ # The purpose of the label and of the branching condition is to
+ # speed up the sed processing (if there are no `@' at all, there
+ # is no need to browse any of the substitutions).
+ # These are the two extra sed commands mentioned above.
+ (echo ':t
+ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+ fi
+ ac_sed_frag=`expr $ac_sed_frag + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_lines`
+ fi
+ done
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+ fi
+fi # test -n "$CONFIG_FILES"
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+
+ if test x"$ac_file" != x-; then
+ { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+ rm -f "$ac_file"
+ fi
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ configure_input=
+ else
+ configure_input="$ac_file. "
+ fi
+ configure_input=$configure_input"Generated from `echo $ac_file_in |
+ sed 's,.*/,,'` by configure."
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s, at configure_input@,$configure_input,;t t
+s, at srcdir@,$ac_srcdir,;t t
+s, at abs_srcdir@,$ac_abs_srcdir,;t t
+s, at top_srcdir@,$ac_top_srcdir,;t t
+s, at abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s, at builddir@,$ac_builddir,;t t
+s, at abs_builddir@,$ac_abs_builddir,;t t
+s, at top_builddir@,$ac_top_builddir,;t t
+s, at abs_top_builddir@,$ac_abs_top_builddir,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+ rm -f $tmp/stdin
+ if test x"$ac_file" != x-; then
+ mv $tmp/out $ac_file
+ else
+ cat $tmp/out
+ rm -f $tmp/out
+ fi
+
+ # Run the commands associated with the file.
+ case $ac_file in
+ ogdi-config ) chmod +x ogdi-config ;;
+ esac
+done
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+
+mv config/generic.mak config/`uname`.mak
+
Property changes on: packages/ogdi-dfsg/branches/upstream/current/configure
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/configure.in
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/configure.in 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/configure.in 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,353 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(config/unix.mak)
+
+OGDI_VERSION=3.2.0beta1
+OGDI_MAJOR=3
+OGDI_MINOR=2
+
+AC_SUBST(OGDI_VERSION)
+AC_SUBST(OGDI_MAJOR)
+AC_SUBST(OGDI_MINOR)
+
+dnl ---------------------------------------------------------------------------
+dnl Check if we have a doomed configuration.
+dnl ---------------------------------------------------------------------------
+
+if test "$TOPDIR" = "" ; then
+ AC_MSG_ERROR([Required TOPDIR environment variable not set, see README.])
+fi
+
+if test "$OS" = "Windows_NT" ; then
+ AC_MSG_ERROR([Please don't use configure for Windows, see README.])
+fi
+
+dnl Checks for programs.
+AC_PROG_CC
+
+dnl We always want to check /usr/local for stuff.
+dnl LIBS="$LIBS -L/usr/local/lib"
+dnl CFLAGS="$CFLAGS -I/usr/local/include"
+
+dnl Checks for libraries.
+AC_CHECK_LIB(dl,dlopen,,,)
+
+dnl check for various compiler flags.
+AC_COMPILER_WFLAGS
+AC_COMPILER_PIC
+AC_LD_SHARED
+
+dnl Strip out optimization if already added
+CFLAGS=`echo "$CFLAGS " | sed "s/-O2 //"`
+
+dnl ---------------------------------------------------------------------------
+dnl Do we have rpc/pmap_clnt.h, float.h, dlfcn.h?
+dnl ---------------------------------------------------------------------------
+AC_CHECK_HEADERS(rpc/pmap_clnt.h float.h dlfcn.h)
+
+if test "$ac_cv_header_rpc_pmap_clnt_h" = yes ; then
+ RPC_INCLUDES=-DHAVE_STD_RPC_INCLUDES
+else
+ RPC_INCLUDES=
+fi
+AC_SUBST(RPC_INCLUDES,$RPC_INCLUDES)
+
+if test "$ac_cv_header_float_h" = no ; then
+ CFLAGS="$CFLAGS -DMISSING_FLOAT_H"
+fi
+if test "$ac_cv_header_dlfcn_h" = no ; then
+ CFLAGS="$CFLAGS -DMISSING_DLFCN_H"
+fi
+
+dnl ---------------------------------------------------------------------------
+dnl Check endian-ness.
+dnl ---------------------------------------------------------------------------
+AC_C_BIGENDIAN
+if test $ac_cv_c_bigendian = yes ; then
+ BIG_ENDIAN=1
+else
+ BIG_ENDIAN=0
+fi
+AC_SUBST(BIG_ENDIAN,$BIG_ENDIAN)
+
+dnl ---------------------------------------------------------------------------
+dnl Check for libproj override.
+dnl ---------------------------------------------------------------------------
+
+PROJ_SETTING=internal
+PROJ_INCLUDE=
+PROJ_LIB=
+export PROJ_LIB PROJ_INCLUDE PROJ_SETTING
+
+AC_ARG_WITH(proj,[ --with-proj[=ARG] Utilize external PROJ.4 support],,)
+
+if test "$with_proj" = "yes" ; then
+
+ AC_CHECK_LIB(proj,pj_init,PROJ_SETTING=external,PROJ_SETTING=missing,)
+ AC_CHECK_HEADERS(projects.h)
+
+ if test $PROJ_SETTING = missing ; then
+ AC_MSG_ERROR([Unable to find external PROJ.4 library, give path or use default internal library.])
+ fi
+ if test "$ac_cv_header_projects_h" = no ; then
+ AC_MSG_ERROR([Unable to find external PROJ.4 projects.h file, give path or use default internal library.])
+ fi
+
+ PROJ_SETTING=external
+ PROJ_LIB=-lproj
+
+elif test "$with_proj" != "no" -a "$with_proj" != "" ; then
+
+ if test -r $with_proj/include/projects.h ; then
+ echo "checking for $with_proj/include/projects.h ... found"
+ PROJ_INCLUDE=-I$with_proj/include
+ else
+ AC_MSG_ERROR([Unable to find $with_proj/include/projects.h])
+ fi
+
+ if test -r $with_proj/lib/libproj.so ; then
+ PROJ_LIB=$with_proj/lib/libproj.so
+ echo "checking for $PROJ_LIB ... found"
+
+ elif test -r $with_proj/lib/libproj.a ; then
+ PROJ_LIB=$with_proj/lib/libproj.a
+ echo "checking for $PROJ_LIB ... found"
+
+ else
+ AC_MSG_ERROR([Unable to find $with_proj/lib/libproj.{so,a}])
+ fi
+
+ PROJ_SETTING=external
+
+fi
+
+AC_ARG_WITH(projlib,[ --with-projlib=path Select PROJ.4 library],,)
+
+if test "$with_projlib" != "" ; then
+ PROJ_LIB=$with_projlib
+ PROJ_SETTING=external
+ echo "Using PROJ_LIB=$PROJ_LIB for PROJ.4 library."
+fi
+
+AC_ARG_WITH(projinc,[ --with-projinc=path Select PROJ.4 include directory],,)
+
+if test "$with_projinc" != "" ; then
+ PROJ_INCLUDE=-I${with_projinc}
+ PROJ_SETTING=external
+ echo "Using PROJ_INCLUDE=$PROJ_INCLUDE for PROJ.4 includes."
+fi
+
+if test "$PROJ_SETTING" = "internal" ; then
+ echo "Using internal PROJ.4 implementation."
+fi
+
+AC_SUBST(PROJ_SETTING,$PROJ_SETTING)
+AC_SUBST(PROJ_INCLUDE,$PROJ_INCLUDE)
+AC_SUBST(PROJ_LIB,$PROJ_LIB)
+
+dnl ---------------------------------------------------------------------------
+dnl Check for zlib override.
+dnl ---------------------------------------------------------------------------
+
+ZLIB_SETTING=internal
+ZLIB_INCLUDE=
+ZLIB_LIB=
+export ZLIB_LIB ZLIB_INCLUDE ZLIB_SETTING
+
+AC_ARG_WITH(zlib,[ --with-zlib[=ARG] Utilize external ZLIB support],,)
+
+if test "$with_zlib" = "yes" ; then
+
+ AC_CHECK_LIB(z,deflateInit_,ZLIB_SETTING=external,ZLIB_SETTING=missing,)
+ AC_CHECK_HEADERS(zlib.h)
+
+ if test $ZLIB_SETTING = missing ; then
+ AC_MSG_ERROR([Unable to find external ZLIB library, give path or use default internal library.])
+ fi
+ if test "$ac_cv_header_zlib_h" = no ; then
+ AC_MSG_ERROR([Unable to find external ZLIB zlib.h file, give path or use default internal library.])
+ fi
+
+ ZLIB_SETTING=external
+ ZLIB_LIB=-lz
+
+elif test "$with_zlib" != "no" -a "$with_zlib" != "" ; then
+
+ if test -r $with_zlib/include/zlib.h ; then
+ AC_MSG_RESULT([checking for $with_zlib/include/zlib.h ... found])
+ ZLIB_INCLUDE=-I$with_zlib/include
+ elif test -r $with_zlib/zlib.h ; then
+ AC_MSG_RESULT([checking for $with_zlib/zlib.h ... found])
+ ZLIB_INCLUDE=-I$with_zlib
+ else
+ AC_MSG_ERROR([Unable to find $with_zlib/include/zlib.h])
+ fi
+
+ if test -r $with_zlib/lib/libz.so ; then
+ ZLIB_LIB=$with_zlib/lib/libz.so
+ AC_MSG_RESULT([checking for $ZLIB_LIB ... found])
+
+ elif test -r $with_zlib/lib/libz.a ; then
+ ZLIB_LIB=$with_zlib/lib/libz.a
+ AC_MSG_RESULT([checking for $ZLIB_LIB ... found])
+
+ elif test -r $with_zlib/libz.so ; then
+ ZLIB_LIB=$with_zlib/libz.so
+ AC_MSG_RESULT([checking for $ZLIB_LIB ... found])
+
+ elif test -r $with_zlib/libz.a ; then
+ ZLIB_LIB=$with_zlib/libz.a
+ AC_MSG_RESULT([checking for $ZLIB_LIB ... found])
+
+ else
+ AC_MSG_ERROR([Unable to find $with_zlib/{lib/,}libz.{so,a}])
+ fi
+
+ ZLIB_SETTING=external
+
+fi
+
+AC_ARG_WITH(zliblib,[ --with-zliblib=path Select ZLIB library],,)
+
+if test "$with_zliblib" != "" ; then
+ ZLIB_LIB=$with_zliblib
+ ZLIB_SETTING=external
+ AC_MSG_RESULT([Using ZLIB_LIB=$ZLIB_LIB for ZLIB library.])
+fi
+
+AC_ARG_WITH(zlibinc,[ --with-zlibinc=path Select ZLIB include directory],,)
+
+if test "$with_zlibinc" != "" ; then
+ ZLIB_INCLUDE=-I${with_zlibinc}
+ ZLIB_SETTING=external
+ AC_MSG_RESULT([Using ZLIB_INCLUDE=$ZLIB_INCLUDE for ZLIB includes.])
+fi
+
+if test "$ZLIB_SETTING" = "internal" ; then
+ AC_MSG_RESULT([Using internal ZLIB implementation.])
+fi
+
+AC_SUBST(ZLIB_SETTING,$ZLIB_SETTING)
+AC_SUBST(ZLIB_INCLUDE,$ZLIB_INCLUDE)
+AC_SUBST(ZLIB_LIB,$ZLIB_LIB)
+
+dnl ---------------------------------------------------------------------------
+dnl Check for expat override, or disabling.
+dnl ---------------------------------------------------------------------------
+
+EXPAT_SETTING=internal
+EXPAT_INCLUDE=
+EXPAT_LIB=
+export EXPAT_LIB EXPAT_INCLUDE EXPAT_SETTING
+
+AC_ARG_WITH(expat,[ --with-expat[=ARG] Utilize external Expat library, or disable Expat.],,)
+
+if test "$with_expat" = "yes" ; then
+
+ AC_CHECK_LIB(expat,XML_ParserCreate,EXPAT_SETTING=external,EXPAT_SETTING=missing,)
+ AC_CHECK_HEADERS(expat.h)
+
+ if test $EXPAT_SETTING = missing ; then
+ AC_MSG_ERROR([Unable to find external Expat library, give path or use default internal library.])
+ fi
+ if test "$ac_cv_header_expat_h" = no ; then
+ AC_MSG_ERROR([Unable to find external expat.h file, give path or use default internal library.])
+ fi
+
+ EXPAT_SETTING=external
+ EXPAT_LIB=-lexpat
+
+elif test "$with_expat" = "no" ; then
+ echo "Disabled use of Expat library, and XML capabilities parsing."
+ EXPAT_SETTING=disabled
+
+elif test "$with_expat" != "" ; then
+
+ if test -r $with_expat/include/expat.h ; then
+ echo "checking for $with_expat/include/expat.h ... found"
+ EXPAT_INCLUDE=-I$with_expat/include
+ elif test -r $with_expat/expat.h ; then
+ echo "checking for $with_expat/expat.h ... found"
+ EXPAT_INCLUDE=-I$with_expat
+ else
+ AC_MSG_ERROR([Unable to find $with_expat/include/expat.h])
+ fi
+
+ if test -r $with_expat/lib/libexpat.so ; then
+ EXPAT_LIB=$with_expat/lib/libexpat.so
+ echo "checking for $EXPAT_LIB ... found"
+
+ elif test -r $with_expat/lib/libexpat.a ; then
+ EXPAT_LIB=$with_expat/lib/libexpat.a
+ echo "checking for $EXPAT_LIB ... found"
+
+ elif test -r $with_expat/libexpat.so ; then
+ EXPAT_LIB=$with_expat/libexpat.so
+ echo "checking for $EXPAT_LIB ... found"
+
+ elif test -r $with_expat/libexpat.a ; then
+ EXPAT_LIB=$with_expat/libexpat.a
+ echo "checking for $EXPAT_LIB ... found"
+
+ else
+ AC_MSG_ERROR([Unable to find $with_expat/{lib/,}libexpat.{so,a}])
+ fi
+
+ EXPAT_SETTING=external
+fi
+
+AC_ARG_WITH(expatlib,[ --with-expatlib=path Select Expat library],,)
+
+if test "$with_expatlib" != "" ; then
+ EXPAT_LIB=$with_expatlib
+ EXPAT_SETTING=external
+ echo "Using EXPAT_LIB=$EXPAT_LIB for Expat library."
+fi
+
+AC_ARG_WITH(expatinc,[ --with-expatinc=path Select Expat include directory],,)
+
+if test "$with_expatinc" != "" ; then
+ EXPAT_INCLUDE=-I${with_expatinc}
+ EXPAT_SETTING=external
+ echo "Using EXPAT_INCLUDE=$EXPAT_INCLUDE for Expat includes."
+fi
+
+if test "$EXPAT_SETTING" = "internal" ; then
+ echo "Using internal Expat implementation."
+fi
+
+AC_SUBST(EXPAT_SETTING,$EXPAT_SETTING)
+AC_SUBST(EXPAT_INCLUDE,$EXPAT_INCLUDE)
+AC_SUBST(EXPAT_LIB,$EXPAT_LIB)
+
+# Allow the pkg-config directory to be set
+AC_ARG_WITH(pkgconfigdir,
+ AC_HELP_STRING([--with-pkgconfigdir],
+ [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
+ [pkgconfigdir=${withval}],
+ [pkgconfigdir='${libdir}/pkgconfig'])
+AC_SUBST([pkgconfigdir])
+AC_MSG_NOTICE([pkgconfig directory is ${pkgconfigdir}])
+
+# Make the *-config binary config scripts optional
+AC_ARG_WITH(binconfigs,
+ AC_HELP_STRING([--with-binconfigs],
+ [Generate shell ogdi-config scripts as well as pkg-config data]
+ [@<:@default=yes@:>@]),
+ [if test "${withval}" = no; then
+ binconfigs=
+ AC_MSG_NOTICE([ogdi-config scripts will not be built])
+ else
+ binconfigs='${binconfigs}'
+ fi],
+ [binconfigs='${binconfigs}'])
+AC_SUBST([binconfigs])
+
+# Config files, substituting as above
+AC_CONFIG_FILES([config/common.mak:config/common.mak.in])
+AC_CONFIG_FILES([ogdi.pc:ogdi.pc.in])
+AC_CONFIG_FILES([ogdi-config:ogdi-config.in],
+ [chmod +x ogdi-config])
+
+AC_OUTPUT(config/generic.mak)
+mv config/generic.mak config/`uname`.mak
+
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gbgetsymbol.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gbgetsymbol.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gbgetsymbol.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,141 @@
+/******************************************************************************
+ * $Id: gbgetsymbol.c,v 1.1 2001/05/04 03:13:35 warmerda Exp $
+ *
+ * Project: GDAL Bridge
+ * Purpose: Fetch a function pointer from a shared library / DLL.
+ * Author: Frank Warmerdam, warmerda at home.com
+ *
+ * Adapted from cplgetsymbol.cpp.
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $Log: gbgetsymbol.c,v $
+ * Revision 1.1 2001/05/04 03:13:35 warmerda
+ * New
+ *
+ * Revision 1.1 2000/10/25 16:43:20 warmerda
+ * New
+ *
+ * Revision 1.2 2000/09/27 13:22:07 warmerda
+ * also allow for unix in check
+ *
+ * Revision 1.1 1999/04/21 23:01:31 warmerda
+ * New
+ *
+ */
+
+#include <stdio.h>
+#include "gdalbridge.h"
+
+/* ==================================================================== */
+/* Unix Implementation */
+/* ==================================================================== */
+#if defined(__unix__) || defined(unix)
+
+#include <dlfcn.h>
+
+/************************************************************************/
+/* GBGetSymbol() */
+/* */
+/* Note that this function doesn't: */
+/* o prevent the reference count on the library from going up */
+/* for every request, or given any opportunity to unload */
+/* the library. */
+/* o Attempt to look for the library in non-standard */
+/* locations. */
+/* o Attempt to try variations on the symbol name, like */
+/* pre-prending or post-pending an underscore. */
+/************************************************************************/
+
+void *GBGetSymbol( const char * pszLibrary, const char * pszSymbolName )
+
+{
+ void *pLibrary;
+ void *pSymbol;
+
+ pLibrary = dlopen(pszLibrary, RTLD_LAZY);
+ if( pLibrary == NULL )
+ {
+ return NULL;
+ }
+
+ pSymbol = dlsym( pLibrary, pszSymbolName );
+
+ if( pSymbol == NULL )
+ {
+ fprintf( stderr, "GBGetSymbol(): %s", dlerror() );
+ return NULL;
+ }
+
+ return( pSymbol );
+}
+
+#endif /* def __unix__ && defined(HAVE_DLFCN_H) */
+
+/* ==================================================================== */
+/* Windows Implementation */
+/* ==================================================================== */
+#ifdef _WIN32
+
+#include <windows.h>
+
+/************************************************************************/
+/* GBGetSymbol() */
+/* */
+/* Note that this function doesn't: */
+/* o prevent the reference count on the library from going up */
+/* for every request, or given any opportunity to unload */
+/* the library. */
+/* o Attempt to look for the library in non-standard */
+/* locations. */
+/* o Attempt to try variations on the symbol name, like */
+/* pre-prending or post-pending an underscore. */
+/************************************************************************/
+
+void *GBGetSymbol( const char * pszLibrary, const char * pszSymbolName )
+
+{
+ void *pLibrary;
+ void *pSymbol;
+
+ pLibrary = LoadLibrary(pszLibrary);
+ if( pLibrary == NULL )
+ {
+ return NULL;
+ }
+
+ pSymbol = GetProcAddress( (HINSTANCE) pLibrary, pszSymbolName );
+
+ if( pSymbol == NULL )
+ {
+ fprintf( stderr,
+ "GBGetSymbol(): Can't find requested entry point: %s\n",
+ pszSymbolName );
+ return NULL;
+ }
+
+ return( pSymbol );
+}
+
+#endif /* def _WIN32 */
+
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,22 @@
+LIBRARY gdal
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_CreateServer
+ dyn_DestroyServer
+ dyn_SelectLayer
+ dyn_ReleaseLayer
+ dyn_SelectRegion
+ dyn_GetDictionary
+ dyn_GetNextObject
+ dyn_UpdateDictionary
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_GetRasterInfo
+ dyn_GetObject
+ dyn_GetObjectIdFromCoord
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_SetServerLanguage
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal_serv.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal_serv.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal_serv.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,780 @@
+/**********************************************************************
+ * $Id: gdal_serv.c,v 1.1 2001/05/04 03:13:35 warmerda Exp $
+ *
+ * Project: GDAL OGDI Server
+ * Purpose: Implements dynamic entry points into the driver.
+ * Author: Frank Warmerda, warmerda at home.com
+ *
+ **********************************************************************
+ * Copyright (c) 2000, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ **********************************************************************
+ *
+ * $Log: gdal_serv.c,v $
+ * Revision 1.1 2001/05/04 03:13:35 warmerda
+ * New
+ *
+ * Revision 1.2 2000/08/28 20:21:47 warmerda
+ * minimally operational
+ *
+ * Revision 1.1 2000/08/23 19:40:17 warmerda
+ * New
+ *
+ */
+
+#include "gdal_serv.h"
+
+static void _releaseAllLayers(ecs_Server *s);
+
+/************************************************************************/
+/* dyn_CreateServer() */
+/************************************************************************/
+
+ecs_Result *dyn_CreateServer(ecs_Server *s, char *Request)
+
+{
+ ServerPrivateData *spriv;
+ int nPixels, nLines;
+ OGRSpatialReferenceH hSRS;
+ char *pszWKT;
+
+ (void) Request;
+
+/* -------------------------------------------------------------------- */
+/* Initialize GDAL Bridge */
+/* -------------------------------------------------------------------- */
+ if( !GDALBridgeInitialize( ".." ) )
+ {
+ ecs_SetError(&(s->result), 1,
+ "Unable to initialize GDAL Bridge." );
+ return &(s->result);
+ }
+
+ GDALAllRegister();
+
+/* -------------------------------------------------------------------- */
+/* Create server private information. */
+/* -------------------------------------------------------------------- */
+ spriv = s->priv = (ServerPrivateData *) malloc(sizeof(ServerPrivateData));
+ if (s->priv == NULL) {
+
+ ecs_SetError(&(s->result), 1,
+ "Could not connect to the skeleton driver, "
+ "not enough memory");
+ return &(s->result);
+ }
+
+/* -------------------------------------------------------------------- */
+/* Open the file. We should eventually capture the real error */
+/* message. */
+/* -------------------------------------------------------------------- */
+ spriv->hDS = GDALOpen( s->pathname, GA_ReadOnly );
+ if( spriv->hDS == NULL )
+ {
+ /* Don't forget to unallocate the previous priv */
+ free(s->priv);
+
+ ecs_SetError(&(s->result), 1,
+ "GDALOpen() open failed for given path.");
+ return &(s->result);
+ }
+
+/* -------------------------------------------------------------------- */
+/* Establish the global bounds. We will assume an unrotated */
+/* frame of reference for now, but this should be checked */
+/* later. */
+/* */
+/* We will treat the bottom left corner as the origin for raw */
+/* rasters in order to maintain a compatible orientation to */
+/* georeferenced rasters. */
+/* -------------------------------------------------------------------- */
+ nPixels = GDALGetRasterXSize( spriv->hDS );
+ nLines = GDALGetRasterYSize( spriv->hDS );
+ if( GDALGetGeoTransform( spriv->hDS, spriv->adfGeoTransform ) != CE_None
+ || (spriv->adfGeoTransform[0] == 0.0
+ && spriv->adfGeoTransform[1] == 1.0
+ && spriv->adfGeoTransform[2] == 0.0
+ && spriv->adfGeoTransform[3] == 0.0
+ && spriv->adfGeoTransform[4] == 0.0
+ && spriv->adfGeoTransform[5] == 1.0 ) )
+ {
+ spriv->adfGeoTransform[0] = 0.0;
+ spriv->adfGeoTransform[1] = 1.0;
+ spriv->adfGeoTransform[2] = 0.0;
+ spriv->adfGeoTransform[3] = 0.0;
+ spriv->adfGeoTransform[4] = 0.0;
+ spriv->adfGeoTransform[5] = -1.0;
+ }
+
+ s->globalRegion.north = spriv->adfGeoTransform[3];
+ s->globalRegion.south =
+ spriv->adfGeoTransform[3] + nLines * spriv->adfGeoTransform[5];
+ s->globalRegion.east =
+ spriv->adfGeoTransform[0] + nPixels * spriv->adfGeoTransform[1];
+ s->globalRegion.west = spriv->adfGeoTransform[0];
+ s->globalRegion.ns_res =
+ (s->globalRegion.north - s->globalRegion.south) / nLines;
+ s->globalRegion.ew_res =
+ (s->globalRegion.east - s->globalRegion.west) / nPixels;
+
+/* -------------------------------------------------------------------- */
+/* Establish the projection */
+/* -------------------------------------------------------------------- */
+ pszWKT = (char *) GDALGetProjectionRef(spriv->hDS);
+
+ spriv->pszProjection = NULL;
+
+ hSRS = OSRNewSpatialReference(NULL);
+ if( OSRImportFromWkt( hSRS, &pszWKT ) != OGRERR_NONE
+ || OSRExportToProj4( hSRS, &(spriv->pszProjection)) != OGRERR_NONE )
+ {
+ /* notdef: what should we used for "ungeoreferenced" datasets? */
+ spriv->pszProjection = strdup("+proj=utm +ellps=clrk66 +zone=13");
+ }
+ OSRDestroySpatialReference( hSRS );
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_DestroyServer() */
+/************************************************************************/
+
+ecs_Result *dyn_DestroyServer(s)
+ ecs_Server *s;
+{
+ ServerPrivateData *spriv = s->priv;
+
+ /*
+ Release all layers selection.
+ */
+
+ _releaseAllLayers(s);
+
+ /*
+ Release spriv
+ */
+
+ if (spriv != NULL) {
+ free( spriv->pszProjection );
+ if( spriv->hDS != NULL )
+ GDALClose( spriv->hDS );
+ free(spriv);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_SelectLayer() */
+/************************************************************************/
+
+ecs_Result *dyn_SelectLayer(ecs_Server *s, ecs_LayerSelection *sel)
+
+{
+ int layer;
+ LayerPrivateData *lpriv;
+ ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+
+ /*
+ First, try to find an existing layer with same request and family
+ using ecs_GetLayer.
+ */
+
+ if ((layer = ecs_GetLayer(s,sel)) != -1) {
+
+ /*
+ If it already exists than assign currentLayer and set index to 0
+ to force a rewind.
+ */
+
+ s->currentLayer = layer;
+ s->layer[layer].index = 0;
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+ }
+
+ /*
+ Is the layer name valid?
+ */
+
+ if( strncmp(sel->Select,"band_",5) != 0
+ || atoi(sel->Select+5) < 1
+ || atoi(sel->Select+5) > GDALGetRasterCount(spriv->hDS) )
+ {
+ ecs_SetError(&(s->result),1,
+ "Illegal layer identifier.");
+ return &(s->result);
+ }
+
+ /*
+ It did not exist so we try to create it with ecs_SetLayer. Don't
+ forget to set the current layer to this new layer.
+ */
+
+ if ((layer = ecs_SetLayer(s,sel)) == -1) {
+ return &(s->result);
+ }
+ s->currentLayer = layer;
+
+ /*
+ Allocate memory to hold private information about this new
+ layer.
+ */
+
+ s->layer[layer].priv = (void *) malloc(sizeof(LayerPrivateData));
+ if (s->layer[layer].priv == NULL) {
+ ecs_FreeLayer(s,layer);
+ ecs_SetError(&(s->result),1,
+ "Not enough memory to allocate layer private data");
+ return &(s->result);
+ }
+
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+
+ lpriv->nBand = atoi(sel->Select+5);
+ lpriv->hBand = GDALGetRasterBand( spriv->hDS, lpriv->nBand );
+ lpriv->nOGDIImageType = 0;
+
+ lpriv->dfMatrixScale = 1.0;
+ lpriv->dfMatrixOffset = 0.0;
+
+ if( sel->F == Image )
+ {
+ switch( GDALGetRasterDataType( lpriv->hBand ) )
+ {
+ case GDT_Byte:
+ lpriv->nOGDIImageType = 2;
+ lpriv->nGDALImageType = GDT_Byte;
+ break;
+
+ case GDT_UInt16:
+ lpriv->nOGDIImageType = 3;
+ lpriv->nGDALImageType = GDT_UInt16;
+ break;
+
+ case GDT_Int16:
+ lpriv->nOGDIImageType = 4;
+ lpriv->nGDALImageType = GDT_Int16;
+ break;
+
+ default:
+ lpriv->nOGDIImageType = 5;
+ lpriv->nGDALImageType = GDT_Int32;
+ break;
+ }
+ }
+
+ s->layer[layer].index = 0;
+
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_ReleaseLayer() */
+/************************************************************************/
+
+ecs_Result *dyn_ReleaseLayer(ecs_Server *s, ecs_LayerSelection *sel)
+
+{
+ int layer;
+ char buffer[200];
+
+ /*
+ First, try to find an existing layer with same request and family.
+ */
+
+ if ((layer = ecs_GetLayer(s,sel)) == -1) {
+ sprintf(buffer,"Invalid layer %s",sel->Select);
+ ecs_SetError(&(s->result),1,buffer);
+ return &(s->result);
+ }
+
+ /*
+ Free the content of lpriv.
+ */
+
+ free( s->layer[layer].priv );
+
+ /*
+ Free the layer.
+ */
+
+ ecs_FreeLayer(s,layer);
+
+ if (s->currentLayer == layer) {
+ s->currentLayer = -1; /* just in case released layer was selected */
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/************************************************************************/
+/* _releaseAllLayers() */
+/************************************************************************/
+
+static void _releaseAllLayers(ecs_Server *s)
+
+{
+ int i;
+
+ for (i = 0; i < s->nblayer; ++i)
+ dyn_ReleaseLayer(s,&(s->layer[i].sel));
+}
+
+/************************************************************************/
+/* dyn_SelectRegion() */
+/************************************************************************/
+
+ecs_Result *dyn_SelectRegion(ecs_Server *s,ecs_Region *gr)
+
+{
+ s->currentRegion.north = gr->north;
+ s->currentRegion.south = gr->south;
+ s->currentRegion.east = gr->east;
+ s->currentRegion.west = gr->west;
+ s->currentRegion.ns_res = gr->ns_res;
+ s->currentRegion.ew_res = gr->ew_res;
+
+ /*
+ Reset currentLayer index to 0 to force a rewind.
+ */
+
+ if (s->currentLayer != -1) {
+ s->layer[s->currentLayer].index = 0;
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_GetDictionary() */
+/************************************************************************/
+
+ecs_Result *dyn_GetDictionary(ecs_Server *s)
+
+{
+ if (ecs_SetText(&(s->result),"")) {
+ ecs_SetSuccess(&(s->result));
+ }
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_GetNextObject() */
+/************************************************************************/
+
+ecs_Result *dyn_GetNextObject(ecs_Server *s)
+
+{
+ ServerPrivateData *spriv = s->priv;
+ LayerPrivateData *lpriv = (LayerPrivateData *)
+ s->layer[s->currentLayer].priv;
+ double dfULX, dfULY, dfLRX, dfLRY, dfRatio;
+ int nXOff, nYOff, nXSize, nYSize;
+ int nOutOffset, nFullSize, nOutSize, i;
+ int nRasterXSize = GDALGetRasterXSize(spriv->hDS);
+ int nRasterYSize = GDALGetRasterYSize(spriv->hDS);
+
+/* -------------------------------------------------------------------- */
+/* Compute desired region in "georeferenced" coordinates. */
+/* -------------------------------------------------------------------- */
+ dfULX = s->currentRegion.west;
+ dfULY = s->currentRegion.north
+ - s->currentRegion.ns_res * s->layer[s->currentLayer].index;
+ dfLRX = s->currentRegion.east;
+ dfLRY = s->currentRegion.north
+ - s->currentRegion.ns_res * (s->layer[s->currentLayer].index+1);
+
+ if( (dfULY+dfLRY)*0.5 < s->currentRegion.south )
+ {
+ ecs_SetError( &(s->result), 2, "End of selection" );
+ return &(s->result);
+ }
+
+/* -------------------------------------------------------------------- */
+/* Convert into pixel coordinates but don't integerize yet. */
+/* -------------------------------------------------------------------- */
+ dfULX = (dfULX - spriv->adfGeoTransform[0]) / spriv->adfGeoTransform[1];
+ dfLRX = (dfLRX - spriv->adfGeoTransform[0]) / spriv->adfGeoTransform[1];
+ dfULY = (dfULY - spriv->adfGeoTransform[3]) / spriv->adfGeoTransform[5];
+ dfLRY = (dfLRY - spriv->adfGeoTransform[3]) / spriv->adfGeoTransform[5];
+
+/* -------------------------------------------------------------------- */
+/* Convert into a raster window, but without clamping to the */
+/* actual raster bounds. */
+/* -------------------------------------------------------------------- */
+ nXOff = (int) floor(dfULX+0.5);
+ nYOff = (int) floor(dfULY+0.5);
+ nXSize = (int) floor(dfLRX+0.5) - nXOff;
+ nYSize = (int) floor(dfLRY+0.5) - nYOff;
+
+ nXSize = MAX(1,nXSize);
+ nYSize = MAX(1,nYSize);
+
+/* -------------------------------------------------------------------- */
+/* Is this entirely on the raster? If not compute the reduced */
+/* window, and the region on the current scanline buffer to set */
+/* from it. */
+/* -------------------------------------------------------------------- */
+ nFullSize = (int) floor((s->currentRegion.east - s->currentRegion.west)
+ / s->currentRegion.ew_res + 0.1);
+
+ nOutOffset = 0;
+ nOutSize = nFullSize;
+ dfRatio = nFullSize / (double) nXSize;
+
+ if( nXOff < 0 )
+ {
+ nOutOffset = (int) floor((-nXOff) * dfRatio + 0.5);
+ nOutSize -= nOutOffset;
+ nXSize += nXOff;
+ nXOff = 0;
+ }
+
+ if( nXOff + nXSize > nRasterXSize )
+ {
+ int nNewXSize = nRasterXSize - nXOff;
+
+ nOutSize = nOutSize - (nXSize - nNewXSize) * dfRatio;
+ nXSize = nNewXSize;
+ }
+
+ if( nYOff < 0 )
+ {
+ nYSize += nYOff;
+ nYOff = 0;
+ }
+
+ nYSize = MAX(1,nYSize);
+ if( nYOff + nYSize > nRasterYSize )
+ {
+ nYSize = nRasterYSize - nYOff;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Setup the buffer, setting to zero initially - for Matrix */
+/* results. */
+/* -------------------------------------------------------------------- */
+ if( s->layer[s->currentLayer].sel.F == Matrix )
+ {
+ void *pData;
+
+ ecs_SetGeomMatrix( &(s->result), nFullSize );
+ pData =
+ s->result.res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.matrix.x.x_val;
+
+ memset( pData, 0, 4 * nFullSize );
+
+ if( nXSize > 0 && nYSize > 0 )
+ {
+ GDALRasterIO( lpriv->hBand, GF_Read, nXOff, nYOff, nXSize, nYSize,
+ ((float *) pData) + nOutOffset,
+ nOutSize, 1, GDT_Float32, 0, 0 );
+
+ for( i = nOutOffset; i < nOutOffset+nOutSize; i++ )
+ {
+ ((GUInt32 *) pData)[i] = (int)
+ (((float *) pData)[i] * lpriv->dfMatrixScale
+ + lpriv->dfMatrixOffset);
+ }
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Setup the buffer, setting to zero initially - for Matrix */
+/* results. */
+/* -------------------------------------------------------------------- */
+ else if( s->layer[s->currentLayer].sel.F == Image )
+ {
+ GByte *pabyData;
+ int nBytesPerWord;
+
+ nBytesPerWord = GDALGetDataTypeSize(lpriv->nGDALImageType)/8;
+
+ ecs_SetGeomImage( &(s->result), nFullSize );
+ pabyData = (GByte *)
+ s->result.res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.matrix.x.x_val;
+
+ memset( pabyData, 0, 4 * nFullSize );
+
+ if( nXSize > 0 && nYSize > 0 )
+ {
+ GDALRasterIO( lpriv->hBand, GF_Read, nXOff, nYOff, nXSize, nYSize,
+ pabyData + nOutOffset * nBytesPerWord,
+ nOutSize, 1, lpriv->nGDALImageType, 0, 0 );
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Increment current line indicator. */
+/* -------------------------------------------------------------------- */
+ s->layer[s->currentLayer].index += 1;
+
+ ecs_SetSuccess(&(s->result));
+
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_GetObject() */
+/************************************************************************/
+
+ecs_Result *dyn_GetObject(ecs_Server *s, char *Id)
+
+{
+ int nOldIndex;
+
+ nOldIndex = s->layer[s->currentLayer].index;
+ s->layer[s->currentLayer].index = atoi(Id);
+
+ dyn_GetNextObject( s );
+
+ s->layer[s->currentLayer].index = nOldIndex;
+
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_GetObjectIdFromCoord() */
+/************************************************************************/
+
+ecs_Result *dyn_GetObjectIdFromCoord( ecs_Server *s,
+ ecs_Coordinate *coord)
+
+{
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_UpdateDictionary() */
+/************************************************************************/
+
+ecs_Result *dyn_UpdateDictionary(ecs_Server *s, char *arg)
+
+{
+ ServerPrivateData *spriv = s->priv;
+ int i;
+
+ /* Make sure an empty list is returned in all cases */
+
+ ecs_SetText(&(s->result),"");
+
+ if( strcmp(arg,"ogdi_server_capabilities") == 0 )
+ {
+ ecs_AddText(&(s->result),
+ "<?xml version=\"1.0\" ?>\n"
+ "<OGDI_Capabilities version=\"3.1\">\n"
+ "</OGDI_Capabilities>\n" );
+ }
+
+ else if( strcmp(arg,"ogdi_capabilities") == 0 )
+ {
+ char line[256];
+
+ ecs_AddText(&(s->result),
+ "<?xml version=\"1.0\" ?>\n"
+ "<OGDI_Capabilities version=\"3.1\">\n" );
+ ecs_AddText(&(s->result),
+ " <FeatureTypeList>\n"
+ " <Operations>\n"
+ " <Query/>\n"
+ " </Operations>\n" );
+
+ for( i = 0; i < GDALGetRasterCount(spriv->hDS); i++ )
+ {
+ ecs_AddText(&(s->result),
+ " <FeatureType>\n" );
+
+ sprintf( line, " <Name>band_%d</Name>\n", i+1 );
+ ecs_AddText(&(s->result),line);
+
+ sprintf( line, " <SRS>PROJ4:%s</SRS>\n",
+ spriv->pszProjection );
+ ecs_AddText(&(s->result),line);
+
+ sprintf(line,
+ " <SRSBoundingBox minx=\"%.9f\" miny=\"%.9f\"\n"
+ " maxx=\"%.9f\" maxy=\"%.9f\"\n"
+ " x_res=\"%.9f\" y_res=\"%.9f\" />\n",
+ s->globalRegion.west, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.north,
+ s->globalRegion.ew_res, s->globalRegion.ns_res );
+ ecs_AddText(&(s->result),line);
+
+ ecs_AddText(&(s->result),
+ " <Family>Matrix</Family>\n"
+ " <Family>Image</Family>\n"
+ " </FeatureType>\n" );
+ }
+ ecs_AddText(&(s->result),
+ " </FeatureTypeList>\n"
+ "</OGDI_Capabilities>\n" );
+ }
+
+ ecs_SetSuccess(&(s->result));
+
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_GetServerProjection() */
+/************************************************************************/
+
+ecs_Result *dyn_GetServerProjection(ecs_Server *s)
+
+{
+ ServerPrivateData *spriv=s->priv;
+
+ ecs_SetText(&(s->result), spriv->pszProjection);
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_GetGlobalBound() */
+/************************************************************************/
+
+ecs_Result *dyn_GetGlobalBound(ecs_Server *s)
+
+{
+ ecs_SetGeoRegion(&(s->result),
+ s->globalRegion.north,
+ s->globalRegion.south,
+ s->globalRegion.east,
+ s->globalRegion.west,
+ s->globalRegion.ns_res,
+ s->globalRegion.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_SetServerLanguage() */
+/************************************************************************/
+
+ecs_Result *dyn_SetServerLanguage( ecs_Server *s, u_int language)
+
+{
+ (void) language;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/************************************************************************/
+/* dyn_SetCompression() */
+/************************************************************************/
+
+ecs_Result *dyn_SetCompression(ecs_Server *s, ecs_Compression *compression)
+
+{
+ (void) compression;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/************************************************************************/
+/* dyn_GetRasterInfo() */
+/************************************************************************/
+
+ecs_Result *dyn_GetRasterInfo(ecs_Server *s)
+
+{
+ ServerPrivateData *spriv = s->priv;
+ LayerPrivateData *lpriv;
+
+ lpriv = (LayerPrivateData *) s->layer[s->currentLayer].priv;
+
+/* -------------------------------------------------------------------- */
+/* Handle Matrix */
+/* -------------------------------------------------------------------- */
+ if( s->layer[s->currentLayer].sel.F == Matrix )
+ {
+ int i;
+ char szName[64];
+ GDALColorTableH hCT;
+
+ ecs_SetRasterInfo(&(s->result),
+ GDALGetRasterXSize( spriv->hDS ),
+ GDALGetRasterYSize( spriv->hDS ) );
+
+ hCT = GDALGetRasterColorTable( lpriv->hBand );
+ if( hCT != NULL )
+ {
+ for( i = 0; i < GDALGetColorEntryCount(hCT); i++ ) {
+ GDALColorEntry sColor;
+
+ GDALGetColorEntryAsRGB(hCT, i, &sColor);
+ sprintf(szName,"%d",i);
+
+ if( sColor.c4 > 0 )
+ ecs_AddRasterInfoCategory(&(s->result),
+ i+1,
+ sColor.c1,
+ sColor.c2,
+ sColor.c3,
+ szName, 0 );
+ }
+ }
+ else
+ {
+ for( i = 1; i < 255; i++ ) {
+ sprintf(szName,"%d-%d",
+ (int) ((i / lpriv->dfMatrixScale) + lpriv->dfMatrixOffset),
+ (int) (((i+1)/lpriv->dfMatrixScale)+lpriv->dfMatrixOffset-1));
+
+ ecs_AddRasterInfoCategory(&(s->result), i, i, i, i, szName, 0);
+ }
+ }
+
+ ecs_SetSuccess(&(s->result));
+ }
+
+/* -------------------------------------------------------------------- */
+/* Handle Image */
+/* -------------------------------------------------------------------- */
+ else if( s->layer[s->currentLayer].sel.F == Image )
+ {
+ ecs_SetRasterInfo(&(s->result), lpriv->nOGDIImageType, 0 );
+
+ ecs_AddRasterInfoCategory(&(s->result),1, 255, 255, 255,"No data",0);
+
+ s->result.res.ecs_ResultUnion_u.ri.mincat = 0;
+ s->result.res.ecs_ResultUnion_u.ri.maxcat = 255;
+
+ ecs_SetSuccess(&(s->result));
+ }
+
+ else
+ {
+ ecs_SetError(&(s->result), 1,
+ "The current layer is not a Matrix or Image");
+ }
+
+ return &(s->result);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal_serv.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal_serv.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdal_serv.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,65 @@
+/**********************************************************************
+ * $Id: gdal_serv.h,v 1.1 2001/05/04 03:13:35 warmerda Exp $
+ *
+ * Project: GDAL OGDI Server
+ * Purpose: Declarations.
+ * Author: Frank Warmerda, warmerda at home.com
+ *
+ **********************************************************************
+ * Copyright (c) 2000, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ **********************************************************************
+ *
+ * $Log: gdal_serv.h,v $
+ * Revision 1.1 2001/05/04 03:13:35 warmerda
+ * New
+ *
+ * Revision 1.2 2000/08/28 20:21:47 warmerda
+ * minimally operational
+ *
+ * Revision 1.1 2000/08/23 19:40:17 warmerda
+ * New
+ *
+ */
+
+#ifndef GDAL_SERV_H
+#define GDAL_SERV_H
+
+#include "ecs.h"
+#include "gdalbridge.h"
+
+typedef struct {
+ int nBand;
+ GDALRasterBandH hBand;
+
+ int nOGDIImageType; /* for Image type only */
+ int nGDALImageType; /* for Image type only */
+
+ double dfMatrixOffset;
+ double dfMatrixScale;
+} LayerPrivateData;
+
+typedef struct {
+ GDALDatasetH hDS;
+ double adfGeoTransform[6];
+ char *pszProjection;
+} ServerPrivateData;
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdalbridge.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdalbridge.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdalbridge.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,362 @@
+/******************************************************************************
+ * $Id: gdalbridge.c,v 1.1 2001/05/04 03:13:35 warmerda Exp $
+ *
+ * Project: GDAL Bridge
+ * Purpose: Implementation of GDALBridgeInitialize()
+ * Author: Frank Warmerdam, warmerda at home.com
+ *
+ * Adapted from cplgetsymbol.cpp.
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $Log: gdalbridge.c,v $
+ * Revision 1.1 2001/05/04 03:13:35 warmerda
+ * New
+ *
+ * Revision 1.1 2000/10/25 16:43:20 warmerda
+ * New
+ *
+ * Revision 1.10 2000/09/26 15:20:32 warmerda
+ * added GDALGetRasterBand{X,Y}Size
+ *
+ * Revision 1.9 2000/09/01 19:12:09 warmerda
+ * fixed const mismatch
+ *
+ * Revision 1.8 2000/08/28 20:16:14 warmerda
+ * added lots of OGRSpatialReference stuff
+ *
+ * Revision 1.7 2000/08/25 20:03:40 warmerda
+ * added more entry points
+ *
+ * Revision 1.6 1999/09/17 03:18:08 warmerda
+ * change to search for a list of GDAL .so/.dll files
+ *
+ * Revision 1.5 1999/05/07 14:08:49 warmerda
+ * change .so name
+ *
+ * Revision 1.4 1999/04/22 13:35:11 warmerda
+ * Fixed copyright header.
+ *
+ */
+
+/* ==================================================================== */
+/* We #define GDAL_ENTRY to nothing so that when the include */
+/* file is include the real definition of the function pointer */
+/* variables will occur in this files object file. */
+/* ==================================================================== */
+
+#define GDAL_ENTRY
+#define GDAL_NULL = NULL
+
+#include "gdalbridge.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef _WIN32
+#define PATH_SEP '\\'
+static const char *papszSOFilenames[] = {
+ "gdal11.dll"
+ ,"gdal.1.0.dll"
+ , NULL };
+#else
+#define PATH_SEP '/'
+static const char *papszSOFilenames[] = {
+ "libgdal.1.1.so"
+ ,"gdal.1.0.so"
+ ,"gdal.so.1.0"
+ ,"libgdal.so.1"
+ , NULL };
+#endif
+
+
+/************************************************************************/
+/* GDALBridgeInitialize() */
+/************************************************************************/
+
+int GDALBridgeInitialize( const char * pszTargetDir )
+
+{
+ char szPath[2048];
+ void *pfnTest = NULL;
+ int iSOFile;
+
+/* -------------------------------------------------------------------- */
+/* The first phase is to try and find the shared library. */
+/* -------------------------------------------------------------------- */
+ for( iSOFile = 0;
+ papszSOFilenames[iSOFile] != NULL && pfnTest == NULL;
+ iSOFile++ )
+ {
+ if( pszTargetDir != NULL )
+ {
+ sprintf( szPath, "%s%c%s",
+ pszTargetDir, PATH_SEP, papszSOFilenames[iSOFile] );
+ pfnTest = GBGetSymbol( szPath, "GDALOpen" );
+ }
+
+ if( pfnTest == NULL && getenv( "GDAL_HOME" ) != NULL )
+ {
+ sprintf( szPath,
+ "%s%c%s", getenv("GDAL_HOME"),
+ PATH_SEP, papszSOFilenames[iSOFile] );
+ pfnTest = GBGetSymbol( szPath, "GDALOpen" );
+ }
+
+ if( pfnTest == NULL )
+ {
+ sprintf( szPath, papszSOFilenames[iSOFile] );
+ pfnTest = GBGetSymbol( szPath, "GDALOpen" );
+ }
+ }
+
+ if( pfnTest == NULL )
+ return FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Start loading functions. */
+/* -------------------------------------------------------------------- */
+
+ GDALGetDataTypeSize = (int (*)(GDALDataType))
+ GBGetSymbol( szPath, "GDALGetDataTypeSize" );
+
+ GDALAllRegister = (void (*)(void))
+ GBGetSymbol( szPath, "GDALAllRegister" );
+
+ GDALCreate = (GDALDatasetH (*)(GDALDriverH, const char *, int, int, int,
+ GDALDataType, char ** ))
+ GBGetSymbol( szPath, "GDALCreate" );
+
+ GDALOpen = (GDALDatasetH (*)(const char *, GDALAccess))
+ GBGetSymbol( szPath, "GDALOpen" );
+
+ GDALGetDriverByName = (GDALDriverH (*)(const char *))
+ GBGetSymbol( szPath, "GDALGetDriverByName" );
+
+ GDALClose = (void (*)(GDALDatasetH))
+ GBGetSymbol( szPath, "GDALClose" );
+
+ GDALGetRasterXSize = (int (*)(GDALDatasetH))
+ GBGetSymbol( szPath, "GDALGetRasterXSize" );
+
+ GDALGetRasterYSize = (int (*)(GDALDatasetH))
+ GBGetSymbol( szPath, "GDALGetRasterYSize" );
+
+ GDALGetRasterCount = (int (*)(GDALDatasetH))
+ GBGetSymbol( szPath, "GDALGetRasterCount" );
+
+ GDALGetRasterBand = (GDALRasterBandH (*)(GDALDatasetH, int))
+ GBGetSymbol( szPath, "GDALGetRasterBand" );
+
+ GDALGetProjectionRef = (const char *(*)(GDALDatasetH))
+ GBGetSymbol( szPath, "GDALGetProjectionRef" );
+
+ GDALSetProjection = (CPLErr (*)(GDALDatasetH, const char *))
+ GBGetSymbol( szPath, "GDALSetProjection" );
+
+ GDALGetGeoTransform = (CPLErr (*)(GDALDatasetH, double *))
+ GBGetSymbol( szPath, "GDALGetGeoTransform" );
+
+ GDALSetGeoTransform = (CPLErr (*)(GDALDatasetH, double *))
+ GBGetSymbol( szPath, "GDALSetGeoTransform" );
+
+ GDALGetInternalHandle = (void *(*)(GDALDatasetH, const char *))
+ GBGetSymbol( szPath, "GDALGetInternalHandle" );
+
+ GDALGetRasterDataType = (GDALDataType (*)(GDALRasterBandH))
+ GBGetSymbol( szPath, "GDALGetRasterDataType" );
+
+ GDALGetRasterBandXSize = (int (*)(GDALRasterBandH))
+ GBGetSymbol( szPath, "GDALGetRasterBandXSize" );
+
+ GDALGetRasterBandYSize = (int (*)(GDALRasterBandH))
+ GBGetSymbol( szPath, "GDALGetRasterBandYSize" );
+
+ GDALGetBlockSize = (void (*)(GDALRasterBandH, int *, int *))
+ GBGetSymbol( szPath, "GDALGetBlockSize" );
+
+ GDALRasterIO = (CPLErr (*)(GDALRasterBandH, GDALRWFlag, int, int, int, int,
+ void *, int, int, GDALDataType, int, int ))
+ GBGetSymbol( szPath, "GDALRasterIO" );
+
+ GDALReadBlock = (CPLErr (*)(GDALRasterBandH, int, int, void *))
+ GBGetSymbol( szPath, "GDALReadBlock" );
+
+ GDALWriteBlock = (CPLErr (*)(GDALRasterBandH, int, int, void *))
+ GBGetSymbol( szPath, "GDALWriteBlock" );
+
+ GDALGetOverviewCount = (int (*)(GDALRasterBandH))
+ GBGetSymbol( szPath, "GDALGetOverviewCount" );
+
+ GDALGetOverview = (GDALRasterBandH (*)(GDALRasterBandH, int))
+ GBGetSymbol( szPath, "GDALGetOverview" );
+
+ GDALGetRasterColorInterpretation = (GDALColorInterp (*)(GDALRasterBandH))
+ GBGetSymbol( szPath, "GDALGetRasterColorInterpretation" );
+
+ GDALGetColorInterpretationName = (const char *(*)(GDALColorInterp))
+ GBGetSymbol( szPath, "GDALGetColorInterpretationName" );
+
+ GDALGetRasterColorTable = (GDALColorTableH (*)(GDALRasterBandH))
+ GBGetSymbol( szPath, "GDALGetRasterColorTable" );
+
+ GDALCreateProjDef = (GDALProjDefH (*)(const char *))
+ GBGetSymbol( szPath, "GDALCreateProjDef" );
+
+ GDALReprojectToLongLat = (CPLErr (*)(GDALProjDefH, double *, double *))
+ GBGetSymbol( szPath, "GDALReprojectToLongLat" );
+
+ GDALReprojectFromLongLat = (CPLErr (*)(GDALProjDefH, double *, double *))
+ GBGetSymbol( szPath, "GDALReprojectFromLongLat" );
+
+ GDALDestroyProjDef = (void (*)(GDALProjDefH))
+ GBGetSymbol( szPath, "GDALDestroyProjDef" );
+
+ GDALDecToDMS = (const char *(*)(double, const char *, int ))
+ GBGetSymbol( szPath, "GDALDecToDMS" );
+
+ GDALGetPaletteInterpretation = (GDALPaletteInterp (*)(GDALColorTableH))
+ GBGetSymbol( szPath, "GDALGetPaletteInterpretation" );
+
+ GDALGetPaletteInterpretationName = (const char *(*)(GDALPaletteInterp))
+ GBGetSymbol( szPath, "GDALGetPaletteInterpretationName" );
+
+ GDALGetColorEntryCount = (int (*)(GDALColorTableH))
+ GBGetSymbol( szPath, "GDALGetColorEntryCount" );
+
+ GDALGetColorEntry = (const GDALColorEntry *(*)(GDALColorTableH,int))
+ GBGetSymbol( szPath, "GDALGetColorEntry" );
+
+ GDALGetColorEntryAsRGB = (int (*)(GDALColorTableH,int,
+ GDALColorEntry*))
+ GBGetSymbol( szPath, "GDALGetColorEntryAsRGB" );
+
+ GDALSetColorEntry = (void (*)(GDALColorTableH, int, const GDALColorEntry*))
+ GBGetSymbol( szPath, "GDALSetColorEntry" );
+
+/* -------------------------------------------------------------------- */
+/* OSR API */
+/* -------------------------------------------------------------------- */
+ OSRNewSpatialReference = (OGRSpatialReferenceH (*)( const char * ))
+ GBGetSymbol( szPath, "OSRNewSpatialReference" );
+
+ OSRCloneGeogCS = (OGRSpatialReferenceH (*)(OGRSpatialReferenceH))
+ GBGetSymbol( szPath, "OSRCloneGeogCS" );
+
+ OSRDestroySpatialReference = (void (*)(OGRSpatialReferenceH))
+ GBGetSymbol( szPath, "OSRDestroySpatialReference" );
+
+ OSRReference = (int (*)(OGRSpatialReferenceH))
+ GBGetSymbol( szPath, "OSRReference" );
+
+ OSRDereference = (int (*)(OGRSpatialReferenceH))
+ GBGetSymbol( szPath, "OSRDereference" );
+
+ OSRImportFromEPSG = (OGRErr (*)(OGRSpatialReferenceH,int))
+ GBGetSymbol( szPath, "OSRImportFromEPSG" );
+
+ OSRImportFromWkt = (OGRErr (*)(OGRSpatialReferenceH,char **))
+ GBGetSymbol( szPath, "OSRImportFromWkt" );
+
+ OSRImportFromProj4 = (OGRErr (*)(OGRSpatialReferenceH,const char *))
+ GBGetSymbol( szPath, "OSRImportFromProj4" );
+
+ OSRExportToWkt = (OGRErr (*)(OGRSpatialReferenceH, char **))
+ GBGetSymbol( szPath, "OSRExportToWkt" );
+
+ OSRExportToPrettyWkt = (OGRErr (*)(OGRSpatialReferenceH, char **, int))
+ GBGetSymbol( szPath, "OSRExportToPrettyWkt" );
+
+ OSRExportToProj4 = (OGRErr (*)(OGRSpatialReferenceH, char **))
+ GBGetSymbol( szPath, "OSRExportToProj4" );
+
+ OSRSetAttrValue = (OGRErr (*)(OGRSpatialReferenceH, const char *,
+ const char *))
+ GBGetSymbol( szPath, "OSRSetAttrValue" );
+
+ OSRGetAttrValue = (const char *(*)(OGRSpatialReferenceH, const char *,int))
+ GBGetSymbol( szPath, "OSRGetAttrValue" );
+
+ OSRSetLinearUnits = (OGRErr (*)(OGRSpatialReferenceH, const char *,double))
+ GBGetSymbol( szPath, "OSRSetLinearUnits" );
+
+ OSRGetLinearUnits = (double (*)(OGRSpatialReferenceH, char **))
+ GBGetSymbol( szPath, "OSRGetLinearUnits" );
+
+ OSRIsGeographic = (int (*)(OGRSpatialReferenceH))
+ GBGetSymbol( szPath, "OSRIsGeographic" );
+
+ OSRIsProjected = (int (*)(OGRSpatialReferenceH))
+ GBGetSymbol( szPath, "OSRIsProjected" );
+
+ OSRIsSameGeogCS = (int (*)(OGRSpatialReferenceH,OGRSpatialReferenceH))
+ GBGetSymbol( szPath, "OSRIsSameGeogCS" );
+
+ OSRIsSame = (int (*)(OGRSpatialReferenceH,OGRSpatialReferenceH))
+ GBGetSymbol( szPath, "OSRIsSame" );
+
+ OSRSetProjCS = (OGRErr (*)(OGRSpatialReferenceH,const char*))
+ GBGetSymbol( szPath, "OSRSetProjCS" );
+
+ OSRSetWellKnownGeogCS = (OGRErr (*)(OGRSpatialReferenceH, const char *))
+ GBGetSymbol( szPath, "OSRSetWellKnownGeogCS" );
+
+ OSRSetGeogCS = (OGRErr (*)( OGRSpatialReferenceH hSRS,
+ const char * pszGeogName,
+ const char * pszDatumName,
+ const char * pszEllipsoidName,
+ double dfSemiMajor, double dfInvFlattening,
+ const char * pszPMName /* = NULL */,
+ double dfPMOffset /* = 0.0 */,
+ const char * pszUnits /* = NULL */,
+ double dfConvertToRadians /* = 0.0 */ ))
+ GBGetSymbol( szPath, "OSRSetGeogCS" );
+
+ OSRGetSemiMajor = (double (*)(OGRSpatialReferenceH, OGRErr *))
+ GBGetSymbol( szPath, "OSRGetSemiMajor" );
+
+ OSRGetSemiMinor = (double (*)(OGRSpatialReferenceH, OGRErr *))
+ GBGetSymbol( szPath, "OSRGetSemiMinor" );
+
+ OSRGetInvFlattening = (double (*)(OGRSpatialReferenceH, OGRErr *))
+ GBGetSymbol( szPath, "OSRGetInvFlattening" );
+
+ OSRSetAuthority = (OGRErr (*)(OGRSpatialReferenceH, const char *,
+ const char *, int))
+ GBGetSymbol( szPath, "OSRSetAuthority" );
+
+ OSRSetProjParm = (OGRErr (*)(OGRSpatialReferenceH, const char *, double))
+ GBGetSymbol( szPath, "OSRSetProjParm" );
+
+ OSRGetProjParm = (double (*)(OGRSpatialReferenceH, const char *,
+ double, OGRErr *))
+ GBGetSymbol( szPath, "OSRGetProjParm" );
+
+ OSRSetUTM = (OGRErr (*)(OGRSpatialReferenceH, int, int))
+ GBGetSymbol( szPath, "OSRSetUTM" );
+
+ OSRGetUTMZone = (int (*)(OGRSpatialReferenceH, int *))
+ GBGetSymbol( szPath, "OSRGetUTMZone" );
+
+ return TRUE;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdalbridge.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdalbridge.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/gdalbridge.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,519 @@
+/******************************************************************************
+ * $Id: gdalbridge.h,v 1.1 2001/05/04 03:13:35 warmerda Exp $
+ *
+ * Project: GDAL Bridge
+ * Purpose: Declarations for GDAL Bridge support.
+ * Author: Frank Warmerdam, warmerda at home.com
+ *
+ * This file needs to be kept up to date with the contents of gdal.h by hand.
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $Log: gdalbridge.h,v $
+ * Revision 1.1 2001/05/04 03:13:35 warmerda
+ * New
+ *
+ * Revision 1.1 2000/10/25 16:43:20 warmerda
+ * New
+ *
+ * Revision 1.7 2000/09/26 15:20:32 warmerda
+ * added GDALGetRasterBand{X,Y}Size
+ *
+ * Revision 1.6 2000/08/28 20:16:14 warmerda
+ * added lots of OGRSpatialReference stuff
+ *
+ * Revision 1.5 2000/08/25 20:03:40 warmerda
+ * added more entry points
+ *
+ * Revision 1.4 1999/09/17 03:18:37 warmerda
+ * added name indirection for function pointer names for libtool
+ *
+ * Revision 1.3 1999/04/22 13:36:43 warmerda
+ * Added copyright header.
+ *
+ */
+
+#ifndef GDALBRIDGE_H_INCLUDED
+#define GDALBRIDGE_H_INCLUDED
+
+/* -------------------------------------------------------------------- */
+/* Start C context. */
+/* -------------------------------------------------------------------- */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ==================================================================== */
+/* Standard types and defines normally supplied by cpl_port.h. */
+/* ==================================================================== */
+#if UINT_MAX == 65535
+typedef long GInt32;
+typedef unsigned long GUInt32;
+#else
+typedef int GInt32;
+typedef unsigned int GUInt32;
+#endif
+
+typedef short GInt16;
+typedef unsigned short GUInt16;
+typedef unsigned char GByte;
+typedef int GBool;
+
+#ifndef FALSE
+# define FALSE 0
+# define TRUE 1
+#endif
+
+#ifndef NULL
+# define NULL 0
+#endif
+
+#ifndef GDAL_ENTRY
+# define GDAL_ENTRY extern
+# define GDAL_NULL
+#endif
+
+/* -------------------------------------------------------------------- */
+/* Significant constants. */
+/* -------------------------------------------------------------------- */
+
+/*! Pixel data types */
+typedef enum {
+ GDT_Unknown = 0,
+ /*! Eight bit unsigned integer */ GDT_Byte = 1,
+ /*! Sixteen bit unsigned integer */ GDT_UInt16 = 2,
+ /*! Sixteen bit signed integer */ GDT_Int16 = 3,
+ /*! Thirty two bit unsigned integer */ GDT_UInt32 = 4,
+ /*! Thirty two bit signed integer */ GDT_Int32 = 5,
+ /*! Thirty two bit floating point */ GDT_Float32 = 6,
+ /*! Sixty four bit floating point */ GDT_Float64 = 7,
+ /*! Complex Int16 */ GDT_CInt16 = 8,
+ /*! Complex Int32 */ GDT_CInt32 = 9,
+ /*! Complex Float32 */ GDT_CFloat32 = 10,
+ /*! Complex Float64 */ GDT_CFloat64 = 11,
+ GDT_TypeCount = 12 /* maximum type # + 1 */
+} GDALDataType;
+
+GDAL_ENTRY int (*pfnGDALGetDataTypeSize)( GDALDataType ) GDAL_NULL;
+#define GDALGetDataTypeSize pfnGDALGetDataTypeSize
+
+typedef enum {
+ GA_ReadOnly = 0,
+ GA_Update = 1
+} GDALAccess;
+
+typedef enum {
+ GF_Read = 0,
+ GF_Write = 1
+} GDALRWFlag;
+
+/*! Types of color interpretation for raster bands. */
+typedef enum
+{
+ GCI_Undefined=0,
+ /*! Greyscale */ GCI_GrayIndex=1,
+ /*! Paletted (see associated color table) */ GCI_PaletteIndex=2,
+ /*! Red band of RGBA image */ GCI_RedBand=3,
+ /*! Green band of RGBA image */ GCI_GreenBand=4,
+ /*! Blue band of RGBA image */ GCI_BlueBand=5,
+ /*! Alpha (0=transparent, 255=opaque) */ GCI_AlphaBand=6,
+ /*! Hue band of HLS image */ GCI_HueBand=7,
+ /*! Saturation band of HLS image */ GCI_SaturationBand=8,
+ /*! Lightness band of HLS image */ GCI_LightnessBand=9,
+ /*! Cyan band of CMYK image */ GCI_CyanBand=10,
+ /*! Magenta band of CMYK image */ GCI_MagentaBand=11,
+ /*! Yellow band of CMYK image */ GCI_YellowBand=12,
+ /*! Black band of CMLY image */ GCI_BlackBand=13
+} GDALColorInterp;
+
+/*! Types of color interpretations for a GDALColorTable. */
+typedef enum
+{
+ /*! Grayscale (in GDALColorEntry.c1) */ GPI_Gray=0,
+ /*! Red, Green, Blue and Alpha in (in c1, c2, c3 and c4) */ GPI_RGB=1,
+ /*! Cyan, Magenta, Yellow and Black (in c1, c2, c3 and c4)*/ GPI_CMYK=2,
+ /*! Hue, Lightness and Saturation (in c1, c2, and c3) */ GPI_HLS=3
+} GDALPaletteInterp;
+
+/* -------------------------------------------------------------------- */
+/* GDAL Specific error codes. */
+/* */
+/* error codes 100 to 299 reserved for GDAL. */
+/* -------------------------------------------------------------------- */
+typedef enum
+{
+ CE_None = 0,
+ CE_Log = 1,
+ CE_Warning = 2,
+ CE_Failure = 3,
+ CE_Fatal = 4
+
+} CPLErr;
+
+#define CPLE_AppDefined 1
+#define CPLE_OutOfMemory 2
+#define CPLE_FileIO 3
+#define CPLE_OpenFailed 4
+#define CPLE_IllegalArg 5
+#define CPLE_NotSupported 6
+#define CPLE_AssertionFailed 7
+#define CPLE_NoWriteAccess 8
+
+#define CPLE_WrongFormat 200
+
+typedef int OGRErr;
+
+#define OGRERR_NONE 0
+#define OGRERR_NOT_ENOUGH_DATA 1 /* not enough data to deserialize */
+#define OGRERR_NOT_ENOUGH_MEMORY 2
+#define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
+#define OGRERR_UNSUPPORTED_OPERATION 4
+#define OGRERR_CORRUPT_DATA 5
+#define OGRERR_FAILURE 6
+#define OGRERR_UNSUPPORTED_SRS 7
+
+/* -------------------------------------------------------------------- */
+/* Define handle types related to various internal classes. */
+/* -------------------------------------------------------------------- */
+
+typedef void *GDALMajorObjectH;
+typedef void *GDALDatasetH;
+typedef void *GDALRasterBandH;
+typedef void *GDALDriverH;
+typedef void *GDALProjDefH;
+typedef void *GDALColorTableH;
+typedef void *OGRSpatialReferenceH;
+
+/* ==================================================================== */
+/* Registration/driver related. */
+/* ==================================================================== */
+
+GDAL_ENTRY void (*pfnGDALAllRegister)( void ) GDAL_NULL;
+#define GDALAllRegister pfnGDALAllRegister
+
+GDAL_ENTRY GDALDatasetH (*pfnGDALCreate)( GDALDriverH hDriver, const char *,
+ int, int, int, GDALDataType,
+ char ** ) GDAL_NULL;
+#define GDALCreate pfnGDALCreate
+
+
+GDAL_ENTRY GDALDatasetH (*pfnGDALOpen)( const char *, GDALAccess ) GDAL_NULL;
+#define GDALOpen pfnGDALOpen
+
+GDAL_ENTRY GDALDriverH (*pfnGDALGetDriverByName)( const char * ) GDAL_NULL;
+#define GDALGetDriverByName pfnGDALGetDriverByName
+
+/* ==================================================================== */
+/* GDALDataset class ... normally this represents one file. */
+/* ==================================================================== */
+
+GDAL_ENTRY void (*pfnGDALClose)( GDALDatasetH ) GDAL_NULL;
+#define GDALClose pfnGDALClose
+
+GDAL_ENTRY int (*pfnGDALGetRasterXSize)( GDALDatasetH ) GDAL_NULL;
+#define GDALGetRasterXSize pfnGDALGetRasterXSize
+
+GDAL_ENTRY int (*pfnGDALGetRasterYSize)( GDALDatasetH ) GDAL_NULL;
+#define GDALGetRasterYSize pfnGDALGetRasterYSize
+
+GDAL_ENTRY int (*pfnGDALGetRasterCount)( GDALDatasetH ) GDAL_NULL;
+#define GDALGetRasterCount pfnGDALGetRasterCount
+
+GDAL_ENTRY GDALRasterBandH
+ (*pfnGDALGetRasterBand)( GDALDatasetH, int) GDAL_NULL;
+#define GDALGetRasterBand pfnGDALGetRasterBand
+
+GDAL_ENTRY const char *(*pfnGDALGetProjectionRef)( GDALDatasetH ) GDAL_NULL;
+#define GDALGetProjectionRef pfnGDALGetProjectionRef
+
+GDAL_ENTRY CPLErr (*pfnGDALSetProjection)( GDALDatasetH,
+ const char * ) GDAL_NULL;
+#define GDALSetProjection pfnGDALSetProjection
+
+GDAL_ENTRY CPLErr (*pfnGDALGetGeoTransform)( GDALDatasetH, double* ) GDAL_NULL;
+#define GDALGetGeoTransform pfnGDALGetGeoTransform
+
+GDAL_ENTRY CPLErr (*pfnGDALSetGeoTransform)( GDALDatasetH, double* ) GDAL_NULL;
+#define GDALSetGeoTransform pfnGDALSetGeoTransform
+
+GDAL_ENTRY void *(*pfnGDALGetInternalHandle)( GDALDatasetH,
+ const char * ) GDAL_NULL;
+#define GDALGetInternalHandle pfnGDALGetInternalHandle
+
+/* ==================================================================== */
+/* GDALRasterBand ... one band/channel in a dataset. */
+/* ==================================================================== */
+
+GDAL_ENTRY GDALDataType (*pGDALGetRasterDataType)( GDALRasterBandH ) GDAL_NULL;
+#define GDALGetRasterDataType pGDALGetRasterDataType
+
+GDAL_ENTRY void (*pGDALGetBlockSize)( GDALRasterBandH,
+ int * pnXSize, int * pnYSize ) GDAL_NULL;
+#define GDALGetBlockSize pGDALGetBlockSize
+
+GDAL_ENTRY CPLErr (*pGDALRasterIO)( GDALRasterBandH hRBand, GDALRWFlag eRWFlag,
+ int nDSXOff, int nDSYOff,
+ int nDSXSize, int nDSYSize,
+ void * pBuffer, int nBXSize, int nBYSize,
+ GDALDataType eBDataType,
+ int nPixelSpace, int nLineSpace ) GDAL_NULL;
+#define GDALRasterIO pGDALRasterIO
+
+GDAL_ENTRY CPLErr (*pGDALReadBlock)( GDALRasterBandH,
+ int, int, void * ) GDAL_NULL;
+#define GDALReadBlock pGDALReadBlock
+
+GDAL_ENTRY CPLErr (*pGDALWriteBlock)( GDALRasterBandH,
+ int, int, void * ) GDAL_NULL;
+#define GDALWriteBlock pGDALWriteBlock
+
+GDAL_ENTRY int (*pGDALGetOverviewCount)( GDALRasterBandH ) GDAL_NULL;
+#define GDALGetOverviewCount pGDALGetOverviewCount
+
+GDAL_ENTRY GDALRasterBandH (*pGDALGetOverview)( GDALRasterBandH, int ) GDAL_NULL;
+#define GDALGetOverview pGDALGetOverview
+
+GDAL_ENTRY GDALColorInterp (*pGDALGetRasterColorInterpretation)
+ ( GDALRasterBandH ) GDAL_NULL;
+#define GDALGetRasterColorInterpretation pGDALGetRasterColorInterpretation
+
+GDAL_ENTRY const char *(*pGDALGetColorInterpretationName)( GDALColorInterp ) GDAL_NULL;
+#define GDALGetColorInterpretationName pGDALGetColorInterpretationName
+
+GDAL_ENTRY GDALColorTableH (*pGDALGetRasterColorTable)( GDALRasterBandH ) GDAL_NULL;
+#define GDALGetRasterColorTable pGDALGetRasterColorTable
+
+GDAL_ENTRY int (*pfnGDALGetRasterBandXSize)( GDALRasterBandH ) GDAL_NULL;
+#define GDALGetRasterBandXSize pfnGDALGetRasterBandXSize
+
+GDAL_ENTRY int (*pfnGDALGetRasterBandYSize)( GDALRasterBandH ) GDAL_NULL;
+#define GDALGetRasterBandYSize pfnGDALGetRasterBandYSize
+
+/* ==================================================================== */
+/* Color tables. */
+/* ==================================================================== */
+/** Color tuple */
+typedef struct
+{
+ /*! gray, red, cyan or hue */
+ short c1;
+
+ /*! green, magenta, or lightness */
+ short c2;
+
+ /*! blue, yellow, or saturation */
+ short c3;
+
+ /*! alpha or blackband */
+ short c4;
+} GDALColorEntry;
+
+GDAL_ENTRY GDALPaletteInterp (*pGDALGetPaletteInterpretation)( GDALColorTableH ) GDAL_NULL;
+#define GDALGetPaletteInterpretation pGDALGetPaletteInterpretation
+
+GDAL_ENTRY const char *(*pGDALGetPaletteInterpretationName)(GDALPaletteInterp) GDAL_NULL;
+#define GDALGetPaletteInterpretationName pGDALGetPaletteInterpretationName
+
+GDAL_ENTRY int (*pGDALGetColorEntryCount)( GDALColorTableH ) GDAL_NULL;
+#define GDALGetColorEntryCount pGDALGetColorEntryCount
+
+GDAL_ENTRY const GDALColorEntry *(*pGDALGetColorEntry)( GDALColorTableH, int ) GDAL_NULL;
+#define GDALGetColorEntry pGDALGetColorEntry
+
+GDAL_ENTRY int (*pGDALGetColorEntryAsRGB)( GDALColorTableH, int,
+ GDALColorEntry *) GDAL_NULL;
+#define GDALGetColorEntryAsRGB pGDALGetColorEntryAsRGB
+
+GDAL_ENTRY void (*pGDALSetColorEntry)( GDALColorTableH, int,
+ const GDALColorEntry * ) GDAL_NULL;
+#define GDALSetColorEntry pGDALSetColorEntry
+
+/* ==================================================================== */
+/* Projections */
+/* ==================================================================== */
+
+GDAL_ENTRY GDALProjDefH (*pGDALCreateProjDef)( const char * ) GDAL_NULL;
+#define GDALCreateProjDef pGDALCreateProjDef
+
+GDAL_ENTRY CPLErr (*pGDALReprojectToLongLat)( GDALProjDefH,
+ double *, double * ) GDAL_NULL;
+#define GDALReprojectToLongLat pGDALReprojectToLongLat
+
+GDAL_ENTRY CPLErr (*pGDALReprojectFromLongLat)( GDALProjDefH,
+ double *, double * ) GDAL_NULL;
+#define GDALReprojectFromLongLat pGDALReprojectFromLongLat
+
+GDAL_ENTRY void (*pGDALDestroyProjDef)( GDALProjDefH ) GDAL_NULL;
+#define GDALDestroyProjDef pGDALDestroyProjDef
+
+GDAL_ENTRY const char *(*pGDALDecToDMS)( double, const char *, int ) GDAL_NULL;
+#define GDALDecToDMS pGDALDecToDMS
+
+/* -------------------------------------------------------------------- */
+/* ogr_srs_api.h services. */
+/* -------------------------------------------------------------------- */
+
+GDAL_ENTRY OGRSpatialReferenceH
+ (*pOSRNewSpatialReference)( const char * ) GDAL_NULL;
+#define OSRNewSpatialReference pOSRNewSpatialReference
+
+GDAL_ENTRY OGRSpatialReferenceH
+ (*pOSRCloneGeogCS)( OGRSpatialReferenceH ) GDAL_NULL;
+#define OSRCloneGeogCS pOSRCloneGeogCS
+
+GDAL_ENTRY void
+ (*pOSRDestroySpatialReference)( OGRSpatialReferenceH ) GDAL_NULL;
+#define OSRDestroySpatialReference pOSRDestroySpatialReference
+
+GDAL_ENTRY int (*pOSRReference)( OGRSpatialReferenceH ) GDAL_NULL;
+#define OSRReference pOSRReference
+
+GDAL_ENTRY int (*pOSRDereference)( OGRSpatialReferenceH ) GDAL_NULL;
+#define OSRDereference pOSRDereference
+
+GDAL_ENTRY OGRErr (*pOSRImportFromEPSG)( OGRSpatialReferenceH, int ) GDAL_NULL;
+#define OSRImportFromEPSG pOSRImportFromEPSG
+
+GDAL_ENTRY OGRErr
+ (*pOSRImportFromWkt)( OGRSpatialReferenceH, char ** ) GDAL_NULL;
+#define OSRImportFromWkt pOSRImportFromWkt
+
+GDAL_ENTRY OGRErr
+ (*pOSRImportFromProj4)( OGRSpatialReferenceH, const char *) GDAL_NULL;
+#define OSRImportFromProj4 pOSRImportFromProj4
+
+GDAL_ENTRY OGRErr
+ (*pOSRExportToWkt)( OGRSpatialReferenceH, char ** ) GDAL_NULL;
+#define OSRExportToWkt pOSRExportToWkt
+
+GDAL_ENTRY OGRErr
+ (*pOSRExportToPrettyWkt)( OGRSpatialReferenceH, char **, int) GDAL_NULL;
+#define OSRExportToPrettyWkt pOSRExportToPrettyWkt
+
+GDAL_ENTRY OGRErr
+ (*pOSRExportToProj4)( OGRSpatialReferenceH, char **) GDAL_NULL;
+#define OSRExportToProj4 pOSRExportToProj4
+
+GDAL_ENTRY OGRErr
+ (*pOSRSetAttrValue)( OGRSpatialReferenceH hSRS,
+ const char * pszNodePath,
+ const char * pszNewNodeValue ) GDAL_NULL;
+#define OSRSetAttrValue pOSRSetAttrValue
+
+GDAL_ENTRY const char * (*pOSRGetAttrValue)( OGRSpatialReferenceH hSRS,
+ const char * pszName, int iChild ) GDAL_NULL;
+#define OSRGetAttrValue pOSRGetAttrValue
+
+GDAL_ENTRY OGRErr (*pOSRSetLinearUnits)( OGRSpatialReferenceH, const char *,
+ double ) GDAL_NULL;
+#define OSRSetLinearUnits pOSRSetLinearUnits
+
+GDAL_ENTRY double (*pOSRGetLinearUnits)( OGRSpatialReferenceH,
+ char ** ) GDAL_NULL;
+#define OSRGetLinearUnits pOSRGetLinearUnits
+
+GDAL_ENTRY int (*pOSRIsGeographic)( OGRSpatialReferenceH ) GDAL_NULL;
+#define OSRIsGeographic pOSRIsGeographic
+
+GDAL_ENTRY int (*pOSRIsProjected)( OGRSpatialReferenceH ) GDAL_NULL;
+#define OSRIsProjected pOSRIsProjected
+
+GDAL_ENTRY int (*pOSRIsSameGeogCS)( OGRSpatialReferenceH,
+ OGRSpatialReferenceH ) GDAL_NULL;
+#define OSRIsSameGeogCS pOSRIsSameGeogCS
+
+GDAL_ENTRY int (*pOSRIsSame)( OGRSpatialReferenceH,
+ OGRSpatialReferenceH ) GDAL_NULL;
+#define OSRIsSame pOSRIsSame
+
+GDAL_ENTRY OGRErr (*pOSRSetProjCS)( OGRSpatialReferenceH hSRS,
+ const char * pszName ) GDAL_NULL;
+#define OSRSetProjCS pOSRSetProjCS
+
+GDAL_ENTRY OGRErr (*pOSRSetWellKnownGeogCS)( OGRSpatialReferenceH hSRS,
+ const char * pszName ) GDAL_NULL;
+#define OSRSetWellKnownGeogCS pOSRSetWellKnownGeogCS
+
+GDAL_ENTRY OGRErr (*pOSRSetGeogCS)( OGRSpatialReferenceH hSRS,
+ const char * pszGeogName,
+ const char * pszDatumName,
+ const char * pszEllipsoidName,
+ double dfSemiMajor, double dfInvFlattening,
+ const char * pszPMName /* = NULL */,
+ double dfPMOffset /* = 0.0 */,
+ const char * pszUnits /* = NULL */,
+ double dfConvertToRadians /* = 0.0 */ ) GDAL_NULL;
+#define OSRSetGeogCS pOSRSetGeogCS
+
+GDAL_ENTRY double (*pOSRGetSemiMajor)( OGRSpatialReferenceH,
+ OGRErr * /* = NULL */ ) GDAL_NULL;
+#define OSRGetSemiMajor pOSRGetSemiMajor
+
+GDAL_ENTRY double (*pOSRGetSemiMinor)( OGRSpatialReferenceH,
+ OGRErr * /* = NULL */ ) GDAL_NULL;
+#define OSRGetSemiMinor pOSRGetSemiMinor
+
+GDAL_ENTRY double (*pOSRGetInvFlattening)( OGRSpatialReferenceH,
+ OGRErr * /*=NULL*/) GDAL_NULL;
+#define OSRGetInvFlattening pOSRGetInvFlattening
+
+GDAL_ENTRY OGRErr (*pOSRSetAuthority)( OGRSpatialReferenceH hSRS,
+ const char * pszTargetKey,
+ const char * pszAuthority,
+ int nCode ) GDAL_NULL;
+#define OSRSetAuthority pOSRSetAuthority
+
+GDAL_ENTRY OGRErr (*pOSRSetProjParm)( OGRSpatialReferenceH,
+ const char *, double ) GDAL_NULL;
+#define OSRSetProjParm pOSRSetProjParm
+
+GDAL_ENTRY double (*pOSRGetProjParm)( OGRSpatialReferenceH hSRS,
+ const char * pszParmName,
+ double dfDefault /* = 0.0 */,
+ OGRErr * /* = NULL */ ) GDAL_NULL;
+#define OSRGetProjParm pOSRGetProjParm
+
+GDAL_ENTRY OGRErr (*pOSRSetUTM)( OGRSpatialReferenceH hSRS,
+ int nZone, int bNorth ) GDAL_NULL;
+#define OSRSetUTM pOSRSetUTM
+
+GDAL_ENTRY int (*pOSRGetUTMZone)( OGRSpatialReferenceH hSRS,
+ int *pbNorth ) GDAL_NULL;
+#define OSRGetUTMZone pOSRGetUTMZone
+
+/* -------------------------------------------------------------------- */
+/* This is the real entry point. It tries to load the shared */
+/* libraries (given a hint of a directory it might be in). It */
+/* returns TRUE if it succeeds, or FALSE otherwise. */
+/* -------------------------------------------------------------------- */
+int GDALBridgeInitialize( const char * );
+void *GBGetSymbol( const char *, const char * );
+
+/* -------------------------------------------------------------------- */
+/* Terminate C context. */
+/* -------------------------------------------------------------------- */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ndef GDALBRIDGE_H_INCLUDED */
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/gdal/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,23 @@
+
+TOBEGEN = gdal
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = \
+ gdal_serv.c \
+ \
+ gdalbridge.c \
+ gbgetsymbol.c
+
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) \
+ $(PROJ_INCLUDE)
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(GUTIL_LINKLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,42 @@
+# Copyright (C) 2001 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+include $(TOPDIR)/config/common.mak
+
+#
+# Sub-directories that need to be built
+#
+subdirs = ogdi_import ogdi_info
+
+#
+# Default target to build everything in all sub-directories
+#
+all: $(subdirs)
+
+#
+# Target to allow individual sub-directories to be built
+# (e.g. make cgmmod)
+#
+.PHONY: $(subdirs)
+$(subdirs):
+ cd $@; $(MAKE)
+
+#
+# Pass specialized targets into the sub-directories
+#
+.PHONY: $(STANDARD_TARGETS)
+$(STANDARD_TARGETS):
+ @for i in $(subdirs); do \
+ $(MAKE) --directory $$i $@; \
+ done
+
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/dbfopen.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/dbfopen.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/dbfopen.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1146 @@
+/******************************************************************************
+ * dbfopen.c,v 1.1 2000/11/23 19:13:49 warmerda Exp
+ *
+ * Project: Shapelib
+ * Purpose: Implementation of .dbf access API documented in dbf_api.html.
+ * Author: Frank Warmerdam, warmerda at home.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * This software is available under the following "MIT Style" license,
+ * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
+ * option is discussed in more detail in shapelib.html.
+ *
+ * --
+ *
+ * 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.
+ ******************************************************************************
+ *
+ * dbfopen.c,v
+ * Revision 1.1 2000/11/23 19:13:49 warmerda
+ * new
+ *
+ * Revision 1.29 2000/10/05 14:36:44 warmerda
+ * fix bug with writing very wide numeric fields
+ *
+ * Revision 1.28 2000/09/25 14:18:07 warmerda
+ * Added some casts of strlen() return result to fix warnings on some
+ * systems, as submitted by Daniel.
+ *
+ * Revision 1.27 2000/09/25 14:15:51 warmerda
+ * added DBFGetNativeFieldType()
+ *
+ * Revision 1.26 2000/07/07 13:39:45 warmerda
+ * removed unused variables, and added system include files
+ *
+ * Revision 1.25 2000/05/29 18:19:13 warmerda
+ * avoid use of uchar, and adding casting fix
+ *
+ * Revision 1.24 2000/05/23 13:38:27 warmerda
+ * Added error checks on return results of fread() and fseek().
+ *
+ * Revision 1.23 2000/05/23 13:25:49 warmerda
+ * Avoid crashing if field or record are out of range in dbfread*attribute().
+ *
+ * Revision 1.22 1999/12/15 13:47:24 warmerda
+ * Added stdlib.h to ensure that atof() is prototyped.
+ *
+ * Revision 1.21 1999/12/13 17:25:46 warmerda
+ * Added support for upper case .DBF extention.
+ *
+ * Revision 1.20 1999/11/30 16:32:11 warmerda
+ * Use atof() instead of sscanf().
+ *
+ * Revision 1.19 1999/11/05 14:12:04 warmerda
+ * updated license terms
+ *
+ * Revision 1.18 1999/07/27 00:53:28 warmerda
+ * ensure that whole old field value clear on write of string
+ *
+ * Revision 1.1 1999/07/05 18:58:07 warmerda
+ * New
+ *
+ * Revision 1.17 1999/06/11 19:14:12 warmerda
+ * Fixed some memory leaks.
+ *
+ * Revision 1.16 1999/06/11 19:04:11 warmerda
+ * Remoted some unused variables.
+ *
+ * Revision 1.15 1999/05/11 03:19:28 warmerda
+ * added new Tuple api, and improved extension handling - add from candrsn
+ *
+ * Revision 1.14 1999/05/04 15:01:48 warmerda
+ * Added 'F' support.
+ *
+ * Revision 1.13 1999/03/23 17:38:59 warmerda
+ * DBFAddField() now actually does return the new field number, or -1 if
+ * it fails.
+ *
+ * Revision 1.12 1999/03/06 02:54:46 warmerda
+ * Added logic to convert shapefile name to dbf filename in DBFOpen()
+ * for convenience.
+ *
+ * Revision 1.11 1998/12/31 15:30:34 warmerda
+ * Improved the interchangability of numeric and string attributes. Add
+ * white space trimming option for attributes.
+ *
+ * Revision 1.10 1998/12/03 16:36:44 warmerda
+ * Use r+b instead of rb+ for binary access.
+ *
+ * Revision 1.9 1998/12/03 15:34:23 warmerda
+ * Updated copyright message.
+ *
+ * Revision 1.8 1997/12/04 15:40:15 warmerda
+ * Added newline character after field definitions.
+ *
+ * Revision 1.7 1997/03/06 14:02:10 warmerda
+ * Ensure bUpdated is initialized.
+ *
+ * Revision 1.6 1996/02/12 04:54:41 warmerda
+ * Ensure that DBFWriteAttribute() returns TRUE if it succeeds.
+ *
+ * Revision 1.5 1995/10/21 03:15:12 warmerda
+ * Changed to use binary file access, and ensure that the
+ * field name field is zero filled, and limited to 10 chars.
+ *
+ * Revision 1.4 1995/08/24 18:10:42 warmerda
+ * Added use of SfRealloc() to avoid pre-ANSI realloc() functions such
+ * as on the Sun.
+ *
+ * Revision 1.3 1995/08/04 03:15:16 warmerda
+ * Fixed up header.
+ *
+ * Revision 1.2 1995/08/04 03:14:43 warmerda
+ * Added header.
+ */
+
+
+#include "shapefil.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef FALSE
+# define FALSE 0
+# define TRUE 1
+#endif
+
+static int nStringFieldLen = 0;
+static char * pszStringField = NULL;
+
+/************************************************************************/
+/* SfRealloc() */
+/* */
+/* A realloc cover function that will access a NULL pointer as */
+/* a valid input. */
+/************************************************************************/
+
+static void * SfRealloc( void * pMem, int nNewSize )
+
+{
+ if( pMem == NULL )
+ return( (void *) malloc(nNewSize) );
+ else
+ return( (void *) realloc(pMem,nNewSize) );
+}
+
+/************************************************************************/
+/* DBFWriteHeader() */
+/* */
+/* This is called to write out the file header, and field */
+/* descriptions before writing any actual data records. This */
+/* also computes all the DBFDataSet field offset/size/decimals */
+/* and so forth values. */
+/************************************************************************/
+
+static void DBFWriteHeader(DBFHandle psDBF)
+
+{
+ unsigned char abyHeader[XBASE_FLDHDR_SZ];
+ int i;
+
+ if( !psDBF->bNoHeader )
+ return;
+
+ psDBF->bNoHeader = FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Initialize the file header information. */
+/* -------------------------------------------------------------------- */
+ for( i = 0; i < XBASE_FLDHDR_SZ; i++ )
+ abyHeader[i] = 0;
+
+ abyHeader[0] = 0x03; /* memo field? - just copying */
+
+ /* date updated on close, record count preset at zero */
+
+ abyHeader[8] = psDBF->nHeaderLength % 256;
+ abyHeader[9] = psDBF->nHeaderLength / 256;
+
+ abyHeader[10] = psDBF->nRecordLength % 256;
+ abyHeader[11] = psDBF->nRecordLength / 256;
+
+/* -------------------------------------------------------------------- */
+/* Write the initial 32 byte file header, and all the field */
+/* descriptions. */
+/* -------------------------------------------------------------------- */
+ fseek( psDBF->fp, 0, 0 );
+ ogdi_fwrite( abyHeader, XBASE_FLDHDR_SZ, 1, psDBF->fp );
+ ogdi_fwrite( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields, psDBF->fp );
+
+/* -------------------------------------------------------------------- */
+/* Write out the newline character if there is room for it. */
+/* -------------------------------------------------------------------- */
+ if( psDBF->nHeaderLength > 32*psDBF->nFields + 32 )
+ {
+ char cNewline;
+
+ cNewline = 0x0d;
+ ogdi_fwrite( &cNewline, 1, 1, psDBF->fp );
+ }
+}
+
+/************************************************************************/
+/* DBFFlushRecord() */
+/* */
+/* Write out the current record if there is one. */
+/************************************************************************/
+
+static void DBFFlushRecord( DBFHandle psDBF )
+
+{
+ int nRecordOffset;
+
+ if( psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1 )
+ {
+ psDBF->bCurrentRecordModified = FALSE;
+
+ nRecordOffset = psDBF->nRecordLength * psDBF->nCurrentRecord
+ + psDBF->nHeaderLength;
+
+ fseek( psDBF->fp, nRecordOffset, 0 );
+ ogdi_fwrite( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+ }
+}
+
+/************************************************************************/
+/* DBFOpen() */
+/* */
+/* Open a .dbf file. */
+/************************************************************************/
+
+DBFHandle DBFOpen( const char * pszFilename, const char * pszAccess )
+
+{
+ DBFHandle psDBF;
+ unsigned char *pabyBuf;
+ int nFields, nRecords, nHeadLen, nRecLen, iField, i;
+ char *pszBasename, *pszFullname;
+
+/* -------------------------------------------------------------------- */
+/* We only allow the access strings "rb" and "r+". */
+/* -------------------------------------------------------------------- */
+ if( strcmp(pszAccess,"r") != 0 && strcmp(pszAccess,"r+") != 0
+ && strcmp(pszAccess,"rb") != 0 && strcmp(pszAccess,"rb+") != 0
+ && strcmp(pszAccess,"r+b") != 0 )
+ return( NULL );
+
+/* -------------------------------------------------------------------- */
+/* Compute the base (layer) name. If there is any extension */
+/* on the passed in filename we will strip it off. */
+/* -------------------------------------------------------------------- */
+ pszBasename = (char *) malloc(strlen(pszFilename)+5);
+ strcpy( pszBasename, pszFilename );
+ for( i = strlen(pszBasename)-1;
+ i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
+ && pszBasename[i] != '\\';
+ i-- ) {}
+
+ if( pszBasename[i] == '.' )
+ pszBasename[i] = '\0';
+
+ pszFullname = (char *) malloc(strlen(pszBasename) + 5);
+ sprintf( pszFullname, "%s.dbf", pszBasename );
+
+ psDBF = (DBFHandle) calloc( 1, sizeof(DBFInfo) );
+ psDBF->fp = fopen( pszFullname, pszAccess );
+
+ if( psDBF->fp == NULL )
+ {
+ sprintf( pszFullname, "%s.DBF", pszBasename );
+ psDBF->fp = fopen(pszFullname, pszAccess );
+ }
+
+ free( pszBasename );
+ free( pszFullname );
+
+ if( psDBF->fp == NULL )
+ {
+ free( psDBF );
+ return( NULL );
+ }
+
+ psDBF->bNoHeader = FALSE;
+ psDBF->nCurrentRecord = -1;
+ psDBF->bCurrentRecordModified = FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Read Table Header info */
+/* -------------------------------------------------------------------- */
+ pabyBuf = (unsigned char *) malloc(500);
+ ogdi_fread( pabyBuf, 32, 1, psDBF->fp );
+
+ psDBF->nRecords = nRecords =
+ pabyBuf[4] + pabyBuf[5]*256 + pabyBuf[6]*256*256 + pabyBuf[7]*256*256*256;
+
+ psDBF->nHeaderLength = nHeadLen = pabyBuf[8] + pabyBuf[9]*256;
+ psDBF->nRecordLength = nRecLen = pabyBuf[10] + pabyBuf[11]*256;
+
+ psDBF->nFields = nFields = (nHeadLen - 32) / 32;
+
+ psDBF->pszCurrentRecord = (char *) malloc(nRecLen);
+
+/* -------------------------------------------------------------------- */
+/* Read in Field Definitions */
+/* -------------------------------------------------------------------- */
+
+ pabyBuf = (unsigned char *) SfRealloc(pabyBuf,nHeadLen);
+ psDBF->pszHeader = (char *) pabyBuf;
+
+ fseek( psDBF->fp, 32, 0 );
+ ogdi_fread( pabyBuf, nHeadLen, 1, psDBF->fp );
+
+ psDBF->panFieldOffset = (int *) malloc(sizeof(int) * nFields);
+ psDBF->panFieldSize = (int *) malloc(sizeof(int) * nFields);
+ psDBF->panFieldDecimals = (int *) malloc(sizeof(int) * nFields);
+ psDBF->pachFieldType = (char *) malloc(sizeof(char) * nFields);
+
+ for( iField = 0; iField < nFields; iField++ )
+ {
+ unsigned char *pabyFInfo;
+
+ pabyFInfo = pabyBuf+iField*32;
+
+ if( pabyFInfo[11] == 'N' || pabyFInfo[11] == 'F' )
+ {
+ psDBF->panFieldSize[iField] = pabyFInfo[16];
+ psDBF->panFieldDecimals[iField] = pabyFInfo[17];
+ }
+ else
+ {
+ psDBF->panFieldSize[iField] = pabyFInfo[16] + pabyFInfo[17]*256;
+ psDBF->panFieldDecimals[iField] = 0;
+ }
+
+ psDBF->pachFieldType[iField] = (char) pabyFInfo[11];
+ if( iField == 0 )
+ psDBF->panFieldOffset[iField] = 1;
+ else
+ psDBF->panFieldOffset[iField] =
+ psDBF->panFieldOffset[iField-1] + psDBF->panFieldSize[iField-1];
+ }
+
+ return( psDBF );
+}
+
+/************************************************************************/
+/* DBFClose() */
+/************************************************************************/
+
+void DBFClose(DBFHandle psDBF)
+{
+/* -------------------------------------------------------------------- */
+/* Write out header if not already written. */
+/* -------------------------------------------------------------------- */
+ if( psDBF->bNoHeader )
+ DBFWriteHeader( psDBF );
+
+ DBFFlushRecord( psDBF );
+
+/* -------------------------------------------------------------------- */
+/* Update last access date, and number of records if we have */
+/* write access. */
+/* -------------------------------------------------------------------- */
+ if( psDBF->bUpdated )
+ {
+ unsigned char abyFileHeader[32];
+
+ fseek( psDBF->fp, 0, 0 );
+ ogdi_fread( abyFileHeader, 32, 1, psDBF->fp );
+
+ abyFileHeader[1] = 95; /* YY */
+ abyFileHeader[2] = 7; /* MM */
+ abyFileHeader[3] = 26; /* DD */
+
+ abyFileHeader[4] = psDBF->nRecords % 256;
+ abyFileHeader[5] = (psDBF->nRecords/256) % 256;
+ abyFileHeader[6] = (psDBF->nRecords/(256*256)) % 256;
+ abyFileHeader[7] = (psDBF->nRecords/(256*256*256)) % 256;
+
+ fseek( psDBF->fp, 0, 0 );
+ ogdi_fwrite( abyFileHeader, 32, 1, psDBF->fp );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Close, and free resources. */
+/* -------------------------------------------------------------------- */
+ fclose( psDBF->fp );
+
+ if( psDBF->panFieldOffset != NULL )
+ {
+ free( psDBF->panFieldOffset );
+ free( psDBF->panFieldSize );
+ free( psDBF->panFieldDecimals );
+ free( psDBF->pachFieldType );
+ }
+
+ free( psDBF->pszHeader );
+ free( psDBF->pszCurrentRecord );
+
+ free( psDBF );
+
+ if( pszStringField != NULL )
+ {
+ free( pszStringField );
+ pszStringField = NULL;
+ nStringFieldLen = 0;
+ }
+}
+
+/************************************************************************/
+/* DBFCreate() */
+/* */
+/* Create a new .dbf file. */
+/************************************************************************/
+
+DBFHandle DBFCreate( const char * pszFilename )
+
+{
+ DBFHandle psDBF;
+ FILE *fp;
+ char *pszFullname, *pszBasename;
+ int i;
+
+/* -------------------------------------------------------------------- */
+/* Compute the base (layer) name. If there is any extension */
+/* on the passed in filename we will strip it off. */
+/* -------------------------------------------------------------------- */
+ pszBasename = (char *) malloc(strlen(pszFilename)+5);
+ strcpy( pszBasename, pszFilename );
+ for( i = strlen(pszBasename)-1;
+ i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
+ && pszBasename[i] != '\\';
+ i-- ) {}
+
+ if( pszBasename[i] == '.' )
+ pszBasename[i] = '\0';
+
+ pszFullname = (char *) malloc(strlen(pszBasename) + 5);
+ sprintf( pszFullname, "%s.dbf", pszBasename );
+ free( pszBasename );
+
+/* -------------------------------------------------------------------- */
+/* Create the file. */
+/* -------------------------------------------------------------------- */
+ fp = fopen( pszFullname, "wb" );
+ if( fp == NULL )
+ return( NULL );
+
+ fputc( 0, fp );
+ fclose( fp );
+
+ fp = fopen( pszFullname, "rb+" );
+ if( fp == NULL )
+ return( NULL );
+
+ free( pszFullname );
+
+/* -------------------------------------------------------------------- */
+/* Create the info structure. */
+/* -------------------------------------------------------------------- */
+ psDBF = (DBFHandle) malloc(sizeof(DBFInfo));
+
+ psDBF->fp = fp;
+ psDBF->nRecords = 0;
+ psDBF->nFields = 0;
+ psDBF->nRecordLength = 1;
+ psDBF->nHeaderLength = 33;
+
+ psDBF->panFieldOffset = NULL;
+ psDBF->panFieldSize = NULL;
+ psDBF->panFieldDecimals = NULL;
+ psDBF->pachFieldType = NULL;
+ psDBF->pszHeader = NULL;
+
+ psDBF->nCurrentRecord = -1;
+ psDBF->bCurrentRecordModified = FALSE;
+ psDBF->pszCurrentRecord = NULL;
+
+ psDBF->bNoHeader = TRUE;
+
+ return( psDBF );
+}
+
+/************************************************************************/
+/* DBFAddField() */
+/* */
+/* Add a field to a newly created .dbf file before any records */
+/* are written. */
+/************************************************************************/
+
+int DBFAddField(DBFHandle psDBF, const char * pszFieldName,
+ DBFFieldType eType, int nWidth, int nDecimals )
+
+{
+ char *pszFInfo;
+ int i;
+
+/* -------------------------------------------------------------------- */
+/* Do some checking to ensure we can add records to this file. */
+/* -------------------------------------------------------------------- */
+ if( psDBF->nRecords > 0 )
+ return( -1 );
+
+ if( !psDBF->bNoHeader )
+ return( -1 );
+
+ if( eType != FTDouble && nDecimals != 0 )
+ return( -1 );
+
+/* -------------------------------------------------------------------- */
+/* SfRealloc all the arrays larger to hold the additional field */
+/* information. */
+/* -------------------------------------------------------------------- */
+ psDBF->nFields++;
+
+ psDBF->panFieldOffset = (int *)
+ SfRealloc( psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
+
+ psDBF->panFieldSize = (int *)
+ SfRealloc( psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
+
+ psDBF->panFieldDecimals = (int *)
+ SfRealloc( psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
+
+ psDBF->pachFieldType = (char *)
+ SfRealloc( psDBF->pachFieldType, sizeof(char) * psDBF->nFields );
+
+/* -------------------------------------------------------------------- */
+/* Assign the new field information fields. */
+/* -------------------------------------------------------------------- */
+ psDBF->panFieldOffset[psDBF->nFields-1] = psDBF->nRecordLength;
+ psDBF->nRecordLength += nWidth;
+ psDBF->panFieldSize[psDBF->nFields-1] = nWidth;
+ psDBF->panFieldDecimals[psDBF->nFields-1] = nDecimals;
+
+ if( eType == FTString )
+ psDBF->pachFieldType[psDBF->nFields-1] = 'C';
+ else
+ psDBF->pachFieldType[psDBF->nFields-1] = 'N';
+
+/* -------------------------------------------------------------------- */
+/* Extend the required header information. */
+/* -------------------------------------------------------------------- */
+ psDBF->nHeaderLength += 32;
+ psDBF->bUpdated = FALSE;
+
+ psDBF->pszHeader = (char *) SfRealloc(psDBF->pszHeader,psDBF->nFields*32);
+
+ pszFInfo = psDBF->pszHeader + 32 * (psDBF->nFields-1);
+
+ for( i = 0; i < 32; i++ )
+ pszFInfo[i] = '\0';
+
+ if( (int) strlen(pszFieldName) < 10 )
+ strncpy( pszFInfo, pszFieldName, strlen(pszFieldName));
+ else
+ strncpy( pszFInfo, pszFieldName, 10);
+
+ pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields-1];
+
+ if( eType == FTString )
+ {
+ pszFInfo[16] = nWidth % 256;
+ pszFInfo[17] = nWidth / 256;
+ }
+ else
+ {
+ pszFInfo[16] = nWidth;
+ pszFInfo[17] = nDecimals;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Make the current record buffer appropriately larger. */
+/* -------------------------------------------------------------------- */
+ psDBF->pszCurrentRecord = (char *) SfRealloc(psDBF->pszCurrentRecord,
+ psDBF->nRecordLength);
+
+ return( psDBF->nFields-1 );
+}
+
+/************************************************************************/
+/* DBFReadAttribute() */
+/* */
+/* Read one of the attribute fields of a record. */
+/************************************************************************/
+
+static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField,
+ char chReqType )
+
+{
+ int nRecordOffset;
+ unsigned char *pabyRec;
+ void *pReturnField = NULL;
+
+ static double dDoubleField;
+
+/* -------------------------------------------------------------------- */
+/* Verify selection. */
+/* -------------------------------------------------------------------- */
+ if( hEntity < 0 || hEntity >= psDBF->nRecords )
+ return( NULL );
+
+ if( iField < 0 || iField >= psDBF->nFields )
+ return( NULL );
+
+/* -------------------------------------------------------------------- */
+/* Have we read the record? */
+/* -------------------------------------------------------------------- */
+ if( psDBF->nCurrentRecord != hEntity )
+ {
+ DBFFlushRecord( psDBF );
+
+ nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+ if( fseek( psDBF->fp, nRecordOffset, 0 ) != 0 )
+ {
+ fprintf( stderr, "fseek(%d) failed on DBF file.\n",
+ nRecordOffset );
+ return NULL;
+ }
+
+ if( fread( psDBF->pszCurrentRecord, psDBF->nRecordLength,
+ 1, psDBF->fp ) != 1 )
+ {
+ fprintf( stderr, "fread(%d) failed on DBF file.\n",
+ psDBF->nRecordLength );
+ return NULL;
+ }
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+
+ pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
+
+/* -------------------------------------------------------------------- */
+/* Ensure our field buffer is large enough to hold this buffer. */
+/* -------------------------------------------------------------------- */
+ if( psDBF->panFieldSize[iField]+1 > nStringFieldLen )
+ {
+ nStringFieldLen = psDBF->panFieldSize[iField]*2 + 10;
+ pszStringField = (char *) SfRealloc(pszStringField,nStringFieldLen);
+ }
+
+/* -------------------------------------------------------------------- */
+/* Extract the requested field. */
+/* -------------------------------------------------------------------- */
+ strncpy( pszStringField,
+ ((const char *) pabyRec) + psDBF->panFieldOffset[iField],
+ psDBF->panFieldSize[iField] );
+ pszStringField[psDBF->panFieldSize[iField]] = '\0';
+
+ pReturnField = pszStringField;
+
+/* -------------------------------------------------------------------- */
+/* Decode the field. */
+/* -------------------------------------------------------------------- */
+ if( chReqType == 'N' )
+ {
+ dDoubleField = atof(pszStringField);
+
+ pReturnField = &dDoubleField;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Should we trim white space off the string attribute value? */
+/* -------------------------------------------------------------------- */
+#ifdef TRIM_DBF_WHITESPACE
+ else
+ {
+ char *pchSrc, *pchDst;
+
+ pchDst = pchSrc = pszStringField;
+ while( *pchSrc == ' ' )
+ pchSrc++;
+
+ while( *pchSrc != '\0' )
+ *(pchDst++) = *(pchSrc++);
+ *pchDst = '\0';
+
+ while( *(--pchDst) == ' ' && pchDst != pszStringField )
+ *pchDst = '\0';
+
+ }
+#endif
+
+ return( pReturnField );
+}
+
+/************************************************************************/
+/* DBFReadIntAttribute() */
+/* */
+/* Read an integer attribute. */
+/************************************************************************/
+
+int DBFReadIntegerAttribute( DBFHandle psDBF, int iRecord, int iField )
+
+{
+ double *pdValue;
+
+ pdValue = (double *) DBFReadAttribute( psDBF, iRecord, iField, 'N' );
+
+ if( pdValue == NULL )
+ return 0;
+ else
+ return( (int) *pdValue );
+}
+
+/************************************************************************/
+/* DBFReadDoubleAttribute() */
+/* */
+/* Read a double attribute. */
+/************************************************************************/
+
+double DBFReadDoubleAttribute( DBFHandle psDBF, int iRecord, int iField )
+
+{
+ double *pdValue;
+
+ pdValue = (double *) DBFReadAttribute( psDBF, iRecord, iField, 'N' );
+
+ if( pdValue == NULL )
+ return 0.0;
+ else
+ return( *pdValue );
+}
+
+/************************************************************************/
+/* DBFReadStringAttribute() */
+/* */
+/* Read a string attribute. */
+/************************************************************************/
+
+const char *DBFReadStringAttribute( DBFHandle psDBF, int iRecord, int iField )
+
+{
+ return( (const char *) DBFReadAttribute( psDBF, iRecord, iField, 'C' ) );
+}
+
+/************************************************************************/
+/* DBFGetFieldCount() */
+/* */
+/* Return the number of fields in this table. */
+/************************************************************************/
+
+int DBFGetFieldCount( DBFHandle psDBF )
+
+{
+ return( psDBF->nFields );
+}
+
+/************************************************************************/
+/* DBFGetRecordCount() */
+/* */
+/* Return the number of records in this table. */
+/************************************************************************/
+
+int DBFGetRecordCount( DBFHandle psDBF )
+
+{
+ return( psDBF->nRecords );
+}
+
+/************************************************************************/
+/* DBFGetFieldInfo() */
+/* */
+/* Return any requested information about the field. */
+/************************************************************************/
+
+DBFFieldType DBFGetFieldInfo( DBFHandle psDBF, int iField, char * pszFieldName,
+ int * pnWidth, int * pnDecimals )
+
+{
+ if( iField < 0 || iField >= psDBF->nFields )
+ return( FTInvalid );
+
+ if( pnWidth != NULL )
+ *pnWidth = psDBF->panFieldSize[iField];
+
+ if( pnDecimals != NULL )
+ *pnDecimals = psDBF->panFieldDecimals[iField];
+
+ if( pszFieldName != NULL )
+ {
+ int i;
+
+ strncpy( pszFieldName, (char *) psDBF->pszHeader+iField*32, 11 );
+ pszFieldName[11] = '\0';
+ for( i = 10; i > 0 && pszFieldName[i] == ' '; i-- )
+ pszFieldName[i] = '\0';
+ }
+
+ if( psDBF->pachFieldType[iField] == 'N'
+ || psDBF->pachFieldType[iField] == 'F'
+ || psDBF->pachFieldType[iField] == 'D' )
+ {
+ if( psDBF->panFieldDecimals[iField] > 0 )
+ return( FTDouble );
+ else
+ return( FTInteger );
+ }
+ else
+ {
+ return( FTString );
+ }
+}
+
+/************************************************************************/
+/* DBFWriteAttribute() */
+/* */
+/* Write an attribute record to the file. */
+/************************************************************************/
+
+static int DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField,
+ void * pValue )
+
+{
+ int nRecordOffset, i, j;
+ unsigned char *pabyRec;
+ char szSField[400], szFormat[20];
+
+/* -------------------------------------------------------------------- */
+/* Is this a valid record? */
+/* -------------------------------------------------------------------- */
+ if( hEntity < 0 || hEntity > psDBF->nRecords )
+ return( FALSE );
+
+ if( psDBF->bNoHeader )
+ DBFWriteHeader(psDBF);
+
+/* -------------------------------------------------------------------- */
+/* Is this a brand new record? */
+/* -------------------------------------------------------------------- */
+ if( hEntity == psDBF->nRecords )
+ {
+ DBFFlushRecord( psDBF );
+
+ psDBF->nRecords++;
+ for( i = 0; i < psDBF->nRecordLength; i++ )
+ psDBF->pszCurrentRecord[i] = ' ';
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Is this an existing record, but different than the last one */
+/* we accessed? */
+/* -------------------------------------------------------------------- */
+ if( psDBF->nCurrentRecord != hEntity )
+ {
+ DBFFlushRecord( psDBF );
+
+ nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+ fseek( psDBF->fp, nRecordOffset, 0 );
+ ogdi_fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+
+ pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
+
+/* -------------------------------------------------------------------- */
+/* Assign all the record fields. */
+/* -------------------------------------------------------------------- */
+ switch( psDBF->pachFieldType[iField] )
+ {
+ case 'D':
+ case 'N':
+ case 'F':
+ if( psDBF->panFieldDecimals[iField] == 0 )
+ {
+ int nWidth = psDBF->panFieldSize[iField];
+
+ if( sizeof(szSField)-2 < nWidth )
+ nWidth = sizeof(szSField)-2;
+
+ sprintf( szFormat, "%%%dd", nWidth );
+ sprintf(szSField, szFormat, (int) *((double *) pValue) );
+ if( (int)strlen(szSField) > psDBF->panFieldSize[iField] )
+ szSField[psDBF->panFieldSize[iField]] = '\0';
+
+ strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
+ szSField, strlen(szSField) );
+ }
+ else
+ {
+ int nWidth = psDBF->panFieldSize[iField];
+
+ if( sizeof(szSField)-2 < nWidth )
+ nWidth = sizeof(szSField)-2;
+
+ sprintf( szFormat, "%%%d.%df",
+ nWidth, psDBF->panFieldDecimals[iField] );
+ sprintf(szSField, szFormat, *((double *) pValue) );
+ if( (int) strlen(szSField) > psDBF->panFieldSize[iField] )
+ szSField[psDBF->panFieldSize[iField]] = '\0';
+ strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
+ szSField, strlen(szSField) );
+ }
+ break;
+
+ default:
+ if( (int) strlen((char *) pValue) > psDBF->panFieldSize[iField] )
+ j = psDBF->panFieldSize[iField];
+ else
+ {
+ memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
+ psDBF->panFieldSize[iField] );
+ j = strlen((char *) pValue);
+ }
+
+ strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
+ (char *) pValue, j );
+ break;
+ }
+
+ psDBF->bCurrentRecordModified = TRUE;
+ psDBF->bUpdated = TRUE;
+
+ return( TRUE );
+}
+
+/************************************************************************/
+/* DBFWriteDoubleAttribute() */
+/* */
+/* Write a double attribute. */
+/************************************************************************/
+
+int DBFWriteDoubleAttribute( DBFHandle psDBF, int iRecord, int iField,
+ double dValue )
+
+{
+ return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) );
+}
+
+/************************************************************************/
+/* DBFWriteIntegerAttribute() */
+/* */
+/* Write a integer attribute. */
+/************************************************************************/
+
+int DBFWriteIntegerAttribute( DBFHandle psDBF, int iRecord, int iField,
+ int nValue )
+
+{
+ double dValue = nValue;
+
+ return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) );
+}
+
+/************************************************************************/
+/* DBFWriteStringAttribute() */
+/* */
+/* Write a string attribute. */
+/************************************************************************/
+
+int DBFWriteStringAttribute( DBFHandle psDBF, int iRecord, int iField,
+ const char * pszValue )
+
+{
+ return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) pszValue ) );
+}
+
+/************************************************************************/
+/* DBFWriteTuple() */
+/* */
+/* Write an attribute record to the file. */
+/************************************************************************/
+
+int DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple )
+
+{
+ int nRecordOffset, i;
+ unsigned char *pabyRec;
+
+/* -------------------------------------------------------------------- */
+/* Is this a valid record? */
+/* -------------------------------------------------------------------- */
+ if( hEntity < 0 || hEntity > psDBF->nRecords )
+ return( FALSE );
+
+ if( psDBF->bNoHeader )
+ DBFWriteHeader(psDBF);
+
+/* -------------------------------------------------------------------- */
+/* Is this a brand new record? */
+/* -------------------------------------------------------------------- */
+ if( hEntity == psDBF->nRecords )
+ {
+ DBFFlushRecord( psDBF );
+
+ psDBF->nRecords++;
+ for( i = 0; i < psDBF->nRecordLength; i++ )
+ psDBF->pszCurrentRecord[i] = ' ';
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Is this an existing record, but different than the last one */
+/* we accessed? */
+/* -------------------------------------------------------------------- */
+ if( psDBF->nCurrentRecord != hEntity )
+ {
+ DBFFlushRecord( psDBF );
+
+ nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+ fseek( psDBF->fp, nRecordOffset, 0 );
+ ogdi_fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+
+ pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
+
+ memcpy ( pabyRec, pRawTuple, psDBF->nRecordLength );
+
+ psDBF->bCurrentRecordModified = TRUE;
+ psDBF->bUpdated = TRUE;
+
+ return( TRUE );
+}
+
+/************************************************************************/
+/* DBFReadTuple() */
+/* */
+/* Read one of the attribute fields of a record. */
+/************************************************************************/
+
+const char *DBFReadTuple(DBFHandle psDBF, int hEntity )
+
+{
+ int nRecordOffset;
+ unsigned char *pabyRec;
+ static char *pReturnTuple = NULL;
+
+ static int nTupleLen = 0;
+
+/* -------------------------------------------------------------------- */
+/* Have we read the record? */
+/* -------------------------------------------------------------------- */
+ if( hEntity < 0 || hEntity >= psDBF->nRecords )
+ return( NULL );
+
+ if( psDBF->nCurrentRecord != hEntity )
+ {
+ DBFFlushRecord( psDBF );
+
+ nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+ fseek( psDBF->fp, nRecordOffset, 0 );
+ ogdi_fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+
+ pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
+
+ if ( nTupleLen < psDBF->nRecordLength) {
+ nTupleLen = psDBF->nRecordLength;
+ pReturnTuple = (char *) SfRealloc(pReturnTuple, psDBF->nRecordLength);
+ }
+
+ memcpy ( pReturnTuple, pabyRec, psDBF->nRecordLength );
+
+ return( pReturnTuple );
+}
+
+/************************************************************************/
+/* DBFCloneEmpty() */
+/* */
+/* Read one of the attribute fields of a record. */
+/************************************************************************/
+
+DBFHandle DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename )
+{
+ DBFHandle newDBF;
+
+ newDBF = DBFCreate ( pszFilename );
+ if ( newDBF == NULL ) return ( NULL );
+
+ newDBF->pszHeader = (void *) malloc ( 32 * psDBF->nFields );
+ memcpy ( newDBF->pszHeader, psDBF->pszHeader, 32 * psDBF->nFields );
+
+ newDBF->nFields = psDBF->nFields;
+ newDBF->nRecordLength = psDBF->nRecordLength;
+ newDBF->nHeaderLength = psDBF->nHeaderLength;
+
+ newDBF->panFieldOffset = (void *) malloc ( sizeof(int) * psDBF->nFields );
+ memcpy ( newDBF->panFieldOffset, psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
+ newDBF->panFieldSize = (void *) malloc ( sizeof(int) * psDBF->nFields );
+ memcpy ( newDBF->panFieldSize, psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
+ newDBF->panFieldDecimals = (void *) malloc ( sizeof(int) * psDBF->nFields );
+ memcpy ( newDBF->panFieldDecimals, psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
+ newDBF->pachFieldType = (void *) malloc ( sizeof(int) * psDBF->nFields );
+ memcpy ( newDBF->pachFieldType, psDBF->pachFieldType, sizeof(int) * psDBF->nFields );
+
+ newDBF->bNoHeader = TRUE;
+ newDBF->bUpdated = TRUE;
+
+ DBFWriteHeader ( newDBF );
+ DBFClose ( newDBF );
+
+ newDBF = DBFOpen ( pszFilename, "rb+" );
+
+ return ( newDBF );
+}
+
+/************************************************************************/
+/* DBFGetNativeFieldType() */
+/* */
+/* Return the DBase field type for the specified field. */
+/* */
+/* Value can be one of: 'C' (String), 'D' (Date), 'F' (Float), */
+/* 'N' (Numeric, with or without decimal), */
+/* 'L' (Logical), */
+/* 'M' (Memo: 10 digits .DBT block ptr) */
+/************************************************************************/
+
+char DBFGetNativeFieldType( DBFHandle psDBF, int iField )
+
+{
+ if( iField >=0 && iField < psDBF->nFields )
+ return psDBF->pachFieldType[iField];
+
+ return ' ';
+}
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,34 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty
+#
+
+TOBEGEN = ogdi_import
+TARGETGEN=$(PROGGEN)
+
+SOURCES = ogdi_import.c shpopen.c dbfopen.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)\
+ $(ZLIB_INCLUDE) $(GENERAL_INCLUDE) $(TCLTK_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS) $(FLAGS_X86DEF)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(ZLIB_LINKLIB) $(RPC_LINKLIB) \
+ $(PROJ_STATICLIB) $(MATH_LINKLIB) \
+ $(LIBC_LINKLIB) $(UCB_STATICLIB) $(DL_LINKLIB) \
+ $(WIN_LINKLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR ogdi_import.c
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/ogdi_import.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/ogdi_import.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/ogdi_import.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1012 @@
+/******************************************************************************
+ * $Id: ogdi_import.c,v 1.13 2007/02/12 15:52:57 cbalint Exp $
+ *
+ * Project: OGDI Contributed Clients
+ * Purpose: Simple console import to shapefile/raw raster.
+ * Author: Frank Warmerdam <warmerdam at pobox.com>
+ *
+ ******************************************************************************
+ * Copyright (c) 2000, Frank Warmerdam <warmerdam at pobox.com>
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of the author not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The author makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ogdi_import.c,v $
+ * Revision 1.13 2007/02/12 15:52:57 cbalint
+ *
+ * Preliminary cleanup.
+ * Get rif of unitialized variables, and unused ones.
+ *
+ * Revision 1.12 2002/02/21 15:54:17 warmerda
+ * fixed bug with declaration of dst
+ *
+ * Revision 1.11 2002/02/08 21:22:58 warmerda
+ * fixed serious bug importing floating point fields of unknown precision
+ *
+ * Revision 1.10 2001/12/11 18:34:18 warmerda
+ * fixed region handling if GetLayerRegion() fails - default to global bounds.
+ *
+ * Revision 1.9 2001/11/14 04:55:47 warmerda
+ * added -no-dict option
+ *
+ * Revision 1.8 2001/10/09 22:48:27 warmerda
+ * preliminary support for setting output projection
+ *
+ * Revision 1.7 2001/10/02 02:06:25 warmerda
+ * various bug fixes related to region setting
+ *
+ * Revision 1.6 2001/08/16 13:44:52 warmerda
+ * fixed roundoff bug xsize/ysize calc from region
+ *
+ * Revision 1.5 2001/07/17 19:03:42 warmerda
+ * Added support for exporting lines, text and areas.
+ *
+ * Revision 1.4 2001/06/22 16:41:42 warmerda
+ * Enabled RGBA image support.
+ *
+ * Revision 1.3 2001/05/30 19:13:06 warmerda
+ * utilize layer capabitilies if available to set region and resolution
+ *
+ * Revision 1.2 2000/11/23 19:15:57 warmerda
+ * added header block
+ *
+ */
+
+#include "ecs.h"
+#include "shapefil.h"
+#include <assert.h>
+#include "projects.h"
+
+#ifndef PJ_VERSION
+#define projPJ PJ*
+#define projUV UV
+#endif
+
+static int ClientID = -1;
+static int bNoDict = FALSE;
+
+#ifndef MAX
+# define MIN(a,b) ((a<b) ? a : b)
+# define MAX(a,b) ((a>b) ? a : b)
+#endif
+
+/************************************************************************/
+/* CheckError() */
+/************************************************************************/
+
+static int CheckError( ecs_Result * result )
+
+{
+ if( ECSERROR( result ) ) {
+ printf( "ECSERROR: %s\n", result->message );
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+/************************************************************************/
+/* AccessURL() */
+/************************************************************************/
+
+static int AccessURL( char * url, ecs_Region * region )
+
+{
+ ecs_Result *result;
+
+/* -------------------------------------------------------------------- */
+/* Close old client if there is one active. */
+/* -------------------------------------------------------------------- */
+ if( ClientID != -1 ) {
+ result = cln_DestroyClient(ClientID);
+ if( CheckError( result ) )
+ return( FALSE );
+ ClientID = -1;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Open new URL/client. */
+/* -------------------------------------------------------------------- */
+ result = cln_CreateClient(&ClientID,url);
+ if( CheckError( result ) )
+ return( FALSE );
+
+/* -------------------------------------------------------------------- */
+/* print the global bounds. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetGlobalBound(ClientID);
+ if( CheckError( result ) )
+ return( FALSE );
+
+ *region = ECSREGION(result);
+
+/* -------------------------------------------------------------------- */
+/* Print the Dictionary (update). */
+/* -------------------------------------------------------------------- */
+ result = cln_UpdateDictionary( ClientID, "" );
+ if( CheckError( result ) )
+ return( FALSE );
+
+ if( !bNoDict )
+ printf( "UpdateDictionary = \n%s\n", ECSTEXT(result) );
+
+/* -------------------------------------------------------------------- */
+/* Print the projection. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetServerProjection( ClientID );
+ if( CheckError( result ) )
+ return( FALSE );
+
+ printf( "Projection = `%s'\n", ECSTEXT(result) );
+
+ return( TRUE );
+}
+
+/************************************************************************/
+/* GetLayerRegion() */
+/* */
+/* Fetch the region and resolution for the named layer if */
+/* possible, from the capabilities. */
+/************************************************************************/
+
+static void GetLayerRegion( const char *layerName, ecs_Region *region )
+
+{
+ const ecs_LayerCapabilities *layer;
+ int layer_index;
+
+ for( layer_index = 0;
+ (layer = cln_GetLayerCapabilities(ClientID,layer_index)) != NULL;
+ layer_index++ )
+ {
+ if( strcmp(layer->name,layerName) == 0 )
+ {
+ region->north = layer->srs_north;
+ region->south = layer->srs_south;
+ region->east = layer->srs_east;
+ region->west = layer->srs_west;
+ region->ew_res = layer->srs_ewres;
+ region->ns_res = layer->srs_nsres;
+ return;
+ }
+ }
+}
+
+/************************************************************************/
+/* ImportVectors() */
+/************************************************************************/
+
+static void ImportVectors( ecs_Region *region, const char * layer,
+ const char * out_file,
+ ecs_Family featureType )
+
+{
+ ecs_Result *result;
+ ecs_LayerSelection selectionLayer;
+ SHPHandle hShape = NULL;
+ DBFHandle hDBF;
+ char filename[1024];
+ ecs_ObjAttributeFormat *oaf;
+ int i, field_count, iText = -1, nFld;
+
+/* -------------------------------------------------------------------- */
+/* Select a region ... this should be overridable from the */
+/* command line. */
+/* -------------------------------------------------------------------- */
+ result = cln_SelectRegion(ClientID,region);
+ if( CheckError( result ) )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Define the layer to select. For now we only support lines. */
+/* -------------------------------------------------------------------- */
+ selectionLayer.Select = (char *) layer;
+ selectionLayer.F = featureType;
+
+ result = cln_SelectLayer(ClientID,&selectionLayer);
+
+ if( CheckError(result) )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Create the shapefile to write the lines to. */
+/* -------------------------------------------------------------------- */
+ sprintf( filename, "%s.shp", out_file );
+ if( featureType == Line )
+ hShape = SHPCreate( filename, SHPT_ARC );
+ else if( featureType == Point || featureType == Text )
+ hShape = SHPCreate( filename, SHPT_POINT );
+ else if( featureType == Area )
+ hShape = SHPCreate( filename, SHPT_POLYGON );
+
+ if( hShape == NULL )
+ {
+ fprintf( stderr, "Unable to create shapefile dataset %s\n", filename );
+ return;
+ }
+
+ sprintf( filename, "%s.dbf", out_file );
+ hDBF = DBFCreate( filename );
+
+ if( hDBF == NULL )
+ {
+ fprintf( stderr, "Unable to create DBF file %s\n", filename );
+ return;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Setup DBF schema. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetAttributesFormat( ClientID );
+ if( CheckError( result ) )
+ return;
+
+ oaf = &(ECSRESULT(result).oaf);
+ field_count = oaf->oa.oa_len;
+ for( i = 0; i < field_count; i++ )
+ {
+ switch( oaf->oa.oa_val[i].type )
+ {
+ case Char:
+ case Varchar:
+ case Longvarchar:
+ if( oaf->oa.oa_val[i].lenght > 0 )
+ nFld = DBFAddField( hDBF, oaf->oa.oa_val[i].name,
+ FTString, oaf->oa.oa_val[i].lenght, 0 );
+ else
+ nFld = DBFAddField( hDBF, oaf->oa.oa_val[i].name,
+ FTString, 64, 0 );
+ break;
+
+ case Decimal:
+ case Smallint:
+ case Integer:
+ if( oaf->oa.oa_val[i].lenght > 0 )
+ nFld = DBFAddField( hDBF, oaf->oa.oa_val[i].name,
+ FTDouble, oaf->oa.oa_val[i].lenght, 0 );
+ else
+ nFld = DBFAddField( hDBF, oaf->oa.oa_val[i].name,
+ FTString, 11, 0 );
+ break;
+
+ case Numeric:
+ case Real:
+ case Float:
+ case Double:
+ if( oaf->oa.oa_val[i].lenght > 0 )
+ nFld = DBFAddField( hDBF, oaf->oa.oa_val[i].name,
+ FTDouble,
+ oaf->oa.oa_val[i].lenght,
+ oaf->oa.oa_val[i].precision );
+ else
+ nFld = DBFAddField( hDBF, oaf->oa.oa_val[i].name,
+ FTDouble, 18, 7 );
+ break;
+
+ default:
+ nFld = 0;
+ fprintf( stderr, "Field %s of unrecognised type %d dropped.\n",
+ oaf->oa.oa_val[i].name, oaf->oa.oa_val[i].type );
+ break;
+ }
+
+ if( nFld == -1 )
+ {
+ fprintf( stderr,
+ "Field %s was not created due to a failure in DBFAddField()\n",
+ oaf->oa.oa_val[i].name );
+
+ }
+ }
+
+ if( featureType == Text )
+ {
+ iText = DBFAddField( hDBF, "text", FTString, 64, 0 );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Process objects. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetNextObject(ClientID);
+ while (ECSSUCCESS(result))
+ {
+ char *pszList;
+ int iField, iShape=0;
+
+/* -------------------------------------------------------------------- */
+/* Write shapefile geometry */
+/* -------------------------------------------------------------------- */
+
+ if( featureType == Area ) {
+ ecs_Area *area = &(ECSGEOM(result).area);
+ double *x, *y;
+ int *parts, nPoints, iRing;
+ SHPObject *psShape;
+
+ nPoints = 0;
+ for( iRing = 0; iRing < (int) area->ring.ring_len; iRing++ )
+ {
+ ecs_FeatureRing *ring = area->ring.ring_val + iRing;
+
+ nPoints += ring->c.c_len;
+ }
+
+ parts = (int *) malloc(sizeof(int) * area->ring.ring_len);
+ x = (double *) malloc(sizeof(double) * nPoints);
+ y = (double *) malloc(sizeof(double) * nPoints);
+
+ nPoints = 0;
+ for( iRing = 0; iRing < (int) area->ring.ring_len; iRing++ )
+ {
+ ecs_FeatureRing *ring = area->ring.ring_val + iRing;
+
+ parts[iRing] = nPoints;
+ for( i = 0; i < (int) ring->c.c_len; i++ )
+ {
+ x[nPoints] = ring->c.c_val[i].x;
+ y[nPoints] = ring->c.c_val[i].y;
+ nPoints++;
+ }
+ }
+
+ psShape = SHPCreateObject( SHPT_POLYGON, -1, area->ring.ring_len,
+ parts, NULL, nPoints, x, y, NULL, NULL);
+
+ free( x );
+ free( y );
+ free( parts );
+
+ iShape = SHPWriteObject( hShape, -1, psShape );
+
+ SHPDestroyObject( psShape );
+ }
+
+ else if( featureType == Line ) {
+ ecs_Line *line = &(ECSGEOM(result).line);
+ double *x, *y;
+ SHPObject *psShape;
+
+ x = (double *) malloc(sizeof(double) * line->c.c_len);
+ y = (double *) malloc(sizeof(double) * line->c.c_len);
+
+ for( i=0; i < (int) line->c.c_len; i++ ) {
+ x[i] = line->c.c_val[i].x;
+ y[i] = line->c.c_val[i].y;
+ }
+
+ psShape = SHPCreateSimpleObject( SHPT_ARC, line->c.c_len,
+ x, y, NULL );
+
+ free( x );
+ free( y );
+
+ iShape = SHPWriteObject( hShape, -1, psShape );
+
+ SHPDestroyObject( psShape );
+ }
+
+ else if( featureType == Point ) {
+ ecs_Point *point = &(ECSGEOM(result).point);
+ SHPObject *psShape;
+
+ psShape = SHPCreateSimpleObject( SHPT_POINT, 1,
+ &(point->c.x), &(point->c.y),
+ NULL );
+
+ iShape = SHPWriteObject( hShape, -1, psShape );
+
+ SHPDestroyObject( psShape );
+ }
+
+ else if( featureType == Text ) {
+ ecs_Text *point = &(ECSGEOM(result).text);
+ SHPObject *psShape;
+
+ psShape = SHPCreateSimpleObject( SHPT_POINT, 1,
+ &(point->c.x), &(point->c.y),
+ NULL );
+
+ iShape = SHPWriteObject( hShape, -1, psShape );
+
+ SHPDestroyObject( psShape );
+
+ DBFWriteStringAttribute( hDBF, iShape, iText, point->desc );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Write attributes to dbf file. */
+/* -------------------------------------------------------------------- */
+ pszList = ECSOBJECTATTR(result);
+
+ for( iField = 0; iField < field_count; iField++ )
+ {
+ char *pszFieldStart;
+ int nNameLen;
+ char chSavedChar;
+
+ /* parse out the next attribute value */
+ if( !ecs_FindElement( pszList, &pszFieldStart, &pszList,
+ &nNameLen, NULL ) )
+ {
+ nNameLen = 0;
+ pszFieldStart = pszList;
+ }
+
+ /* Skip any trailing white space (for string constants). */
+
+ if( nNameLen > 0 && pszFieldStart[nNameLen-1] == ' ' )
+ nNameLen--;
+
+ /* zero terminate the single field value, but save the */
+ /* character we overwrote, so we can restore it when done. */
+
+ chSavedChar = pszFieldStart[nNameLen];
+ pszFieldStart[nNameLen] = '\0';
+
+ switch( DBFGetFieldInfo( hDBF, iField, NULL, NULL, NULL ) )
+ {
+ case FTString:
+ DBFWriteStringAttribute( hDBF, iShape, iField, pszFieldStart );
+ break;
+
+ case FTInteger:
+ DBFWriteIntegerAttribute( hDBF, iShape, iField,
+ atoi(pszFieldStart) );
+ break;
+
+ case FTDouble:
+ DBFWriteDoubleAttribute( hDBF, iShape, iField,
+ atof(pszFieldStart) );
+ break;
+
+ default:
+ break;
+ }
+
+ pszFieldStart[nNameLen] = chSavedChar;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Read next object */
+/* -------------------------------------------------------------------- */
+ result = cln_GetNextObject(ClientID);
+ }
+
+ SHPClose( hShape );
+ DBFClose( hDBF );
+}
+
+/************************************************************************/
+/* ImportMatrix() */
+/************************************************************************/
+
+static void ImportMatrix( ecs_Region *region, const char * layer,
+ const char * out_file )
+
+{
+ FILE *fp_aux, *fp_raw;
+ char filename[256];
+ int i, xsize, ysize;
+ ecs_Result *result;
+ ecs_LayerSelection selectionLayer;
+
+/* -------------------------------------------------------------------- */
+/* Select a region ... this should be overridable from the */
+/* command line. */
+/* -------------------------------------------------------------------- */
+ result = cln_SelectRegion(ClientID,region);
+ if( CheckError( result ) )
+ return;
+
+ xsize = (int) ((region->east - region->west) / region->ew_res + 0.5);
+ ysize = (int) ((region->north - region->south) / region->ns_res + 0.5);
+
+/* -------------------------------------------------------------------- */
+/* Define the layer to select. */
+/* -------------------------------------------------------------------- */
+ selectionLayer.Select = (char *) layer;
+ selectionLayer.F = Matrix;
+
+ result = cln_SelectLayer(ClientID,&selectionLayer);
+
+ if( CheckError( result ) )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Write .aux file header. */
+/* -------------------------------------------------------------------- */
+ sprintf( filename, "%s.aux", out_file );
+ fp_aux = fopen( filename, "wt" );
+
+ sprintf( filename, "%s.raw", out_file );
+
+ fprintf( fp_aux, "AuxilaryTarget: %s\n", filename );
+
+/* -------------------------------------------------------------------- */
+/* Get the raster information. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetRasterInfo( ClientID );
+ if( CheckError( result ) )
+ return;
+
+ fprintf( fp_aux, "RawDefinition: %d %d 1\n", xsize, ysize );
+
+ fprintf( fp_aux, "ChanDefinition-1: 8U 0 1 %d Swapped\n", xsize );
+
+ for( i = 0; i < (int) ECSRASTERINFO(result).cat.cat_len; i++ ) {
+ fprintf( fp_aux, "METADATA_IMG_1_Class_%d_Name: %s\n",
+ (int) ECSRASTERINFO(result).mincat + i,
+ ECSRASTERINFO(result).cat.cat_val[i].label );
+ fprintf( fp_aux, "METADATA_IMG_1_Class_%d_Color: (RGB:%d %d %d)\n",
+ (int) ECSRASTERINFO(result).mincat + i,
+ ECSRASTERINFO(result).cat.cat_val[i].r,
+ ECSRASTERINFO(result).cat.cat_val[i].g,
+ ECSRASTERINFO(result).cat.cat_val[i].b );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Attach the projection information. */
+/* -------------------------------------------------------------------- */
+ fprintf( fp_aux, "MapUnits: METER\n" );
+ fprintf( fp_aux, "UpLeftX: %24.15E\n", region->west );
+ fprintf( fp_aux, "UpLeftY: %25.15E\n", region->north );
+ fprintf( fp_aux, "LoRightX: %25.15E\n", region->east );
+ fprintf( fp_aux, "LoRightY: %25.15E\n", region->south );
+
+ fclose( fp_aux );
+
+/* -------------------------------------------------------------------- */
+/* open the raw data file. */
+/* -------------------------------------------------------------------- */
+ fp_raw = fopen( filename, "wb" );
+
+ result = cln_GetNextObject(ClientID);
+ while (ECSSUCCESS(result)) {
+
+ static int report_flag = 0;
+
+ if( (int) ECSOBJECT(result).geom.ecs_Geometry_u.matrix.x.x_len
+ != xsize && report_flag == 0 ) {
+
+ report_flag = 1;
+ printf( "Got %d pixels, instead of expected %d pixels!\n",
+ (int) ECSOBJECT(result).geom.ecs_Geometry_u.matrix.x.x_len,
+ xsize );
+ }
+
+ for( i = 0; i < xsize; i++ )
+ {
+ fprintf( fp_raw, "%c", ECSRASTER(result)[i] );
+ }
+
+ result = cln_GetNextObject(ClientID);
+ }
+
+ CheckError( result );
+
+ fclose( fp_raw );
+}
+
+/************************************************************************/
+/* ImportImage() */
+/************************************************************************/
+
+static void ImportImage( ecs_Region *region, const char * layer,
+ const char * out_file )
+
+{
+ FILE *fp_aux, *fp_raw;
+ char filename[256];
+ int i, xsize, ysize, width_code;
+ ecs_Result *result;
+ ecs_LayerSelection selectionLayer;
+
+/* -------------------------------------------------------------------- */
+/* Select a region ... this should be overridable from the */
+/* command line. */
+/* -------------------------------------------------------------------- */
+ result = cln_SelectRegion(ClientID,region);
+ if( CheckError( result ) )
+ return;
+
+ xsize = (int) ((region->east - region->west) / region->ew_res + 0.5);
+ ysize = (int) ((region->north - region->south) / region->ns_res + 0.5);
+
+/* -------------------------------------------------------------------- */
+/* Define the layer to select. */
+/* -------------------------------------------------------------------- */
+ selectionLayer.Select = (char *) layer;
+ selectionLayer.F = Image;
+
+ result = cln_SelectLayer(ClientID,&selectionLayer);
+
+ if( CheckError( result ) )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Write .aux file header. */
+/* -------------------------------------------------------------------- */
+ sprintf( filename, "%s.aux", out_file );
+ fp_aux = fopen( filename, "wt" );
+
+ sprintf( filename, "%s.raw", out_file );
+
+ fprintf( fp_aux, "AuxilaryTarget: %s\n", filename );
+
+/* -------------------------------------------------------------------- */
+/* Get the raster information. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetRasterInfo( ClientID );
+ if( CheckError( result ) )
+ return;
+
+ width_code = ECSRASTERINFO(result).width;
+ if( width_code == 1 /* RGBA */ ) {
+ fprintf( fp_aux, "RawDefinition: %d %d 4\n", xsize, ysize );
+ fprintf( fp_aux, "ChanDefinition-1: 8U 0 4 %d\n", xsize*4 );
+ fprintf( fp_aux, "ChanDefinition-2: 8U 1 4 %d\n", xsize*4 );
+ fprintf( fp_aux, "ChanDefinition-3: 8U 2 4 %d\n", xsize*4 );
+ fprintf( fp_aux, "ChanDefinition-4: 8U 3 4 %d\n", xsize*4 );
+ } else if( width_code == 5 /* int32 */ ) {
+ fprintf( fp_aux, "RawDefinition: %d %d 1\n", xsize, ysize );
+ fprintf( fp_aux, "ChanDefinition-1: 16U 0 2 %d Swapped\n", xsize*2 );
+ }
+ else {
+ printf( "Unsupported Image raster type %d.\n",
+ ECSRASTERINFO(result).width );
+ assert( FALSE );
+ return;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Attach the projection information. */
+/* -------------------------------------------------------------------- */
+ fprintf( fp_aux, "MapUnits: METER\n" );
+ fprintf( fp_aux, "UpLeftX: %24.15E\n", region->west );
+ fprintf( fp_aux, "UpLeftY: %25.15E\n", region->north );
+ fprintf( fp_aux, "LoRightX: %25.15E\n", region->east );
+ fprintf( fp_aux, "LoRightY: %25.15E\n", region->south );
+
+ fclose( fp_aux );
+
+/* -------------------------------------------------------------------- */
+/* open the raw data file. */
+/* -------------------------------------------------------------------- */
+ fp_raw = fopen( filename, "wb" );
+
+ result = cln_GetNextObject(ClientID);
+ while (ECSSUCCESS(result)) {
+
+ static int report_flag = 0;
+
+ if( (int) ECSOBJECT(result).geom.ecs_Geometry_u.matrix.x.x_len
+ != xsize && report_flag == 0 ) {
+
+ report_flag = 1;
+ printf( "Got %d pixels, instead of expected %d pixels!\n",
+ (int) ECSOBJECT(result).geom.ecs_Geometry_u.matrix.x.x_len,
+ xsize );
+ }
+
+ for( i = 0; i < xsize; i++ ) {
+ if( width_code == 5 )
+ {
+ fprintf( fp_raw, "%c%c",
+ (ECSRASTER(result)[i] & 0xff),
+ (ECSRASTER(result)[i] >> 8) & 0xff );
+ }
+ else if( width_code == 1 )
+ {
+ unsigned char red, green, blue, trans;
+
+ ecs_GetRGBFromPixel( ECSRASTER(result)[i],
+ &trans, &red, &green, &blue );
+ fprintf( fp_raw, "%c%c%c%c",
+ red, green, blue, trans );
+ }
+ }
+
+ result = cln_GetNextObject(ClientID);
+ }
+
+ fclose( fp_raw );
+}
+
+/************************************************************************/
+/* ParseProjection() */
+/************************************************************************/
+
+projPJ ParseProjection( const char *projection )
+
+{
+ char wproj[1024];
+ char *proj_parms[30];
+ int parm_count = 0;
+ projPJ pj;
+
+/* -------------------------------------------------------------------- */
+/* Parse into tokens. */
+/* -------------------------------------------------------------------- */
+ strcpy( wproj, projection );
+ proj_parms[parm_count] = strtok( wproj, " " );
+ while( proj_parms[parm_count] != NULL )
+ proj_parms[++parm_count] = strtok( NULL, " " );
+
+/* -------------------------------------------------------------------- */
+/* Call pj_init() */
+/* -------------------------------------------------------------------- */
+ pj = pj_init( parm_count, proj_parms );
+
+ if( pj == NULL )
+ {
+ printf( "Failed to initialize projection from: %s\n", projection );
+ }
+
+ return pj;
+}
+
+/************************************************************************/
+/* RecomputeRegion() */
+/* */
+/* Translate the source region into the indicate output */
+/* coordinate system. */
+/************************************************************************/
+
+static int RecomputeRegion( const char * output_projection,
+ ecs_Region *region )
+
+{
+ ecs_Result *result;
+ projPJ src;
+ projPJ dst;
+ projUV corners[4];
+ ecs_Region out_region = {0,0,0,0,0,0};
+ int iCorner, src_xsize, src_ysize, max_dim;
+
+/* -------------------------------------------------------------------- */
+/* Fetch source projection. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetServerProjection( ClientID );
+ if( CheckError( result ) )
+ return( FALSE );
+
+ src = ParseProjection( ECSTEXT(result) );
+
+/* -------------------------------------------------------------------- */
+/* Parse destination projection. */
+/* -------------------------------------------------------------------- */
+ dst = ParseProjection( output_projection );
+
+/* -------------------------------------------------------------------- */
+/* Setup input coordinates of corners. */
+/* -------------------------------------------------------------------- */
+ corners[0].u = region->west;
+ corners[0].v = region->north;
+ corners[1].u = region->east;
+ corners[1].v = region->north;
+ corners[2].u = region->east;
+ corners[2].v = region->south;
+ corners[3].u = region->west;
+ corners[3].v = region->south;
+
+/* -------------------------------------------------------------------- */
+/* Reproject, and establish new bounding region. */
+/* -------------------------------------------------------------------- */
+ for( iCorner = 0; iCorner < 4; iCorner++ )
+ {
+ /* Translate source to radians */
+
+ if( src != NULL )
+ {
+ corners[iCorner] = pj_inv( corners[iCorner], src );
+ }
+ else
+ {
+ corners[iCorner].u *= DEG_TO_RAD;
+ corners[iCorner].v *= DEG_TO_RAD;
+ }
+
+ /* Translate into destination projection or back to degrees */
+
+ if( dst != NULL )
+ {
+ corners[iCorner] = pj_fwd( corners[iCorner], dst );
+ }
+ else
+ {
+ corners[iCorner].u *= DEG_TO_RAD;
+ corners[iCorner].v *= DEG_TO_RAD;
+ }
+
+ /* Grow region to hold result */
+
+ if( iCorner == 0 )
+ {
+ out_region.north = out_region.south = corners[iCorner].v;
+ out_region.east = out_region.west = corners[iCorner].u;
+ }
+ else
+ {
+ out_region.north = MAX(out_region.north,corners[iCorner].v);
+ out_region.south = MIN(out_region.south,corners[iCorner].v);
+ out_region.east = MAX(out_region.east,corners[iCorner].u);
+ out_region.west = MIN(out_region.west,corners[iCorner].u);
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Establish output resolution. */
+/* -------------------------------------------------------------------- */
+ src_xsize = (int) ceil((region->east - region->west) / region->ew_res);
+ src_ysize = (int) ceil((region->north - region->south) / region->ns_res);
+
+ max_dim = MAX(src_xsize,src_ysize);
+ if( out_region.north - out_region.south >
+ out_region.east - out_region.west )
+ {
+ out_region.ns_res = (out_region.north - out_region.south) / max_dim;
+ out_region.ew_res = out_region.ns_res;
+ }
+ else
+ {
+ out_region.ew_res = (out_region.east - out_region.west) / max_dim;
+ out_region.ns_res = out_region.ew_res;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Grow region by one pixel to help with weird round off issues. */
+/* -------------------------------------------------------------------- */
+ out_region.north += out_region.ns_res;
+ out_region.south -= out_region.ns_res;
+ out_region.east += out_region.ew_res;
+ out_region.west -= out_region.ew_res;
+
+ *region = out_region;
+
+ printf( "out_region.north = %f\n", out_region.north );
+ printf( "out_region.south = %f\n", out_region.south );
+ printf( "out_region.east = %f\n", out_region.east );
+ printf( "out_region.west = %f\n", out_region.west );
+ printf( "out_region.ns_res = %f\n", out_region.ns_res );
+ printf( "out_region.ew_res = %f\n", out_region.ew_res );
+
+ return TRUE;
+}
+
+/************************************************************************/
+/* main() */
+/************************************************************************/
+
+int main( int argc, char ** argv )
+{
+ ecs_Family featureType = Point;
+ char *layer = "";
+ static ecs_Region reg, *region;
+ ecs_Result *result;
+ int i, set_region = FALSE, set_res = FALSE;
+ char *out_file = "ogdi_out";
+ const char *output_projection = NULL;
+
+ if( argc == 1 )
+ {
+ printf("Usage: ogdi_import [-no-dict] -u url -f family\n");
+ printf(" [-op output_projection]\n" );
+ printf(" [-r north south east west] [-res ns_res ew_res]\n" );
+ printf(" [-o filename]\n" );
+ printf(" -l layername [more_opts -l layername]\n" );
+ exit( 1 );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Handle commandline arguments. */
+/* -------------------------------------------------------------------- */
+ for( i = 1; i < argc; i++ ) {
+
+ if( i == argc - 1 ) {
+ /* skip ... the rest require arguments. */
+ }
+ else if( strcmp(argv[i],"-u") == 0 ) {
+ AccessURL( argv[++i], ® );
+ if( region == NULL )
+ region = ®
+ }
+ else if( strcmp(argv[i], "-no-dict") == 0 ) {
+ bNoDict = TRUE;
+ }
+ else if( strcmp(argv[i],"-o") == 0 ) {
+ out_file = argv[++i];
+ }
+ else if( strcmp(argv[i],"-op") == 0 ) {
+ output_projection = argv[++i];
+ RecomputeRegion( output_projection, region );
+ set_res = TRUE;
+ set_region = TRUE;
+ result = cln_SetClientProjection( ClientID,
+ (char *) output_projection );
+ if( CheckError( result ) )
+ break;
+ }
+ else if( strcmp(argv[i], "-l") == 0 ) {
+ layer = argv[++i];
+
+ if( !set_region )
+ {
+ ecs_Region reg2 = *region;
+
+ GetLayerRegion( layer, ®2 );
+ if( set_res )
+ {
+ reg2.ew_res = region->ew_res;
+ reg2.ns_res = region->ns_res;
+ }
+ *region = reg2;
+ }
+
+ if( featureType == Matrix ) {
+ ImportMatrix( region, layer, out_file );
+ }
+ else if( featureType == Image ) {
+ ImportImage( region, layer, out_file );
+ }
+ else {
+ ImportVectors( region, layer, out_file, featureType );
+ }
+ }
+ else if( strcmp(argv[i], "-f") == 0 ) {
+ if( strcmp(argv[i+1],"Point") == 0 )
+ featureType = Point;
+ else if( strcmp(argv[i+1],"Line") == 0 )
+ featureType = Line;
+ else if( strcmp(argv[i+1],"Area") == 0 )
+ featureType = Area;
+ else if( strcmp(argv[i+1],"Text") == 0 )
+ featureType = Text;
+ else if( strcmp(argv[i+1],"Matrix") == 0 )
+ featureType = Matrix;
+ else if( strcmp(argv[i+1],"Image") == 0 )
+ featureType = Image;
+ i++;
+ }
+ else if( strcmp(argv[i], "-r") == 0 && i < argc - 4 ) {
+
+ region = ®
+ reg.north = atof(argv[++i]);
+ reg.south = atof(argv[++i]);
+ reg.east = atof(argv[++i]);
+ reg.west = atof(argv[++i]);
+
+ set_region = TRUE;
+ }
+ else if( strcmp(argv[i], "-res") == 0 && i < argc - 2 ) {
+
+ reg = *region;
+ region = ®
+
+ reg.ns_res = atof(argv[++i]);
+ reg.ew_res = atof(argv[++i]);
+
+ set_res = TRUE;
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Close old client if there is one active. */
+/* -------------------------------------------------------------------- */
+ if( ClientID != -1 ) {
+ result = cln_DestroyClient(ClientID);
+ if( CheckError( result ) )
+ return( FALSE );
+ ClientID = -1;
+ }
+
+ return 0;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/shapefil.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/shapefil.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/shapefil.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,357 @@
+#ifndef _SHAPEFILE_H_INCLUDED
+#define _SHAPEFILE_H_INCLUDED
+
+/******************************************************************************
+ * shapefil.h,v 1.1 2000/11/23 19:14:32 warmerda Exp
+ *
+ * Project: Shapelib
+ * Purpose: Primary include file for Shapelib.
+ * Author: Frank Warmerdam, warmerda at home.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * This software is available under the following "MIT Style" license,
+ * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
+ * option is discussed in more detail in shapelib.html.
+ *
+ * --
+ *
+ * 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.
+ ******************************************************************************
+ *
+ * shapefil.h,v
+ * Revision 1.1 2000/11/23 19:14:32 warmerda
+ * New
+ *
+ * Revision 1.16 2000/09/25 14:15:59 warmerda
+ * added DBFGetNativeFieldType()
+ *
+ * Revision 1.15 2000/02/16 16:03:51 warmerda
+ * added null shape support
+ *
+ * Revision 1.14 1999/11/05 14:12:05 warmerda
+ * updated license terms
+ *
+ * Revision 1.13 1999/06/02 18:24:21 warmerda
+ * added trimming code
+ *
+ * Revision 1.12 1999/06/02 17:56:12 warmerda
+ * added quad'' subnode support for trees
+ *
+ * Revision 1.11 1999/05/18 19:11:11 warmerda
+ * Added example searching capability
+ *
+ * Revision 1.10 1999/05/18 17:49:38 warmerda
+ * added initial quadtree support
+ *
+ * Revision 1.9 1999/05/11 03:19:28 warmerda
+ * added new Tuple api, and improved extension handling - add from candrsn
+ *
+ * Revision 1.8 1999/03/23 17:22:27 warmerda
+ * Added extern "C" protection for C++ users of shapefil.h.
+ *
+ * Revision 1.7 1998/12/31 15:31:07 warmerda
+ * Added the TRIM_DBF_WHITESPACE and DISABLE_MULTIPATCH_MEASURE options.
+ *
+ * Revision 1.6 1998/12/03 15:48:15 warmerda
+ * Added SHPCalculateExtents().
+ *
+ * Revision 1.5 1998/11/09 20:57:16 warmerda
+ * Altered SHPGetInfo() call.
+ *
+ * Revision 1.4 1998/11/09 20:19:33 warmerda
+ * Added 3D support, and use of SHPObject.
+ *
+ * Revision 1.3 1995/08/23 02:24:05 warmerda
+ * Added support for reading bounds.
+ *
+ * Revision 1.2 1995/08/04 03:17:39 warmerda
+ * Added header.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <ogdi_macro.h>
+
+#ifdef USE_DBMALLOC
+#include <dbmalloc.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************************************************************************/
+/* Configuration options. */
+/************************************************************************/
+
+/* -------------------------------------------------------------------- */
+/* Should the DBFReadStringAttribute() strip leading and */
+/* trailing white space? */
+/* -------------------------------------------------------------------- */
+#define TRIM_DBF_WHITESPACE
+
+/* -------------------------------------------------------------------- */
+/* Should we write measure values to the Multipatch object? */
+/* Reportedly ArcView crashes if we do write it, so for now it */
+/* is disabled. */
+/* -------------------------------------------------------------------- */
+#define DISABLE_MULTIPATCH_MEASURE
+
+/************************************************************************/
+/* SHP Support. */
+/************************************************************************/
+typedef struct
+{
+ FILE *fpSHP;
+ FILE *fpSHX;
+
+ int nShapeType; /* SHPT_* */
+
+ int nFileSize; /* SHP file */
+
+ int nRecords;
+ int nMaxRecords;
+ int *panRecOffset;
+ int *panRecSize;
+
+ double adBoundsMin[4];
+ double adBoundsMax[4];
+
+ int bUpdated;
+} SHPInfo;
+
+typedef SHPInfo * SHPHandle;
+
+/* -------------------------------------------------------------------- */
+/* Shape types (nSHPType) */
+/* -------------------------------------------------------------------- */
+#define SHPT_NULL 0
+#define SHPT_POINT 1
+#define SHPT_ARC 3
+#define SHPT_POLYGON 5
+#define SHPT_MULTIPOINT 8
+#define SHPT_POINTZ 11
+#define SHPT_ARCZ 13
+#define SHPT_POLYGONZ 15
+#define SHPT_MULTIPOINTZ 18
+#define SHPT_POINTM 21
+#define SHPT_ARCM 23
+#define SHPT_POLYGONM 25
+#define SHPT_MULTIPOINTM 28
+#define SHPT_MULTIPATCH 31
+
+
+/* -------------------------------------------------------------------- */
+/* Part types - everything but SHPT_MULTIPATCH just uses */
+/* SHPP_RING. */
+/* -------------------------------------------------------------------- */
+
+#define SHPP_TRISTRIP 0
+#define SHPP_TRIFAN 1
+#define SHPP_OUTERRING 2
+#define SHPP_INNERRING 3
+#define SHPP_FIRSTRING 4
+#define SHPP_RING 5
+
+/* -------------------------------------------------------------------- */
+/* SHPObject - represents on shape (without attributes) read */
+/* from the .shp file. */
+/* -------------------------------------------------------------------- */
+typedef struct
+{
+ int nSHPType;
+
+ int nShapeId; /* -1 is unknown/unassigned */
+
+ int nParts;
+ int *panPartStart;
+ int *panPartType;
+
+ int nVertices;
+ double *padfX;
+ double *padfY;
+ double *padfZ;
+ double *padfM;
+
+ double dfXMin;
+ double dfYMin;
+ double dfZMin;
+ double dfMMin;
+
+ double dfXMax;
+ double dfYMax;
+ double dfZMax;
+ double dfMMax;
+} SHPObject;
+
+/* -------------------------------------------------------------------- */
+/* SHP API Prototypes */
+/* -------------------------------------------------------------------- */
+SHPHandle SHPOpen( const char * pszShapeFile, const char * pszAccess );
+SHPHandle SHPCreate( const char * pszShapeFile, int nShapeType );
+void SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType,
+ double * padfMinBound, double * padfMaxBound );
+
+SHPObject *SHPReadObject( SHPHandle hSHP, int iShape );
+int SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject );
+
+void SHPDestroyObject( SHPObject * psObject );
+void SHPComputeExtents( SHPObject * psObject );
+SHPObject *SHPCreateObject( int nSHPType, int nShapeId,
+ int nParts, int * panPartStart, int * panPartType,
+ int nVertices, double * padfX, double * padfY,
+ double * padfZ, double * padfM );
+SHPObject *SHPCreateSimpleObject( int nSHPType, int nVertices,
+ double * padfX, double * padfY, double * padfZ );
+
+void SHPClose( SHPHandle hSHP );
+
+const char *SHPTypeName( int nSHPType );
+const char *SHPPartTypeName( int nPartType );
+
+/* -------------------------------------------------------------------- */
+/* Shape quadtree indexing API. */
+/* -------------------------------------------------------------------- */
+
+/* this can be two or four for binary or quad tree */
+#define MAX_SUBNODE 4
+
+typedef struct shape_tree_node
+{
+ /* region covered by this node */
+ double adfBoundsMin[4];
+ double adfBoundsMax[4];
+
+ /* list of shapes stored at this node. The papsShapeObj pointers
+ or the whole list can be NULL */
+ int nShapeCount;
+ int *panShapeIds;
+ SHPObject **papsShapeObj;
+
+ int nSubNodes;
+ struct shape_tree_node *apsSubNode[MAX_SUBNODE];
+
+} SHPTreeNode;
+
+typedef struct
+{
+ SHPHandle hSHP;
+
+ int nMaxDepth;
+ int nDimension;
+
+ SHPTreeNode *psRoot;
+} SHPTree;
+
+SHPTree *SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth,
+ double *padfBoundsMin, double *padfBoundsMax );
+void SHPDestroyTree( SHPTree * hTree );
+
+int SHPWriteTree( SHPTree *hTree, const char * pszFilename );
+SHPTree SHPReadTree( const char * pszFilename );
+
+int SHPTreeAddObject( SHPTree * hTree, SHPObject * psObject );
+int SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject );
+int SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId );
+
+void SHPTreeTrimExtraNodes( SHPTree * hTree );
+
+int *SHPTreeFindLikelyShapes( SHPTree * hTree,
+ double * padfBoundsMin,
+ double * padfBoundsMax,
+ int * );
+int SHPCheckBoundsOverlap( double *, double *, double *, double *, int );
+
+/************************************************************************/
+/* DBF Support. */
+/************************************************************************/
+typedef struct
+{
+ FILE *fp;
+
+ int nRecords;
+
+ int nRecordLength;
+ int nHeaderLength;
+ int nFields;
+ int *panFieldOffset;
+ int *panFieldSize;
+ int *panFieldDecimals;
+ char *pachFieldType;
+
+ char *pszHeader;
+
+ int nCurrentRecord;
+ int bCurrentRecordModified;
+ char *pszCurrentRecord;
+
+ int bNoHeader;
+ int bUpdated;
+} DBFInfo;
+
+typedef DBFInfo * DBFHandle;
+
+typedef enum {
+ FTString,
+ FTInteger,
+ FTDouble,
+ FTInvalid
+} DBFFieldType;
+
+#define XBASE_FLDHDR_SZ 32
+
+DBFHandle DBFOpen( const char * pszDBFFile, const char * pszAccess );
+DBFHandle DBFCreate( const char * pszDBFFile );
+
+int DBFGetFieldCount( DBFHandle psDBF );
+int DBFGetRecordCount( DBFHandle psDBF );
+int DBFAddField( DBFHandle hDBF, const char * pszFieldName,
+ DBFFieldType eType, int nWidth, int nDecimals );
+
+DBFFieldType DBFGetFieldInfo( DBFHandle psDBF, int iField,
+ char * pszFieldName,
+ int * pnWidth, int * pnDecimals );
+
+int DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
+double DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
+const char *DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
+
+int DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField,
+ int nFieldValue );
+int DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField,
+ double dFieldValue );
+int DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField,
+ const char * pszFieldValue );
+
+const char *DBFReadTuple(DBFHandle psDBF, int hEntity );
+int DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple );
+
+DBFHandle DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename );
+
+void DBFClose( DBFHandle hDBF );
+char DBFGetNativeFieldType( DBFHandle hDBF, int iField );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ndef _SHAPEFILE_H_INCLUDED */
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/shpopen.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/shpopen.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_import/shpopen.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1634 @@
+/******************************************************************************
+ * shpopen.c,v 1.1 2000/11/23 19:13:49 warmerda Exp
+ *
+ * Project: Shapelib
+ * Purpose: Implementation of core Shapefile read/write functions.
+ * Author: Frank Warmerdam, warmerda at home.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * This software is available under the following "MIT Style" license,
+ * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
+ * option is discussed in more detail in shapelib.html.
+ *
+ * --
+ *
+ * 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.
+ ******************************************************************************
+ *
+ * shpopen.c,v
+ * Revision 1.1 2000/11/23 19:13:49 warmerda
+ * new
+ *
+ * Revision 1.27 2000/07/18 15:21:33 warmerda
+ * added better enforcement of -1 for append in SHPWriteObject
+ *
+ * Revision 1.26 2000/02/16 16:03:51 warmerda
+ * added null shape support
+ *
+ * Revision 1.25 1999/12/15 13:47:07 warmerda
+ * Fixed record size settings in .shp file (was 4 words too long)
+ * Added stdlib.h.
+ *
+ * Revision 1.24 1999/11/05 14:12:04 warmerda
+ * updated license terms
+ *
+ * Revision 1.23 1999/07/27 00:53:46 warmerda
+ * added support for rewriting shapes
+ *
+ * Revision 1.22 1999/06/11 19:19:11 warmerda
+ * Cleanup pabyRec static buffer on SHPClose().
+ *
+ * Revision 1.21 1999/06/02 14:57:56 kshih
+ * Remove unused variables
+ *
+ * Revision 1.20 1999/04/19 21:04:17 warmerda
+ * Fixed syntax error.
+ *
+ * Revision 1.19 1999/04/19 21:01:57 warmerda
+ * Force access string to binary in SHPOpen().
+ *
+ * Revision 1.18 1999/04/01 18:48:07 warmerda
+ * Try upper case extensions if lower case doesn't work.
+ *
+ * Revision 1.17 1998/12/31 15:29:39 warmerda
+ * Disable writing measure values to multipatch objects if
+ * DISABLE_MULTIPATCH_MEASURE is defined.
+ *
+ * Revision 1.16 1998/12/16 05:14:33 warmerda
+ * Added support to write MULTIPATCH. Fixed reading Z coordinate of
+ * MULTIPATCH. Fixed record size written for all feature types.
+ *
+ * Revision 1.15 1998/12/03 16:35:29 warmerda
+ * r+b is proper binary access string, not rb+.
+ *
+ * Revision 1.14 1998/12/03 15:47:56 warmerda
+ * Fixed setting of nVertices in SHPCreateObject().
+ *
+ * Revision 1.13 1998/12/03 15:33:54 warmerda
+ * Made SHPCalculateExtents() separately callable.
+ *
+ * Revision 1.12 1998/11/11 20:01:50 warmerda
+ * Fixed bug writing ArcM/Z, and PolygonM/Z for big endian machines.
+ *
+ * Revision 1.11 1998/11/09 20:56:44 warmerda
+ * Fixed up handling of file wide bounds.
+ *
+ * Revision 1.10 1998/11/09 20:18:51 warmerda
+ * Converted to support 3D shapefiles, and use of SHPObject.
+ *
+ * Revision 1.9 1998/02/24 15:09:05 warmerda
+ * Fixed memory leak.
+ *
+ * Revision 1.8 1997/12/04 15:40:29 warmerda
+ * Fixed byte swapping of record number, and record length fields in the
+ * .shp file.
+ *
+ * Revision 1.7 1995/10/21 03:15:58 warmerda
+ * Added support for binary file access, the magic cookie 9997
+ * and tried to improve the int32 selection logic for 16bit systems.
+ *
+ * Revision 1.6 1995/09/04 04:19:41 warmerda
+ * Added fix for file bounds.
+ *
+ * Revision 1.5 1995/08/25 15:16:44 warmerda
+ * Fixed a couple of problems with big endian systems ... one with bounds
+ * and the other with multipart polygons.
+ *
+ * Revision 1.4 1995/08/24 18:10:17 warmerda
+ * Switch to use SfRealloc() to avoid problems with pre-ANSI realloc()
+ * functions (such as on the Sun).
+ *
+ * Revision 1.3 1995/08/23 02:23:15 warmerda
+ * Added support for reading bounds, and fixed up problems in setting the
+ * file wide bounds.
+ *
+ * Revision 1.2 1995/08/04 03:16:57 warmerda
+ * Added header.
+ *
+ */
+
+#include "shapefil.h"
+
+#include <math.h>
+#include <limits.h>
+#include <assert.h>
+#include <stdlib.h>
+
+typedef unsigned char uchar;
+
+#if UINT_MAX == 65535
+typedef long int32;
+#else
+typedef int int32;
+#endif
+
+#ifndef FALSE
+# define FALSE 0
+# define TRUE 1
+#endif
+
+#define ByteCopy( a, b, c ) memcpy( b, a, c )
+#ifndef MAX
+# define MIN(a,b) ((a<b) ? a : b)
+# define MAX(a,b) ((a>b) ? a : b)
+#endif
+
+static int bBigEndian;
+static uchar *pabyRec = NULL;
+static int nBufSize = 0;
+
+
+/************************************************************************/
+/* SwapWord() */
+/* */
+/* Swap a 2, 4 or 8 byte word. */
+/************************************************************************/
+
+static void SwapWord( int length, void * wordP )
+
+{
+ int i;
+ uchar temp;
+
+ for( i=0; i < length/2; i++ )
+ {
+ temp = ((uchar *) wordP)[i];
+ ((uchar *)wordP)[i] = ((uchar *) wordP)[length-i-1];
+ ((uchar *) wordP)[length-i-1] = temp;
+ }
+}
+
+/************************************************************************/
+/* SfRealloc() */
+/* */
+/* A realloc cover function that will access a NULL pointer as */
+/* a valid input. */
+/************************************************************************/
+
+static void * SfRealloc( void * pMem, int nNewSize )
+
+{
+ if( pMem == NULL )
+ return( (void *) malloc(nNewSize) );
+ else
+ return( (void *) realloc(pMem,nNewSize) );
+}
+
+/************************************************************************/
+/* SHPWriteHeader() */
+/* */
+/* Write out a header for the .shp and .shx files as well as the */
+/* contents of the index (.shx) file. */
+/************************************************************************/
+
+static void SHPWriteHeader( SHPHandle psSHP )
+
+{
+ uchar abyHeader[100];
+ int i;
+ int32 i32;
+ double dValue;
+ int32 *panSHX;
+
+/* -------------------------------------------------------------------- */
+/* Prepare header block for .shp file. */
+/* -------------------------------------------------------------------- */
+ for( i = 0; i < 100; i++ )
+ abyHeader[i] = 0;
+
+ abyHeader[2] = 0x27; /* magic cookie */
+ abyHeader[3] = 0x0a;
+
+ i32 = psSHP->nFileSize/2; /* file size */
+ ByteCopy( &i32, abyHeader+24, 4 );
+ if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
+
+ i32 = 1000; /* version */
+ ByteCopy( &i32, abyHeader+28, 4 );
+ if( bBigEndian ) SwapWord( 4, abyHeader+28 );
+
+ i32 = psSHP->nShapeType; /* shape type */
+ ByteCopy( &i32, abyHeader+32, 4 );
+ if( bBigEndian ) SwapWord( 4, abyHeader+32 );
+
+ dValue = psSHP->adBoundsMin[0]; /* set bounds */
+ ByteCopy( &dValue, abyHeader+36, 8 );
+ if( bBigEndian ) SwapWord( 8, abyHeader+36 );
+
+ dValue = psSHP->adBoundsMin[1];
+ ByteCopy( &dValue, abyHeader+44, 8 );
+ if( bBigEndian ) SwapWord( 8, abyHeader+44 );
+
+ dValue = psSHP->adBoundsMax[0];
+ ByteCopy( &dValue, abyHeader+52, 8 );
+ if( bBigEndian ) SwapWord( 8, abyHeader+52 );
+
+ dValue = psSHP->adBoundsMax[1];
+ ByteCopy( &dValue, abyHeader+60, 8 );
+ if( bBigEndian ) SwapWord( 8, abyHeader+60 );
+
+ dValue = psSHP->adBoundsMin[2]; /* z */
+ ByteCopy( &dValue, abyHeader+68, 8 );
+ if( bBigEndian ) SwapWord( 8, abyHeader+68 );
+
+ dValue = psSHP->adBoundsMax[2];
+ ByteCopy( &dValue, abyHeader+76, 8 );
+ if( bBigEndian ) SwapWord( 8, abyHeader+76 );
+
+ dValue = psSHP->adBoundsMin[3]; /* m */
+ ByteCopy( &dValue, abyHeader+84, 8 );
+ if( bBigEndian ) SwapWord( 8, abyHeader+84 );
+
+ dValue = psSHP->adBoundsMax[3];
+ ByteCopy( &dValue, abyHeader+92, 8 );
+ if( bBigEndian ) SwapWord( 8, abyHeader+92 );
+
+/* -------------------------------------------------------------------- */
+/* Write .shp file header. */
+/* -------------------------------------------------------------------- */
+ fseek( psSHP->fpSHP, 0, 0 );
+ ogdi_fwrite( abyHeader, 100, 1, psSHP->fpSHP );
+
+/* -------------------------------------------------------------------- */
+/* Prepare, and write .shx file header. */
+/* -------------------------------------------------------------------- */
+ i32 = (psSHP->nRecords * 2 * sizeof(int32) + 100)/2; /* file size */
+ ByteCopy( &i32, abyHeader+24, 4 );
+ if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
+
+ fseek( psSHP->fpSHX, 0, 0 );
+ ogdi_fwrite( abyHeader, 100, 1, psSHP->fpSHX );
+
+/* -------------------------------------------------------------------- */
+/* Write out the .shx contents. */
+/* -------------------------------------------------------------------- */
+ panSHX = (int32 *) malloc(sizeof(int32) * 2 * psSHP->nRecords);
+
+ for( i = 0; i < psSHP->nRecords; i++ )
+ {
+ panSHX[i*2 ] = psSHP->panRecOffset[i]/2;
+ panSHX[i*2+1] = psSHP->panRecSize[i]/2;
+ if( !bBigEndian ) SwapWord( 4, panSHX+i*2 );
+ if( !bBigEndian ) SwapWord( 4, panSHX+i*2+1 );
+ }
+
+ ogdi_fwrite( panSHX, sizeof(int32) * 2, psSHP->nRecords, psSHP->fpSHX );
+
+ free( panSHX );
+}
+
+/************************************************************************/
+/* SHPOpen() */
+/* */
+/* Open the .shp and .shx files based on the basename of the */
+/* files or either file name. */
+/************************************************************************/
+
+SHPHandle SHPOpen( const char * pszLayer, const char * pszAccess )
+
+{
+ char *pszFullname, *pszBasename;
+ SHPHandle psSHP;
+
+ uchar *pabyBuf;
+ int i;
+ double dValue;
+
+/* -------------------------------------------------------------------- */
+/* Ensure the access string is one of the legal ones. We */
+/* ensure the result string indicates binary to avoid common */
+/* problems on Windows. */
+/* -------------------------------------------------------------------- */
+ if( strcmp(pszAccess,"rb+") == 0 || strcmp(pszAccess,"r+b") == 0
+ || strcmp(pszAccess,"r+") == 0 )
+ pszAccess = "r+b";
+ else
+ pszAccess = "rb";
+
+/* -------------------------------------------------------------------- */
+/* Establish the byte order on this machine. */
+/* -------------------------------------------------------------------- */
+ i = 1;
+ if( *((uchar *) &i) == 1 )
+ bBigEndian = FALSE;
+ else
+ bBigEndian = TRUE;
+
+/* -------------------------------------------------------------------- */
+/* Initialize the info structure. */
+/* -------------------------------------------------------------------- */
+ psSHP = (SHPHandle) malloc(sizeof(SHPInfo));
+
+ psSHP->bUpdated = FALSE;
+
+/* -------------------------------------------------------------------- */
+/* Compute the base (layer) name. If there is any extension */
+/* on the passed in filename we will strip it off. */
+/* -------------------------------------------------------------------- */
+ pszBasename = (char *) malloc(strlen(pszLayer)+5);
+ strcpy( pszBasename, pszLayer );
+ for( i = strlen(pszBasename)-1;
+ i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
+ && pszBasename[i] != '\\';
+ i-- ) {}
+
+ if( pszBasename[i] == '.' )
+ pszBasename[i] = '\0';
+
+/* -------------------------------------------------------------------- */
+/* Open the .shp and .shx files. Note that files pulled from */
+/* a PC to Unix with upper case filenames won't work! */
+/* -------------------------------------------------------------------- */
+ pszFullname = (char *) malloc(strlen(pszBasename) + 5);
+ sprintf( pszFullname, "%s.shp", pszBasename );
+ psSHP->fpSHP = fopen(pszFullname, pszAccess );
+ if( psSHP->fpSHP == NULL )
+ {
+ sprintf( pszFullname, "%s.SHP", pszBasename );
+ psSHP->fpSHP = fopen(pszFullname, pszAccess );
+ }
+
+ if( psSHP->fpSHP == NULL )
+ return( NULL );
+
+ sprintf( pszFullname, "%s.shx", pszBasename );
+ psSHP->fpSHX = fopen(pszFullname, pszAccess );
+ if( psSHP->fpSHX == NULL )
+ {
+ sprintf( pszFullname, "%s.SHX", pszBasename );
+ psSHP->fpSHX = fopen(pszFullname, pszAccess );
+ }
+
+ if( psSHP->fpSHX == NULL )
+ return( NULL );
+
+ free( pszFullname );
+ free( pszBasename );
+
+/* -------------------------------------------------------------------- */
+/* Read the file size from the SHP file. */
+/* -------------------------------------------------------------------- */
+ pabyBuf = (uchar *) malloc(100);
+ ogdi_fread( pabyBuf, 100, 1, psSHP->fpSHP );
+
+ psSHP->nFileSize = (pabyBuf[24] * 256 * 256 * 256
+ + pabyBuf[25] * 256 * 256
+ + pabyBuf[26] * 256
+ + pabyBuf[27]) * 2;
+
+/* -------------------------------------------------------------------- */
+/* Read SHX file Header info */
+/* -------------------------------------------------------------------- */
+ ogdi_fread( pabyBuf, 100, 1, psSHP->fpSHX );
+
+ if( pabyBuf[0] != 0
+ || pabyBuf[1] != 0
+ || pabyBuf[2] != 0x27
+ || (pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d) )
+ {
+ fclose( psSHP->fpSHP );
+ fclose( psSHP->fpSHX );
+ free( psSHP );
+
+ return( NULL );
+ }
+
+ psSHP->nRecords = pabyBuf[27] + pabyBuf[26] * 256
+ + pabyBuf[25] * 256 * 256 + pabyBuf[24] * 256 * 256 * 256;
+ psSHP->nRecords = (psSHP->nRecords*2 - 100) / 8;
+
+ psSHP->nShapeType = pabyBuf[32];
+
+/* -------------------------------------------------------------------- */
+/* Read the bounds. */
+/* -------------------------------------------------------------------- */
+ if( bBigEndian ) SwapWord( 8, pabyBuf+36 );
+ memcpy( &dValue, pabyBuf+36, 8 );
+ psSHP->adBoundsMin[0] = dValue;
+
+ if( bBigEndian ) SwapWord( 8, pabyBuf+44 );
+ memcpy( &dValue, pabyBuf+44, 8 );
+ psSHP->adBoundsMin[1] = dValue;
+
+ if( bBigEndian ) SwapWord( 8, pabyBuf+52 );
+ memcpy( &dValue, pabyBuf+52, 8 );
+ psSHP->adBoundsMax[0] = dValue;
+
+ if( bBigEndian ) SwapWord( 8, pabyBuf+60 );
+ memcpy( &dValue, pabyBuf+60, 8 );
+ psSHP->adBoundsMax[1] = dValue;
+
+ if( bBigEndian ) SwapWord( 8, pabyBuf+68 ); /* z */
+ memcpy( &dValue, pabyBuf+68, 8 );
+ psSHP->adBoundsMin[2] = dValue;
+
+ if( bBigEndian ) SwapWord( 8, pabyBuf+76 );
+ memcpy( &dValue, pabyBuf+76, 8 );
+ psSHP->adBoundsMax[2] = dValue;
+
+ if( bBigEndian ) SwapWord( 8, pabyBuf+84 ); /* z */
+ memcpy( &dValue, pabyBuf+84, 8 );
+ psSHP->adBoundsMin[3] = dValue;
+
+ if( bBigEndian ) SwapWord( 8, pabyBuf+92 );
+ memcpy( &dValue, pabyBuf+92, 8 );
+ psSHP->adBoundsMax[3] = dValue;
+
+ free( pabyBuf );
+
+/* -------------------------------------------------------------------- */
+/* Read the .shx file to get the offsets to each record in */
+/* the .shp file. */
+/* -------------------------------------------------------------------- */
+ psSHP->nMaxRecords = psSHP->nRecords;
+
+ psSHP->panRecOffset =
+ (int *) malloc(sizeof(int) * MAX(1,psSHP->nMaxRecords) );
+ psSHP->panRecSize =
+ (int *) malloc(sizeof(int) * MAX(1,psSHP->nMaxRecords) );
+
+ pabyBuf = (uchar *) malloc(8 * MAX(1,psSHP->nRecords) );
+ ogdi_fread( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX );
+
+ for( i = 0; i < psSHP->nRecords; i++ )
+ {
+ int32 nOffset, nLength;
+
+ memcpy( &nOffset, pabyBuf + i * 8, 4 );
+ if( !bBigEndian ) SwapWord( 4, &nOffset );
+
+ memcpy( &nLength, pabyBuf + i * 8 + 4, 4 );
+ if( !bBigEndian ) SwapWord( 4, &nLength );
+
+ psSHP->panRecOffset[i] = nOffset*2;
+ psSHP->panRecSize[i] = nLength*2;
+ }
+ free( pabyBuf );
+
+ return( psSHP );
+}
+
+/************************************************************************/
+/* SHPClose() */
+/* */
+/* Close the .shp and .shx files. */
+/************************************************************************/
+
+void SHPClose(SHPHandle psSHP )
+
+{
+/* -------------------------------------------------------------------- */
+/* Update the header if we have modified anything. */
+/* -------------------------------------------------------------------- */
+ if( psSHP->bUpdated )
+ {
+ SHPWriteHeader( psSHP );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Free all resources, and close files. */
+/* -------------------------------------------------------------------- */
+ free( psSHP->panRecOffset );
+ free( psSHP->panRecSize );
+
+ fclose( psSHP->fpSHX );
+ fclose( psSHP->fpSHP );
+
+ free( psSHP );
+
+ if( pabyRec != NULL )
+ {
+ free( pabyRec );
+ pabyRec = NULL;
+ nBufSize = 0;
+ }
+}
+
+/************************************************************************/
+/* SHPGetInfo() */
+/* */
+/* Fetch general information about the shape file. */
+/************************************************************************/
+
+void SHPGetInfo(SHPHandle psSHP, int * pnEntities, int * pnShapeType,
+ double * padfMinBound, double * padfMaxBound )
+
+{
+ int i;
+
+ if( pnEntities != NULL )
+ *pnEntities = psSHP->nRecords;
+
+ if( pnShapeType != NULL )
+ *pnShapeType = psSHP->nShapeType;
+
+ for( i = 0; i < 4; i++ )
+ {
+ if( padfMinBound != NULL )
+ padfMinBound[i] = psSHP->adBoundsMin[i];
+ if( padfMaxBound != NULL )
+ padfMaxBound[i] = psSHP->adBoundsMax[i];
+ }
+}
+
+/************************************************************************/
+/* SHPCreate() */
+/* */
+/* Create a new shape file and return a handle to the open */
+/* shape file with read/write access. */
+/************************************************************************/
+
+SHPHandle SHPCreate( const char * pszLayer, int nShapeType )
+
+{
+ char *pszBasename, *pszFullname;
+ int i;
+ FILE *fpSHP, *fpSHX;
+ uchar abyHeader[100];
+ int32 i32;
+ double dValue;
+
+/* -------------------------------------------------------------------- */
+/* Establish the byte order on this system. */
+/* -------------------------------------------------------------------- */
+ i = 1;
+ if( *((uchar *) &i) == 1 )
+ bBigEndian = FALSE;
+ else
+ bBigEndian = TRUE;
+
+/* -------------------------------------------------------------------- */
+/* Compute the base (layer) name. If there is any extension */
+/* on the passed in filename we will strip it off. */
+/* -------------------------------------------------------------------- */
+ pszBasename = (char *) malloc(strlen(pszLayer)+5);
+ strcpy( pszBasename, pszLayer );
+ for( i = strlen(pszBasename)-1;
+ i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
+ && pszBasename[i] != '\\';
+ i-- ) {}
+
+ if( pszBasename[i] == '.' )
+ pszBasename[i] = '\0';
+
+/* -------------------------------------------------------------------- */
+/* Open the two files so we can write their headers. */
+/* -------------------------------------------------------------------- */
+ pszFullname = (char *) malloc(strlen(pszBasename) + 5);
+ sprintf( pszFullname, "%s.shp", pszBasename );
+ fpSHP = fopen(pszFullname, "wb" );
+ if( fpSHP == NULL )
+ return( NULL );
+
+ sprintf( pszFullname, "%s.shx", pszBasename );
+ fpSHX = fopen(pszFullname, "wb" );
+ if( fpSHX == NULL )
+ return( NULL );
+
+ free( pszFullname );
+ free( pszBasename );
+
+/* -------------------------------------------------------------------- */
+/* Prepare header block for .shp file. */
+/* -------------------------------------------------------------------- */
+ for( i = 0; i < 100; i++ )
+ abyHeader[i] = 0;
+
+ abyHeader[2] = 0x27; /* magic cookie */
+ abyHeader[3] = 0x0a;
+
+ i32 = 50; /* file size */
+ ByteCopy( &i32, abyHeader+24, 4 );
+ if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
+
+ i32 = 1000; /* version */
+ ByteCopy( &i32, abyHeader+28, 4 );
+ if( bBigEndian ) SwapWord( 4, abyHeader+28 );
+
+ i32 = nShapeType; /* shape type */
+ ByteCopy( &i32, abyHeader+32, 4 );
+ if( bBigEndian ) SwapWord( 4, abyHeader+32 );
+
+ dValue = 0.0; /* set bounds */
+ ByteCopy( &dValue, abyHeader+36, 8 );
+ ByteCopy( &dValue, abyHeader+44, 8 );
+ ByteCopy( &dValue, abyHeader+52, 8 );
+ ByteCopy( &dValue, abyHeader+60, 8 );
+
+/* -------------------------------------------------------------------- */
+/* Write .shp file header. */
+/* -------------------------------------------------------------------- */
+ ogdi_fwrite( abyHeader, 100, 1, fpSHP );
+
+/* -------------------------------------------------------------------- */
+/* Prepare, and write .shx file header. */
+/* -------------------------------------------------------------------- */
+ i32 = 50; /* file size */
+ ByteCopy( &i32, abyHeader+24, 4 );
+ if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
+
+ ogdi_fwrite( abyHeader, 100, 1, fpSHX );
+
+/* -------------------------------------------------------------------- */
+/* Close the files, and then open them as regular existing files. */
+/* -------------------------------------------------------------------- */
+ fclose( fpSHP );
+ fclose( fpSHX );
+
+ return( SHPOpen( pszLayer, "r+b" ) );
+}
+
+/************************************************************************/
+/* _SHPSetBounds() */
+/* */
+/* Compute a bounds rectangle for a shape, and set it into the */
+/* indicated location in the record. */
+/************************************************************************/
+
+static void _SHPSetBounds( uchar * pabyRec, SHPObject * psShape )
+
+{
+ ByteCopy( &(psShape->dfXMin), pabyRec + 0, 8 );
+ ByteCopy( &(psShape->dfYMin), pabyRec + 8, 8 );
+ ByteCopy( &(psShape->dfXMax), pabyRec + 16, 8 );
+ ByteCopy( &(psShape->dfYMax), pabyRec + 24, 8 );
+
+ if( bBigEndian )
+ {
+ SwapWord( 8, pabyRec + 0 );
+ SwapWord( 8, pabyRec + 8 );
+ SwapWord( 8, pabyRec + 16 );
+ SwapWord( 8, pabyRec + 24 );
+ }
+}
+
+/************************************************************************/
+/* SHPComputeExtents() */
+/* */
+/* Recompute the extents of a shape. Automatically done by */
+/* SHPCreateObject(). */
+/************************************************************************/
+
+void SHPComputeExtents( SHPObject * psObject )
+
+{
+ int i;
+
+/* -------------------------------------------------------------------- */
+/* Build extents for this object. */
+/* -------------------------------------------------------------------- */
+ if( psObject->nVertices > 0 )
+ {
+ psObject->dfXMin = psObject->dfXMax = psObject->padfX[0];
+ psObject->dfYMin = psObject->dfYMax = psObject->padfY[0];
+ psObject->dfZMin = psObject->dfZMax = psObject->padfZ[0];
+ psObject->dfMMin = psObject->dfMMax = psObject->padfM[0];
+ }
+
+ for( i = 0; i < psObject->nVertices; i++ )
+ {
+ psObject->dfXMin = MIN(psObject->dfXMin, psObject->padfX[i]);
+ psObject->dfYMin = MIN(psObject->dfYMin, psObject->padfY[i]);
+ psObject->dfZMin = MIN(psObject->dfZMin, psObject->padfZ[i]);
+ psObject->dfMMin = MIN(psObject->dfMMin, psObject->padfM[i]);
+
+ psObject->dfXMax = MAX(psObject->dfXMax, psObject->padfX[i]);
+ psObject->dfYMax = MAX(psObject->dfYMax, psObject->padfY[i]);
+ psObject->dfZMax = MAX(psObject->dfZMax, psObject->padfZ[i]);
+ psObject->dfMMax = MAX(psObject->dfMMax, psObject->padfM[i]);
+ }
+}
+
+/************************************************************************/
+/* SHPCreateObject() */
+/* */
+/* Create a shape object. It should be freed with */
+/* SHPDestroyObject(). */
+/************************************************************************/
+
+SHPObject *SHPCreateObject( int nSHPType, int nShapeId, int nParts,
+ int * panPartStart, int * panPartType,
+ int nVertices, double * padfX, double * padfY,
+ double * padfZ, double * padfM )
+
+{
+ SHPObject *psObject;
+ int i, bHasM, bHasZ;
+
+ psObject = (SHPObject *) calloc(1,sizeof(SHPObject));
+ psObject->nSHPType = nSHPType;
+ psObject->nShapeId = nShapeId;
+
+/* -------------------------------------------------------------------- */
+/* Establish whether this shape type has M, and Z values. */
+/* -------------------------------------------------------------------- */
+ if( nSHPType == SHPT_ARCM
+ || nSHPType == SHPT_POINTM
+ || nSHPType == SHPT_POLYGONM
+ || nSHPType == SHPT_MULTIPOINTM )
+ {
+ bHasM = TRUE;
+ bHasZ = FALSE;
+ }
+ else if( nSHPType == SHPT_ARCZ
+ || nSHPType == SHPT_POINTZ
+ || nSHPType == SHPT_POLYGONZ
+ || nSHPType == SHPT_MULTIPOINTZ
+ || nSHPType == SHPT_MULTIPATCH )
+ {
+ bHasM = TRUE;
+ bHasZ = TRUE;
+ }
+ else
+ {
+ bHasM = FALSE;
+ bHasZ = FALSE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Capture parts. Note that part type is optional, and */
+/* defaults to ring. */
+/* -------------------------------------------------------------------- */
+ if( nSHPType == SHPT_ARC || nSHPType == SHPT_POLYGON
+ || nSHPType == SHPT_ARCM || nSHPType == SHPT_POLYGONM
+ || nSHPType == SHPT_ARCZ || nSHPType == SHPT_POLYGONZ
+ || nSHPType == SHPT_MULTIPATCH )
+ {
+ psObject->nParts = MAX(1,nParts);
+
+ psObject->panPartStart = (int *)
+ malloc(sizeof(int) * psObject->nParts);
+ psObject->panPartType = (int *)
+ malloc(sizeof(int) * psObject->nParts);
+
+ psObject->panPartStart[0] = 0;
+ psObject->panPartType[0] = SHPP_RING;
+
+ for( i = 0; i < nParts; i++ )
+ {
+ psObject->panPartStart[i] = panPartStart[i];
+ if( panPartType != NULL )
+ psObject->panPartType[i] = panPartType[i];
+ else
+ psObject->panPartType[i] = SHPP_RING;
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Capture vertices. Note that Z and M are optional, but X and */
+/* Y are not. */
+/* -------------------------------------------------------------------- */
+ psObject->padfX = (double *) calloc(sizeof(double),nVertices);
+ psObject->padfY = (double *) calloc(sizeof(double),nVertices);
+ psObject->padfZ = (double *) calloc(sizeof(double),nVertices);
+ psObject->padfM = (double *) calloc(sizeof(double),nVertices);
+
+ assert( padfX != NULL );
+ assert( padfY != NULL );
+
+ for( i = 0; i < nVertices; i++ )
+ {
+ psObject->padfX[i] = padfX[i];
+ psObject->padfY[i] = padfY[i];
+ if( padfZ != NULL && bHasZ )
+ psObject->padfZ[i] = padfZ[i];
+ if( padfM != NULL && bHasM )
+ psObject->padfM[i] = padfM[i];
+ }
+
+/* -------------------------------------------------------------------- */
+/* Compute the extents. */
+/* -------------------------------------------------------------------- */
+ psObject->nVertices = nVertices;
+
+ SHPComputeExtents( psObject );
+
+ return( psObject );
+}
+
+/************************************************************************/
+/* SHPCreateSimpleObject() */
+/* */
+/* Create a simple (common) shape object. Destroy with */
+/* SHPDestroyObject(). */
+/************************************************************************/
+
+SHPObject *SHPCreateSimpleObject( int nSHPType, int nVertices,
+ double * padfX, double * padfY,
+ double * padfZ )
+
+{
+ return( SHPCreateObject( nSHPType, -1, 0, NULL, NULL,
+ nVertices, padfX, padfY, padfZ, NULL ) );
+}
+
+/************************************************************************/
+/* SHPWriteObject() */
+/* */
+/* Write out the vertices of a new structure. Note that it is */
+/* only possible to write vertices at the end of the file. */
+/************************************************************************/
+
+int SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject )
+
+{
+ int nRecordOffset, i, nRecordSize;
+ uchar *pabyRec;
+ int32 i32;
+
+ psSHP->bUpdated = TRUE;
+
+/* -------------------------------------------------------------------- */
+/* Ensure that shape object matches the type of the file it is */
+/* being written to. */
+/* -------------------------------------------------------------------- */
+ assert( psObject->nSHPType == psSHP->nShapeType );
+
+/* -------------------------------------------------------------------- */
+/* Ensure that -1 is used for appends. Either blow an */
+/* assertion, or if they are disabled, set the shapeid to -1 */
+/* for appends. */
+/* -------------------------------------------------------------------- */
+ assert( nShapeId == -1
+ || (nShapeId >= 0 && nShapeId < psSHP->nRecords) );
+
+ if( nShapeId != -1 && nShapeId >= psSHP->nRecords )
+ nShapeId = -1;
+
+/* -------------------------------------------------------------------- */
+/* Add the new entity to the in memory index. */
+/* -------------------------------------------------------------------- */
+ if( nShapeId == -1 && psSHP->nRecords+1 > psSHP->nMaxRecords )
+ {
+ psSHP->nMaxRecords =(int) ( psSHP->nMaxRecords * 1.3 + 100);
+
+ psSHP->panRecOffset = (int *)
+ SfRealloc(psSHP->panRecOffset,sizeof(int) * psSHP->nMaxRecords );
+ psSHP->panRecSize = (int *)
+ SfRealloc(psSHP->panRecSize,sizeof(int) * psSHP->nMaxRecords );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Initialize record. */
+/* -------------------------------------------------------------------- */
+ pabyRec = (uchar *) malloc(psObject->nVertices * 4 * sizeof(double)
+ + psObject->nParts * 8 + 128);
+
+/* -------------------------------------------------------------------- */
+/* Extract vertices for a Polygon or Arc. */
+/* -------------------------------------------------------------------- */
+ if( psSHP->nShapeType == SHPT_POLYGON
+ || psSHP->nShapeType == SHPT_POLYGONZ
+ || psSHP->nShapeType == SHPT_POLYGONM
+ || psSHP->nShapeType == SHPT_ARC
+ || psSHP->nShapeType == SHPT_ARCZ
+ || psSHP->nShapeType == SHPT_ARCM
+ || psSHP->nShapeType == SHPT_MULTIPATCH )
+ {
+ int32 nPoints, nParts;
+ int i;
+
+ nPoints = psObject->nVertices;
+ nParts = psObject->nParts;
+
+ _SHPSetBounds( pabyRec + 12, psObject );
+
+ if( bBigEndian ) SwapWord( 4, &nPoints );
+ if( bBigEndian ) SwapWord( 4, &nParts );
+
+ ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
+ ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
+
+ nRecordSize = 52;
+
+ /*
+ * Write part start positions.
+ */
+ ByteCopy( psObject->panPartStart, pabyRec + 44 + 8,
+ 4 * psObject->nParts );
+ for( i = 0; i < psObject->nParts; i++ )
+ {
+ if( bBigEndian ) SwapWord( 4, pabyRec + 44 + 8 + 4*i );
+ nRecordSize += 4;
+ }
+
+ /*
+ * Write multipatch part types if needed.
+ */
+ if( psSHP->nShapeType == SHPT_MULTIPATCH )
+ {
+ memcpy( pabyRec + nRecordSize, psObject->panPartType,
+ 4*psObject->nParts );
+ for( i = 0; i < psObject->nParts; i++ )
+ {
+ if( bBigEndian ) SwapWord( 4, pabyRec + nRecordSize );
+ nRecordSize += 4;
+ }
+ }
+
+ /*
+ * Write the (x,y) vertex values.
+ */
+ for( i = 0; i < psObject->nVertices; i++ )
+ {
+ ByteCopy( psObject->padfX + i, pabyRec + nRecordSize, 8 );
+ ByteCopy( psObject->padfY + i, pabyRec + nRecordSize + 8, 8 );
+
+ if( bBigEndian )
+ SwapWord( 8, pabyRec + nRecordSize );
+
+ if( bBigEndian )
+ SwapWord( 8, pabyRec + nRecordSize + 8 );
+
+ nRecordSize += 2 * 8;
+ }
+
+ /*
+ * Write the Z coordinates (if any).
+ */
+ if( psSHP->nShapeType == SHPT_POLYGONZ
+ || psSHP->nShapeType == SHPT_ARCZ
+ || psSHP->nShapeType == SHPT_MULTIPATCH )
+ {
+ ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+
+ ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+
+ for( i = 0; i < psObject->nVertices; i++ )
+ {
+ ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+ }
+ }
+
+ /*
+ * Write the M values, if any.
+ */
+ if( psSHP->nShapeType == SHPT_POLYGONM
+ || psSHP->nShapeType == SHPT_ARCM
+#ifndef DISABLE_MULTIPATCH_MEASURE
+ || psSHP->nShapeType == SHPT_MULTIPATCH
+#endif
+ || psSHP->nShapeType == SHPT_POLYGONZ
+ || psSHP->nShapeType == SHPT_ARCZ )
+ {
+ ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+
+ ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+
+ for( i = 0; i < psObject->nVertices; i++ )
+ {
+ ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+ }
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Extract vertices for a MultiPoint. */
+/* -------------------------------------------------------------------- */
+ else if( psSHP->nShapeType == SHPT_MULTIPOINT
+ || psSHP->nShapeType == SHPT_MULTIPOINTZ
+ || psSHP->nShapeType == SHPT_MULTIPOINTM )
+ {
+ int32 nPoints;
+ int i;
+
+ nPoints = psObject->nVertices;
+
+ _SHPSetBounds( pabyRec + 12, psObject );
+
+ if( bBigEndian ) SwapWord( 4, &nPoints );
+ ByteCopy( &nPoints, pabyRec + 44, 4 );
+
+ for( i = 0; i < psObject->nVertices; i++ )
+ {
+ ByteCopy( psObject->padfX + i, pabyRec + 48 + i*16, 8 );
+ ByteCopy( psObject->padfY + i, pabyRec + 48 + i*16 + 8, 8 );
+
+ if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 + 8 );
+ }
+
+ nRecordSize = 48 + 16 * psObject->nVertices;
+
+ if( psSHP->nShapeType == SHPT_MULTIPOINTZ )
+ {
+ ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+
+ ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+
+ for( i = 0; i < psObject->nVertices; i++ )
+ {
+ ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+ }
+ }
+
+ if( psSHP->nShapeType == SHPT_MULTIPOINTZ
+ || psSHP->nShapeType == SHPT_MULTIPOINTM )
+ {
+ ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+
+ ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+
+ for( i = 0; i < psObject->nVertices; i++ )
+ {
+ ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+ }
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Extract vertices for a point. */
+/* -------------------------------------------------------------------- */
+ else if( psSHP->nShapeType == SHPT_POINT
+ || psSHP->nShapeType == SHPT_POINTZ
+ || psSHP->nShapeType == SHPT_POINTM )
+ {
+ ByteCopy( psObject->padfX, pabyRec + 12, 8 );
+ ByteCopy( psObject->padfY, pabyRec + 20, 8 );
+
+ if( bBigEndian ) SwapWord( 8, pabyRec + 12 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + 20 );
+
+ nRecordSize = 28;
+
+ if( psSHP->nShapeType == SHPT_POINTZ )
+ {
+ ByteCopy( psObject->padfZ, pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+ }
+
+ if( psSHP->nShapeType == SHPT_POINTZ
+ || psSHP->nShapeType == SHPT_POINTM )
+ {
+ ByteCopy( psObject->padfM, pabyRec + nRecordSize, 8 );
+ if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+ nRecordSize += 8;
+ }
+ }
+
+ else
+ {
+ /* unknown type */
+ assert( FALSE );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Establish where we are going to put this record. If we are */
+/* rewriting and existing record, and it will fit, then put it */
+/* back where the original came from. Otherwise write at the end. */
+/* -------------------------------------------------------------------- */
+ if( nShapeId == -1 || psSHP->panRecSize[nShapeId] < nRecordSize-8 )
+ {
+ if( nShapeId == -1 )
+ nShapeId = psSHP->nRecords++;
+
+ psSHP->panRecOffset[nShapeId] = nRecordOffset = psSHP->nFileSize;
+ psSHP->panRecSize[nShapeId] = nRecordSize-8;
+ psSHP->nFileSize += nRecordSize;
+ }
+ else
+ {
+ nRecordOffset = psSHP->panRecOffset[nShapeId];
+ }
+
+/* -------------------------------------------------------------------- */
+/* Set the shape type, record number, and record size. */
+/* -------------------------------------------------------------------- */
+ i32 = nShapeId+1; /* record # */
+ if( !bBigEndian ) SwapWord( 4, &i32 );
+ ByteCopy( &i32, pabyRec, 4 );
+
+ i32 = (nRecordSize-8)/2; /* record size */
+ if( !bBigEndian ) SwapWord( 4, &i32 );
+ ByteCopy( &i32, pabyRec + 4, 4 );
+
+ i32 = psSHP->nShapeType; /* shape type */
+ if( bBigEndian ) SwapWord( 4, &i32 );
+ ByteCopy( &i32, pabyRec + 8, 4 );
+
+/* -------------------------------------------------------------------- */
+/* Write out record. */
+/* -------------------------------------------------------------------- */
+ if( fseek( psSHP->fpSHP, nRecordOffset, 0 ) != 0
+ || fwrite( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 )
+ {
+ printf( "Error in fseek() or fwrite().\n" );
+ free( pabyRec );
+ return -1;
+ }
+
+ free( pabyRec );
+
+/* -------------------------------------------------------------------- */
+/* Expand file wide bounds based on this shape. */
+/* -------------------------------------------------------------------- */
+ if( psSHP->nRecords == 1 )
+ {
+ psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0];
+ psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0];
+ psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ[0];
+ psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM[0];
+ }
+
+ for( i = 0; i < psObject->nVertices; i++ )
+ {
+ psSHP->adBoundsMin[0] = MIN(psSHP->adBoundsMin[0],psObject->padfX[i]);
+ psSHP->adBoundsMin[1] = MIN(psSHP->adBoundsMin[1],psObject->padfY[i]);
+ psSHP->adBoundsMin[2] = MIN(psSHP->adBoundsMin[2],psObject->padfZ[i]);
+ psSHP->adBoundsMin[3] = MIN(psSHP->adBoundsMin[3],psObject->padfM[i]);
+ psSHP->adBoundsMax[0] = MAX(psSHP->adBoundsMax[0],psObject->padfX[i]);
+ psSHP->adBoundsMax[1] = MAX(psSHP->adBoundsMax[1],psObject->padfY[i]);
+ psSHP->adBoundsMax[2] = MAX(psSHP->adBoundsMax[2],psObject->padfZ[i]);
+ psSHP->adBoundsMax[3] = MAX(psSHP->adBoundsMax[3],psObject->padfM[i]);
+ }
+
+ return( nShapeId );
+}
+
+/************************************************************************/
+/* SHPReadObject() */
+/* */
+/* Read the vertices, parts, and other non-attribute information */
+/* for one shape. */
+/************************************************************************/
+
+SHPObject *SHPReadObject( SHPHandle psSHP, int hEntity )
+
+{
+ SHPObject *psShape;
+
+/* -------------------------------------------------------------------- */
+/* Validate the record/entity number. */
+/* -------------------------------------------------------------------- */
+ if( hEntity < 0 || hEntity >= psSHP->nRecords )
+ return( NULL );
+
+/* -------------------------------------------------------------------- */
+/* Ensure our record buffer is large enough. */
+/* -------------------------------------------------------------------- */
+ if( psSHP->panRecSize[hEntity]+8 > nBufSize )
+ {
+ nBufSize = psSHP->panRecSize[hEntity]+8;
+ pabyRec = (uchar *) SfRealloc(pabyRec,nBufSize);
+ }
+
+/* -------------------------------------------------------------------- */
+/* Read the record. */
+/* -------------------------------------------------------------------- */
+ fseek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 );
+ ogdi_fread( pabyRec, psSHP->panRecSize[hEntity]+8, 1, psSHP->fpSHP );
+
+/* -------------------------------------------------------------------- */
+/* Allocate and minimally initialize the object. */
+/* -------------------------------------------------------------------- */
+ psShape = (SHPObject *) calloc(1,sizeof(SHPObject));
+ psShape->nShapeId = hEntity;
+
+ memcpy( &psShape->nSHPType, pabyRec + 8, 4 );
+ if( bBigEndian ) SwapWord( 4, &(psShape->nSHPType) );
+
+/* ==================================================================== */
+/* Extract vertices for a Polygon or Arc. */
+/* ==================================================================== */
+ if( psShape->nSHPType == SHPT_POLYGON || psShape->nSHPType == SHPT_ARC
+ || psShape->nSHPType == SHPT_POLYGONZ
+ || psShape->nSHPType == SHPT_POLYGONM
+ || psShape->nSHPType == SHPT_ARCZ
+ || psShape->nSHPType == SHPT_ARCM
+ || psShape->nSHPType == SHPT_MULTIPATCH )
+ {
+ int32 nPoints, nParts;
+ int i, nOffset;
+
+/* -------------------------------------------------------------------- */
+/* Get the X/Y bounds. */
+/* -------------------------------------------------------------------- */
+ memcpy( &(psShape->dfXMin), pabyRec + 8 + 4, 8 );
+ memcpy( &(psShape->dfYMin), pabyRec + 8 + 12, 8 );
+ memcpy( &(psShape->dfXMax), pabyRec + 8 + 20, 8 );
+ memcpy( &(psShape->dfYMax), pabyRec + 8 + 28, 8 );
+
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) );
+
+/* -------------------------------------------------------------------- */
+/* Extract part/point count, and build vertex and part arrays */
+/* to proper size. */
+/* -------------------------------------------------------------------- */
+ memcpy( &nPoints, pabyRec + 40 + 8, 4 );
+ memcpy( &nParts, pabyRec + 36 + 8, 4 );
+
+ if( bBigEndian ) SwapWord( 4, &nPoints );
+ if( bBigEndian ) SwapWord( 4, &nParts );
+
+ psShape->nVertices = nPoints;
+ psShape->padfX = (double *) calloc(nPoints,sizeof(double));
+ psShape->padfY = (double *) calloc(nPoints,sizeof(double));
+ psShape->padfZ = (double *) calloc(nPoints,sizeof(double));
+ psShape->padfM = (double *) calloc(nPoints,sizeof(double));
+
+ psShape->nParts = nParts;
+ psShape->panPartStart = (int *) calloc(nParts,sizeof(int));
+ psShape->panPartType = (int *) calloc(nParts,sizeof(int));
+
+ for( i = 0; i < nParts; i++ )
+ psShape->panPartType[i] = SHPP_RING;
+
+/* -------------------------------------------------------------------- */
+/* Copy out the part array from the record. */
+/* -------------------------------------------------------------------- */
+ memcpy( psShape->panPartStart, pabyRec + 44 + 8, 4 * nParts );
+ for( i = 0; i < nParts; i++ )
+ {
+ if( bBigEndian ) SwapWord( 4, psShape->panPartStart+i );
+ }
+
+ nOffset = 44 + 8 + 4*nParts;
+
+/* -------------------------------------------------------------------- */
+/* If this is a multipatch, we will also have parts types. */
+/* -------------------------------------------------------------------- */
+ if( psShape->nSHPType == SHPT_MULTIPATCH )
+ {
+ memcpy( psShape->panPartType, pabyRec + nOffset, 4*nParts );
+ for( i = 0; i < nParts; i++ )
+ {
+ if( bBigEndian ) SwapWord( 4, psShape->panPartType+i );
+ }
+
+ nOffset += 4*nParts;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Copy out the vertices from the record. */
+/* -------------------------------------------------------------------- */
+ for( i = 0; i < nPoints; i++ )
+ {
+ memcpy(psShape->padfX + i,
+ pabyRec + nOffset + i * 16,
+ 8 );
+
+ memcpy(psShape->padfY + i,
+ pabyRec + nOffset + i * 16 + 8,
+ 8 );
+
+ if( bBigEndian ) SwapWord( 8, psShape->padfX + i );
+ if( bBigEndian ) SwapWord( 8, psShape->padfY + i );
+ }
+
+ nOffset += 16*nPoints;
+
+/* -------------------------------------------------------------------- */
+/* If we have a Z coordinate, collect that now. */
+/* -------------------------------------------------------------------- */
+ if( psShape->nSHPType == SHPT_POLYGONZ
+ || psShape->nSHPType == SHPT_ARCZ
+ || psShape->nSHPType == SHPT_MULTIPATCH )
+ {
+ memcpy( &(psShape->dfZMin), pabyRec + nOffset, 8 );
+ memcpy( &(psShape->dfZMax), pabyRec + nOffset + 8, 8 );
+
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) );
+
+ for( i = 0; i < nPoints; i++ )
+ {
+ memcpy( psShape->padfZ + i,
+ pabyRec + nOffset + 16 + i*8, 8 );
+ if( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
+ }
+
+ nOffset += 16 + 8*nPoints;
+ }
+
+/* -------------------------------------------------------------------- */
+/* If we have a M measure value, then read it now. We assume */
+/* that the measure can be present for any shape if the size is */
+/* big enough, but really it will only occur for the Z shapes */
+/* (options), and the M shapes. */
+/* -------------------------------------------------------------------- */
+ if( psSHP->panRecSize[hEntity]+8 >= nOffset + 16 + 8*nPoints )
+ {
+ memcpy( &(psShape->dfMMin), pabyRec + nOffset, 8 );
+ memcpy( &(psShape->dfMMax), pabyRec + nOffset + 8, 8 );
+
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) );
+
+ for( i = 0; i < nPoints; i++ )
+ {
+ memcpy( psShape->padfM + i,
+ pabyRec + nOffset + 16 + i*8, 8 );
+ if( bBigEndian ) SwapWord( 8, psShape->padfM + i );
+ }
+ }
+
+ }
+
+/* ==================================================================== */
+/* Extract vertices for a MultiPoint. */
+/* ==================================================================== */
+ else if( psShape->nSHPType == SHPT_MULTIPOINT
+ || psShape->nSHPType == SHPT_MULTIPOINTM
+ || psShape->nSHPType == SHPT_MULTIPOINTZ )
+ {
+ int32 nPoints;
+ int i, nOffset;
+
+ memcpy( &nPoints, pabyRec + 44, 4 );
+ if( bBigEndian ) SwapWord( 4, &nPoints );
+
+ psShape->nVertices = nPoints;
+ psShape->padfX = (double *) calloc(nPoints,sizeof(double));
+ psShape->padfY = (double *) calloc(nPoints,sizeof(double));
+ psShape->padfZ = (double *) calloc(nPoints,sizeof(double));
+ psShape->padfM = (double *) calloc(nPoints,sizeof(double));
+
+ for( i = 0; i < nPoints; i++ )
+ {
+ memcpy(psShape->padfX+i, pabyRec + 48 + 16 * i, 8 );
+ memcpy(psShape->padfY+i, pabyRec + 48 + 16 * i + 8, 8 );
+
+ if( bBigEndian ) SwapWord( 8, psShape->padfX + i );
+ if( bBigEndian ) SwapWord( 8, psShape->padfY + i );
+ }
+
+ nOffset = 48 + 16*nPoints;
+
+/* -------------------------------------------------------------------- */
+/* Get the X/Y bounds. */
+/* -------------------------------------------------------------------- */
+ memcpy( &(psShape->dfXMin), pabyRec + 8 + 4, 8 );
+ memcpy( &(psShape->dfYMin), pabyRec + 8 + 12, 8 );
+ memcpy( &(psShape->dfXMax), pabyRec + 8 + 20, 8 );
+ memcpy( &(psShape->dfYMax), pabyRec + 8 + 28, 8 );
+
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) );
+
+/* -------------------------------------------------------------------- */
+/* If we have a Z coordinate, collect that now. */
+/* -------------------------------------------------------------------- */
+ if( psShape->nSHPType == SHPT_MULTIPOINTZ )
+ {
+ memcpy( &(psShape->dfZMin), pabyRec + nOffset, 8 );
+ memcpy( &(psShape->dfZMax), pabyRec + nOffset + 8, 8 );
+
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) );
+
+ for( i = 0; i < nPoints; i++ )
+ {
+ memcpy( psShape->padfZ + i,
+ pabyRec + nOffset + 16 + i*8, 8 );
+ if( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
+ }
+
+ nOffset += 16 + 8*nPoints;
+ }
+
+/* -------------------------------------------------------------------- */
+/* If we have a M measure value, then read it now. We assume */
+/* that the measure can be present for any shape if the size is */
+/* big enough, but really it will only occur for the Z shapes */
+/* (options), and the M shapes. */
+/* -------------------------------------------------------------------- */
+ if( psSHP->panRecSize[hEntity]+8 >= nOffset + 16 + 8*nPoints )
+ {
+ memcpy( &(psShape->dfMMin), pabyRec + nOffset, 8 );
+ memcpy( &(psShape->dfMMax), pabyRec + nOffset + 8, 8 );
+
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) );
+ if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) );
+
+ for( i = 0; i < nPoints; i++ )
+ {
+ memcpy( psShape->padfM + i,
+ pabyRec + nOffset + 16 + i*8, 8 );
+ if( bBigEndian ) SwapWord( 8, psShape->padfM + i );
+ }
+ }
+ }
+
+/* ==================================================================== */
+/* Extract vertices for a point. */
+/* ==================================================================== */
+ else if( psShape->nSHPType == SHPT_POINT
+ || psShape->nSHPType == SHPT_POINTM
+ || psShape->nSHPType == SHPT_POINTZ )
+ {
+ int nOffset;
+
+ psShape->nVertices = 1;
+ psShape->padfX = (double *) calloc(1,sizeof(double));
+ psShape->padfY = (double *) calloc(1,sizeof(double));
+ psShape->padfZ = (double *) calloc(1,sizeof(double));
+ psShape->padfM = (double *) calloc(1,sizeof(double));
+
+ memcpy( psShape->padfX, pabyRec + 12, 8 );
+ memcpy( psShape->padfY, pabyRec + 20, 8 );
+
+ if( bBigEndian ) SwapWord( 8, psShape->padfX );
+ if( bBigEndian ) SwapWord( 8, psShape->padfY );
+
+ nOffset = 20 + 8;
+
+/* -------------------------------------------------------------------- */
+/* If we have a Z coordinate, collect that now. */
+/* -------------------------------------------------------------------- */
+ if( psShape->nSHPType == SHPT_POINTZ )
+ {
+ memcpy( psShape->padfZ, pabyRec + nOffset, 8 );
+
+ if( bBigEndian ) SwapWord( 8, psShape->padfZ );
+
+ nOffset += 8;
+ }
+
+/* -------------------------------------------------------------------- */
+/* If we have a M measure value, then read it now. We assume */
+/* that the measure can be present for any shape if the size is */
+/* big enough, but really it will only occur for the Z shapes */
+/* (options), and the M shapes. */
+/* -------------------------------------------------------------------- */
+ if( psSHP->panRecSize[hEntity]+8 >= nOffset + 8 )
+ {
+ memcpy( psShape->padfM, pabyRec + nOffset, 8 );
+
+ if( bBigEndian ) SwapWord( 8, psShape->padfM );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Since no extents are supplied in the record, we will apply */
+/* them from the single vertex. */
+/* -------------------------------------------------------------------- */
+ psShape->dfXMin = psShape->dfXMax = psShape->padfX[0];
+ psShape->dfYMin = psShape->dfYMax = psShape->padfY[0];
+ psShape->dfZMin = psShape->dfZMax = psShape->padfZ[0];
+ psShape->dfMMin = psShape->dfMMax = psShape->padfM[0];
+ }
+
+ return( psShape );
+}
+
+/************************************************************************/
+/* SHPTypeName() */
+/************************************************************************/
+
+const char *SHPTypeName( int nSHPType )
+
+{
+ switch( nSHPType )
+ {
+ case 0:
+ return "NullShape";
+
+ case SHPT_POINT:
+ return "Point";
+
+ case SHPT_ARC:
+ return "Arc";
+
+ case SHPT_POLYGON:
+ return "Polygon";
+
+ case SHPT_MULTIPOINT:
+ return "MultiPoint";
+
+ case SHPT_POINTZ:
+ return "PointZ";
+
+ case SHPT_ARCZ:
+ return "ArcZ";
+
+ case SHPT_POLYGONZ:
+ return "PolygonZ";
+
+ case SHPT_MULTIPOINTZ:
+ return "MultiPointZ";
+
+ case SHPT_POINTM:
+ return "PointM";
+
+ case SHPT_ARCM:
+ return "ArcM";
+
+ case SHPT_POLYGONM:
+ return "PolygonM";
+
+ case SHPT_MULTIPOINTM:
+ return "MultiPointM";
+
+ case SHPT_MULTIPATCH:
+ return "MultiPatch";
+
+ default:
+ return "UnknownShapeType";
+ }
+}
+
+/************************************************************************/
+/* SHPPartTypeName() */
+/************************************************************************/
+
+const char *SHPPartTypeName( int nPartType )
+
+{
+ switch( nPartType )
+ {
+ case SHPP_TRISTRIP:
+ return "TriangleStrip";
+
+ case SHPP_TRIFAN:
+ return "TriangleFan";
+
+ case SHPP_OUTERRING:
+ return "OuterRing";
+
+ case SHPP_INNERRING:
+ return "InnerRing";
+
+ case SHPP_FIRSTRING:
+ return "FirstRing";
+
+ case SHPP_RING:
+ return "Ring";
+
+ default:
+ return "UnknownPartType";
+ }
+}
+
+/************************************************************************/
+/* SHPDestroyObject() */
+/************************************************************************/
+
+void SHPDestroyObject( SHPObject * psShape )
+
+{
+ if( psShape == NULL )
+ return;
+
+ if( psShape->padfX != NULL )
+ free( psShape->padfX );
+ if( psShape->padfY != NULL )
+ free( psShape->padfY );
+ if( psShape->padfZ != NULL )
+ free( psShape->padfZ );
+ if( psShape->padfM != NULL )
+ free( psShape->padfM );
+
+ if( psShape->panPartStart != NULL )
+ free( psShape->panPartStart );
+ if( psShape->panPartType != NULL )
+ free( psShape->panPartType );
+
+ free( psShape );
+}
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,34 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty
+#
+
+TOBEGEN = ogdi_info
+TARGETGEN=$(PROGGEN)
+
+SOURCES = ogdi_info.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)\
+ $(ZLIB_INCLUDE) $(GENERAL_INCLUDE) $(TCLTK_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS) $(FLAGS_X86DEF)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(ZLIB_LINKLIB) $(RPC_LINKLIB) \
+ $(PROJ_STATICLIB) $(MATH_LINKLIB) \
+ $(LIBC_LINKLIB) $(UCB_STATICLIB) $(DL_LINKLIB) \
+ $(WIN_LINKLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR ogdi_info.c
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Property changes on: packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/makefile
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/ogdi_info.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/ogdi_info.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/ogdi_info.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,876 @@
+/******************************************************************************
+ * $Id: ogdi_info.c,v 1.14 2004/10/26 19:45:53 warmerda Exp $
+ *
+ * Project: OGDI Contributed Clients
+ * Purpose: Simple console query program for testing OGDI.
+ * Author: Frank Warmerdam <warmerdam at pobox.com>
+ *
+ ******************************************************************************
+ * Copyright (c) 2000, Frank Warmerdam <warmerdam at pobox.com>
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of the author not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The author makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ogdi_info.c,v $
+ * Revision 1.14 2004/10/26 19:45:53 warmerda
+ * Fixed last fix.
+ *
+ * Revision 1.13 2004/10/26 19:37:52 warmerda
+ * Close old clientid if multiple -u's met.
+ * Report errors on illegal family specifications.
+ *
+ * Revision 1.12 2004/02/18 21:27:13 warmerda
+ * Use ecs_CleanUp() to recover result memory
+ *
+ * Revision 1.11 2001/12/14 21:22:02 warmerda
+ * dont reproject to latlong if already latlong
+ *
+ * Revision 1.10 2001/08/17 00:37:15 warmerda
+ * updated formatting of capabilities bounds
+ *
+ * Revision 1.9 2001/07/17 19:08:01 warmerda
+ * Fixed reporting of Text layers.
+ *
+ * Revision 1.8 2001/04/19 05:28:50 warmerda
+ * improve region bounds reporting
+ *
+ * Revision 1.7 2001/04/12 19:26:08 warmerda
+ * added RGB image support
+ *
+ * Revision 1.6 2001/04/12 18:12:42 warmerda
+ * Added lots of capabilities related to capabilities
+ *
+ * Revision 1.5 2001/04/10 14:41:47 warmerda
+ * Added support for reporting Image values.
+ *
+ * Revision 1.4 2001/04/09 16:06:53 warmerda
+ * added -no-proj support
+ *
+ * Revision 1.3 2001/02/19 04:46:13 warmerda
+ * use projUV, not UV
+ *
+ * Revision 1.2 2000/11/23 19:10:36 warmerda
+ * added copyright header
+ *
+ */
+
+#include "ecs.h"
+#include "projects.h"
+
+static int ClientID = -1;
+static int bNoDict = FALSE;
+static int bNoProj = FALSE;
+static int nSampleFrequency = 1;
+
+/************************************************************************/
+/* CheckError() */
+/************************************************************************/
+
+static int CheckError( ecs_Result * result )
+
+{
+ if( ECSERROR( result ) ) {
+ printf( "ECSERROR: %s\n", result->message );
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+/************************************************************************/
+/* DumpCapabilities() */
+/************************************************************************/
+
+static void DumpCapabilities()
+
+{
+ const ecs_LayerCapabilities *layer;
+ int layer_index;
+ ecs_Result *result;
+
+ result = cln_GetVersion( ClientID );
+ if( CheckError( result ) )
+ return;
+
+ printf( "Version: `%s'\n", ECSTEXT(result) );
+
+ for( layer_index = 0;
+ (layer = cln_GetLayerCapabilities(ClientID,layer_index)) != NULL;
+ layer_index++ )
+ {
+ printf( "Layer %d: %s\n", layer_index, layer->name );
+
+ if( layer->title )
+ printf( " Title: %s\n", layer->title );
+
+ if( layer->srs )
+ printf( " SRS: %s\n", layer->srs );
+
+ printf( " Families: " );
+ if( layer->families[Area] )
+ printf( "Area " );
+ if( layer->families[Point] )
+ printf( "Point " );
+ if( layer->families[Line] )
+ printf( "Line " );
+ if( layer->families[Text] )
+ printf( "Text " );
+ if( layer->families[Image] )
+ printf( "Image " );
+ if( layer->families[Matrix] )
+ printf( "Matrix " );
+ printf( "\n" );
+
+ printf( " Bounds: n=%.4f, s=%.4f, nsres=%g\n"
+ " e=%.4f, w=%.4f, ewres=%g\n",
+ layer->srs_north,
+ layer->srs_south,
+ layer->srs_nsres,
+ layer->srs_east,
+ layer->srs_west,
+ layer->srs_ewres );
+ if( layer->ll_bounds_set )
+ {
+ printf( " LLBounds: n=%.14f, s=%.14f\n"
+ " e=%.14f, w=%.14f\n",
+ layer->ll_north,
+ layer->ll_south,
+ layer->ll_east,
+ layer->ll_west );
+ }
+
+ if( layer->extensions != NULL )
+ {
+ int i;
+
+ printf( " Extensions:" );
+
+ for( i = 0; layer->extensions[i] != NULL; i++ )
+ printf( " %s", layer->extensions[i] );
+
+ printf( "\n" );
+ }
+
+ if( layer->query_expression_set )
+ {
+ printf( " Query Expression:\n" );
+ if( layer->qe_prefix != NULL )
+ printf( " prefix=\"%s\"\n", layer->qe_prefix );
+ if( layer->qe_suffix != NULL )
+ printf( " suffix=\"%s\"\n", layer->qe_suffix );
+ if( layer->qe_format != NULL )
+ printf( " format=\"%s\"\n", layer->qe_format );
+ if( layer->qe_description != NULL )
+ printf( " description=\"%s\"\n", layer->qe_description );
+ }
+ }
+}
+
+
+/************************************************************************/
+/* DecToDMS() */
+/************************************************************************/
+
+const char * DecToDMS( double dfAngle )
+
+{
+ static char szDMS1[128];
+ static char szDMS2[128];
+ static int nRotator = 1;
+ int nDeg, nMin;
+ double dfRemainder;
+
+
+ nDeg = (int) dfAngle;
+
+ dfRemainder = (fabs(dfAngle) - fabs(nDeg));
+
+ nMin = (int) floor(dfRemainder*60.0);
+ dfRemainder = dfRemainder - nMin / 60.0;
+
+ if( nRotator == 1 )
+ {
+ nRotator = 2;
+ sprintf( szDMS1, "%4dd%2d'%7.4f\"", nDeg, nMin, dfRemainder*3600.0 );
+ return( szDMS1 );
+ }
+ else
+ {
+ nRotator = 1;
+ sprintf( szDMS2, "%4dd%2d'%7.4f\"", nDeg, nMin, dfRemainder*3600.0 );
+ return( szDMS2 );
+ }
+}
+
+/************************************************************************/
+/* DumpGlobalRegion() */
+/************************************************************************/
+
+static int DumpGlobalRegion( ecs_Region * region, PJ * proj_defn )
+
+{
+ ecs_Result *result;
+ ecs_Region tmpRegion;
+ projUV proj_pnt;
+
+ if( region == NULL )
+ region = &tmpRegion;
+
+/* -------------------------------------------------------------------- */
+/* print the global bounds. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetGlobalBound(ClientID);
+ if( CheckError( result ) )
+ return( FALSE );
+
+ printf( "Bounds\n" );
+ printf( "north = %f\n", ECSREGION(result).north );
+ printf( "south = %f\n", ECSREGION(result).south );
+ printf( "east = %f\n", ECSREGION(result).east );
+ printf( "west = %f\n", ECSREGION(result).west );
+ printf( "ns_res = %.9f\n", ECSREGION(result).ns_res );
+ printf( "ew_res = %.9f\n", ECSREGION(result).ew_res );
+
+ *region = ECSREGION(result);
+
+/* -------------------------------------------------------------------- */
+/* Print the corner coordinates in lat/long. */
+/* -------------------------------------------------------------------- */
+#ifndef _WINDOWS
+ if( proj_defn != NULL )
+ {
+ printf( "Lat/Long Corners\n" );
+
+ proj_pnt.v = region->north;
+ proj_pnt.u = region->west;
+ proj_pnt = pj_inv(proj_pnt, proj_defn);
+ printf( "Upper Left: (%s,%s) (%g,%g)\n",
+ DecToDMS(proj_pnt.u/DEG_TO_RAD),
+ DecToDMS(proj_pnt.v/DEG_TO_RAD),
+ proj_pnt.u/DEG_TO_RAD, proj_pnt.v/DEG_TO_RAD );
+
+ proj_pnt.v = region->north;
+ proj_pnt.u = region->east;
+ proj_pnt = pj_inv(proj_pnt, proj_defn);
+ printf( "Upper Right: (%s,%s) (%g,%g)\n",
+ DecToDMS(proj_pnt.u/DEG_TO_RAD),
+ DecToDMS(proj_pnt.v/DEG_TO_RAD),
+ proj_pnt.u/DEG_TO_RAD, proj_pnt.v/DEG_TO_RAD );
+
+ proj_pnt.v = region->south;
+ proj_pnt.u = region->west;
+ proj_pnt = pj_inv(proj_pnt, proj_defn);
+ printf( "Lower Left: (%s,%s) (%g,%g)\n",
+ DecToDMS(proj_pnt.u/DEG_TO_RAD),
+ DecToDMS(proj_pnt.v/DEG_TO_RAD),
+ proj_pnt.u/DEG_TO_RAD, proj_pnt.v/DEG_TO_RAD );
+
+ proj_pnt.v = region->south;
+ proj_pnt.u = region->east;
+ proj_pnt = pj_inv(proj_pnt, proj_defn);
+ printf( "Lower Right: (%s,%s) (%g,%g)\n",
+ DecToDMS(proj_pnt.u/DEG_TO_RAD),
+ DecToDMS(proj_pnt.v/DEG_TO_RAD),
+ proj_pnt.u/DEG_TO_RAD, proj_pnt.v/DEG_TO_RAD );
+ }
+#endif
+
+ return TRUE;
+}
+
+/************************************************************************/
+/* DumpRasterObject() */
+/************************************************************************/
+
+static void DumpRasterObject( ecs_Result * result, ecs_Family featureType,
+ int nDataType )
+
+{
+ int i, xsize;
+ unsigned char *raw = (unsigned char *) ECSRASTER(result);
+
+ xsize = ECSOBJECT(result).geom.ecs_Geometry_u.matrix.x.x_len;
+
+ printf("Object ID:%s (%d pixels)\n",ECSOBJECTID(result), xsize);
+
+ for( i = 0; i < xsize; i += nSampleFrequency )
+ {
+ if( nSampleFrequency != 1 )
+ printf( "%d:", i );
+
+ if( featureType == Matrix )
+ {
+ printf( "%d ", ECSRASTER(result)[i] );
+ }
+ else if( featureType == Image )
+ {
+ if( nDataType == 1 )
+ {
+ if( raw[i*4+3] != 0 )
+ printf( "%d,%d,%d ", raw[i*4], raw[i*4+1], raw[i*4+2] );
+ else
+ printf( "<null> " );
+ }
+ else if( nDataType == 2 )
+ printf( "%d ", raw[i] );
+ else if( nDataType == 3 )
+ printf( "%d ", ((unsigned short *) ECSRASTER(result))[i] );
+ else if( nDataType == 4 )
+ printf( "%d ", ((short *) ECSRASTER(result))[i] );
+ else if( nDataType == 5 )
+ printf( "%d ", ((int *) ECSRASTER(result))[i] );
+ else
+ printf( "?? " );
+ }
+ }
+
+ printf( "\n" );
+}
+
+/************************************************************************/
+/* DumpVectorObject() */
+/************************************************************************/
+
+static void DumpVectorObject( ecs_Result * result, ecs_Family featureType )
+
+{
+ printf("Object ID:%s\n",ECSOBJECTID(result));
+ printf("Object Attributes:%s\n",ECSOBJECTATTR(result));
+
+ if( featureType == Text ) {
+ printf( "%d: (%f , %f) Text=%s\n", 0,
+ ECSGEOM(result).text.c.x,
+ ECSGEOM(result).text.c.y,
+ ECSGEOM(result).text.desc );
+ }
+ else if( featureType == Point ) {
+ printf( "%d: (%f , %f)\n", 0,
+ ECSGEOM(result).point.c.x,
+ ECSGEOM(result).point.c.y );
+ }
+ else if( featureType == Line ) {
+ int i;
+
+ for( i=0;
+ i < (int) ECSGEOM(result).line.c.c_len;
+ i += nSampleFrequency ) {
+ printf("%d: (%f , %f)\n", i,
+ ECSGEOM(result).line.c.c_val[i].x,
+ ECSGEOM(result).line.c.c_val[i].y );
+ }
+ }
+ else if( featureType == Area ) {
+ int i, iRing;
+
+ for( iRing=0;
+ iRing < (int) ECSGEOM(result).area.ring.ring_len;
+ iRing++ ) {
+ ecs_FeatureRing *ring;
+
+ printf( "Ring %d\n", iRing );
+
+ ring = ECSGEOM(result).area.ring.ring_val + iRing;
+
+ for( i=0; i < (int) ring->c.c_len; i += nSampleFrequency ) {
+ printf("%d: (%f , %f)\n", i,
+ ring->c.c_val[i].x,
+ ring->c.c_val[i].y );
+ }
+ printf( "\n" );
+ }
+ }
+ printf( "\n" );
+}
+
+/************************************************************************/
+/* AccessURL() */
+/************************************************************************/
+
+static int AccessURL( char * url, ecs_Region * region )
+
+{
+ ecs_Result *result;
+ PJ *proj_defn = NULL;
+
+/* -------------------------------------------------------------------- */
+/* Close old client if there is one active. */
+/* -------------------------------------------------------------------- */
+ if( ClientID != -1 ) {
+ result = cln_DestroyClient(ClientID);
+ if( CheckError( result ) )
+ return( FALSE );
+ ClientID = -1;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Open new URL/client. */
+/* -------------------------------------------------------------------- */
+ result = cln_CreateClient(&ClientID,url);
+ if( CheckError( result ) )
+ return( FALSE );
+
+/* -------------------------------------------------------------------- */
+/* Print the projection. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetServerProjection( ClientID );
+ if( CheckError( result ) )
+ return( FALSE );
+
+ printf( "Projection = `%s'\n", ECSTEXT(result) );
+
+#ifndef _WINDOWS
+ if( !bNoProj
+ && strstr(ECSTEXT(result),"latlong") == NULL
+ && strstr(ECSTEXT(result),"longlat") == NULL )
+ proj_defn = cln_ProjInit( ECSTEXT(result) );
+#endif
+
+/* -------------------------------------------------------------------- */
+/* Dump the global region. */
+/* -------------------------------------------------------------------- */
+ DumpGlobalRegion( region, proj_defn );
+
+/* -------------------------------------------------------------------- */
+/* Print the Dictionary (update). */
+/* -------------------------------------------------------------------- */
+ result = cln_UpdateDictionary( ClientID, "" );
+ if( CheckError( result ) )
+ return( FALSE );
+
+ if( !bNoDict )
+ printf( "UpdateDictionary = \n%s\n", ECSTEXT(result) );
+
+ return( TRUE );
+}
+
+/************************************************************************/
+/* IdSearch() */
+/************************************************************************/
+
+static void IdSearch( char * layer, ecs_Family featureType,
+ const char * id )
+
+{
+ ecs_LayerSelection selectionLayer;
+ ecs_Result *result;
+
+/* -------------------------------------------------------------------- */
+/* Define the layer to select. */
+/* -------------------------------------------------------------------- */
+ selectionLayer.Select = (char *) layer;
+ selectionLayer.F = featureType;
+
+ result = cln_SelectLayer(ClientID,&selectionLayer);
+
+ if( CheckError( result ) )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Search for the coordinate. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetObject( ClientID, (char *) id );
+ if( CheckError( result ) )
+ return;
+
+ if( featureType == Matrix || featureType == Image )
+ {
+ DumpRasterObject( result, featureType, 5 );
+ }
+ else
+ {
+ DumpVectorObject( result, featureType );
+ }
+}
+
+/************************************************************************/
+/* CoordSearch() */
+/************************************************************************/
+
+static void CoordSearch( char * layer, ecs_Family featureType,
+ double x, double y )
+
+{
+ ecs_LayerSelection selectionLayer;
+ ecs_Result *result;
+ ecs_Coordinate coord;
+
+/* -------------------------------------------------------------------- */
+/* Define the layer to select. */
+/* -------------------------------------------------------------------- */
+ selectionLayer.Select = (char *) layer;
+ selectionLayer.F = featureType;
+
+ result = cln_SelectLayer(ClientID,&selectionLayer);
+
+ if( CheckError( result ) )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Search for the coordinate. */
+/* -------------------------------------------------------------------- */
+ coord.x = x;
+ coord.y = y;
+ result = cln_GetObjectIdFromCoord( ClientID, &coord );
+ if( CheckError( result ) )
+ return;
+
+ printf( "cln_GetObjectIdFromCoord(%f,%f) = `%s'\n",
+ x, y, ECSTEXT(result) );
+}
+
+/************************************************************************/
+/* DumpDict() */
+/************************************************************************/
+
+static void DumpDict( const char * pszDictName )
+
+{
+ ecs_Result *result;
+
+ result = cln_UpdateDictionary( ClientID, (char *) pszDictName );
+ if( CheckError( result ) )
+ return;
+
+ printf( "UpdateDictionary(%s) = \n%s\n", pszDictName, ECSTEXT(result) );
+}
+
+/************************************************************************/
+/* DumpLayer() */
+/************************************************************************/
+
+static void DumpLayer( const char * options, ecs_Region * region,
+ char * layer, ecs_Family featureType )
+
+{
+ int nObjectCount = 0, i;
+ ecs_Result *result;
+ ecs_Region selectionRegion;
+ ecs_LayerSelection selectionLayer;
+ ecs_ObjAttributeFormat *oaf;
+
+ (void) options;
+
+/* -------------------------------------------------------------------- */
+/* Select a region ... this should be overridable from the */
+/* command line. */
+/* -------------------------------------------------------------------- */
+ if( region != NULL ) {
+ selectionRegion = *region;
+ result = cln_SelectRegion(ClientID,&selectionRegion);
+ if( CheckError( result ) )
+ return;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Define the layer to select. */
+/* -------------------------------------------------------------------- */
+ selectionLayer.Select = (char *) layer;
+ selectionLayer.F = featureType;
+
+ result = cln_SelectLayer(ClientID,&selectionLayer);
+
+ if( CheckError( result ) )
+ return;
+
+ DumpGlobalRegion( NULL, NULL );
+
+/* -------------------------------------------------------------------- */
+/* Dump the attribute definitions. */
+/* -------------------------------------------------------------------- */
+ if( featureType != Matrix && featureType != Image ) {
+ int nSampleCounter = 0;
+
+ result = cln_GetAttributesFormat( ClientID );
+ if( CheckError( result ) )
+ return;
+
+ oaf = &(ECSRESULT(result).oaf);
+ for( i = 0; i < (int) oaf->oa.oa_len; i++ )
+ {
+ printf( "Field %d: %s ", i, oaf->oa.oa_val[i].name );
+
+ if( oaf->oa.oa_val[i].type == Char )
+ printf( " (Char)" );
+ else if( oaf->oa.oa_val[i].type == Varchar )
+ printf( " (Varchar)" );
+ else if( oaf->oa.oa_val[i].type == Longvarchar )
+ printf( " (Longvarchar)" );
+ else if( oaf->oa.oa_val[i].type == Decimal )
+ printf( " (Decimal)" );
+ else if( oaf->oa.oa_val[i].type == Numeric )
+ printf( " (Numeric)" );
+ else if( oaf->oa.oa_val[i].type == Smallint )
+ printf( " (Smallint)" );
+ else if( oaf->oa.oa_val[i].type == Integer )
+ printf( " (Integer)" );
+ else if( oaf->oa.oa_val[i].type == Real )
+ printf( " (Real)" );
+ else if( oaf->oa.oa_val[i].type == Float )
+ printf( " (Float)" );
+ else if( oaf->oa.oa_val[i].type == Double )
+ printf( " (Double)" );
+ else
+ printf( " (unknown)" );
+
+ printf( " %d.%d",
+ oaf->oa.oa_val[i].lenght,
+ oaf->oa.oa_val[i].precision );
+
+ if( oaf->oa.oa_val[i].nullable )
+ printf( " nullable" );
+ printf( "\n" );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Process all shapes. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetNextObject(ClientID);
+ while (ECSSUCCESS(result)) {
+
+ if( ++nSampleCounter >= nSampleFrequency )
+ {
+ DumpVectorObject( result, featureType );
+ nSampleCounter = 0;
+ }
+
+ nObjectCount++;
+ result = cln_GetNextObject(ClientID);
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Report on matrix information. */
+/* -------------------------------------------------------------------- */
+ if( featureType == Matrix || featureType == Image ) {
+ int i;
+ int nSampleCounter = 0;
+ int nDataType = 5;
+
+ printf( "RasterInfo:\n" );
+
+ result = cln_GetRasterInfo( ClientID );
+ if( CheckError( result ) )
+ return;
+
+ printf( "mincat = %ld\n", ECSRASTERINFO(result).mincat );
+ printf( "maxcat = %ld\n", ECSRASTERINFO(result).maxcat );
+
+ printf( "width = %d", ECSRASTERINFO(result).width );
+ if( featureType == Image )
+ {
+ nDataType = ECSRASTERINFO(result).width;
+ if( ECSRASTERINFO(result).width == 1 )
+ printf( " (RGB)" );
+ else if( ECSRASTERINFO(result).width == 2 )
+ printf( " (8U)" );
+ else if( ECSRASTERINFO(result).width == 3 )
+ printf( " (16U)" );
+ else if( ECSRASTERINFO(result).width == 4 )
+ printf( " (16S)" );
+ else if( ECSRASTERINFO(result).width == 5 )
+ printf( " (32S)" );
+ else
+ printf( " (unknown data type)") ;
+
+ }
+ printf( "\nheight = %d\n", ECSRASTERINFO(result).height );
+
+ printf( "cat_len = %d\n", ECSRASTERINFO(result).cat.cat_len );
+
+ for( i = 0; i < (int) ECSRASTERINFO(result).cat.cat_len; i++ ) {
+ printf( "%d: no=%ld, rgb=%d,%d,%d %s\n",
+ i,
+ ECSRASTERINFO(result).cat.cat_val[i].no_cat,
+ ECSRASTERINFO(result).cat.cat_val[i].r,
+ ECSRASTERINFO(result).cat.cat_val[i].g,
+ ECSRASTERINFO(result).cat.cat_val[i].b,
+ ECSRASTERINFO(result).cat.cat_val[i].label );
+ }
+/* -------------------------------------------------------------------- */
+/* Process all lines. */
+/* -------------------------------------------------------------------- */
+ result = cln_GetNextObject(ClientID);
+ while (ECSSUCCESS(result)) {
+
+ if( ++nSampleCounter >= nSampleFrequency )
+ {
+ DumpRasterObject( result, featureType, nDataType );
+ nSampleCounter = 0;
+ }
+
+ nObjectCount++;
+ result = cln_GetNextObject(ClientID);
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Release the layer, and client and cleanup. */
+/* -------------------------------------------------------------------- */
+/* result = cln_ReleaseLayer(ClientID,&selectionLayer); */
+
+ printf( "Object Count = %d\n", nObjectCount );
+}
+
+/************************************************************************/
+/* Usage() */
+/************************************************************************/
+
+static void Usage()
+
+{
+ printf(
+ "Usage: ogdi_info [-no-dict] [-no-proj] -u url\n"
+ " [-dict arg] [-cap] [-ext name [layer]]\n"
+ " -l layername -f family [-r north south east west]\n"
+ " [-dl] [-cs easting northing]\n"
+ " [-id object_id] [-sf sample_frequency]\n" );
+ exit( 1 );
+}
+
+/************************************************************************/
+/* main() */
+/************************************************************************/
+
+int main( int argc, char ** argv )
+{
+ ecs_Family featureType = Point;
+ char *layer = "label";
+ static ecs_Region reg;
+ ecs_Region *region = NULL;
+ ecs_Result *result;
+ int i;
+
+ if( argc == 1 )
+ Usage();
+
+/* -------------------------------------------------------------------- */
+/* Handle commandline arguments. */
+/* -------------------------------------------------------------------- */
+ for( i = 1; i < argc; i++ ) {
+
+ if( strcmp(argv[i],"-dl") == 0 ) {
+ DumpLayer( "", region, layer, featureType );
+ }
+ else if( strcmp(argv[i],"-dr") == 0 ) {
+ DumpGlobalRegion( NULL, NULL );
+ }
+ else if( strcmp(argv[i], "-no-proj") == 0 ) {
+ bNoProj = TRUE;
+ }
+ else if( strcmp(argv[i], "-no-dict") == 0 ) {
+ bNoDict = TRUE;
+ }
+ else if( strcmp(argv[i], "-cap") == 0 ) {
+ DumpCapabilities();
+ }
+ else if( i == argc - 1 ) {
+ /* skip ... the rest require arguments. */
+ Usage();
+ }
+ else if( strcmp(argv[i], "-dict") == 0 ) {
+ DumpDict( argv[++i] );
+ }
+ else if( strcmp(argv[i],"-u") == 0 ) {
+ if( ClientID != -1 ) {
+ result = cln_DestroyClient(ClientID);
+ if( CheckError( result ) )
+ return( FALSE );
+ ecs_CleanUp( result );
+ ClientID = -1;
+ }
+
+ AccessURL( argv[++i], ® );
+ region = ®
+ }
+ else if( strcmp(argv[i], "-l") == 0 ) {
+ layer = argv[++i];
+ }
+ else if( strcmp(argv[i], "-sf") == 0 ) {
+ nSampleFrequency = atoi(argv[++i]);
+ }
+ else if( strcmp(argv[i], "-f") == 0 ) {
+ if( strcmp(argv[i+1],"Point") == 0 )
+ featureType = Point;
+ else if( strcmp(argv[i+1],"Line") == 0 )
+ featureType = Line;
+ else if( strcmp(argv[i+1],"Area") == 0 )
+ featureType = Area;
+ else if( strcmp(argv[i+1],"Text") == 0 )
+ featureType = Text;
+ else if( strcmp(argv[i+1],"Matrix") == 0 )
+ featureType = Matrix;
+ else if( strcmp(argv[i+1],"Image") == 0 )
+ featureType = Image;
+ else
+ fprintf( stderr,
+ "-f argument (%s) not recognised (case matters!)\n",
+ argv[i] );
+ i++;
+ }
+ else if( strcmp(argv[i], "-r") == 0 && i < argc - 4 ) {
+
+ region = ®
+ reg.north = atof(argv[++i]);
+ reg.south = atof(argv[++i]);
+ reg.east = atof(argv[++i]);
+ reg.west = atof(argv[++i]);
+ }
+ else if( strcmp(argv[i], "-cs") == 0 && i < argc - 2 ) {
+ CoordSearch( layer, featureType,
+ atof(argv[i+1]), atof(argv[i+2]) );
+
+ i += 2;
+ }
+ else if( strcmp(argv[i], "-id") == 0 && i < argc - 1 ) {
+ IdSearch( layer, featureType, argv[i+1] );
+ i += 1;
+ }
+ else if( strcmp(argv[i], "-ext") == 0 && i < argc - 1 ) {
+ const char *layer = NULL;
+
+ printf( "Check Extension %s", argv[i+1] );
+
+ if( i < argc - 2 && argv[i+2][0] != '-' )
+ {
+ layer = argv[i+2];
+ printf( " on layer %s", layer );
+ }
+
+ if( cln_CheckExtension( ClientID, argv[i+1], layer ) )
+ printf( ": enabled\n" );
+ else
+ printf( ": not enabled\n" );
+
+ if( layer != NULL )
+ i += 2;
+ else
+ i += 1;
+ }
+ else
+ Usage();
+ }
+
+/* -------------------------------------------------------------------- */
+/* Close old client if there is one active. */
+/* -------------------------------------------------------------------- */
+ if( ClientID != -1 ) {
+ result = cln_DestroyClient(ClientID);
+ if( CheckError( result ) )
+ return( FALSE );
+ ecs_CleanUp( result );
+ ClientID = -1;
+ }
+
+ return 0;
+}
+
+
+
Property changes on: packages/ogdi-dfsg/branches/upstream/current/contrib/ogdi_info/ogdi_info.c
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/include/Linux/ogdi_macro.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/include/Linux/ogdi_macro.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/include/Linux/ogdi_macro.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,48 @@
+#include <signal.h>
+#include <wait.h>
+#include <rpc/xdr.h>
+#include <stdio.h>
+
+#define ogdi_IXDR_PUT_LONG(buf, v) { \
+ long ZF = ((long)IXDR_PUT_INT32(buf, (long)(v))); \
+ ZF = ZF; \
+ }
+
+#define ogdi_IXDR_PUT_U_LONG(buf, v) ogdi_IXDR_PUT_LONG(buf, (long)(v))
+
+
+
+
+// Hook fread/fwrite/fgets/system. Check returns for errors and print tham verbose if any.
+
+#define ogdi_read(p,s,fp) { \
+ unsigned int ZF = read(p,s,fp); \
+ if (ZF == -1 ) \
+ printf("Error: read error\n"); \
+ }
+
+#define ogdi_fread(p,s,n,fp) { \
+ unsigned int ZF = fread(p,s,n,fp); \
+ if (ZF != (unsigned) (n)) \
+ printf("Error: fread found %d bytes, not %d at %d\n", ZF, (int)(n), (int) ftell(fp)); \
+ }
+
+#define ogdi_fwrite(p,s,n,fp) { \
+ unsigned int ZF = fwrite(p,s,n,fp); \
+ if (ZF != (unsigned) (n)) \
+ printf("Error: fwrite wrote %d bytes, not %d at %d\n", ZF, (int)(n), (int) ftell(fp)); \
+ }
+
+#define ogdi_fgets(p,n,fp) { \
+ void *ZF = fgets(p,n,fp); \
+ if (ZF == NULL) \
+ printf("Error: fgets seek error at %d byte\n", (int)(n)); \
+ }
+
+#define ogdi_system(fp) { \
+ int ZF = system(fp); \
+ if (WIFSIGNALED(ZF) && \
+ (WTERMSIG(ZF) == SIGINT || WTERMSIG(ZF) == SIGQUIT)) \
+ printf("Error: shell not found or command error.\n"); \
+ }
+
Added: packages/ogdi-dfsg/branches/upstream/current/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,61 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+EXTRA_INSTALL_TARGETS = mk_nonlocal_install_dirs
+
+include $(TOPDIR)/config/common.mak
+
+#
+# Sub-directories that need to be built
+#
+subdirs = external vpflib ogdi contrib
+
+ifneq ($(PROJ_SETTING),external)
+subdirs := proj $(subdirs)
+endif
+
+#
+# Default target to build everything in all sub-directories
+#
+all: $(subdirs)
+
+
+#
+# Target to allow individual sub-directories to be built
+# (e.g. make cmpts)
+#
+.PHONY: $(subdirs)
+$(subdirs): mkinstalldirs
+ cd $@; $(MAKE)
+
+#
+# Make the (local) installation directories
+#
+.PHONY: mkinstalldirs
+mkinstalldirs:
+ @echo making install dirs using $(MKINSTALLDIR)
+ $(MKINSTALLDIR) $(TOPDIR)/lib/$(TARGET)/static
+ $(MKINSTALLDIR) $(TOPDIR)/bin/$(TARGET)
+
+#
+# Pass specialized targets into the sub-directories
+#
+.PHONY: $(STANDARD_TARGETS)
+$(STANDARD_TARGETS):
+ @for i in $(subdirs); do \
+ $(MAKE) --directory $$i $@; \
+ done
+
+
+mk_nonlocal_install_dirs:
+ $(MKINSTALLDIR) $(prefix) $(exec_prefix) $(INST_LIB) $(INST_BIN) $(INST_INCLUDE)
+
Added: packages/ogdi-dfsg/branches/upstream/current/mkbindist.sh
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/mkbindist.sh 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/mkbindist.sh 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+if [ $# -lt 1 ] ; then
+ echo "Usage: mkbindist.sh version"
+ echo
+ echo "Example: mkbindist.sh 1.1.5"
+ exit
+fi
+
+VERSION=$1
+PLATFORM=$TARGET
+
+#
+# Prepare tree.
+#
+
+DIST_DIR=ogdi-${PLATFORM}-bin.${VERSION}
+
+rm -rf $DIST_DIR
+mkdir $DIST_DIR
+
+mkdir $DIST_DIR/bin
+mkdir $DIST_DIR/include
+
+cp bin/$TARGET/* $DIST_DIR/bin
+cp bin/$TARGET/*.* $DIST_DIR/bin
+rm -f $DIST_DIR/bin/*.pdb
+rm -f $DIST_DIR/bin/core
+rm -f $DIST_DIR/bin/*_pure*
+
+cp ogdi/include/*.h $DIST_DIR/include
+
+sed -e "s/@PLATFORM@/${TARGET}/g" < README-BIN.TXT \
+ | sed -e "s/@VERSION@/${VERSION}/g" > $DIST_DIR/README-BIN.TXT
+
+if test "$TARGET" = "win32" ; then
+ mkdir $DIST_DIR/lib
+ cp lib/$TARGET/ogdi* $DIST_DIR/lib
+fi
+
+#
+# Make compressed distribution file.
+#
+if test "$TARGET" = "win32" ; then
+ rm -f ${DIST_DIR}.zip
+ zip -r ${DIST_DIR}.zip $DIST_DIR
+ echo "Created: ${DIST_DIR}.zip"
+else
+ rm -f ${DIST_DIR}.tar.gz
+ tar cf ${DIST_DIR}.tar ${DIST_DIR}
+ gzip -9 ${DIST_DIR}.tar
+ echo "Created: ${DIST_DIR}.tar.gz"
+fi
Property changes on: packages/ogdi-dfsg/branches/upstream/current/mkbindist.sh
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/mkogdidist.sh
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/mkogdidist.sh 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/mkogdidist.sh 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# Copyright (C) 2001 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TARGETDIR=ogdi.sourceforge.net:ftp-ogdi/.
+
+if [ $# -lt 1 ] ; then
+ echo "Usage: mkogdidist version [-install]"
+ echo
+ echo "Example: mkogdidist 3.1alpha"
+ exit
+fi
+
+OGDI_VERSION=$1
+DIST_NAME=ogdi-$OGDI_VERSION
+
+
+rm -rf dist_wrk
+mkdir dist_wrk
+cd dist_wrk
+
+export CVSROOT=:pserver:anonymous at ogdi.cvs.sourceforge.net:/cvsroot/ogdi
+
+echo "Please hit enter when prompted for a password."
+cvs login
+
+cvs checkout -P devdir
+
+if [ \! -d devdir ] ; then
+ echo "cvs checkout reported an error ... abandoning mkogdidist"
+ exit
+fi
+
+# remove junks
+find devdir -name CVS -exec rm -rf {} \;
+find devdir -name ".cvsignore" -exec rm -rf '{}' \;
+# fix wrongly encoded files from tarball
+set +x
+for f in `find . -type f` ; do
+ if file $f | grep -q ISO-8859 ; then
+ set -x
+ iconv -f ISO-8859-1 -t UTF-8 $f > ${f}.tmp && \
+ mv -f ${f}.tmp $f
+ set +x
+ fi
+ if file $f | grep -q CRLF ; then
+ set -x
+ sed -i -e 's|\r||g' $f
+ set +x
+ fi
+done
+set -x
+
+mv devdir $DIST_NAME
+
+echo "${OGDI_VERSION}: `date`" > $DIST_NAME/VERSION
+
+rm -f ../${DIST_NAME}.tar.gz ../${DIST_NAME}.zip
+
+tar cf ../${DIST_NAME}.tar ${DIST_NAME}
+gzip -9 ../${DIST_NAME}.tar
+zip -r ../${DIST_NAME}.zip ${DIST_NAME}
+
+cd ..
+rm -rf dist_wrk
+
+if test "$2" = "-install" ; then
+ scp ${DIST_NAME}.tar.gz $TARGETDIR
+ scp ${DIST_NAME}.zip $TARGETDIR
+fi
Property changes on: packages/ogdi-dfsg/branches/upstream/current/mkogdidist.sh
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+include $(TOPDIR)/config/common.mak
+# SHELL = /usr/bin/bash
+#
+# Sub-directories that need to be built
+#
+ifeq ($(TARGET),win32)
+subdirs = odbc
+else
+subdirs =
+endif
+
+#
+# Default target to build everything in all sub-directories
+#
+all: $(subdirs)
+
+#
+# Target to allow individual sub-directories to be built
+# (e.g. make odbc)
+#
+.PHONY: $(subdirs)
+$(subdirs):
+ cd $@; $(MAKE)
+
+#
+# Pass specialized targets into the sub-directories
+#
+.PHONY: $(STANDARD_TARGETS)
+$(STANDARD_TARGETS):
+ @for i in null $(subdirs); do \
+ if test $$i != null ; then \
+ $(MAKE) --directory $$i $@; \
+ fi \
+ done
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/lodbc.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/lodbc.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/lodbc.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,12 @@
+LIBRARY LODBC
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_InitializeDBLink
+ dyn_DeinitializeDBLink
+ dyn_GetColumnsInfo
+ dyn_SelectAttributes
+ dyn_IsSelected
+ dyn_GetSelectedAttributes
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = lodbc
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = odbc.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) \
+ $(OGDI_INCLUDE) $(PROJ_INCLUDE)
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(ODBC_LINKLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/odbc.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/odbc.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/odbc.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,700 @@
+/*********************************************************************
+
+ CSOURCE_INFORMATION
+
+ NAME
+ odbc.c
+
+ DESCRIPTION
+ Implementation of the odbc attribute driver
+ END_DESCRIPTION
+
+ END_CSOURCE_INFORMATION
+
+ Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ ********************************************************************/
+
+#include "odbc.h"
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ odbcEnv
+
+ DESCRIPTION
+ The global environment handler. Set only at the first call to
+ dyn_InitializeDBLink. To know if an allocation must be done,
+ check the variable odbc_count.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ HENV odbcEnv: Global environment handler
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+SQLHENV odbcEnv;
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ odbc_count
+
+ DESCRIPTION
+ Indicate the number of layers using this attribute driver.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ int odbc_count: Qty of links.
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+int odbc_count = 0;
+
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ odbc_count
+
+ DESCRIPTION
+ Indicate the number of layers using this attribute driver.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ int odbc_count: Qty of links.
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+char *odbcerrorlist[] = {
+ "Not enough memory"
+};
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_InitializeDBLink
+
+ DESCRIPTION
+ Initialize the database link
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer object attributes
+ OUTPUT
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Set the private data structure to l->attribute_priv and set attributes in
+ it to NULL.
+
+ 2. If odbc_count equal 0, the call SQLAllocEnv and set the odbcEnv
+
+ 3. Increment odbc_count and set l->attribute_priv.isLinked to FALSE.
+
+ 4. Call SQLAllocConnect to initialize the link between SQL and this application.
+ If an error occur, call dyn_DeinitializeDBLink and return an error code
+
+ 5. Call SQLConnect to connect to the ODBC with the attributes initialisation
+ in l->AttributeDriverLinkPtr. Set l->AttributeDriverHandle with it. If an
+ error occur, call dyn_DeinitializeDBLink and return an error code
+
+ 6. Call SQLAllocStmt to prepare the memory of l->attribute_priv.odbcSQLInfo.
+ If an error occur, call dyn_DeinitializeDBLink and return an error code
+
+ 7. Call SQLPrepare to prepare the SQL request execution with the information
+ in l->AttributeDriverLinkPtr.SelectionRequest.
+ If an error occur, call dyn_DeinitializeDBLink and return an error code
+
+ 8. Get the quantity of attribute columns in the selection with
+ SQLColAttributes and set l->attribute_priv.nb_field.
+
+ 9. Set l->attribute_priv.isLinked to TRUE and return a success message.
+
+ ********************************************************************
+ */
+
+int dyn_InitializeDBLink(s,l,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char **error;
+{
+ char buffer[512];
+ unsigned char sqlmessage[SQL_MAX_MESSAGE_LENGTH];
+ unsigned char sqlstate[32];
+ SQLINTEGER truc;
+ short length;
+ PrivateODBCInfo *apriv;
+ char **temp=NULL;
+
+ l->attribute_priv = (void *) malloc(sizeof(PrivateODBCInfo));
+ apriv = (PrivateODBCInfo *) l->attribute_priv;
+ if (l->attribute_priv == NULL) {
+ *error = odbcerrorlist[0];
+ return 1;
+ }
+ apriv->nb_field = 0;
+ apriv->isSelected = FALSE;
+ apriv->attributes = NULL;
+
+ if (odbc_count == 0) {
+ if (SQLAllocEnv(&odbcEnv) != SQL_SUCCESS) {
+ SQLError(odbcEnv, SQL_NULL_HDBC, SQL_NULL_HSTMT, sqlstate,
+ &truc, sqlmessage, SQL_MAX_MESSAGE_LENGTH - 1,
+ &length);
+ *error = (char *)sqlmessage;
+ dyn_DeinitializeDBLink(s,l,temp);
+ return 1;
+ }
+
+ }
+
+ odbc_count++;
+ apriv->isLinked = FALSE;
+ l->AttributeDriverHandle = (void *) &(apriv->odbcHandle);
+
+ if (SQLAllocConnect(odbcEnv,&(apriv->odbcHandle)) != SQL_SUCCESS) {
+ SQLError(odbcEnv, SQL_NULL_HDBC, SQL_NULL_HSTMT, sqlstate,
+ &truc, sqlmessage, SQL_MAX_MESSAGE_LENGTH - 1,
+ &length);
+
+ *error = (char *)sqlmessage;
+ dyn_DeinitializeDBLink(s,l,temp);
+ return 1;
+ }
+
+ if (SQLConnect((SQLHDBC) apriv->odbcHandle,
+ (SQLCHAR *) l->AttributeDriverLinkPtr->InformationSource,
+ (SQLSMALLINT) SQL_NTS,
+ (SQLCHAR *) l->AttributeDriverLinkPtr->UserDescription,
+ (SQLSMALLINT) SQL_NTS,
+ (SQLCHAR *) l->AttributeDriverLinkPtr->AutorizationDescription,
+ (SQLSMALLINT) SQL_NTS) != SQL_SUCCESS) {
+ SQLError(odbcEnv, apriv->odbcHandle, SQL_NULL_HSTMT, sqlstate,
+ &truc, sqlmessage, SQL_MAX_MESSAGE_LENGTH - 1,
+ &length);
+ *error = (char *)sqlmessage;
+ dyn_DeinitializeDBLink(s,l,temp);
+ return 1;
+ }
+
+ if (SQLAllocStmt(apriv->odbcHandle,&(apriv->odbcSqlInfo)) != SQL_SUCCESS) {
+ SQLError(odbcEnv, apriv->odbcHandle, SQL_NULL_HSTMT, sqlstate,
+ &truc, sqlmessage, SQL_MAX_MESSAGE_LENGTH - 1,
+ &length);
+ *error = (char *)sqlmessage;
+
+ dyn_DeinitializeDBLink(s,l,temp);
+ return 1;
+ }
+
+ if (SQLPrepare(apriv->odbcSqlInfo,(unsigned char *)(l->AttrRequest),SQL_NTS) != SQL_SUCCESS) {
+ SQLError(odbcEnv, apriv->odbcHandle, SQL_NULL_HSTMT, sqlstate,
+ &truc, sqlmessage, SQL_MAX_MESSAGE_LENGTH - 1,
+ &length);
+ *error = (char *)sqlmessage;
+ dyn_DeinitializeDBLink(s,l,temp);
+ return 1;
+ }
+
+ SQLColAttributes(apriv->odbcSqlInfo,0,SQL_COLUMN_COUNT,
+ buffer,255,&length,(SQLINTEGER *)&(apriv->nb_field));
+ apriv->isLinked = TRUE;
+
+ return 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_DeinitializeDBLink
+
+ DESCRIPTION
+ Deinitialize the database link
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer object attributes
+ OUTPUT
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. If the selection is link (l->attribute_priv.isLinked).
+ Begin
+
+ 1.1. Call SQLFreeStmt
+ 1.2. Call SQLDisconnect
+ 1.3. Call SQLFreeConnect
+
+ End
+
+ 2. Decrement odbc_count
+
+ 3. If the odbc_count is to 0, call SQLFreeEnv
+
+ ********************************************************************
+ */
+
+int dyn_DeinitializeDBLink(s,l,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char **error;
+{
+ PrivateODBCInfo *apriv;
+
+ apriv = (PrivateODBCInfo *) l->attribute_priv;
+ if (apriv->isLinked == TRUE) {
+ SQLFreeStmt(apriv->odbcSqlInfo,SQL_DROP);
+ SQLDisconnect(apriv->odbcHandle);
+ SQLFreeConnect(apriv->odbcHandle);
+ }
+
+ if (apriv != NULL)
+ free(apriv);
+ l->attribute_priv = NULL;
+ l->AttributeDriverHandle = NULL;
+ odbc_count--;
+ if (odbc_count <= 0) {
+ SQLFreeEnv(odbcEnv);
+ }
+
+ return 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_GetColumnsInfo
+
+ DESCRIPTION
+ Get the column information from the selection string
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer object attributes
+ OUTPUT
+ int *columns_qty: Quantity of columns defined in attr
+ ecs_ObjAttribute **attr: A list of attribute information
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Initialize a table of l->attribute_priv.nb_field elements ecs_ObjAttribute
+ in attr.
+
+ 2. For each field i
+ Begin
+
+ 2.1. Call SQLColAttributes to retreive the name of the attribute and set
+ it in attr[i].name.
+
+ 2.1. Call SQLColAttributes to retreive the type of the attribute and set
+ it in attr[i].type.
+
+ 2.1. Call SQLColAttributes to retreive the lenght of the attribute and set
+ it in attr[i].lenght.
+
+ 2.1. Call SQLColAttributes to retreive the precision of the attribute and set
+ it in attr[i].precision.
+
+ 2.1. Call SQLColAttributes to retreive the nullable of the attribute and set
+ it in attr[i].nullable.
+
+ End
+
+ 3. Set columns_qty with l->attribute_priv.nb_field
+
+ 4. Return a success
+
+ ********************************************************************
+ */
+
+int dyn_GetColumnsInfo(s,l,columns_qty,attr,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int *columns_qty;
+ ecs_ObjAttribute **attr;
+ char **error;
+{
+ int i,j;
+ PrivateODBCInfo *apriv = (PrivateODBCInfo *) l->attribute_priv;
+ int buffer[514];
+ SDWORD count;
+ char name[33];
+ SWORD length;
+ int precision;
+ int type;
+ int nullable;
+ int readlength;
+
+ *attr = malloc(sizeof(ecs_ObjAttribute) * apriv->nb_field);
+ if (*attr == NULL) {
+ *error = odbcerrorlist[0];
+ return 1;
+ }
+
+ for(i=0;i<apriv->nb_field;++i) {
+ SQLColAttributes((SQLHSTMT) apriv->odbcSqlInfo,(SQLUSMALLINT) (i+1),SQL_COLUMN_NAME,
+ name,32,&length,&count);
+ SQLColAttributes((SQLHSTMT) apriv->odbcSqlInfo,(SQLUSMALLINT) (i+1),SQL_COLUMN_TYPE,
+ buffer,513,&length,(SQLINTEGER *)&(type));
+ SQLColAttributes((SQLHSTMT) apriv->odbcSqlInfo,(SQLUSMALLINT) (i+1),SQL_COLUMN_LENGTH,
+ buffer,513,&length,(SQLINTEGER *)&(readlength));
+ SQLColAttributes((SQLHSTMT) apriv->odbcSqlInfo,(SQLUSMALLINT) (i+1),SQL_COLUMN_PRECISION,
+ buffer,513,&length,(SQLINTEGER *)&(precision));
+ SQLColAttributes((SQLHSTMT) apriv->odbcSqlInfo,(SQLUSMALLINT) (i+1),SQL_COLUMN_NULLABLE,
+ buffer,513,&length,(SQLINTEGER *)&(nullable));
+
+ (*attr)[i].name = malloc(strlen(name)+1);
+ if ((*attr)[i].name == NULL) {
+ for(j=0;j<i;j++)
+ free((*attr)[j].name);
+ free(*attr);
+ *error = odbcerrorlist[0];
+ return 1;
+
+ }
+ strcpy((*attr)[i].name,name);
+
+ switch(type) {
+ case SQL_CHAR: (*attr)[i].type = Char;
+ break;
+ case SQL_VARCHAR: (*attr)[i].type = Varchar;
+ break;
+ case SQL_LONGVARCHAR: (*attr)[i].type = Longvarchar;
+ break;
+ case SQL_DECIMAL: (*attr)[i].type = Decimal;
+ break;
+ case SQL_NUMERIC: (*attr)[i].type = Numeric;
+ break;
+ case SQL_SMALLINT: (*attr)[i].type = Smallint;
+ break;
+ case SQL_INTEGER: (*attr)[i].type = Integer;
+ break;
+ case SQL_REAL: (*attr)[i].type = Real;
+ break;
+ case SQL_FLOAT: (*attr)[i].type = Float;
+ break;
+ case SQL_DOUBLE: (*attr)[i].type = Double;
+ break;
+ }
+
+ (*attr)[i].lenght = readlength;
+ (*attr)[i].precision = precision;
+ (*attr)[i].nullable = nullable;
+ }
+
+ *columns_qty = apriv->nb_field;
+
+ return 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_SelectAttributes
+
+ DESCRIPTION
+ Select the attributes defined in the selection request with
+ the attributes set in the arguments.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer object attributes
+ int attribute_qty: The lenght of the attribute list
+ char **attribute_list: List of attributes to be bind with the selection request
+ OUTPUT
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. For each attribute in attribute_list
+ Begin
+ 1.1. Call SQLBindParameter with this attribute. If an error occur,
+ return an error message
+ End
+ 2. Call SQLExecute, if an error occur, return an error message
+ 3. Call SQLFetch. If the result is a success, set l->attribute_priv.isSelected to
+ true. If the return code is SQL_NO_DATA_FOUND, set it to false. Else, return an error
+ message.
+ 4. Free the old l->attribute_priv.attribute if it's different than NULL.
+ Set the l->attribute_priv.attributes to NULL
+ 5. If l->attribute_priv.isSelected is true
+ Begin
+ 5.1. For each field i
+ Begin
+ Call SQLGetData for this field and concatenate the result to l->attribute_priv.attributes
+ End
+ End
+ 6. Return 0
+
+ ********************************************************************
+ */
+
+int dyn_SelectAttributes(s,l,attribute_qty,attribute_list,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int attribute_qty;
+ char **attribute_list;
+ char **error;
+{
+ int i;
+ PrivateODBCInfo *apriv = (PrivateODBCInfo *) l->attribute_priv;
+ char theKey[128];
+ char buffer[1024],buffer2[256];
+ unsigned char sqlmessage[SQL_MAX_MESSAGE_LENGTH];
+ unsigned char sqlstate[32];
+ int truc;
+ SDWORD length;
+ short collength;
+ RETCODE retcode;
+ short count;
+ int type;
+
+ for(i=0;i<attribute_qty;i++) {
+ strcpy(theKey,attribute_list[i]);
+ length = SQL_NTS;
+ if (SQLBindParameter(apriv->odbcSqlInfo, (SQLUSMALLINT) (i+1), SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 127, 0,
+ (SQLPOINTER) theKey, (SQLINTEGER) 0, (SQLINTEGER *) &length) != SQL_SUCCESS) {
+ SQLError(odbcEnv, apriv->odbcHandle, apriv->odbcSqlInfo, sqlstate,
+ (SQLINTEGER *)&truc, sqlmessage, SQL_MAX_MESSAGE_LENGTH - 1,
+ &count);
+ *error = (char *)sqlmessage;
+ return 1;
+ }
+ }
+
+ if (SQLExecute(apriv->odbcSqlInfo) != SQL_SUCCESS) {
+ SQLError(odbcEnv, apriv->odbcHandle, apriv->odbcSqlInfo, sqlstate,
+ (SQLINTEGER *)&truc, sqlmessage, SQL_MAX_MESSAGE_LENGTH - 1,
+ &count);
+ *error = (char *)sqlmessage;
+ SQLFreeStmt(apriv->odbcSqlInfo,SQL_CLOSE);
+ return 1;
+ }
+
+ /*
+ 3. Call SQLFetch. If the result is a success, set l->attribute_priv.isSelected to
+ true. If the return code is SQL_NO_DATA_FOUND, set it to false. Else, return an error
+ message.
+ */
+
+ retcode = SQLFetch(apriv->odbcSqlInfo);
+ if ((retcode == SQL_SUCCESS) || (retcode == SQL_SUCCESS_WITH_INFO)) {
+ apriv->isSelected = TRUE;
+ } else {
+ if (retcode == SQL_NO_DATA_FOUND) {
+ apriv->isSelected = FALSE;
+ } else {
+ SQLError(odbcEnv, apriv->odbcHandle, apriv->odbcSqlInfo, sqlstate,
+ (SQLINTEGER *)&truc, sqlmessage, SQL_MAX_MESSAGE_LENGTH - 1,
+ &count);
+ SQLFreeStmt(apriv->odbcSqlInfo,SQL_CLOSE);
+ return 1;
+ }
+ }
+
+ /*
+ 4. Free the old l->attribute_priv.attribute if it's different than NULL.
+ Set the l->attribute_priv.attributes to NULL
+ */
+
+ if (apriv->attributes != NULL)
+ free(apriv->attributes);
+ apriv->attributes = NULL;
+ strcpy(buffer,"");
+
+ if (apriv->isSelected == TRUE) {
+ for(i = 0; i < apriv->nb_field; ++i) {
+ SQLGetData(apriv->odbcSqlInfo,(SQLUSMALLINT) (i+1), SQL_C_CHAR,
+ buffer2, 255, &length);
+ SQLColAttributes(apriv->odbcSqlInfo,(SQLUSMALLINT) (i+1),SQL_COLUMN_TYPE,
+ buffer,32,&collength,(SQLINTEGER *)&(type));
+
+ if ((type < 2) || (type > 8)) {
+ sprintf(&(buffer[strlen(buffer)]),"{%s} ",buffer2);
+ } else {
+ sprintf(&(buffer[strlen(buffer)]),"%s ",buffer2);
+ }
+ }
+
+ apriv->attributes = malloc(strlen(buffer)+1);
+ if (apriv->attributes == NULL) {
+ SQLFreeStmt(apriv->odbcSqlInfo,SQL_CLOSE);
+ *error = odbcerrorlist[0];
+ return 1;
+ }
+ strcpy(apriv->attributes,buffer);
+ }
+
+ SQLFreeStmt(apriv->odbcSqlInfo,SQL_CLOSE);
+
+ return 0;
+
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_IsSelected
+
+ DESCRIPTION
+ This method indicate to the ogdi if the function is inside the selection
+ request execute in SelectAttributes
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer object attributes
+ OUTPUT
+ short *isSelected: Indication if the current object
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Return l->attribute_priv.isSelected
+
+ ********************************************************************
+ */
+
+int dyn_IsSelected(s,l,isSelected,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ short *isSelected;
+ char **error;
+{
+ PrivateODBCInfo *apriv = (PrivateODBCInfo *) l->attribute_priv;
+ *isSelected = apriv->isSelected;
+ return 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_GetSelectedAttributes
+
+ DESCRIPTION
+ Get the record in the table selected previously with dyn_SelectAttributes
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer object attributes
+ OUTPUT
+ char **attributes: A string with all the attributes
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Return l->attribute_priv.attributes
+
+ ********************************************************************
+ */
+
+int dyn_GetSelectedAttributes(s,l,attributes,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char **attributes;
+ char **error;
+{
+ PrivateODBCInfo *apriv = (PrivateODBCInfo *) l->attribute_priv;
+ *attributes = apriv->attributes;
+ return 0;
+}
+
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/odbc.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/odbc.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/attr_driver/odbc/odbc.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,73 @@
+/*********************************************************************
+
+ CSOURCE_INFORMATION
+
+ NAME
+ odbc.h
+
+ DESCRIPTION
+ Header file of the odbc attribute driver
+ END_DESCRIPTION
+
+ END_CSOURCE_INFORMATION
+
+ Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ ********************************************************************/
+
+#ifndef ODBCDRIVER
+#define ODBCDRIVER
+
+#include "ecs.h"
+#include "sql.h"
+#include "sqlext.h"
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ PrivateODBCInfo
+
+ DESCRIPTION
+ The private information of this attribute driver.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ HSTMT odbcSqlInfo: SQL request handler
+ int nb_field: Field quantity in the odbcSqlInfo structure
+ int isLinked: Indicate if a link with odbc is active
+ int isSelected: Indicate if the current request get something in it
+ char *attributes: The attribute list.
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+
+typedef struct {
+ SQLHDBC odbcHandle;
+ SQLHSTMT odbcSqlInfo;
+ int nb_field;
+ int isLinked;
+ int isSelected;
+ char *attributes;
+} PrivateODBCInfo;
+
+#endif
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/client.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/client.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/client.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,4584 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Control dispatch of locals client. Also control cache management
+ * and projection changes.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: client.c,v $
+ * Revision 1.15 2007/02/19 19:31:33 cbalint
+ * Reimplement Matrix algebra under an opensource compatible license.
+ * Modified Files:
+ * LICENSE ogdi/c-api/client.c ogdi/c-api/makefile
+ * Added Files:
+ * ogdi/c-api/matrix.c ogdi/c-api/matrix.h
+ *
+ * Revision 1.14 2007/02/12 15:52:57 cbalint
+ *
+ * Preliminary cleanup.
+ * Get rif of unitialized variables, and unused ones.
+ *
+ * Revision 1.13 2004/02/19 06:20:09 warmerda
+ * ecs_CleanUp() cln_dummy_result in ecs_DestroyServer()
+ *
+ * Revision 1.12 2003/08/27 05:26:36 warmerda
+ * Call ecs_SplitURL(NULL) in cln_DestroyClient() to free static resources.
+ * This makes use of memory checkers easier even though this wasn't a *real*
+ * memory leak.
+ *
+ * Revision 1.11 2001/10/01 19:51:13 warmerda
+ * fixed bug in cln_CalcCtlPoints() with 1 pixel regions
+ *
+ * Revision 1.10 2001/08/16 15:34:23 warmerda
+ * fixed roundoff bug with width/height in cln_ConvRegion
+ *
+ * Revision 1.9 2001/05/04 17:59:37 warmerda
+ * clear autoCache in cln_SelectRegion
+ *
+ * Revision 1.8 2001/04/12 18:14:16 warmerda
+ * added/finished capabilities support
+ *
+ * Revision 1.7 2001/04/12 05:31:23 warmerda
+ * added init/free support for capabilities fields in ecs_Client
+ *
+ * Revision 1.6 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+#include "matrix.h"
+#include <assert.h>
+
+ECS_CVSID("$Id: client.c,v 1.15 2007/02/19 19:31:33 cbalint Exp $");
+
+/*
+ Definitions specific to c_interface
+ */
+
+static int multiblock = 0;
+
+ecs_Result cln_dummy_result;
+
+ecs_Client *soc[MAXCLIENT] = {
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+};
+
+
+char *cln_messages[] = {
+ "success",
+ "no more memory",
+ "client not found",
+ "unable to set the client projection",
+ "unable to set the server projection",
+ "maximum number of clients reached",
+ "cache not found",
+ "ecs_Result do not contain an object",
+ "unable to change the projection of this point",
+ "unable to split this projection",
+ "unable to convert the actual region",
+ "unable to convert the global region",
+ "Invalid layer type for a cache",
+ "Invalid region returned by the server",
+ "unable to execute the command, the OGDI is blocked"
+};
+
+char cln_empty_string[1] = "";
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_FreeClient: Free the client structure
+ *
+ * IN
+ * ecs_Client *cln: Client to be freed
+ *
+ * MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+ * Description: Free the cahche using the cln_FreeCache() function
+ * instead of freeing only the cache autocache pointer
+ * that causes memory leaks.
+ * Addition of NULL pointer assignment after the free.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void cln_FreeClient(cln)
+ ecs_Client **cln;
+{
+ if ((*cln) != NULL) {
+ if ((*cln)->url != NULL) {
+ free((*cln)->url);
+ (*cln)->url = NULL;
+ }
+ if ((*cln)->cache != NULL) {
+ cln_FreeCache((*cln)->cache);
+ (*cln)->cache = NULL;
+ }
+ if ((*cln)->autoCache != NULL)
+ {
+ cln_FreeCache((*cln)->autoCache);
+ (*cln)->autoCache = NULL;
+ }
+ if ((*cln)->tclprocname != NULL)
+ {
+ free((*cln)->tclprocname);
+ (*cln)->tclprocname = NULL;
+ }
+ if ((*cln)->mask != NULL) {
+ if ((*cln)->mask->c.c_val != NULL) {
+ free((*cln)->mask->c.c_val);
+ (*cln)->mask->c.c_val = NULL;
+ }
+ free((*cln)->mask);
+ (*cln)->mask = NULL;
+ }
+ if ((*cln)->target != NULL)
+ {
+ pj_free((*cln)->target);
+ (*cln)->target = NULL;
+ }
+ if ((*cln)->target_proj != NULL)
+ {
+ free((*cln)->target_proj);
+ (*cln)->target_proj = NULL;
+ }
+ if ((*cln)->source != NULL)
+ {
+ pj_free((*cln)->source);
+ (*cln)->source = NULL;
+ }
+ if ((*cln)->dthandle != NULL && ((*cln)->nad_close != NULL)) {
+ ((*cln)->nad_close)((*cln)->privdatuminfo);
+ ecs_CloseDynamicLib((*cln)->dthandle);
+ (*cln)->privdatuminfo = NULL;
+ (*cln)->nad_close = NULL;
+ (*cln)->dthandle = NULL;
+ }
+
+ if( (*cln)->global_extensions != NULL )
+ {
+ int i;
+
+ for( i = 0; (*cln)->global_extensions[i] != NULL; i++ )
+ free( (*cln)->global_extensions[i] );
+ free( (*cln)->global_extensions );
+ (*cln)->global_extensions = NULL;
+ }
+
+ if( (*cln)->layer_cap_count > 0 )
+ {
+ int lindex;
+
+ for( lindex = 0; lindex < (*cln)->layer_cap_count; lindex++ )
+ {
+ ecs_LayerCapabilities *layer;
+ int i;
+
+ layer = (*cln)->layer_cap[lindex];
+
+ if( layer->name != NULL )
+ free( layer->name );
+ if( layer->title != NULL )
+ free( layer->title );
+ if( layer->srs != NULL )
+ free( layer->srs );
+
+ for( i = 0;
+ layer->parents != NULL && layer->parents[i] != NULL;
+ i++ )
+ {
+ free( layer->parents[i] );
+ }
+ if( layer->parents != NULL )
+ free( layer->parents );
+
+ for( i = 0;
+ layer->extensions != NULL && layer->extensions[i] != NULL;
+ i++ )
+ {
+ free( layer->extensions[i] );
+ }
+ if( layer->extensions != NULL )
+ free( layer->extensions );
+
+ if( layer->qe_prefix != NULL )
+ free( layer->qe_prefix );
+ if( layer->qe_suffix != NULL )
+ free( layer->qe_suffix );
+ if( layer->qe_format != NULL )
+ free( layer->qe_format );
+ if( layer->qe_description != NULL )
+ free( layer->qe_description );
+
+ free( layer );
+ }
+
+ free( (*cln)->layer_cap );
+
+ (*cln)->layer_cap = NULL;
+ (*cln)->layer_cap_count = 0;
+ }
+
+ free((*cln));
+ (*cln) = NULL;
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_AllocClient: Add a client in the table
+ *
+ * IN
+ * URL: Url of the client
+ * OUT
+ * error_code: pointer to an error code. This code is the position
+ * in the cln_messages.
+ *
+ * Results:
+ * int: ClientID to the new client.
+ * If negative, an error occur in the operation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_AllocClient(URL, error_code)
+ char *URL;
+ int *error_code;
+{
+ ecs_Client *cln;
+ int i,ClientID;
+
+ *error_code = 0;
+
+ /*
+ * Found the new client position.
+ */
+
+ ClientID = -1;
+ for(i=0;i<MAXCLIENT;i++) {
+ if (soc[i] == NULL) {
+ ClientID = i;
+ break;
+ }
+ }
+ if (ClientID == -1) {
+ /* no avalable client space, return a error message */
+ *error_code = 5;
+ return ClientID;
+ }
+
+ /*
+ * Client allocation
+ */
+
+ cln = (ecs_Client *) calloc(1,sizeof(ecs_Client));
+ if (cln != NULL) {
+ cln->url = (char *) malloc(strlen(URL)+1);
+ if (cln->url != NULL)
+ strcpy(cln->url,URL);
+ cln->cache = NULL;
+ cln->autoCache = NULL;
+ cln->selectCache = NULL;
+ cln->tclprocname = NULL;
+ cln->target = NULL;
+ cln->source = NULL;
+ cln->target_proj = NULL;
+ cln->isSourceLL = FALSE;
+ cln->isTargetLL = FALSE;
+ cln->isProjEqual = FALSE;
+ cln->currentSelectionFamily = 0;
+ cln->isCurrentRegionSet = FALSE;
+ cln->targetdatum = nodatum;
+ cln->sourcedatum = nodatum;
+ strcpy(cln->datumtable,"");
+ cln->dthandle = NULL;
+ cln->nad_init = NULL;
+ cln->nad_forward = NULL;
+ cln->nad_reverse = NULL;
+ cln->nad_close = NULL;
+ cln->mask = NULL;
+ strcpy( cln->server_version_str, "3.0" );
+ cln->server_version = 3000;
+ }
+
+ if ((cln == NULL) || (cln->url == NULL)) {
+ cln_FreeClient(&(cln));
+ /* no memory space left, return a error message */
+ *error_code = 1;
+ return -1;
+ }
+ soc[ClientID] = cln;
+
+ return ClientID;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_BroadCloseLayers: For each URL, call the svr_CloseLayer command.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void cln_BroadCloseLayers()
+{
+ int i;
+ for(i=0;i<MAXCLIENT;i++) {
+ if (soc[i] != NULL) {
+ svr_CloseLayer(&(soc[i]->s));
+ }
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ * Client creation. Will register this new client into
+ * a global structure (soc).
+ *
+ * IN
+ * URL: This string is used to create a new server
+ *
+ * OUT
+ * ecs_Result: Operation result
+ * ReturnedID: ClientID of the new client
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_CreateClient(ReturnedID,URL)
+ int *ReturnedID;
+ char *URL;
+{
+ ecs_Client *cln;
+ int i;
+ ecs_Result *res;
+ int error_code;
+ char *projection;
+
+ if (multiblock != 0) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[14]);
+ return res;
+ }
+
+ /*
+ * Check actual clients is there is a client with the same URL.
+ * If it's the case, return this ClientID.
+ */
+
+ if ((i = cln_GetClientIdFromURL(URL)) >= 0) {
+ *ReturnedID = i;
+
+ /*
+ Because the CreateClient could be call more than one time for a client,
+ it is possible the projection change. Specially for the unknown projections.
+ */
+
+ cln = soc[*ReturnedID];
+ res = svr_GetServerProjection(&(cln->s));
+ if ((res->error == 0) && (res->res.type == AText)) {
+ projection = (char *) malloc(strlen(res->res.ecs_ResultUnion_u.s)+1);
+ if (projection != NULL) {
+ strcpy(projection,res->res.ecs_ResultUnion_u.s);
+ res = cln_SetClientProjection(*ReturnedID,projection);
+ free(projection);
+ } else {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[1]);
+ cln_FreeClient(&cln);
+ soc[*ReturnedID] = NULL;
+ *ReturnedID = -1;
+ }
+ } else {
+ return res;
+ }
+
+ ecs_SetSuccess(&cln_dummy_result);
+ return &cln_dummy_result;
+ }
+
+ if (((*ReturnedID) = cln_AllocClient(URL,&error_code)) < 0) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[error_code]);
+ } else {
+ cln = soc[*ReturnedID];
+
+ /*
+ * Call the server creation. If an error occur, destroy
+ * the client.
+ */
+
+ res = svr_CreateServer(&(cln->s),URL,1);
+ if (res->error == 1) {
+ cln_FreeClient(&cln);
+ soc[*ReturnedID] = NULL;
+ *ReturnedID = -1;
+ } else {
+ /*
+ * The CreateServer is a success. Now get the source projection
+ * and set the target projection with this projection as a
+ * default value.
+ */
+
+ res = svr_GetServerProjection(&(cln->s));
+ if ((res->error == 0) && (res->res.type == AText)) {
+ projection = (char *) malloc(strlen(res->res.ecs_ResultUnion_u.s)+1);
+ if (projection != NULL) {
+ strcpy(projection,res->res.ecs_ResultUnion_u.s);
+ res = cln_SetClientProjection(*ReturnedID,projection);
+ free(projection);
+ } else {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[1]);
+ cln_FreeClient(&cln);
+ soc[*ReturnedID] = NULL;
+ *ReturnedID = -1;
+ }
+ }
+ }
+ }
+
+ return res;
+}
+
+/*
+ *----------------------------------------------------------------------
+ * Client destruction. Will destroy the client and free
+ * is location into soc.
+ *
+ * IN
+ * ClientID: Id of the client in soc
+ *
+ * OUT
+ * ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_DestroyClient(ClientID)
+ int ClientID;
+{
+ ecs_Client *cln;
+ ecs_Result *msg;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[2]);
+ return msg;
+ }
+
+ msg = svr_DestroyServer(&(cln->s));
+ cln_FreeClient(&cln);
+ soc[ClientID] = NULL;
+
+ /* free regex resources for spliturl */
+ ecs_SplitURL( NULL, NULL, NULL, NULL );
+ ecs_CleanUp( &cln_dummy_result );
+
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ * cln_SelectLayer: Select a layer of object in the database.
+ * If the layer is present in a local cache, the selection
+ * will be there.
+ *
+ * IN
+ * int ClientID: Id of the client in soc
+ * ecs_LayerSelection *ls: Layer information structure
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+
+ecs_Result *cln_SelectLayer(ClientID, ls)
+ int ClientID;
+ ecs_LayerSelection *ls;
+{
+ ecs_Cache *CachePtr;
+ register ecs_Client *cln;
+ ecs_Result *res;
+ char *error_message;
+ ecs_CtlPoints *cpts;
+ ecs_Region region;
+ int regionset = FALSE;
+ int code;
+
+ if (multiblock != 0) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[14]);
+ return res;
+ }
+
+ cln = soc[ClientID];
+
+ if (cln == NULL) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[2]);
+ return res;
+ }
+
+ /*
+ * Found the cache related to this request
+ */
+
+ CachePtr = cln_FoundCache(ClientID, ls);
+ if (CachePtr != NULL) {
+ cln->selectCache = CachePtr;
+ res = &cln_dummy_result;
+ CachePtr->currentpos = 0;
+ ecs_SetSuccess(res);
+ } else {
+ cln->selectCache = NULL;
+ res = svr_SelectLayer(&(cln->s),ls);
+ cln->currentSelectionFamily = ls->F;
+ if (res->error == 0 && res->res.type == GeoRegion) {
+ region.north = res->res.ecs_ResultUnion_u.gr.north;
+ region.south = res->res.ecs_ResultUnion_u.gr.south;
+ region.east = res->res.ecs_ResultUnion_u.gr.east;
+ region.west = res->res.ecs_ResultUnion_u.gr.west;
+ region.ns_res = res->res.ecs_ResultUnion_u.gr.ns_res;
+ region.ew_res = res->res.ecs_ResultUnion_u.gr.ew_res;
+ regionset = TRUE;
+ }
+ }
+
+ if ((res->error == 0) && ((cln->currentSelectionFamily == Matrix) ||
+ (cln->currentSelectionFamily == Image))) {
+ cpts = NULL;
+ if (!cln_SetRasterConversion(ClientID,&cpts,nn,projective,&error_message)) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,error_message);
+ return res;
+ }
+ }
+
+ if (cln->autoCache != NULL) {
+ cln_FreeCache(cln->autoCache);
+ cln->autoCache = NULL;
+ }
+
+ if (regionset == TRUE) {
+ if (region.north != region.south &&
+ region.west != region.east &&
+ region.ew_res != 0.0 &&
+ region.ns_res != 0.0) {
+ code = cln_ConvRegion(ClientID,®ion,ECS_STOT);
+ if (code != 0) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[code]);
+ return res;
+ }
+ } else {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[13]);
+ return res;
+ }
+
+ ecs_SetGeoRegion(res,region.north, region.south,
+ region.east, region.west, region.ns_res,
+ region.ew_res);
+ ecs_SetSuccess(res);
+ }
+
+ return res;
+}
+
+/*
+ *----------------------------------------------------------------------
+ * cln_ReleaseLayer: Release a layer of object in the database.
+ * If the layer is actually in this local cache, this selection will be
+ * unset.
+ *
+ * IN
+ * int ClientID: Id of the client in soc
+ * ecs_LayerSelection *ls: Layer information structure
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_ReleaseLayer(ClientID, ls)
+ int ClientID;
+ ecs_LayerSelection *ls;
+{
+ register ecs_Client *cln;
+ ecs_Result *res;
+
+ if (multiblock != 0) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[14]);
+ return res;
+ }
+
+ cln = soc[ClientID];
+
+ if (cln == NULL) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[2]);
+ return res;
+ }
+
+ /*
+ * check is the actual cache is this request
+ */
+
+ if ((cln->selectCache != NULL) &&
+ (cln->selectCache->coverage.Select != NULL) &&
+ (strcmp(cln->selectCache->coverage.Select,ls->Select) == 0) &&
+ (cln->selectCache->coverage.F == ls->F)) {
+ cln->selectCache = NULL;
+ }
+
+ if (cln->autoCache != NULL) {
+ cln_FreeCache(cln->autoCache);
+ cln->autoCache = NULL;
+ }
+
+ res = svr_ReleaseLayer(&(cln->s),ls);
+ return res;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_SelectRegion: Select the geographic region on the server.
+ *
+ * IN
+ * int ClientID: Client identifier
+ * ecs_Region *gr: Geographic region
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_SelectRegion(ClientID, gr)
+ int ClientID;
+ ecs_Region *gr;
+{
+ ecs_Result *msg;
+ ecs_Region tmpgr;
+ register ecs_Client *cln;
+ char *error_message;
+ ecs_CtlPoints *cpts;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[2]);
+ return msg;
+ }
+
+ tmpgr.north = gr->north;
+ tmpgr.south = gr->south;
+ tmpgr.east = gr->east;
+ tmpgr.west = gr->west;
+ tmpgr.ns_res = gr->ns_res;
+ tmpgr.ew_res = gr->ew_res;
+
+ cln->currentRegion.north = gr->north;
+ cln->currentRegion.south = gr->south;
+ cln->currentRegion.east = gr->east;
+ cln->currentRegion.west = gr->west;
+ cln->currentRegion.ns_res = gr->ns_res;
+ cln->currentRegion.ew_res = gr->ew_res;
+
+ cln_ConvRegion(ClientID,&(tmpgr),ECS_TTOS);
+ cln->isCurrentRegionSet = TRUE;
+
+ msg = svr_SelectRegion(&(cln->s),&tmpgr);
+
+ if (cln->autoCache != NULL) {
+ cln_FreeCache(cln->autoCache);
+ cln->autoCache = NULL;
+ }
+
+ if ((msg->error == 0) && ((cln->currentSelectionFamily == Matrix) ||
+ (cln->currentSelectionFamily == Image))) {
+ cpts = NULL;
+ if (!cln_SetRasterConversion(ClientID,&cpts,nn,projective,&error_message)) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,error_message);
+ return msg;
+ }
+ }
+
+ return msg;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_SelectMask --
+ *
+ * Set a polygon mask for object retreival.
+ *
+ * PARAMETERS
+ * INPUT
+ * int ClientID: Client's identifier
+ * ecs_FeatureRing *mask: The mask itself
+ * int isInclusive: A boolean that indicate if the selected objects will be completely inside (TRUE) or only partially inside (FALSE) the polygon
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Set the attributes in ecs_Client with the polygon and the flag
+ * set in the parameters of the function.
+ *
+ * 2. Return a success message
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_SelectMask(ClientID, mask, isInclusive)
+ int ClientID;
+ ecs_FeatureRing *mask;
+ int isInclusive;
+{
+ ecs_Result *msg;
+ register ecs_Client *cln;
+ int i;
+
+ (void) isInclusive;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[2]);
+ return msg;
+ }
+
+ if (cln->mask != NULL) {
+ if (cln->mask->c.c_val != NULL)
+ free(cln->mask->c.c_val);
+ free(cln->mask);
+ cln->mask = NULL;
+ }
+
+ cln->mask = (ecs_FeatureRing *) malloc(sizeof(ecs_FeatureRing));
+ if (cln->mask == NULL) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[1]);
+ return msg;
+ }
+
+ cln->mask->centroid.x = mask->centroid.x;
+ cln->mask->centroid.y = mask->centroid.y;
+ cln->mask->c.c_len = mask->c.c_len;
+
+ cln->mask->c.c_val = (ecs_Coordinate *) malloc(sizeof(ecs_Coordinate)*mask->c.c_len);
+ if (cln->mask->c.c_val == NULL) {
+ free(cln->mask);
+ cln->mask = NULL;
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[1]);
+ return msg;
+ }
+
+ cln->maskregion.west = cln->maskregion.east = mask->c.c_val[0].x;
+ cln->maskregion.north = cln->maskregion.south = mask->c.c_val[0].y;
+ for (i=0;i<(int) mask->c.c_len;i++) {
+ cln->mask->c.c_val[i].x = mask->c.c_val[i].x;
+ cln->mask->c.c_val[i].y = mask->c.c_val[i].y;
+
+ if (cln->maskregion.west > mask->c.c_val[i].x)
+ cln->maskregion.west = mask->c.c_val[i].x;
+ if (cln->maskregion.east < mask->c.c_val[i].x)
+ cln->maskregion.east = mask->c.c_val[i].x;
+ if (cln->maskregion.south > mask->c.c_val[i].y)
+ cln->maskregion.south = mask->c.c_val[i].y;
+ if (cln->maskregion.north < mask->c.c_val[i].y)
+ cln->maskregion.north = mask->c.c_val[i].y;
+ }
+
+ msg = &cln_dummy_result;
+ ecs_SetText(msg,"");
+ ecs_SetSuccess(msg);
+ return msg;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_UnSelectMask --
+ *
+ * Unselect a previously selected mask
+ *
+ * PARAMETERS
+ * INPUT
+ * int ClientID: Client's identifier
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Free the memory of the mask in ecs_Client
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_UnSelectMask(ClientID)
+ int ClientID;
+{
+ ecs_Result *msg;
+ register ecs_Client *cln;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[2]);
+ return msg;
+ }
+
+ if (cln->mask != NULL) {
+ if (cln->mask->c.c_val != NULL)
+ free(cln->mask->c.c_val);
+ free(cln->mask);
+ cln->mask = NULL;
+ }
+
+ msg = &cln_dummy_result;
+ ecs_SetText(msg,"");
+ ecs_SetSuccess(msg);
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetDictionary: Get the dictionary from the server
+ *
+ * IN
+ * int ClientID: Client identifier
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+
+ecs_Result *cln_GetDictionary(ClientID)
+ int ClientID;
+{
+ register ecs_Client *cln;
+ ecs_Result *msg;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+
+ msg = svr_GetDictionary(&(cln->s));
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetAttributesFormat: Get the attribute format of a given layer
+ *
+ * IN
+ * int ClientID: Client identifier
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_GetAttributesFormat(ClientID)
+ int ClientID;
+{
+ register ecs_Client *cln;
+ ecs_Result *msg;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+
+ msg = svr_GetAttributesFormat(&(cln->s));
+ return msg;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetNextObject: Get the next selected object in the server.
+ *
+ * IN
+ * int ClientID: Client identifier
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+
+ecs_Result *cln_GetNextObject(ClientID)
+ int ClientID;
+{
+ ecs_Result *msg, *obj, *temp;
+ register ecs_Client *cln;
+ int code;
+ int pos;
+ ecs_Cache *cache;
+ int n;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[2]);
+ return msg;
+ }
+
+ /*
+ * Extract the object
+ */
+
+ if (cln->selectCache) {
+ cache = cln->selectCache;
+ } else if (cln->autoCache) {
+ cache = cln->autoCache;
+ } else {
+ cache = NULL;
+ }
+
+ msg = NULL;
+ if (cache) {
+ pos = cache->currentpos - cache->startpos;
+ if (pos >= 0 && pos < cache->size) {
+ msg = cache->o[pos];
+ if (msg->res.type == Object) {
+ code = cln_ChangeProjection(ClientID, &(msg->res.ecs_ResultUnion_u.dob));
+ if (code > 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[code]);
+ }
+ }
+
+ while (!(cln_IsGeoObjectInsideMask(ClientID,msg)) && !(msg->error)) {
+ cache->currentpos++;
+ pos = cache->currentpos - cache->startpos;
+ if (pos >= 0 && pos < cache->size-1) {
+ msg = cache->o[pos];
+ if (msg->res.type == Object) {
+ code = cln_ChangeProjection(ClientID, &(msg->res.ecs_ResultUnion_u.dob));
+ if (code > 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[code]);
+ }
+ }
+ } else {
+ msg = &cln_dummy_result;
+ ecs_SetSuccess(msg);
+ break;
+ }
+ }
+
+ cache->currentpos++;
+ if (msg->error) {
+ ecs_SetError(&cln_dummy_result,msg->error,msg->message);
+ msg = &cln_dummy_result;
+ cln_FreeCache(cln->autoCache);
+ cln->autoCache = NULL;
+ return msg;
+ }
+ } else if (cln->selectCache) {
+ /* Not allowed outside the bounds of the cache with explicit caches */
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,2,"End of selection in cache");
+ return msg;
+ } else {
+ cln_FreeCache(cln->autoCache);
+ cln->autoCache = NULL;
+ }
+ }
+
+ if (msg == NULL) {
+ msg = svr_GetNextObject(&(cln->s));
+ if (msg->res.type == Object) {
+ code = cln_ChangeProjection(ClientID, &(msg->res.ecs_ResultUnion_u.dob));
+ if (code > 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[code]);
+ }
+ }
+
+ /*
+ * Apply the filter of the mask if not MultiResult
+ */
+
+ while ((msg->res.type != MultiResult) && !(msg->error) && !(cln_IsGeoObjectInsideMask(ClientID,msg))) {
+ msg = svr_GetNextObject(&(cln->s));
+ if (msg->res.type == Object) {
+ code = cln_ChangeProjection(ClientID, &(msg->res.ecs_ResultUnion_u.dob));
+ if (code > 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[code]);
+ }
+ }
+ }
+
+ /*
+ * If the result contains multiple pieces, we need to break
+ * the response into separate result pieces.
+ */
+
+ if (msg->res.type == MultiResult) {
+ n = msg->res.ecs_ResultUnion_u.results.results_len;
+ if (msg->error) {
+ n++;
+ }
+ cache = cln_NewCache(n);
+ if(cache == NULL) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg, 1, cln_messages[1]);
+ return msg;
+ }
+
+ for (n = 0; n < (int) msg->res.ecs_ResultUnion_u.results.results_len; n++) {
+ code = ecs_CopyResultFromUnion(&msg->res.ecs_ResultUnion_u.results.results_val[n],&obj);
+ if (code == FALSE) {
+ cln_FreeCache(cache);
+
+ msg = &cln_dummy_result;
+ ecs_SetError(msg, 1, cln_messages[1]);
+ return msg;
+ }
+ cache->o[cache->size++] = obj;
+ }
+ if (msg->error) {
+ obj = malloc(sizeof(ecs_Result));
+ obj->message = NULL;
+ ecs_SetError(obj,msg->error,msg->message);
+ cache->o[cache->size++] = obj;
+ }
+ cln->autoCache = cache;
+ temp = cln_GetNextObject(ClientID);
+ return temp;
+ }
+ }
+ return msg;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ cln_IsGeoObjectInsideMask
+
+ Indicate if the object is inside the mask. If the object
+ is not valid or the mask don't exist, return a success message (the
+ program will handle the error but we must give him the chance to do
+ it). Only vector is handle by this function, but it could be modified
+ in the future to clip rasters.
+
+ PARAMETERS
+ INPUT
+ int ClientID: Client's identifier
+ ecs_Result *obj: The geographic object
+
+ RETURN_VALUE
+ int : The boolean indication if the object is outside or inside the mask
+
+ PSEUDO_CODE
+
+
+ ----------------------------------------------------------------------
+ */
+
+int cln_IsGeoObjectInsideMask(ClientID, obj)
+ int ClientID;
+ ecs_Result *obj;
+{
+ register ecs_Client *cln;
+
+ cln = soc[ClientID];
+ if (cln == NULL)
+ return TRUE;
+
+ if (obj->res.type != Object)
+ return TRUE;
+ if (obj->res.ecs_ResultUnion_u.dob.geom.family != Line &&
+ obj->res.ecs_ResultUnion_u.dob.geom.family != Area &&
+ obj->res.ecs_ResultUnion_u.dob.geom.family != Point &&
+ obj->res.ecs_ResultUnion_u.dob.geom.family != Text)
+ return TRUE;
+
+ /*
+ If the mask don't exist, the object is always valid
+ */
+
+ if (cln->mask == NULL)
+ return TRUE;
+
+ /*
+ Check the bounding box of the object, if it's outside the extent of the mask,
+ always return FALSE
+ */
+
+ if (!((cln->maskregion.north > obj->res.ecs_ResultUnion_u.dob.ymin) &&
+ (cln->maskregion.south < obj->res.ecs_ResultUnion_u.dob.ymax) &&
+ (cln->maskregion.east > obj->res.ecs_ResultUnion_u.dob.xmin) &&
+ (cln->maskregion.west < obj->res.ecs_ResultUnion_u.dob.xmax))) {
+ return FALSE;
+ }
+
+ /*
+ Knowing the object is inside the extent of the mask is not enough. Check each corner
+ of the extent of the object. If one of the corner is inside the mask and cln->isMaskInclusive
+ is FALSE, return TRUE. If the four corner is inside the mask and cln->isMaskInclusive is TRUE,
+ return TRUE. Else, return FALSE.
+ */
+
+ if (ecs_IsPointInPolygon(cln->mask->c.c_len,cln->mask->c.c_val,
+ obj->res.ecs_ResultUnion_u.dob.xmin,
+ obj->res.ecs_ResultUnion_u.dob.ymin)) {
+ if (!cln->isMaskInclusive)
+ return TRUE;
+ }
+
+ if (ecs_IsPointInPolygon(cln->mask->c.c_len,cln->mask->c.c_val,
+ obj->res.ecs_ResultUnion_u.dob.xmin,
+ obj->res.ecs_ResultUnion_u.dob.ymax)) {
+ if (!cln->isMaskInclusive)
+ return TRUE;
+ }
+
+ if (ecs_IsPointInPolygon(cln->mask->c.c_len,cln->mask->c.c_val,
+ obj->res.ecs_ResultUnion_u.dob.xmax,
+ obj->res.ecs_ResultUnion_u.dob.ymin)) {
+ if (!cln->isMaskInclusive)
+ return TRUE;
+ }
+
+ if (ecs_IsPointInPolygon(cln->mask->c.c_len,cln->mask->c.c_val,
+ obj->res.ecs_ResultUnion_u.dob.xmax,
+ obj->res.ecs_ResultUnion_u.dob.ymax)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetRasterInfo: Get the raster information for a given selected layer.
+ *
+ * IN
+ * int ClientID: Client identifier
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_GetRasterInfo(ClientID)
+ int ClientID;
+{
+ register ecs_Client *cln;
+ ecs_Result *msg;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+
+ msg = svr_GetRasterInfo(&(cln->s));
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetObject: Get an object in the server with an id.
+ *
+ * IN
+ * int ClientID: Client identifier
+ * char *id: Identifiant of object
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+
+ecs_Result *cln_GetObject(ClientID,id)
+ int ClientID;
+ char *id;
+{
+ ecs_Result *msg;
+ register ecs_Client *cln;
+ int code;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[2]);
+ return msg;
+ }
+
+ msg = svr_GetObject(&(cln->s),id);
+ if (msg->res.type == Object) {
+ code = cln_ChangeProjection(ClientID, &(msg->res.ecs_ResultUnion_u.dob));
+ if (code > 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[code]);
+ }
+ }
+
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetObjectIdFromCoord: Get the id of the nearest object of a point
+ * in the selected layer.
+ *
+ * IN
+ * int ClientID: Client identifier
+ * ecs_Coordinate *coord: coordinate
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_GetObjectIdFromCoord(ClientID, coord)
+ int ClientID;
+ ecs_Coordinate *coord;
+{
+ double dx,dy;
+ int position;
+ double distance;
+ double mindist;
+ int error_code;
+ register ecs_Client *cln;
+ ecs_Result *msg;
+ char *id;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[2]);
+ return msg;
+ }
+
+ dx = coord->x;
+ dy = coord->y;
+ if ((error_code = cln_ConvTtoS(ClientID, &dx, &dy)) > 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[error_code]);
+ return msg;
+ }
+ coord->x = dx;
+ coord->y = dy;
+
+ if (cln->selectCache == NULL) {
+ msg = svr_GetObjectIdFromCoord(&(cln->s),coord);
+ } else {
+ /*
+ * If a cache exist for this layer, select directly the
+ * object in this cache.
+ */
+
+ switch(cln->selectCache->coverage.F) {
+ case Line:
+ case Area:
+ case Text:
+ case Point:
+ position = 0;
+ distance = ecs_DistanceObject(&(cln->selectCache->o[position]->res.ecs_ResultUnion_u.dob),dx,dy);
+ if (distance>=0.0)
+ mindist = distance;
+ else
+ mindist = HUGE_VAL;
+ cln->selectCache->currentpos = 0;
+ for(position=1;position<cln->selectCache->size;position++) {
+ distance = ecs_DistanceObject(&(cln->selectCache->o[position]->res.ecs_ResultUnion_u.dob),dx,dy);
+ if (mindist>distance && distance>=0.0) {
+ mindist=distance;
+ cln->selectCache->currentpos = position;
+ }
+ }
+ id = cln->selectCache->o[cln->selectCache->currentpos]->res.ecs_ResultUnion_u.dob.Id;
+ msg = &cln_dummy_result;
+ ecs_SetText(msg,id);
+ break;
+ default:
+ msg = svr_GetObjectIdFromCoord(&(cln->s),coord);
+ break;
+ }
+ }
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_UpdateDictionary: Get the update dictionary information from the server
+ *
+ * IN
+ * int ClientID: Client identifier
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_UpdateDictionary(ClientID, info)
+ int ClientID;
+ char *info;
+{
+ register ecs_Client *cln;
+ ecs_Result *msg;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+
+ if (info == NULL) {
+ info = cln_empty_string;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+ msg = svr_UpdateDictionary(&(cln->s),info);
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetGlobalBound: Get the global rectangle of the server.
+ *
+ * IN
+ * ClientID: Client identifier
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_GetGlobalBound(ClientID)
+ int ClientID;
+{
+ ecs_Result *res;
+ register ecs_Client *cln;
+ int code;
+
+ if (multiblock != 0) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[14]);
+ return res;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[2]);
+ return res;
+ }
+
+ res = svr_GetGlobalBound(&(cln->s));
+ if (res->error == 0) {
+ if (res->res.type == GeoRegion &&
+ res->res.ecs_ResultUnion_u.gr.north != res->res.ecs_ResultUnion_u.gr.south &&
+ res->res.ecs_ResultUnion_u.gr.west != res->res.ecs_ResultUnion_u.gr.east &&
+ res->res.ecs_ResultUnion_u.gr.ew_res != 0.0 &&
+ res->res.ecs_ResultUnion_u.gr.ns_res != 0.0) {
+ code = cln_ConvRegion(ClientID,&(res->res.ecs_ResultUnion_u.gr),ECS_STOT);
+ if (code != 0) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[code]);
+ }
+ } else {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[13]);
+ }
+ }
+
+ return res;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_SetServerLanguage: Set the server language
+ *
+ * IN
+ * int ClientID: Client identifier
+ * u_int language: Server language applied
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_SetServerLanguage(ClientID,language)
+ int ClientID;
+ u_int language;
+{
+ register ecs_Client *cln;
+ ecs_Result *msg;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+ msg = svr_SetServerLanguage(&(cln->s),language);
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_SetServerProjection: Set the server projection
+ *
+ * IN
+ * int ClientID: Client identifier
+ * char *projection: Server projection applied
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_SetServerProjection(ClientID,projection)
+ int ClientID;
+ char *projection;
+{
+ register ecs_Client *cln;
+ char *error_message;
+ ecs_CtlPoints *cpts;
+ ecs_Result *res;
+ PJ *tempproj;
+
+ if (multiblock != 0) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[14]);
+ return res;
+ }
+
+ if (projection != NULL) {
+ while(projection[0]==' ')
+ projection++;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+
+ /* Check if the projection is valid */
+
+ if (strncmp(projection,PROJ_LONGLAT,13) != 0) {
+ tempproj = (PJ *) cln_ProjInit(projection);
+ if(tempproj == NULL) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,"This projection string is invalid");
+ return res;
+ }
+ pj_free(tempproj);
+ }
+
+ res = svr_SetServerProjection(&(cln->s),projection);
+ if ((res->error == 0) && ((cln->currentSelectionFamily == Matrix) ||
+ (cln->currentSelectionFamily == Image))) {
+ cpts = NULL;
+ if (!cln_SetRasterConversion(ClientID,&cpts,nn,projective,&error_message)) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,error_message);
+ return res;
+ }
+ }
+
+
+ return res;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetServerProjection: Get the server projection.
+ *
+ * IN
+ * ClientID: Client's identifier
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_GetServerProjection(ClientID)
+ int ClientID;
+{
+ register ecs_Client *cln;
+ ecs_Result *msg;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+
+ msg = svr_GetServerProjection(&(cln->s));
+ return msg;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ cln_SetClientProjection --
+
+ Set the target (client) projection. In return, if the operation
+ is a success, it will return the current region transformed in
+ the new projection.
+
+ PARAMETERS
+ INPUT
+ int ClientID: Client's identifier
+ char *projection: Projection string
+
+ RETURN_VALUE
+ ecs_Result *: A structure with the result information
+
+ PSEUDO_CODE
+
+ 1. Verify if the client id is valid. If not, return an error
+ message
+
+ 2. Keep the old projection initiator and the different flags of the
+ client structure related to the projection and the nad. If a
+ problem appear in the current function, the function will be able
+ to get back to is original stage.
+
+ 3. Change the client region into the projection of the source. This
+ way, when the projection will be completely set, we will be able to
+ know the region of the current region in the new projection.
+
+ 4. Set the isProjEqual (the indicator of projection to FALSE).
+ Totalitarian algorithm.
+
+ 5. Check if target (client) projection is "unknown". If it's the
+ case, set the isProjEqual to true and return a success message.
+
+ 6. Check if the target (client) projection is "longlat". If it's
+ the case
+ Begin
+ 6.1. Set isTargetLL to TRUE
+ End
+ 7. Else
+ Begin
+ 7.1. Set isTargetLL to FALSE
+
+ 7.2. Call cln_ProjInit to set the cln->target. If an error
+ occur, go to 99.
+ End
+
+ 8. Get the driver projection from the source. If an error occur,
+ return an error.
+
+ 9. Check if the source (driver) projection is "longlat". If it's
+ the case
+ Begin
+ 9.1. Set isSourceLL to TRUE
+ End
+ 10. Else
+ Begin
+ 10.1. Set isSourceLL to FALSE
+
+ 10.2. Call cln_ProjInit to set the cln->source. If an error
+ occur, go to 99.
+ End
+
+ 11. If a link to a datum converter already exist, close the old one
+ but keep the old converter information in memory if a problem
+ appear.
+
+ 12. Datum initialization. Check the string of the target projection
+ and the source projection and extract the nad item descriptor
+ (nad27 or nad83).
+
+ 13. If the nads are differents
+ Begin
+ 13.1. Extract the table indicator from the target projection.
+
+ 13.2. If the table indicator don't exist, use the default one.
+
+ 13.3. Open a link to the nad converter driver named after the
+ table indicator and call nad_init. If an error occur, return an
+ error message and goto 99.
+ End
+
+ 14. Check if an azimuth is defined in the projection definition. If
+ it's the case, get the value and set target_azimuth with the
+ value. Take care to apply a modulo of 360 to this value.
+
+ 15. Change the current client region previously calculated in the
+ driver projection to the new projection. If the current region is
+ not set, use the global region. If an error occur, goto 99.
+
+ 16. Free the old source and target
+
+ 17. Return the region calculated in 15.
+
+ 99. Free the new target and source and set the projection
+ attributes to the value kept in 2. Restore also the old datum
+ environment. Return an error message.
+
+ MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+ Description: The result of ecsGetDynamicLibFunction() has been cast
+ to type (dtfunc *). The original cas to (void *)
+ seems incorrect.
+
+ ----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_SetClientProjection(ClientID,projection)
+ int ClientID;
+ char *projection;
+{
+ ecs_Result *res;
+ register ecs_Client *cln;
+ char *server_proj;
+ PJ *oldtarget,*oldsource;
+ ecs_Region oldreg;
+ int oldisprojequal;
+ int oldisTargetLL;
+ int oldisSourceLL;
+ int code = 0;
+ int result;
+ char olddatumtable[10],datumtable[10];
+ char filename[15];
+ ecs_Datum oldtargetdatum=0;
+ ecs_Datum oldsourcedatum=0;
+ char *ptr,*ptr1=NULL;
+ char *temp;
+ int tempint;
+
+ if (multiblock != 0) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[14]);
+ return res;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ res = &cln_dummy_result;
+ ecs_SetError(res,1,cln_messages[2]);
+ return res;
+ }
+
+ if (projection != NULL) {
+ while(projection[0]==' ')
+ projection++;
+ }
+
+ /* If the old projection string is the same, don't change anything */
+
+ if (cln->target_proj != NULL && strcmp(cln->target_proj,projection) == 0) {
+ res = &cln_dummy_result;
+ ecs_SetSuccess(res);
+ return res;
+ }
+
+ /* keep the old values */
+
+ oldisprojequal = cln->isProjEqual;
+ oldisTargetLL= cln->isTargetLL;
+ oldisSourceLL= cln->isSourceLL;
+ oldtarget = cln->target;
+ oldsource = cln->source;
+
+ /* Change the current client region to the projection of the driver */
+
+ if (cln->isCurrentRegionSet == TRUE) {
+ oldreg.north = cln->currentRegion.north;
+ oldreg.south = cln->currentRegion.south;
+ oldreg.east = cln->currentRegion.east;
+ oldreg.west = cln->currentRegion.west;
+ oldreg.ns_res = cln->currentRegion.ns_res;
+ oldreg.ew_res = cln->currentRegion.ew_res;
+ result = cln_ConvRegion(ClientID,&(oldreg),ECS_TTOS);
+ if (result != 0) {
+ code = 10;
+ goto setprojerror;
+ }
+ }
+
+
+ /*
+ * Strategy:
+ * Keep the old projection until the new projection is correctly set.
+ * If a problem appear, nothing will change.
+ */
+
+ cln->isProjEqual = FALSE;
+
+ /*
+ * Set the client projection
+ */
+
+ cln->target = NULL;
+
+ /* Check if client projection is "unknown" */
+
+ if (strncmp(projection,PROJ_UNKNOWN,7) == 0) {
+ cln->isProjEqual = TRUE;
+ res = &cln_dummy_result;
+ ecs_SetGeoRegion(res,cln->currentRegion.north,
+ cln->currentRegion.south,
+ cln->currentRegion.east,
+ cln->currentRegion.west,
+ cln->currentRegion.ns_res,
+ cln->currentRegion.ew_res);
+ ecs_SetSuccess(res);
+ return res;
+ }
+
+ /* Check the projection if not unknown */
+
+ if (strncmp(projection,PROJ_LONGLAT,13) != 0) {
+ cln->isTargetLL = FALSE;
+ cln->target = (PJ *) cln_ProjInit(projection);
+ if(cln->target == NULL) {
+ goto setprojerror;
+ }
+ } else {
+ cln->isTargetLL = TRUE;
+ }
+
+ /*
+ * Get the server projection
+ */
+
+ res = cln_GetServerProjection(ClientID);
+ if ((res->res.type == AText) || (res->res.ecs_ResultUnion_u.s != NULL)) {
+ server_proj = res->res.ecs_ResultUnion_u.s;
+ while(server_proj[0]==' ')
+ server_proj++;
+ } else {
+ return res;
+ }
+
+ /*
+ * Set the server projection
+ */
+
+ cln->source = NULL;
+
+ /* Check if server projection is "unknown" */
+
+ if (strncmp(server_proj,PROJ_UNKNOWN,7) == 0) {
+ cln->isProjEqual = TRUE;
+ res = &cln_dummy_result;
+ ecs_SetGeoRegion(res,cln->currentRegion.north,
+ cln->currentRegion.south,
+ cln->currentRegion.east,
+ cln->currentRegion.west,
+ cln->currentRegion.ns_res,
+ cln->currentRegion.ew_res);
+ ecs_SetSuccess(res);
+ return res;
+ }
+
+ /* Check the projection if not unknown */
+
+ if (strncmp(server_proj,PROJ_LONGLAT,13) != 0) {
+ cln->isSourceLL = FALSE;
+ cln->source = (PJ *) cln_ProjInit(server_proj);
+ if(cln->source == NULL) {
+ goto setprojerror;
+ }
+
+ } else {
+ cln->isSourceLL = TRUE;
+ }
+
+ /*
+ * 11. If a link to a datum converter already exist, close the old one but
+ * keep the old converter in memory if a problem appear.
+ */
+
+ if (cln->dthandle != NULL && (cln->nad_close != NULL)) {
+ (cln->nad_close)(cln->privdatuminfo);
+ ecs_CloseDynamicLib(cln->dthandle);
+ }
+ strcpy(olddatumtable,cln->datumtable);
+ oldtargetdatum = cln->targetdatum;
+ oldsourcedatum = cln->sourcedatum;
+ strcpy(cln->datumtable,"");
+ cln->dthandle = NULL;
+
+ /*
+ * 12. Datum initialization. Check the string of the target projection
+ * and the source projection and extract the nad item descriptor (nad27
+ * or nad83).
+ */
+
+ cln->targetdatum = cln_GetDatumInfo(projection);
+ cln->sourcedatum = cln_GetDatumInfo(server_proj);
+
+ if ((cln->targetdatum == nad27 && cln->sourcedatum == nad83) ||
+ (cln->targetdatum == nad83 && cln->sourcedatum == nad27)) {
+ /*
+ * 13.1. Extract the table indicator from the target projection.
+ */
+
+ strcpy(datumtable,"conus");
+ ptr = projection;
+ while(ptr[0] != '\0') {
+#ifdef _WINDOWS
+ if (strnicmp(ptr,"+datumconv",10) == 0)
+#else
+ if (strncasecmp(ptr,"+datumconv",10) == 0)
+#endif
+ {
+ ptr+=11;
+ if (ptr != '\0') {
+ ptr1 = ptr;
+ while(ptr1[0] != '\0' && ptr1[0] != ' ')
+ ptr1++;
+ }
+ if ((int) (ptr1-ptr) < 10) {
+ strncpy(datumtable,ptr,(int) (ptr1-ptr));
+ datumtable[(int) (ptr1-ptr)] = '\0';
+ }
+ }
+ ptr++;
+ }
+
+#ifdef _WINDOWS
+ if (stricmp(datumtable,"canada") == 0)
+#else
+ if (strncasecmp(datumtable,"canada",10) == 0)
+#endif
+ {
+ strcpy(filename,"dtcanada");
+ } else {
+ strcpy(filename,"dtusa");
+ }
+
+ cln->dthandle = ecs_OpenDynamicLib(filename);
+ if (cln->dthandle != NULL) {
+/**MOD START**/
+ cln->nad_init = (dtfunc *) ecs_GetDynamicLibFunction(cln->dthandle,"dyn_nad_init");
+ cln->nad_forward = (dtfunc *) ecs_GetDynamicLibFunction(cln->dthandle,"dyn_nad_forward");
+ cln->nad_reverse = (dtfunc *) ecs_GetDynamicLibFunction(cln->dthandle,"dyn_nad_reverse");
+ cln->nad_close = (dtfunc *) ecs_GetDynamicLibFunction(cln->dthandle,"dyn_nad_close");
+/**MOD END**/
+
+ if (cln->nad_init == NULL || cln->nad_forward == NULL ||
+ cln->nad_reverse == NULL || cln->nad_close == NULL) {
+ } else {
+ if ((cln->nad_init)(&(cln->privdatuminfo),datumtable) != TRUE) {
+ }
+ }
+ }
+ }
+
+ /*
+ Check if in the target there is a azimuth defined
+ */
+
+ ptr = projection;
+ cln->target_azimuth = 0.0;
+ while(ptr[0] != '\0') {
+#ifdef _WINDOWS
+ if (strnicmp(ptr,"+azimuth",8) == 0)
+#else
+ if (strncasecmp(ptr,"+azimuth",8) == 0)
+#endif
+ {
+ ptr+=9;
+ if (ptr != '\0') {
+ sscanf(ptr,"%d",&tempint);
+ cln->target_azimuth = (double) tempint;
+ cln->target_azimuth = cln->target_azimuth*PI/180.0;
+ cln->sinazimuth = sin(cln->target_azimuth);
+ cln->cosazimuth = cos(cln->target_azimuth);
+ }
+ }
+ ptr++;
+ }
+
+ /*
+ * Compare both projections and see if they are equals
+ */
+
+ cln->isProjEqual = cln_CompareProjections(ClientID);
+
+ /*
+ * Get the global bound and put it on currentRegion
+ */
+
+ /*
+ * Change the current client region previously calculated
+ * in the driver projection to the new projection
+ */
+
+ if (cln->isCurrentRegionSet == TRUE) {
+ if (cln_ConvRegion(ClientID,&oldreg,ECS_STOT) == 0) {
+ cln->currentRegion.north = oldreg.north;
+ cln->currentRegion.south = oldreg.south;
+ cln->currentRegion.east = oldreg.east;
+ cln->currentRegion.west = oldreg.west;
+ cln->currentRegion.ns_res = oldreg.ns_res;
+ cln->currentRegion.ew_res = oldreg.ew_res;
+ res = cln_SelectRegion(ClientID,&(cln->currentRegion));
+ } else {
+ code = 10;
+ goto setprojerror;
+ }
+ } else {
+ res = cln_GetGlobalBound(ClientID);
+ if ((res->error == 0) && (res->res.type == GeoRegion)) {
+ cln->currentRegion.north = ECSRESULT(res).gr.north;
+ cln->currentRegion.south = ECSRESULT(res).gr.south;
+ cln->currentRegion.east = ECSRESULT(res).gr.east;
+ cln->currentRegion.west = ECSRESULT(res).gr.west;
+ cln->currentRegion.ns_res = ECSRESULT(res).gr.ns_res;
+ cln->currentRegion.ew_res = ECSRESULT(res).gr.ew_res;
+
+ res = cln_SelectRegion(ClientID,&(cln->currentRegion));
+ } else {
+ code = 11;
+ goto setprojerror;
+ }
+ }
+
+ if (cln->mask != NULL) {
+ if (cln->mask->c.c_val != NULL)
+ free(cln->mask->c.c_val);
+ free(cln->mask);
+ cln->mask = NULL;
+ }
+
+ temp = malloc(strlen(projection)+1);
+ if (temp == NULL) {
+ code = 2;
+ goto setprojerror;
+ }
+ if (cln->target_proj != NULL)
+ free(cln->target_proj);
+ cln->target_proj = temp;
+ strcpy(cln->target_proj,projection);
+
+ if (oldtarget != NULL)
+ pj_free(oldtarget);
+ if (oldsource != NULL)
+ pj_free(oldsource);
+
+ res = &cln_dummy_result;
+ ecs_SetGeoRegion(res,cln->currentRegion.north,
+ cln->currentRegion.south,
+ cln->currentRegion.east,
+ cln->currentRegion.west,
+ cln->currentRegion.ns_res,
+ cln->currentRegion.ew_res);
+
+ ecs_SetSuccess(res);
+ return res;
+
+setprojerror:
+
+ if (cln->target != NULL)
+ pj_free(cln->target);
+ if (cln->source != NULL)
+ pj_free(cln->source);
+ cln->isProjEqual = oldisprojequal;
+ cln->isTargetLL = oldisTargetLL;
+ cln->isSourceLL = oldisSourceLL;
+ cln->target = oldtarget;
+ cln->source = oldsource;
+
+ /*
+ * Datum reinitiator
+ */
+
+ if (strlen(olddatumtable) != 0) {
+#ifdef _WINDOWS
+ if (stricmp(olddatumtable,"canada") == 0)
+#else
+ if (strncasecmp(olddatumtable,"canada",10) == 0)
+#endif
+ {
+ strcpy(filename,"dtcanada");
+ } else {
+ strcpy(filename,"dtusa");
+ }
+
+
+ cln->dthandle = ecs_OpenDynamicLib(filename);
+
+ if (cln->dthandle != NULL) {
+ cln->dthandle = NULL;
+ } else {
+ cln->nad_init = (void *) ecs_GetDynamicLibFunction(cln->dthandle,"dyn_nad_init");
+ cln->nad_forward = (void *) ecs_GetDynamicLibFunction(cln->dthandle,"dyn_nad_forward");
+ cln->nad_reverse = (void *) ecs_GetDynamicLibFunction(cln->dthandle,"dyn_nad_reverse");
+ cln->nad_close = (void *) ecs_GetDynamicLibFunction(cln->dthandle,"dyn_nad_close");
+
+ if (cln->nad_init == NULL || cln->nad_forward == NULL ||
+ cln->nad_reverse == NULL || cln->nad_close == NULL) {
+ ecs_CloseDynamicLib(cln->dthandle);
+ cln->dthandle = NULL;
+ } else {
+ if ((cln->nad_init)(&(cln->privdatuminfo),olddatumtable) != TRUE) {
+ ecs_CloseDynamicLib(cln->dthandle);
+ cln->dthandle = NULL;
+ }
+ }
+ }
+ } else {
+ cln->dthandle = NULL;
+ }
+ cln->targetdatum = oldtargetdatum;
+ cln->sourcedatum = oldsourcedatum;
+
+ res = &cln_dummy_result;
+ if (code == 0)
+ ecs_SetError(res,1,cln_messages[4]);
+ else
+ ecs_SetError(res,1,cln_messages[code]);
+
+ return res;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * cln_GetDatumInfo
+ *
+ * DESCRIPTION
+ * Get the datum information from the datum projection.
+ *
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * char *projection: The projection string
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Datum: The returned information. Could be nodatum,
+ * nad27 or nad83.
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Set ptr to the beginning of the string projection
+ *
+ * 2. While ptr is not the end of the string
+ * Begin
+ * 2.1. Compare the first 12 characters of ptr and "+datum=nad27"
+ * without the case sensitivity. If they are the same, return
+ * nad27.
+ *
+ * 2.2. Compare the first 12 characters of ptr and "+datum=nad83"
+ * without the case sensitivity. If they are the same, return
+ * nad83.
+ *
+ * 2.3. Increment ptr
+ * End
+ *
+ * 3. Return nodatum
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Datum cln_GetDatumInfo(projection)
+ char *projection;
+{
+ char *ptr;
+
+ if (projection==NULL) return nodatum;
+
+ ptr = projection;
+ while(ptr[0]!='\0') {
+
+#ifdef _WINDOWS
+ if (strnicmp(ptr,"+datum=nad27",12) == 0)
+#else
+ if (strncasecmp(ptr,"+datum=nad27",12) == 0)
+#endif
+ return nad27;
+
+#ifdef _WINDOWS
+ if (strnicmp(ptr,"+datum=nad83",12) == 0)
+#else
+ if (strncasecmp(ptr,"+datum=nad83",12) == 0)
+#endif
+ return nad83;
+
+ ptr++;
+ }
+
+ return nodatum;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_SetTclProc: Set in the client tclprocname with the value of the
+ * attribute.
+ *
+ * IN
+ * int ClientID: Client's identifier
+ * char *tclproc: TCL procedure name
+ *
+ *----------------------------------------------------------------------
+ */
+
+void cln_SetTclProc(ClientID,tclproc)
+ int ClientID;
+ char *tclproc;
+{
+ register ecs_Client *cln;
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ return;
+ }
+
+ if (cln->tclprocname != NULL)
+ free(cln->tclprocname);
+ if (tclproc != NULL) {
+ cln->tclprocname = (char *) malloc(strlen(tclproc)+1);
+ if (cln->tclprocname != NULL)
+ strcpy(cln->tclprocname, tclproc);
+ } else {
+ cln->tclprocname = NULL;
+ }
+ return;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetTclProc: Return the client tclprocname
+ *
+ * IN
+ * int ClientID: Client's identifier
+ *
+ * OUT
+ * return char *: Pointer to tclprocname. If NULL, there is no
+ * tclprocname.
+ *
+ *----------------------------------------------------------------------
+ */
+
+char *cln_GetTclProc(ClientID)
+ int ClientID;
+{
+ register ecs_Client *cln;
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ return NULL;
+ }
+
+ return cln->tclprocname;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ProjInit: Initialize a projection
+ *
+ * IN
+ * char *d: Projection name
+ *
+ * OUT
+ * return PJ *: New projection structure. If NULL, the operation
+ * is a failure.
+ *
+ *----------------------------------------------------------------------
+ */
+
+PJ *cln_ProjInit(d)
+ char *d;
+{
+ int i,n;
+ int pos;
+ char **tableau;
+ char *l;
+ int longueur;
+ char *c;
+ PJ *retour;
+
+ if ((c = (char *) malloc(strlen(d)+3)) == NULL) {
+ return NULL;
+ }
+ strcpy(c,d);
+
+ n=0;
+ pos = 0;
+ l = c;
+
+ longueur = strlen(c);
+ if ((tableau = (char **) malloc(sizeof(char *)*longueur)) == NULL) {
+ free(c);
+ return NULL;
+ }
+ for(i=0; i<longueur; i++) {
+ if (c[i] == ' ') {
+ c[i]= '\0';
+ tableau[n] = l;
+ pos = i;
+ l = &c[i+1];
+ if (strncmp(tableau[n],"+",1) == 0)
+ tableau[n]++;
+ n++;
+ }
+ }
+
+ if (strlen(l)>0) {
+ tableau[n] = l;
+ if (strncmp(tableau[n],"+",1) == 0)
+ tableau[n]++;
+ n++;
+ }
+
+ retour = (PJ *) pj_init(n, (char **) tableau);
+ free(c);
+ free(tableau);
+
+ return retour;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_CompareProjections: Compare target and source projections of a client
+ * and indicate if they are equals.
+ *
+ * IN
+ * int ClientID: Client's identifier
+ *
+ * OUT
+ * return int: Flag indicate if both projections are equals.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_CompareProjections(ClientID)
+ int ClientID;
+{
+ ecs_Region *gr;
+ register ecs_Client *cln;
+ ecs_Result *res;
+
+ cln = soc[ClientID];
+
+ if (cln == NULL)
+ return FALSE;
+
+ if(cln->isTargetLL == TRUE ||
+ cln->isSourceLL == TRUE)
+ return FALSE;
+
+ /*
+ * Strategy: Extract the default region and compare the four corners in it.
+ * If the four corners are equivalent in both projections, the projections
+ * will be considered as equivalent.
+ */
+
+ res = svr_GetGlobalBound(&(cln->s));
+ if ((res->error != 0) || (res->res.type != GeoRegion)) {
+ return FALSE;
+ }
+
+ gr = &(res->res.ecs_ResultUnion_u.gr);
+
+ if (!cln_PointValid(ClientID,gr->west,gr->south) &&
+ !cln_PointValid(ClientID,gr->east,gr->north) &&
+ !cln_PointValid(ClientID,gr->west,gr->north) &&
+ !cln_PointValid(ClientID,gr->east,gr->south)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_UpdateMaxRegion: The function update a geographic region "gr"
+ * in a projection "A" and update it with a point (x,y) taken
+ * in a projection "B". If "direction" is ECS_TTOS, projection "A" will
+ * be the target projection and "B" the source. If "direction" is ECS_TTOS,
+ * projection "A" will be the target projection and "B" the source.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * x,y : Point to convert
+ * gr : Geographical region to convert (already allocated)
+ * direction : Direction of convertion
+ * first : Indicate if the point (x,y) is the first to convert
+ *
+ * OUT
+ *
+ * return int : If 0, the operation is a success. Hense,
+ * an error code is send. This error code correspond
+ * to a position in cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_UpdateMaxRegion(ClientID,x,y,gr,direction,first)
+ int ClientID;
+ double x;
+ double y;
+ ecs_Region *gr;
+ int direction;
+ int first;
+{
+ int error_code = 0;
+ double temp_x = x;
+ double temp_y = y;
+
+ if (direction == ECS_STOT) {
+ if ((error_code = cln_ConvStoT(ClientID, &temp_x, &temp_y)) != 0) {
+ return error_code;
+ }
+ } else {
+ if ((error_code = cln_ConvTtoS(ClientID, &temp_x, &temp_y)) != 0) {
+ return error_code;
+ }
+ }
+
+ if (first==TRUE) {
+ gr->north = temp_y;
+ gr->south = temp_y;
+ gr->east = temp_x;
+ gr->west = temp_x;
+ } else {
+ if (gr->north < temp_y)
+ gr->north = temp_y;
+ if (gr->south > temp_y)
+ gr->south = temp_y;
+ if (gr->east < temp_x)
+ gr->east = temp_x;
+ if (gr->west > temp_x)
+ gr->west = temp_x;
+ }
+
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ConvMBR: Convert a geographic region from a projection "A" to
+ * a projection "B". If "direction" is ECS_TTOS, projection "A" will
+ * be the target projection and "B" the source. If "direction" is ECS_TTOS,
+ * projection "A" will be the target projection and "B" the source.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * double *xl : Left of MBR
+ * double *yl : Bottom of MBR
+ * double *xu : Right of MBR
+ * double *yu : Top of MBR
+ * direction : Direction of convertion
+ *
+ * OUT
+ * return int : If 0, the operation is a success. Hense,
+ * an error code is send. This error code correspond
+ * to a position in cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ConvMBR(ClientID,xl,yl,xu,yu,direction)
+ int ClientID;
+ double *xl;
+ double *yl;
+ double *xu;
+ double *yu;
+ int direction;
+{
+ ecs_Region maxgr;
+ double middle_x;
+ double fquart_x;
+ double squart_x;
+ double middle_y;
+ double fquart_y;
+ double squart_y;
+ int ret = 0;
+ register ecs_Client *cln;
+
+ cln = soc[ClientID];
+ if (cln == NULL)
+ return 2;
+
+ middle_x = ((*xl)+(*xu))/2.0;
+ middle_y = ((*yu)+(*yl))/2.0;
+ fquart_x = (middle_x + (*xl))/2.0;
+ squart_x = (middle_x + (*xu))/2.0;
+ fquart_y = (middle_y + (*yl))/2.0;
+ squart_y = (middle_y + (*yu))/2.0;
+
+ cln_UpdateMaxRegion(ClientID,(*xl),(*yl),&maxgr,direction,TRUE);
+ cln_UpdateMaxRegion(ClientID,(*xl),(*yu),&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,(*xu),(*yu),&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,(*xu),(*yl),&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,(*xu),middle_y,&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,(*xl),middle_y,&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,middle_x,(*yu),&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,middle_x,(*yl),&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,middle_x,middle_y,&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,fquart_x,fquart_y,&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,fquart_x,squart_y,&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,squart_x,fquart_y,&maxgr,direction,FALSE);
+ cln_UpdateMaxRegion(ClientID,squart_x,squart_y,&maxgr,direction,FALSE);
+ (*yu) = maxgr.north;
+ (*yl) = maxgr.south;
+ (*xu) = maxgr.east;
+ (*xl) = maxgr.west;
+ ret = 0;
+
+ return ret;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ConvRegion: Convert a geographic region from a projection "A" to
+ * a projection "B". If "direction" is ECS_TTOS, projection "A" will
+ * be the target projection and "B" the source. If "direction" is ECS_TTOS,
+ * projection "A" will be the target projection and "B" the source.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * gr : Geographical region to convert (already allocated)
+ * direction : Direction of convertion
+ *
+ * OUT
+ * return int : If 0, the operation is a success. Hense,
+ * an error code is send. This error code correspond
+ * to a position in cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ConvRegion(ClientID,gr,direction)
+ int ClientID;
+ ecs_Region *gr;
+ int direction;
+{
+ double width,height;
+ int ret = 0;
+ int intwidth,intheight;
+ register ecs_Client *cln;
+ double ox,oy,dx,dy,temp;
+ int i;
+
+ cln = soc[ClientID];
+ if (cln == NULL)
+ return 2;
+
+ width = (gr->east - gr->west) / gr->ew_res;
+ height = (gr->north - gr->south) / gr->ns_res;
+
+ intwidth = (int) floor(width+0.5);
+ intheight = (int) floor(height+0.5);
+
+ /*
+ * Calculate resolution. For that, calculate four points in
+ * the middle of the original region. Convert these points
+ * and calculate the resolution.
+ */
+
+ /* Calculate ew_res */
+
+ ox = gr->west;
+ dx = gr->east - 0.00001;
+ temp = (ox + dx)/2.0;
+ oy = dy = (gr->north + gr->south) / 2.0;
+
+ gr->ew_res = 1.0;
+ for(i=0;i<4;i++) {
+ if (direction == ECS_STOT) {
+ if ((cln_ConvStoT(ClientID, &ox, &oy) == 0) &&
+ (cln_ConvStoT(ClientID, &dx, &dy) == 0)) {
+ gr->ew_res = (sqrt(((dx-ox)*(dx-ox)) + ((dy-oy)*(dy-oy))) /
+ (width/(i+1)));
+ break;
+ }
+ } else {
+ if ((cln_ConvTtoS(ClientID, &ox, &oy) == 0) &&
+ (cln_ConvTtoS(ClientID, &dx, &dy) == 0)) {
+ gr->ew_res = (sqrt(((dx-ox)*(dx-ox)) + ((dy-oy)*(dy-oy))) /
+ (width/(i+1)));
+ break;
+ }
+ }
+ /* Divide the distance to the central point by 2 */
+
+ ox = ox + temp / 2.0;
+ dx = dx + temp / 2.0;
+ }
+
+ /* Calculate ns_res */
+
+ oy = gr->south;
+ dy = gr->north - 0.00001;
+ temp = (oy + dy) / 2.0;
+ ox = dx = (gr->west + gr->east) / 2.0;
+
+ gr->ns_res = 1.0;
+ for(i=0;i<4;i++) {
+ if (direction == ECS_STOT) {
+ if ((cln_ConvStoT(ClientID, &ox, &oy) == 0) &&
+ (cln_ConvStoT(ClientID, &dx, &dy) == 0)) {
+ gr->ns_res = (sqrt(((dx-ox)*(dx-ox)) + ((dy-oy)*(dy-oy))) /
+ (height/(i+1)));
+ break;
+ }
+ } else {
+ if ((cln_ConvTtoS(ClientID, &ox, &oy) == 0) &&
+ (cln_ConvTtoS(ClientID, &dx, &dy) == 0)) {
+ gr->ns_res = (sqrt(((dx-ox)*(dx-ox)) + ((dy-oy)*(dy-oy))) /
+ (height/(i+1)));
+ break;
+ }
+ }
+ /* Divide the distance to the central point by 2 */
+
+ oy = oy + temp / 2.0;
+ dy = dy + temp / 2.0;
+ }
+
+ /* Calculate bounding box */
+
+ ret = cln_ConvMBR(ClientID,&(gr->west),&(gr->south),
+ &(gr->east),&(gr->north),direction);
+
+ /* Check the resolution. If the new width and height of the
+ region is 10X smaller than the original one, then simply
+ make the calculation with the width and the height. Also
+ check if the resolution is negative */
+
+ gr->ew_res = (gr->east - gr->west)/(double) intwidth;
+ gr->ns_res = (gr->north - gr->south)/(double) intheight;
+
+ return ret;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ cln_ConvTtoS
+
+ DESCRIPTION
+ Convert a geographical point from the target geographic
+ projection (client) to the source projectioné
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ int ClientID: Client's identifier
+ IN/OUT
+ double *X: Pointer to X, the x coordinate of the geographic point to convert
+ double *Y: Pointer to Y, the y coordinate of the geographic point to convert
+
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int: If 0, the operation is a success. Hense an error code is send. This error code correspond to a position in cln_messages.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. If the projections are not equal (isProjEqual == FALSE)
+ Begin
+
+ 1.1. Apply the conter-rotation if the target_azimuth is different of 0.
+ The equations are x1 = x*cos(target_azimuth) + y*sin(target_azimuth)
+ and y1 = y*cos(target_azimuth) - x*sin(target_azimuth).
+
+ 1.2. If the target projection is not longlat
+ Begin
+ 1.2.1. Convert the point using pj_inv. If an error occur,
+ return an error.
+ End
+ 1.3. Else
+ Begin
+ 1.3.1. Check the range of the point. If outside, return an error
+ End
+
+ At this point, the coordinate is in longlat
+
+ 1.4. Convert the point nad with nad_converter if the link exist.
+
+ 1.5. If the target projection is not longlat
+ Begin
+ 1.5.1. Convert the point using pj_fwd. If an error occur,
+ return an error.
+ End
+ 1.6. Else
+ Begin
+ 1.6.1. Check the range of the point. If outside, return an error
+ End
+ End
+
+ ----------------------------------------------------------------------
+ */
+
+int cln_ConvTtoS(ClientID, X, Y)
+ int ClientID;
+ double *X;
+ double *Y;
+{
+ projUV data1,data2;
+ register ecs_Client *cln;
+ double temp_x,temp_y,temp1_x,temp1_y;
+
+ cln = soc[ClientID];
+
+ if (cln == NULL)
+ return 2;
+
+ if (cln->isProjEqual == FALSE) {
+
+ /*
+ Apply the conter-rotation
+ */
+
+ temp_x = *X;
+ temp_y = *Y;
+
+ if (cln->target_azimuth != 0.0) {
+ temp1_x = ((temp_x * cln->cosazimuth) -
+ temp_y * cln->sinazimuth);
+ temp1_y = ((temp_x * cln->sinazimuth) +
+ temp_y * cln->cosazimuth);
+ temp_x = temp1_x;
+ temp_y = temp1_y;
+ }
+
+ /*
+ Projection change
+ */
+
+ if (cln->isTargetLL == FALSE) {
+ data1.u = temp_x;
+ data1.v = temp_y;
+ data2 = pj_inv(data1,cln->target);
+ if ((data2.u == HUGE_VAL) || (data2.v == HUGE_VAL))
+ return 8;
+ } else {
+ if (temp_y <= -90.0)
+ temp_y = -89.9999;
+ if (temp_y >= 90.0)
+ temp_y = 89.9999;
+ if (temp_x <= -180.0)
+ temp_x = -179.9999;
+ if (temp_x >= 180.0)
+ temp_x = 179.9999;
+ data2.u = temp_x * DEG_TO_RAD;
+ data2.v = temp_y * DEG_TO_RAD;
+ }
+
+ if (cln->dthandle != NULL) {
+ temp_x = data2.u * RAD_TO_DEG;
+ temp_y = data2.v * RAD_TO_DEG;
+ if (cln->targetdatum == nad27 && cln->sourcedatum == nad83) {
+ (cln->nad_forward)(cln->privdatuminfo,&temp_x,&temp_y);
+ }
+ if (cln->targetdatum == nad83 && cln->sourcedatum == nad27) {
+ (cln->nad_reverse)(cln->privdatuminfo,&temp_x,&temp_y);
+ }
+ data2.u = temp_x * DEG_TO_RAD;
+ data2.v = temp_y * DEG_TO_RAD;
+ }
+
+ if (cln->isSourceLL == FALSE) {
+ data1 = pj_fwd(data2,cln->source);
+ if (data1.u == HUGE_VAL || data1.v == HUGE_VAL) {
+ if (data2.v >= 1.5707)
+ data2.v = 1.5707;
+ if (data2.v <= -1.5707)
+ data2.v = -1.5707;
+ data1 = pj_fwd(data2,cln->source);
+ if (data1.u == HUGE_VAL || data1.v == HUGE_VAL) {
+ return 8;
+ }
+ }
+ *X = data1.u;
+ *Y = data1.v;
+ } else {
+ *X = data2.u * RAD_TO_DEG;
+ *Y = data2.v * RAD_TO_DEG;
+ if (*X < -180.0)
+ *X = -180.0;
+ if (*X > 180.0)
+ *X = 180.0;
+ if (*Y < -90.0)
+ *Y = -90.0;
+ if (*Y > 90.0)
+ *Y = 90.0;
+ }
+ }
+ return 0;
+}
+
+
+/*
+ ----------------------------------------------------------------------
+
+ FUNCTION_INFORMATION
+
+ NAME
+ cln_ConvStoT
+
+ DESCRIPTION
+ Convert a geographical point from the source geographic
+ projection (client) to the target projection.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ int ClientID: Client's identifier
+ IN/OUT
+ double *X: Pointer to X, the x coordinate of the geographic point to convert
+ double *Y: Pointer to Y, the y coordinate of the geographic point to convert
+
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int: If 0, the operation is a success. Hense an error code is send. This error code correspond to a position in cln_messages.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. If the projections are not equal (isProjEqual == FALSE)
+ Begin
+ 1.1. If the source projection is not longlat
+ Begin
+ 1.1.1. Convert the point using pj_inv. If an error occur,
+ return an error.
+ End
+ 1.2. Else
+ Begin
+ 1.2.1. Check the range of the point. If outside, return an error
+ End
+
+ At this point, the coordinate is in longlat
+
+ 1.3. Convert the point nad with nad_converter if the link exist.
+
+ 1.4. If the source projection is not longlat
+ Begin
+ 1.4.1. Convert the point using pj_fwd. If an error occur,
+ return an error.
+ End
+ 1.5. Else
+ Begin
+ 1.5.1. Check the range of the point. If outside, return an error
+ End
+
+ 1.6. Apply the rotation if the cln->target_azimuth is different of 0.
+ The equations are x1 = x*cos(target_azimuth) - y*sin(target_azimuth)
+ and y1 = y*cos(target_azimuth) + x*sin(target_azimuth). Take care also
+ of the quadrant where the angle is.
+
+ End
+
+ ----------------------------------------------------------------------
+ */
+
+int cln_ConvStoT(ClientID, X, Y)
+ int ClientID;
+ double *X;
+ double *Y;
+{
+ projUV data1,data2;
+ register ecs_Client *cln;
+ double temp_x,temp_y,temp1_x,temp1_y;
+
+ cln = soc[ClientID];
+
+ if (cln == NULL)
+ return 2;
+
+ if (cln->isProjEqual == FALSE) {
+
+ /*
+ Projection change
+ */
+
+ if (cln->isSourceLL == FALSE) {
+ data1.u = *X;
+ data1.v = *Y;
+ data2 = pj_inv(data1,cln->source);
+ if (data2.u == HUGE_VAL || data2.v == HUGE_VAL)
+ return 8;
+ } else {
+ if (*Y <= -90.0)
+ *Y = -89.9999;
+ if (*Y >= 90.0)
+ *Y = 89.9999;
+ if (*X <= -180.0)
+ *X = -179.9999;
+ if (*X >= 180.0)
+ *X = 179.9999;
+ data2.u = *X * DEG_TO_RAD;
+ data2.v = *Y * DEG_TO_RAD;
+ }
+
+ if (cln->dthandle != NULL) {
+ temp_x = data2.u * RAD_TO_DEG;
+ temp_y = data2.v * RAD_TO_DEG;
+ if (cln->targetdatum == nad27 && cln->sourcedatum == nad83) {
+ (cln->nad_reverse)(cln->privdatuminfo,&temp_x,&temp_y);
+ }
+ if (cln->targetdatum == nad83 && cln->sourcedatum == nad27) {
+ (cln->nad_forward)(cln->privdatuminfo,&temp_x,&temp_y);
+ }
+ data2.u = temp_x * DEG_TO_RAD;
+ data2.v = temp_y * DEG_TO_RAD;
+ }
+
+ if (cln->isTargetLL == FALSE) {
+ data1 = pj_fwd(data2,cln->target);
+ if (data1.u == HUGE_VAL || data1.v == HUGE_VAL) {
+ if (data2.v >= 1.5707)
+ data2.v = 1.5707;
+ if (data2.v <= -1.5707)
+ data2.v = -1.5707;
+ data1 = pj_fwd(data2,cln->target);
+ if (data1.u == HUGE_VAL || data1.v == HUGE_VAL) {
+ return 8;
+ }
+ }
+ *X = data1.u;
+ *Y = data1.v;
+ } else {
+ *X = data2.u * RAD_TO_DEG;
+ *Y = data2.v * RAD_TO_DEG;
+ if (*X < -180.0)
+ *X = -180.0;
+ if (*X > 180.0)
+ *X = 180.0;
+ if (*Y < -90.0)
+ *Y = -90.0;
+ if (*Y > 90.0)
+ *Y = 90.0;
+ }
+
+ /*
+ Apply the conter-rotation
+ */
+
+ temp_x = *X;
+ temp_y = *Y;
+
+ if (cln->target_azimuth != 0.0) {
+ temp1_x = (temp_x * cln->cosazimuth +
+ temp_y * cln->sinazimuth);
+ temp1_y = (temp_y * cln->cosazimuth -
+ temp_x * cln->sinazimuth);
+ *X = temp1_x;
+ *Y = temp1_y;
+ }
+
+
+ }
+ return 0;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ChangeProjection: Change the geographic projection of an object
+ * from source projection to target projection.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * ecs_Object *obj: Pointer to object
+ *
+ * OUT
+ * return int : error code. If 0, the operation is succes. Else,
+ * an error code correspond to a position in the cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ChangeProjection(ClientID,obj)
+ int ClientID;
+ ecs_Object *obj;
+{
+ int code;
+ register ecs_Client *cln;
+
+ cln = soc[ClientID];
+
+ if (cln->isProjEqual == TRUE)
+ return 0;
+
+ /* Change the MBR of the object */
+
+ code = cln_ConvMBR(ClientID,&(obj->xmin),&(obj->ymin),
+ &(obj->xmax),&(obj->ymax),ECS_STOT);
+ if (code != 0)
+ return code;
+
+ /* Change the geom attribute */
+
+ switch (obj->geom.family) {
+ case Area:
+ code = cln_ChangeProjectionArea(ClientID,
+ &(obj->geom.ecs_Geometry_u.area));
+ break;
+ case Line:
+ code = cln_ChangeProjectionLine(ClientID,
+ &(obj->geom.ecs_Geometry_u.line));
+ break;
+ case Point:
+ code = cln_ChangeProjectionPoint(ClientID,
+ &(obj->geom.ecs_Geometry_u.point));
+ break;
+ case Text:
+ code = cln_ChangeProjectionText(ClientID,
+ &(obj->geom.ecs_Geometry_u.text));
+ break;
+ case Matrix:
+ code = cln_ChangeProjectionMatrix(ClientID,
+ &(obj->geom.ecs_Geometry_u.matrix));
+ break;
+ case Image:
+ code = cln_ChangeProjectionImage(ClientID,
+ &(obj->geom.ecs_Geometry_u.image));
+ break;
+ default:
+ break;
+ }
+ return code;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ChangeProjectionArea: Change the geographic projection of an area
+ * from source projection to target projection.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * ecs_Area *obj: Pointer to area object
+ *
+ * OUT
+ * return int : error code. If 0, the operation is success. Else,
+ * an error code correspond to a position in the cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ChangeProjectionArea(ClientID,obj)
+ int ClientID;
+ ecs_Area *obj;
+{
+ register int i,j;
+ int code;
+
+ for(i=0;(int) i<(int) obj->ring.ring_len; i++) {
+ if ((code = cln_ConvStoT(ClientID, &(obj->ring.ring_val[i].centroid.x),
+ &(obj->ring.ring_val[i].centroid.y))) != 0) {
+ return code;
+ }
+
+ for(j=0; (int) j< (int) obj->ring.ring_val[i].c.c_len; j++) {
+ if ((code = cln_ConvStoT(ClientID,
+ &(obj->ring.ring_val[i].c.c_val[j].x),
+ &(obj->ring.ring_val[i].c.c_val[j].y))) != 0) {
+ return code;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ChangeProjectionLine: Change the geographic projection of an line
+ * from source projection to target projection.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * ecs_Line *obj: Pointer to line object
+ *
+ * OUT
+ * return int : error code. If 0, the operation is success. Else,
+ * an error code correspond to a position in the cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ChangeProjectionLine(ClientID,obj)
+ int ClientID;
+ ecs_Line *obj;
+{
+ register int i;
+ int code;
+
+ for(i=0;(int) i<(int) obj->c.c_len; i++) {
+ if ((code = cln_ConvStoT(ClientID,
+ &(obj->c.c_val[i].x),
+ &(obj->c.c_val[i].y))) != 0) {
+ return code;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ChangeProjectionPoint: Change the geographic projection of an point
+ * from source projection to target projection.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * ecs_Point *obj: Pointer to point object
+ *
+ * OUT
+ * return int : error code. If 0, the operation is success. Else,
+ * an error code correspond to a position in the cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ChangeProjectionPoint(ClientID,obj)
+ int ClientID;
+ ecs_Point *obj;
+{
+ int code;
+
+ if ((code = cln_ConvStoT(ClientID,&(obj->c.x),&(obj->c.y))) != 0) {
+ return code;
+ }
+
+ return 0;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ChangeProjectionText: Change the geographic projection of an text
+ * from source projection to target projection.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * ecs_Text *obj: Pointer to text object
+ *
+ * OUT
+ * return int : error code. If 0, the operation is success. Else,
+ * an error code correspond to a position in the cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ChangeProjectionText(ClientID,obj)
+ int ClientID;
+ ecs_Text *obj;
+{
+ int code;
+
+ if ((code = cln_ConvStoT(ClientID,&(obj->c.x),&(obj->c.y))) != 0) {
+ return code;
+ }
+
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ChangeProjectionMatrix: Change the geographic projection of an matrix
+ * from source projection to target projection.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * ecs_Matrix *obj: Pointer to matrix object
+ *
+ * OUT
+ * return int : error code. If 0, the operation is success. Else,
+ * an error code correspond to a position in the cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ChangeProjectionMatrix(ClientID,obj)
+ int ClientID;
+ ecs_Matrix *obj;
+{
+ ClientID = 0;
+ obj = NULL;
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ChangeProjectionImage: Change the geographic projection of an image
+ * from source projection to target projection.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * ecs_Image *obj: Pointer to image object
+ *
+ * OUT
+ * return int : error code. If 0, the operation is success. Else,
+ * an error code correspond to a position in the cln_messages.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ChangeProjectionImage(ClientID,obj)
+ int ClientID;
+ ecs_Image *obj;
+{
+ ClientID = 0;
+ obj = NULL;
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_PointValid: With a point (X,Y), check if this point, when converted
+ * from target to source projection, give a equivalent result.
+ *
+ * IN
+ * int ClientID : Client's identifier
+ * double X: Pointer to X, the x coordinate to convert
+ * double Y: Pointer to Y, the y coordinate to convert
+ *
+ * OUT
+ * return int : If TRUE, this point is equivalent in both projection
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_PointValid(ClientID, x, y)
+ int ClientID;
+ double x;
+ double y;
+{
+ double ox,oy; /* Original value */
+ double cx,cy; /* Converted value */
+ double dx,dy; /* Difference between points */
+ register ecs_Client *cln;
+
+ cln = soc[ClientID];
+ if (cln == NULL)
+ return FALSE;
+
+ ox = x;
+ oy = y;
+ cx = x;
+ cy = y;
+ if (cln_ConvStoT(ClientID, &cx, &cy) != 0) {
+ return FALSE;
+ }
+ dx = ox-cx;
+ if (dx<0)
+ dx*=-1;
+ if (ox<0)
+ ox*=-1;
+ dy = oy-cy;
+ if (dy<0)
+ dy*=-1;
+ if (oy<0)
+ oy*=-1;
+
+ if (cln->dthandle == NULL) {
+ if (((dx/ox) > COMPARETOLERANCE) || ((dy/oy) > COMPARETOLERANCE)) {
+ return FALSE;
+ }
+ } else {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetClientIdFromURL: With an URL, return the related ClientID.
+ *
+ * IN
+ * char *url: Client URL
+ *
+ * OUT
+ * return int: Client ID. If >= 0, the operation is a success.
+ * If < 0 , it failed to found the client
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_GetClientIdFromURL(url)
+ char *url;
+{
+ int i;
+
+ for(i=0;i<MAXCLIENT;i++) {
+ if (soc[i] != NULL) {
+ if (strcmp(soc[i]->url,url) == 0) {
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetURLList: Get URL list
+ *
+ * OUT
+ * char **urllist: Pointer to a string (char *)
+ * return int: error_code flag. TRUE: Success
+ * FALSE: Failure
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_GetURLList(urllist)
+ char **urllist;
+{
+ static char *retstring = NULL;
+ int i;
+ int lenght;
+
+ *urllist = NULL;
+
+ if (retstring != NULL)
+ free(retstring);
+ retstring = NULL;
+ lenght = 0;
+
+ retstring = (char *) malloc(1);
+ if (retstring == NULL)
+ return FALSE;
+ strcpy(retstring,"");
+
+ for(i=0;i<MAXCLIENT;i++) {
+ if (soc[i] != NULL) {
+
+ /*
+ * Add a space
+ */
+
+ if (lenght>0)
+ strcat(retstring," ");
+
+ /*
+ * Concatenate url to retstring
+ */
+
+ lenght += strlen(soc[i]->url) + 2;
+ retstring = (char *) realloc(retstring,lenght);
+ if (retstring == NULL)
+ return FALSE;
+ strcat(retstring,soc[i]->url);
+ }
+ }
+
+ *urllist = retstring;
+ return TRUE;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_SetRegionCaches: Set the geographic region occupied
+ * by caches.
+ *
+ * IN
+ * int ClientID: Identifiant of client
+ * ecs_Region *GR: Geographic region in the
+ *
+ * OUT
+ * char **error_message: Pointer to a string with a error message
+ * return int: Error message returned.
+ * TRUE: Success
+ * FALSE: Failure
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_SetRegionCaches(ClientID, GR,error_message)
+ int ClientID;
+ ecs_Region *GR;
+ char **error_message;
+{
+ register ecs_Client *cln;
+
+ *error_message = NULL;
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ *error_message = cln_messages[2];
+ return FALSE;
+ }
+
+ cln->cacheRegion.north = GR->north;
+ cln->cacheRegion.south = GR->south;
+ cln->cacheRegion.east = GR->east;
+ cln->cacheRegion.west = GR->west;
+ cln->cacheRegion.ns_res = GR->ns_res;
+ cln->cacheRegion.ew_res = GR->ew_res;
+
+ return TRUE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_LoadCache: Create a new cache and assign to it the
+ * objects requested in a layer selection, in the region
+ * given by cln->cacheRegion.
+ *
+ * IN
+ * int ClientID: Identifiant of client
+ * ecs_LayerSelection *ls: Layer selection to assign
+ * to this server
+ *
+ * OUT
+ * char **error_message: Error message to return to client.
+ * return int: Error message returned.
+ * TRUE: Success
+ * FALSE: Failure
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_LoadCache(ClientID, ls, error_message)
+ int ClientID;
+ ecs_LayerSelection *ls;
+ char **error_message;
+{
+ ecs_Cache *NewCache;
+ ecs_Cache *CachePtr;
+ ecs_Result *obj;
+ register ecs_Client *cln;
+ ecs_Result *res;
+ int code;
+ int n;
+
+ *error_message = NULL;
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ *error_message = cln_messages[2];
+ return FALSE;
+ }
+
+ /*
+ * Check if the type is vectorial. If not, return an error message.
+ */
+
+ if (ls->F != Area && ls->F != Line && ls->F != Point && ls->F != Text) {
+ *error_message = cln_messages[12];
+ return FALSE;
+ }
+
+ /*
+ * Check if the cache already exist in the cache.
+ */
+
+ CachePtr = cln->cache;
+ while(CachePtr!=NULL) {
+ if ((strcmp(CachePtr->coverage.Select,ls->Select) == 0) &&
+ (CachePtr->coverage.F == ls->F)) {
+ return TRUE;
+ }
+ CachePtr = CachePtr->next;
+ }
+
+ /*
+ * If the cache don't exist, create a new one. First start a selection
+ * with a certain layer.
+ */
+
+ res = cln_SelectLayer(ClientID, ls);
+ if (res->error != 0) {
+ *error_message = res->message;
+ return FALSE;
+ }
+
+ res = cln_SelectRegion(ClientID, &(cln->cacheRegion));
+ if (res->error != 0) {
+ *error_message = res->message;
+ return FALSE;
+ }
+
+ NewCache = cln_NewCache(CACHEINITSIZE);
+ if (NewCache==NULL) {
+ *error_message = cln_messages[1];
+ return FALSE;
+ }
+
+ /*
+ * Allocate coverage
+ */
+
+ NewCache->coverage.Select = (char *) malloc(strlen(ls->Select)+1);
+ if (NewCache->coverage.Select == NULL) {
+ cln_FreeCache(NewCache);
+ *error_message = cln_messages[1];
+ return FALSE;
+ }
+ strcpy(NewCache->coverage.Select,ls->Select);
+ NewCache->coverage.F = ls->F;
+
+ /*
+ * Add to object cache table all the selected objects.
+ * MultiResult responses have to be dealt with a little differently.
+ * Only a single error is returned for a MultiResult, and that error
+ * pertains only to the a request after the last object in the MultiResult
+ * array. All objects in the array were retrieved without an error.
+ * When the server encounters an error, it sends all accumulated results
+ * so far and sets the error condition.
+ */
+
+ res = svr_GetNextObject(&(cln->s));
+ while((res->error == 0) ||
+ (res->res.type == MultiResult && res->res.ecs_ResultUnion_u.results.results_len > 0)) {
+
+ n = (res->res.type == MultiResult) ? res->res.ecs_ResultUnion_u.results.results_len : 1;
+ if (NewCache->size+n >= NewCache->allocatedSize) {
+ NewCache->allocatedSize += (CACHEINITSIZE >= n) ? CACHEINITSIZE : n;
+ NewCache->o = (ecs_Result **)
+ realloc(NewCache->o,sizeof(ecs_Result *)*(NewCache->allocatedSize));
+ if(NewCache == NULL) {
+ *error_message = cln_messages[1];
+ return FALSE;
+ }
+ }
+ if (res->res.type != MultiResult) {
+ /*
+ * Make a copy of the object
+ */
+ code = ecs_CopyResult(res,&obj);
+ if (code == FALSE) {
+ cln_FreeCache(NewCache);
+ return FALSE;
+ }
+ NewCache->o[NewCache->size++] = obj;
+ } else {
+ /*
+ * Break MultiResult object apart
+ */
+ for (n = 0; n < (int) res->res.ecs_ResultUnion_u.results.results_len; n++) {
+ code = ecs_CopyResultFromUnion(&res->res,&obj);
+ if (code == FALSE) {
+ cln_FreeCache(NewCache);
+ return FALSE;
+ }
+ NewCache->o[NewCache->size++] = obj;
+ }
+ if (res->error) {
+ break;
+ }
+ }
+ res = svr_GetNextObject(&(cln->s));
+ }
+
+ /* Ajouter la nouvelle cache dans la liste */
+
+ if (cln->cache != NULL) {
+ cln->cache->previous = NewCache;
+ NewCache->next = cln->cache;
+ cln->cache = NewCache;
+ } else {
+ cln->cache = NewCache;
+ }
+
+ return TRUE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_ReleaseCache: Destroy the cache related to a coverage
+ *
+ * IN
+ * int ClientID: Identifiant of client
+ * ecs_LayerSelection *ls: Layer selection to assign
+ * to this server
+ *
+ * OUT
+ * char **error_message: Error message to return to client.
+ * return int: Error message returned.
+ * TRUE: Success
+ * FALSE: Failure
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_ReleaseCache(ClientID, ls, error_message)
+ int ClientID;
+ ecs_LayerSelection *ls;
+ char **error_message;
+{
+ ecs_Cache *CachePtr;
+ register ecs_Client *cln;
+
+ *error_message = NULL;
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ *error_message = cln_messages[2];
+ return FALSE;
+ }
+
+ cln->selectCache = NULL;
+ CachePtr = cln->cache;
+ while(CachePtr!=NULL) {
+ if ((strcmp(CachePtr->coverage.Select,ls->Select) == 0) &&
+ CachePtr->coverage.F == ls->F) {
+ if (cln->cache == CachePtr) {
+ cln->cache = CachePtr->next;
+ if (cln->cache != NULL)
+ cln->cache->previous = NULL;
+ } else {
+ if(CachePtr->next!=NULL)
+ CachePtr->next->previous = CachePtr->previous;
+ if(CachePtr->previous!=NULL)
+ CachePtr->previous->next = CachePtr->next;
+ }
+ cln_FreeCache(CachePtr);
+ return TRUE;
+ }
+
+ CachePtr = CachePtr->next;
+ }
+
+ *error_message = cln_messages[6];
+ return FALSE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_NewCache: Allocate a new cache structure
+ *
+ * OUT
+ * return : NULL if no memory available, a cache otherwise
+ *
+ *----------------------------------------------------------------------
+ */
+ecs_Cache *
+cln_NewCache(int size)
+{
+ ecs_Cache *cache;
+
+ cache = (ecs_Cache *) malloc(sizeof(ecs_Cache));
+ if (cache==NULL) {
+ return NULL;
+ }
+
+ cache->coverage.Select = NULL;
+ cache->o = NULL;
+ cache->startpos = 0;
+ cache->currentpos = 0;
+ cache->size = 0;
+ cache->next = NULL;
+ cache->previous = NULL;
+
+ /*
+ * Allocate object cache table
+ */
+
+ cache->allocatedSize = size;
+ cache->o = (ecs_Result **) malloc(sizeof(ecs_Result *) * size);
+ if (cache->o == NULL) {
+ free(cache);
+ return NULL;
+ }
+
+ return cache;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_FreeCache: Free the cache memory
+ *
+ * IN
+ * ecs_Cache *Cache: Cache to be free
+ *
+ *----------------------------------------------------------------------
+ */
+
+void cln_FreeCache(Cache)
+ ecs_Cache *Cache;
+{
+ int i;
+
+ if (Cache != NULL) {
+ if (Cache->coverage.Select != NULL)
+ free(Cache->coverage.Select);
+ if (Cache->o != NULL) {
+ for(i=0;i<Cache->size;i++) {
+ if (Cache->o[i] != NULL) {
+ if (Cache->o[i]->res.type == Object) {
+ ecs_FreeObject(&(Cache->o[i]->res.ecs_ResultUnion_u.dob));
+ }
+ free(Cache->o[i]);
+ Cache->o[i] = NULL;
+ }
+ }
+ free(Cache->o);
+ }
+ free(Cache);
+ }
+
+ return;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_FoundCache: Search the cache list for a cache who correspond to
+ * a layer.
+ *
+ * IN
+ * int ClientID: Identifiant of client
+ * ecs_LayerSelection *ls: Layer information structure
+ *
+ * OUT
+ * return ecs_Cache *: A pointer to a cache. If NULL, the cache was
+ * not found.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Cache *cln_FoundCache(ClientID, ls)
+ int ClientID;
+ ecs_LayerSelection *ls;
+{
+ ecs_Cache *CachePtr,*FoundCache;
+ register ecs_Client *cln;
+
+ cln = soc[ClientID];
+ if (cln == NULL)
+ return NULL;
+
+ FoundCache = NULL;
+ CachePtr = cln->cache;
+
+ while(CachePtr!=NULL) {
+ if ((strcmp(CachePtr->coverage.Select,ls->Select) == 0) &&
+ (CachePtr->coverage.F == ls->F)) {
+ FoundCache = CachePtr;
+ break;
+ }
+
+ CachePtr = CachePtr->next;
+ }
+
+ return FoundCache;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_CalcCtlPoint: For a given point in the client region,
+ * calculate the corresponding point in the server region.
+ *
+ * IN
+ * int ClientID: Identifiant of client
+ * ecs_Region *server_region: Server region
+ * int SI, SJ: Control point in T matrix
+ *
+ * OUT
+ * ecs_CtlPoint *pt: Control point
+ * return int: Error message returned.
+ * TRUE: Success
+ * FALSE: Failure
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_CalcCtlPoint(ClientID,server_region,SI,SJ,pt)
+ int ClientID;
+ ecs_Region *server_region;
+ int SI;
+ int SJ;
+ ecs_CtlPoint *pt;
+{
+ double X,Y;
+ register ecs_Client *cln;
+ int error_code;
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ return FALSE;
+ }
+
+ /* Found the geographic position of SI,SJ in source */
+
+ X = cln->currentRegion.west + SI * cln->currentRegion.ew_res;
+ Y = cln->currentRegion.north - SJ * cln->currentRegion.ns_res;
+
+ /* Convert this point in server projection */
+
+ if ((error_code = cln_ConvTtoS(ClientID, &X, &Y)) != 0) {
+ return FALSE;
+ }
+
+ /* Found the corresponding position of this point in server region */
+
+ pt->e1 = (double) SI;
+ pt->n1 = (double) SJ;
+ pt->e2 = (X - server_region->west) / server_region->ew_res;
+ pt->n2 = (server_region->north - Y) / server_region->ns_res;
+ return TRUE;
+}
+
+
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_CalcCtlPoints: For a given region, calculate control points
+ * for matrix transformation.
+ *
+ * IN
+ * int ClientID: Identifiant of client
+ *
+ * OUT
+ * ecs_CalcCtlPoints **pts: new structure with control points
+ * char **error_message: error message
+ * return int: Error message returned.
+ * TRUE: Success
+ * FALSE: Failure
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_CalcCtlPoints(ClientID,pts,error_message)
+ int ClientID;
+ ecs_CtlPoints **pts;
+ char **error_message;
+{
+ static ecs_CtlPoints *newpts = NULL;
+ register ecs_Client *cln;
+ int width, height;
+ ecs_Region server_region;
+
+ *error_message = NULL;
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ *error_message = cln_messages[2];
+ *pts = NULL;
+ return FALSE;
+ }
+
+ /* Prepare newpts structure */
+
+ if (newpts != NULL) {
+ if (newpts->pts != NULL) {
+ free(newpts->pts);
+ newpts->pts = NULL;
+ }
+ free(newpts);
+ newpts = NULL;
+ }
+
+ newpts = (ecs_CtlPoints *) malloc(sizeof(ecs_CtlPoints));
+ if (newpts == NULL) {
+ *error_message = cln_messages[1];
+ *pts = NULL;
+ return FALSE;
+ }
+
+ newpts->nbpts = 9;
+ newpts->pts = (ecs_CtlPoint *) malloc(sizeof(ecs_CtlPoint)*9);
+ if (newpts->pts == NULL) {
+ *error_message = cln_messages[1];
+ free(newpts);
+ newpts = NULL;
+ *pts = NULL;
+ return FALSE;
+ }
+
+ /* Calculate server region with client value */
+
+ server_region.north = cln->currentRegion.north;
+ server_region.south = cln->currentRegion.south;
+ server_region.east = cln->currentRegion.east;
+ server_region.west = cln->currentRegion.west;
+ server_region.ns_res = cln->currentRegion.ns_res;
+ server_region.ew_res = cln->currentRegion.ew_res;
+ cln_ConvRegion(ClientID,&(server_region),ECS_TTOS);
+
+ /* Calculate raster width and height */
+
+ width = (int) (((cln->currentRegion.east - cln->currentRegion.west) /
+ cln->currentRegion.ew_res) + 0.5);
+ height = (int)(((cln->currentRegion.north - cln->currentRegion.south) /
+ cln->currentRegion.ns_res) + 0.5);
+
+ if( width < 1 )
+ width = 1;
+ if( height < 1 )
+ height = 1;
+
+ /* Assign points and return result */
+
+ if ((cln_CalcCtlPoint(ClientID, &server_region, 0, 0, &(newpts->pts[0]))) &&
+ (cln_CalcCtlPoint(ClientID, &server_region, 0, (height / 2), &(newpts->pts[1]))) &&
+ (cln_CalcCtlPoint(ClientID, &server_region, 0, height, &(newpts->pts[2]))) &&
+ (cln_CalcCtlPoint(ClientID, &server_region, (width / 2), 0, &(newpts->pts[3]))) &&
+ (cln_CalcCtlPoint(ClientID, &server_region, (width / 2), (height / 2), &(newpts->pts[4]))) &&
+ (cln_CalcCtlPoint(ClientID, &server_region, (width / 2), height, &(newpts->pts[5]))) &&
+ (cln_CalcCtlPoint(ClientID, &server_region, width, 0, &(newpts->pts[6]))) &&
+ (cln_CalcCtlPoint(ClientID, &server_region, width, (height / 2), &(newpts->pts[7]))) &&
+ (cln_CalcCtlPoint(ClientID, &server_region, width, height, &(newpts->pts[8])))) {
+ *pts = newpts;
+ return TRUE;
+ }
+
+ *error_message = cln_messages[8];
+ free(newpts->pts);
+ free(newpts);
+ newpts = NULL;
+ *pts = NULL;
+ return FALSE;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_SetRasterConversion: Set the matrix projection conversion.
+ *
+ * This program computes the planar projective transformation
+ * parameters and the corresponding residuals.
+ *
+ * The transformation is done from system x, y (rect.in) to
+ * system X, Y (nonrect.in) obtained from the original image.
+ *
+ * For the client server extension, these coordinates become:
+ *
+ * x : e1 Coordinates of the Client
+ * y : n1
+ *
+ * X : e2 Coordinates of the Server
+ * Y : n2
+ *
+ * IN
+ * int ClientID: Identifiant of client
+ * ecs_Resampling resampling: Resampling value
+ * ecs_Transformation trans: Transformation value
+ *
+ *
+ * IN/OUT
+ * ecs_CalcCtlPoints **pts: new structure with control points.
+ * If this structure is NULL, the procedure cln_CalcCtlPoints
+ * will be called. In the other cases, the calculations will
+ * be done with this argument value. It's return the same structure
+ * with errorx and errory set.
+ *
+ * OUT
+ * char **error_message: error message
+ * return int: Error message returned.
+ * TRUE: Success
+ * FALSE: Failure
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_SetRasterConversion(ClientID,pts,resampling,trans,error_message)
+ int ClientID;
+ ecs_CtlPoints **pts;
+ ecs_Resampling resampling;
+ ecs_Transformation trans;
+ char **error_message;
+{
+ register ecs_Client *cln;
+ ecs_CtlPoints *localpts;
+ ecs_RasterConversion rc;
+ ecs_Result *result;
+ double **A, **AtA, **Atw, **w, **d, **res;
+ int i, j, k;
+
+ *error_message = NULL;
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ *error_message = cln_messages[2];
+ *pts = NULL;
+ return FALSE;
+ }
+
+ /* prepare the ecs_RasterConversion structure */
+
+ rc.coef.coef_len = 8;
+ rc.coef.coef_val = (double *) malloc(sizeof(double)*8);
+ if (rc.coef.coef_val == NULL) {
+ *error_message = cln_messages[1];
+ *pts = NULL;
+ return FALSE;
+ }
+
+ /* step 1: Calculate control points */
+
+ if (*pts == NULL) {
+ localpts = NULL;
+ if (!cln_CalcCtlPoints(ClientID,&localpts,error_message)) {
+ *pts = NULL;
+ return FALSE;
+ }
+ } else {
+ localpts = *pts;
+ }
+
+ /* step 2: Generate matrix A and vector W for least-squares adjustment */
+
+ A = mat_malloc(localpts->nbpts*2, 8);
+ AtA = mat_malloc(8, 8);
+ Atw = mat_malloc(8, 1);
+ w = mat_malloc(localpts->nbpts*2, 1);
+ d = mat_malloc(8, 1);
+ res = mat_malloc(localpts->nbpts, 2);
+
+ if ((A == NULL) || (AtA == NULL) || (Atw == NULL) || (w == NULL) ||
+ (d == NULL) || (res == NULL)) {
+ *error_message = cln_messages[1];
+ *pts = NULL;
+ free(rc.coef.coef_val);
+ return FALSE;
+ }
+
+ /* Form the design matrix A and vector w */
+
+ for(i=0, k=0; i<localpts->nbpts*2; i+=2, k++) {
+
+ /* Matrix inxy(x,y) or e1[k], n1[k] : corrected coordinates (client) */
+ /* Matrix inXY(X,Y) or e2[k], n2[k] : uncorrected coordinates (server) */
+
+ j = i+1;
+
+ /* Design Matrix A */
+
+ A[i][0] = localpts->pts[k].e1;
+ A[i][1] = localpts->pts[k].n1;
+ A[i][2] = 0;
+ A[i][3] = 0;
+ A[i][4] = -(localpts->pts[k].e1)*localpts->pts[k].e2;
+ A[i][5] = -(localpts->pts[k].n1)*localpts->pts[k].e2;
+ A[i][6] = 1;
+ A[i][7] = 0;
+
+ A[j][0] = 0;
+ A[j][1] = 0;
+ A[j][2] = localpts->pts[k].e1;
+ A[j][3] = localpts->pts[k].n1;
+ A[j][4] = -(localpts->pts[k].e1)*localpts->pts[k].n2;
+ A[j][5] = -(localpts->pts[k].n1)*localpts->pts[k].n2;
+ A[j][6] = 0;
+ A[j][7] = 1;
+
+ /* Vector w */
+
+ w[i][0] = localpts->pts[k].e2;
+ w[j][0] = localpts->pts[k].n2;
+ }
+
+ /* step 3: Matrix resolution and parameters generation */
+
+ /* Compute the parameters using a least-squares adjustment */
+ /* d = (AtA)-1 * Atw */
+
+ mat_mul_transposed(A,localpts->nbpts*2,8,A,localpts->nbpts*2,8,AtA);
+
+ mat_inverse(AtA, 8);
+
+ mat_mul_transposed(A,localpts->nbpts*2,8,w,localpts->nbpts*2,1,Atw);
+
+ mat_mul_direct(AtA,8,8,Atw,8,1,d);
+
+ /* Compute the residuals */
+
+ for(i=0; i<localpts->nbpts; i++) {
+ localpts->pts[i].errorx = ((d[0][0]*localpts->pts[i].e1+d[1][0]*localpts->pts[i].n1+d[6][0])/(d[4][0]*localpts->pts[i].e1+d[5][0]*localpts->pts[i].n1+1)) - localpts->pts[i].e2;
+
+ localpts->pts[i].errory = ((d[2][0]*localpts->pts[i].e1+d[3][0]*localpts->pts[i].n1+d[7][0])/(d[4][0]*localpts->pts[i].e1+d[5][0]*localpts->pts[i].n1+1)) - localpts->pts[i].n2;
+ }
+
+ /* Puts information in ecs_RasterConversion */
+
+ if(cln->isTargetLL == TRUE &&
+ cln->isSourceLL == TRUE)
+ rc.isProjEqual = TRUE;
+ else
+ rc.isProjEqual = cln->isProjEqual;
+ rc.r_method = resampling;
+ rc.t_method = trans;
+ rc.coef.coef_len = 8;
+ for (i=0; i<8; i++) {
+ rc.coef.coef_val[i] = d[i][0];
+ }
+
+ /* Call the server */
+
+ result = svr_SetRasterConversion(&(cln->s),&rc);
+ if (result->error != 0) {
+ *error_message = result->message;
+ *pts = NULL;
+ mat_free(A,localpts->nbpts*2);
+ mat_free(AtA, 8);
+ mat_free(Atw, 8);
+ mat_free(w, localpts->nbpts*2);
+ mat_free(d, 8);
+ mat_free(res, localpts->nbpts);
+ free(rc.coef.coef_val);
+ return FALSE;
+ }
+ mat_free(A,localpts->nbpts*2);
+ mat_free(AtA, 8);
+ mat_free(Atw, 8);
+ mat_free(w, localpts->nbpts*2);
+ mat_free(d, 8);
+ mat_free(res, localpts->nbpts);
+ free(rc.coef.coef_val);
+ *pts = localpts;
+ return TRUE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_SetCompression: Set the server compression parameters
+ *
+ * IN
+ * int ClientID: Client identifier
+ * ecs_Compression: Compression parameters
+ *
+ * OUT
+ * return ecs_Result: Operation result
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_SetCompression(ClientID,compression)
+ int ClientID;
+ ecs_Compression *compression;
+{
+ register ecs_Client *cln;
+ ecs_Result *msg;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+ msg = svr_SetCompression(&(cln->s),compression);
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_LoadCapabilities(): Load and parse capabilities document.
+ *
+ * IN
+ * int ClientID: Client identifier
+ * const char *arg: Either "ogdi_capabilities" or
+ * "ogdi_server_capabilities".
+ *
+ * OUT
+ * return ecs_Result: Operation result (success is ecs_Text or error)
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_LoadCapabilities(int ClientID, const char *arg,
+ int error_if_unsupported)
+
+{
+ ecs_Client *cln;
+ ecs_Result *msg, *result;
+ char *cap_doc;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+
+ /*
+ * Don't do anything, if these capabilities already loaded. Eventually
+ * we should allow re-loading of capabilities document in case the
+ * application wants to test error reports, or force a refresh.
+ */
+ if( (cln->have_server_capabilities
+ && strcmp(arg,"ogdi_server_capabilities") == 0)
+ || (cln->have_capabilities
+ && strcmp(arg,"ogdi_capabilities") == 0) )
+ {
+ msg = &cln_dummy_result;
+ ecs_SetText(msg,"");
+ ecs_SetSuccess(msg);
+ return msg;
+ }
+
+ /*
+ * Load the requested capabilities document.
+ */
+ result = cln_UpdateDictionary(ClientID, (char *) arg);
+ if( ECSERROR(result) && error_if_unsupported )
+ return result;
+
+ /*
+ * Did we get an error, or is this clearly not a capabilities document?
+ * If not, apply a default configuration for pre 3.1 compatibility.
+ */
+ if( ECSERROR(result)
+ || strncmp(ECSTEXT(result),"<?xml",5) != 0
+ || strstr(ECSTEXT(result),"OGDI_Capabilities") == NULL )
+ {
+ if( error_if_unsupported )
+ {
+ assert( result == &cln_dummy_result );
+ if( !ECSERROR(result) )
+ {
+ char error[1024];
+
+ sprintf( error,
+ "Return value of cln_UpdateDictionary(%s) is clearly "
+ "not an OGDI_Capabilities result.",
+ arg );
+ ecs_SetError(&cln_dummy_result,1, error );
+ }
+
+ return &cln_dummy_result;
+ }
+
+ ecs_SetText(&cln_dummy_result,"");
+ ecs_SetSuccess(&cln_dummy_result);
+
+ cln->have_server_capabilities = TRUE;
+ strcpy( cln->server_version_str, "3.0" );
+ cln->server_version = 3000;
+
+ cln->have_capabilities = TRUE;
+
+ return &cln_dummy_result;
+ }
+
+ /*
+ * Make a copy of the document so nothing weird happens as our static
+ * result object is modified during parsing.
+ */
+ cap_doc = strdup(ECSTEXT(result));
+ if (cap_doc == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[1]);
+ return &cln_dummy_result;
+ }
+
+ /*
+ * Parse it.
+ */
+ ecs_SetSuccess( &cln_dummy_result );
+ ecs_ParseCapabilities( cln, cap_doc, &cln_dummy_result );
+
+ free( cap_doc );
+
+ return &cln_dummy_result;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetVersion(): Return the driver version string.
+ *
+ * IN
+ * int ClientID: Client identifier
+ *
+ * OUT
+ * return ecs_Result: Operation result (ecs_Text with version string)
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *cln_GetVersion(int ClientID)
+
+{
+ ecs_Client *cln;
+ ecs_Result *msg;
+
+ if (multiblock != 0) {
+ msg = &cln_dummy_result;
+ ecs_SetError(msg,1,cln_messages[14]);
+ return msg;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ ecs_SetError(&cln_dummy_result,1,cln_messages[2]);
+ return &cln_dummy_result;
+ }
+
+ cln_LoadCapabilities(ClientID, "ogdi_server_capabilities", 0 );
+
+ msg = &cln_dummy_result;
+ ecs_SetText(msg,cln->server_version_str);
+ ecs_SetSuccess(msg);
+
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_CheckExtension(): Test if requested extension is enabled.
+ *
+ * IN
+ * int ClientID: Client identifier
+ * const char *extension: the name of the extension to test for.
+ * const char *layer_name: the name of the layer to test on or NULL.
+ *
+ * OUT
+ * return ecs_Result: Operation result (ecs_Text with version string)
+ *
+ *----------------------------------------------------------------------
+ */
+
+int cln_CheckExtension(int ClientID, const char *extension,
+ const char *layer_name )
+
+{
+ ecs_Client *cln;
+ ecs_Result *result;
+ char **extensions;
+ int i, layer;
+
+ if (multiblock != 0) {
+ return FALSE;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ return FALSE;
+ }
+
+ if( layer_name == NULL )
+ result = cln_LoadCapabilities(ClientID, "ogdi_server_capabilities", 0 );
+ else
+ result = cln_LoadCapabilities(ClientID, "ogdi_capabilities", 0 );
+
+ if( ECSERROR(result) )
+ return FALSE;
+
+ /*
+ * Test in global extensions.
+ */
+
+ extensions = cln->global_extensions;
+ for( i = 0; extensions != NULL && extensions[i] != NULL; i++ )
+ {
+ if( strcmp(extensions[i],extension) == 0 )
+ return TRUE;
+ }
+
+ if( layer_name == NULL )
+ return FALSE;
+
+ /*
+ * Test within layer.
+ */
+ for( layer = 0; layer < cln->layer_cap_count; layer++ )
+ {
+ if( strcmp(layer_name, cln->layer_cap[layer]->name) == 0 )
+ {
+ extensions = cln->layer_cap[layer]->extensions;
+ for( i = 0; extensions != NULL && extensions[i] != NULL; i++ )
+ {
+ if( strcmp(extensions[i],extension) == 0 )
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+ }
+
+ return FALSE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * cln_GetLayerCapabilities(): Get layer definition.
+ *
+ * Note that there is no way to find out the number of layers explicitly.
+ * Applications are intended to call cln_GetLayerCapabilities() repeatedly
+ * with incrementing layer_index values till a NULL is returned.
+ *
+ * IN
+ * int ClientID: Client identifier
+ * int layer_index: The zero based index of the layer.
+ *
+ * OUT
+ * return ecs_LayerCapabilities of layer or NULL if unavailable. The
+ * returned pointer is to internal data and should not be
+ * modified or freed. It will be invalidated when the client
+ * is destroyed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+const ecs_LayerCapabilities *
+cln_GetLayerCapabilities( int ClientID, int layer_index )
+
+{
+ ecs_Client *cln;
+
+ if (multiblock != 0) {
+ return NULL;
+ }
+
+ cln = soc[ClientID];
+ if (cln == NULL) {
+ return NULL;
+ }
+
+ if( ECSERROR(cln_LoadCapabilities(ClientID, "ogdi_capabilities", 0 )) )
+ return NULL;
+
+ if( layer_index < 0 || layer_index >= cln->layer_cap_count )
+ return NULL;
+ else
+ return cln->layer_cap[layer_index];
+}
+
+/*
+ cln_BlockOGDI
+
+ Block the ogdi
+ */
+
+void cln_BlockOGDI()
+{
+ multiblock = 1;
+}
+
+/*
+ cln_UnBlockOGDI
+
+ Block the ogdi
+ */
+
+void cln_UnBlockOGDI()
+{
+ multiblock = 0;
+}
+
+#ifdef _WINDOWS
+/*
+ *----------------------------------------------------------------------
+ * DllMain --
+ *
+ * When the DLL is being unloaded, make sure to destroy all of
+ * the clients that remain open.
+ *
+ * OUT
+ * return TRUE
+ *----------------------------------------------------------------------
+ */
+BOOL WINAPI
+DllMain( HINSTANCE hinstDLL, // handle of DLL module
+ DWORD fdwReason, // reason for calling function
+ LPVOID lpvReserved)
+{
+ switch (fdwReason) {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ break;
+ case DLL_PROCESS_DETACH:
+ {
+ int i;
+ for(i=0;i<MAXCLIENT;i++) {
+ cln_DestroyClient(i);
+ }
+ }
+ break;
+ }
+ return TRUE;
+}
+#endif /* ifdef _WINDOWS */
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_capabilities.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_capabilities.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_capabilities.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,570 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Low level XML Parsing functions for XML Capabilities documents.
+ *
+ ******************************************************************************
+ * Copyright (C) 2001 Information Interoperability Institute (3i)
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of 3i not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. 3i makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecs_capabilities.c,v $
+ * Revision 1.3 2001/06/13 17:17:40 warmerda
+ * fixed capabilities to match 6.2 spec
+ *
+ * Revision 1.2 2001/04/12 18:14:16 warmerda
+ * added/finished capabilities support
+ *
+ * Revision 1.1 2001/04/12 05:30:31 warmerda
+ * New
+ *
+ */
+
+#include <stdarg.h>
+#include "ecs.h"
+
+#ifndef EXPAT_DISABLED
+
+#include "expat.h"
+
+ECS_CVSID("$Id: ecs_capabilities.c,v 1.3 2001/06/13 17:17:40 warmerda Exp $");
+
+#define STACK_MAX 100
+
+/*
+ * NOTE: The following uses the Expat XML parsing library found in
+ * devdir/external/expat. More information on Expat can be found at:
+ *
+ * http://expat.sourceforge.net/
+ * http://www.xml.com/pub/a/1999/09/expat/index.html
+ */
+
+/* -------------------------------------------------------------------- */
+/* The capParseInfo structure is used to keep state information */
+/* through the parsing process of a capabilities document. */
+/* -------------------------------------------------------------------- */
+typedef struct {
+ ecs_Client *cln;
+
+ char *error;
+
+ char *version;
+
+ char **extensions;
+
+ int element_depth;
+ char *element_stack[STACK_MAX];
+
+ int found_feature_type_list;
+ int layer_count;
+ ecs_LayerCapabilities **layers;
+
+ ecs_LayerCapabilities *cur_layer;
+
+ char cdata[5000];
+
+} capParseInfo;
+
+/************************************************************************/
+/* recordError() */
+/************************************************************************/
+
+static void recordError( capParseInfo *pi, const char *fmt, ... )
+
+{
+ char buffer[10000];
+ va_list args;
+
+ va_start(args, fmt);
+ vsprintf( buffer, fmt, args );
+ va_end(args);
+
+ pi->error = strdup(buffer);
+#ifdef DEBUG
+ fprintf( stderr, "ecs_capabilities.c recordError():\n%s\n", pi->error );
+#endif
+}
+
+/************************************************************************/
+/* startElementHandler() */
+/************************************************************************/
+
+static void startElementHandler( void *cbData, const char *element,
+ const char **attr )
+
+{
+ capParseInfo *pi = (capParseInfo *) cbData;
+ int i;
+
+ if( pi->error != NULL )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Clear the current cdata we are collecting. */
+/* -------------------------------------------------------------------- */
+ pi->cdata[0] = '\0';
+
+/* -------------------------------------------------------------------- */
+/* Push this element onto our stack so we have a sense of context. */
+/* -------------------------------------------------------------------- */
+ if( pi->element_depth == STACK_MAX )
+ {
+ recordError( pi, "Element stack max (%d) exceeded with element <%s>.",
+ STACK_MAX, element );
+ return;
+ }
+ else
+ {
+ pi->element_stack[pi->element_depth] = strdup(element);
+ pi->element_depth++;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Pull driver OGDI version off the OGDI_Capabilities tag. */
+/* -------------------------------------------------------------------- */
+ if( strcmp(element,"OGDI_Capabilities") == 0 )
+ {
+ for( i = 0; attr != NULL && attr[i] != NULL; i += 2 )
+ {
+ if( strcmp(attr[i],"version") == 0 )
+ pi->version = strdup(attr[i+1]);
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* If we encounter a <FeatureType> element, create a new layer */
+/* object and initialize it. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"FeatureType") == 0 )
+ {
+ pi->layers = (ecs_LayerCapabilities **)
+ realloc(pi->layers, sizeof(void*) * (1 + ++pi->layer_count));
+ if( pi->layers == NULL )
+ {
+ pi->layers = 0;
+ recordError( pi, "out of memory" );
+ return;
+ }
+
+ pi->layers[pi->layer_count-1] =
+ (ecs_LayerCapabilities *) calloc(1,sizeof(ecs_LayerCapabilities));
+ pi->layers[pi->layer_count] = NULL;
+
+ /* eventually we need to capture the "parents" at this point */
+
+ pi->cur_layer = pi->layers[pi->layer_count-1];
+ }
+
+/* -------------------------------------------------------------------- */
+/* We try to capture cdata as a query expression description, */
+/* if available. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"QueryExpression") == 0 && pi->cur_layer != NULL )
+ {
+ pi->cur_layer->query_expression_set = TRUE;
+
+ for( i = 0; attr != NULL && attr[i] != NULL; i += 2 )
+ {
+ if( strcmp(attr[i],"qe_prefix") == 0 )
+ pi->cur_layer->qe_prefix = strdup(attr[i+1]);
+ else if( strcmp(attr[i],"qe_suffix") == 0 )
+ pi->cur_layer->qe_suffix = strdup(attr[i+1]);
+ else if( strcmp(attr[i],"qe_format") == 0 )
+ pi->cur_layer->qe_format = strdup(attr[i+1]);
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* We can handle LatLonBoundingBox immediately since all the */
+/* information is passed as attributes. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"LatLonBoundingBox") == 0
+ && pi->cur_layer != NULL )
+ {
+ int minx_set = 0, maxx_set = 0, miny_set = 0, maxy_set = 0;
+
+ for( i = 0; attr != NULL && attr[i] != NULL; i += 2 )
+ {
+ if( strcmp(attr[i],"minx") == 0 )
+ {
+ pi->cur_layer->ll_west = atof(attr[i+1]);
+ minx_set = 1;
+ }
+ else if( strcmp(attr[i],"maxx") == 0 )
+ {
+ pi->cur_layer->ll_east = atof(attr[i+1]);
+ maxx_set = 1;
+ }
+ else if( strcmp(attr[i],"miny") == 0 )
+ {
+ pi->cur_layer->ll_south = atof(attr[i+1]);
+ miny_set = 1;
+ }
+ else if( strcmp(attr[i],"maxy") == 0 )
+ {
+ pi->cur_layer->ll_north = atof(attr[i+1]);
+ maxy_set = 1;
+ }
+ else
+ {
+ /* we deliberately don't warn about unexpected attributes */
+ }
+ }
+
+ if( !minx_set || !maxx_set || !miny_set || !maxy_set )
+ {
+ recordError( pi, "One of minx, miny, maxx, or maxy not set for LatLonBoundingBox." );
+ return;
+ }
+
+ pi->cur_layer->ll_bounds_set = TRUE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* We can handle BoundingBox immediately since all the */
+/* information is passed as attributes. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"BoundingBox") == 0
+ && pi->cur_layer != NULL )
+ {
+ int minx_set = 0, maxx_set = 0, miny_set = 0, maxy_set = 0;
+ int x_res_set = 0, y_res_set = 0;
+
+ for( i = 0; attr != NULL && attr[i] != NULL; i += 2 )
+ {
+ if( strcmp(attr[i],"minx") == 0 )
+ {
+ pi->cur_layer->srs_west = atof(attr[i+1]);
+ minx_set = 1;
+ }
+ else if( strcmp(attr[i],"maxx") == 0 )
+ {
+ pi->cur_layer->srs_east = atof(attr[i+1]);
+ maxx_set = 1;
+ }
+ else if( strcmp(attr[i],"miny") == 0 )
+ {
+ pi->cur_layer->srs_south = atof(attr[i+1]);
+ miny_set = 1;
+ }
+ else if( strcmp(attr[i],"maxy") == 0 )
+ {
+ pi->cur_layer->srs_north = atof(attr[i+1]);
+ maxy_set = 1;
+ }
+ else if( strcmp(attr[i],"resy") == 0 )
+ {
+ pi->cur_layer->srs_nsres = atof(attr[i+1]);
+ y_res_set = 1;
+ }
+ else if( strcmp(attr[i],"resx") == 0 )
+ {
+ pi->cur_layer->srs_ewres = atof(attr[i+1]);
+ x_res_set = 1;
+ }
+ else
+ {
+ /* we deliberately don't warn about unexpected attributes */
+ }
+ }
+
+ if( !minx_set || !maxx_set || !miny_set || !maxy_set
+ || !x_res_set || !y_res_set )
+ {
+ recordError( pi, "One of resx, resy, minx, miny, maxx, or maxy not set for BoundingBox" );
+ return;
+ }
+ }
+}
+
+/************************************************************************/
+/* endElementHandler() */
+/************************************************************************/
+
+static void endElementHandler( void *cbData, const char *element )
+
+{
+ capParseInfo *pi = (capParseInfo *) cbData;
+
+ if( pi->error != NULL )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* On the end of a layer definition we check that we have */
+/* required fields. */
+/* -------------------------------------------------------------------- */
+ if( strcmp( element, "FeatureType" ) == 0 && pi->cur_layer != NULL )
+ {
+ if( pi->cur_layer->name == NULL )
+ {
+ recordError( pi, "Didn't get a <Name> for a layer." );
+ return;
+ }
+ else if( pi->cur_layer->srs_ewres == 0.0 )
+ {
+ recordError( pi, "Didn't get valid BoundingBox for layer %s.",
+ pi->cur_layer->name );
+ }
+
+ pi->cur_layer = NULL;
+ }
+
+/* -------------------------------------------------------------------- */
+/* If we are processing a layer and encounter a name, apply to */
+/* the layer. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"Name") == 0 && pi->cur_layer != NULL )
+ {
+ pi->cur_layer->name = strdup(pi->cdata);
+ }
+
+/* -------------------------------------------------------------------- */
+/* If we are processing a layer and encounter a title, apply to */
+/* the layer. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"Title") == 0 && pi->cur_layer != NULL )
+ {
+ pi->cur_layer->title = strdup(pi->cdata);
+ }
+
+/* -------------------------------------------------------------------- */
+/* If we are processing a layer and encounter an SRS, apply to */
+/* the layer. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"SRS") == 0 && pi->cur_layer != NULL )
+ {
+ if( strncmp(pi->cdata,"PROJ4:",6) == 0 )
+ pi->cur_layer->srs = strdup(pi->cdata+6);
+ else
+ pi->cur_layer->srs = strdup(pi->cdata);
+ }
+
+/* -------------------------------------------------------------------- */
+/* We try to capture cdata as a query expression description, */
+/* if available. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"QueryExpression") == 0
+ && pi->cur_layer != NULL && strlen(pi->cdata) > 0 )
+ {
+ pi->cur_layer->qe_description = strdup(pi->cdata);
+ }
+
+/* -------------------------------------------------------------------- */
+/* If we are processing a layer and encounter a family, add to */
+/* the layer. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"Family") == 0 && pi->cur_layer != NULL )
+ {
+ if( strcmp(pi->cdata,"Matrix") == 0 )
+ pi->cur_layer->families[Matrix] = 1;
+ else if( strcmp(pi->cdata,"Image") == 0 )
+ pi->cur_layer->families[Image] = 1;
+ else if( strcmp(pi->cdata,"Area") == 0 )
+ pi->cur_layer->families[Area] = 1;
+ else if( strcmp(pi->cdata,"Line") == 0 )
+ pi->cur_layer->families[Line] = 1;
+ else if( strcmp(pi->cdata,"Point") == 0 )
+ pi->cur_layer->families[Point] = 1;
+ else if( strcmp(pi->cdata,"Text") == 0 )
+ pi->cur_layer->families[Text] = 1;
+ else if( strcmp(pi->cdata,"Edge") == 0 )
+ pi->cur_layer->families[Edge] = 1;
+ else if( strcmp(pi->cdata,"Face") == 0 )
+ pi->cur_layer->families[Face] = 1;
+ else if( strcmp(pi->cdata,"Node") == 0 )
+ pi->cur_layer->families[Node] = 1;
+ else if( strcmp(pi->cdata,"Ring") == 0 )
+ pi->cur_layer->families[Ring] = 1;
+ }
+
+/* -------------------------------------------------------------------- */
+/* We keep track of whether we got through to the end of a */
+/* FeatureTypeList to know if this is really a full capabilities */
+/* document, rather than just a server capabilities document. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"FeatureTypeList") == 0 )
+ {
+ pi->found_feature_type_list = TRUE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Append extensions to the global, or layer list as appropriate. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(element,"Extension") == 0 )
+ {
+ char ***list;
+ int count;
+
+ if( pi->cur_layer != NULL )
+ list = &(pi->cur_layer->extensions);
+ else
+ list = &(pi->extensions);
+
+ for( count = 0; *list != NULL && (*list)[count] != NULL; count++ ) {}
+
+ if( *list == NULL )
+ *list = (char **) calloc(2,sizeof(char*));
+ else
+ *list = (char **) realloc(*list,(count+2) * sizeof(char*));
+
+ (*list)[count++] = strdup( pi->cdata );
+ (*list)[count] = NULL;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Pop the element off the stack. */
+/* -------------------------------------------------------------------- */
+ if( pi->element_depth > 0
+ && strcmp(element,pi->element_stack[pi->element_depth-1]) == 0 )
+ {
+ pi->element_depth--;
+ free( pi->element_stack[pi->element_depth] );
+ }
+ else
+ {
+ recordError( pi, "endElement(): unbalanced tag %s\n", element );
+ return;
+ }
+}
+
+/************************************************************************/
+/* charDataHandler() */
+/************************************************************************/
+
+static void charDataHandler( void *cbData, const char *text, int len )
+
+{
+ capParseInfo *pi = (capParseInfo *) cbData;
+
+ if( pi->error != NULL )
+ return;
+
+ if( strlen(pi->cdata) + len < sizeof(pi->cdata)-1 )
+ {
+ int cdata_len = strlen(pi->cdata);
+
+ strncpy( pi->cdata + cdata_len, text, len );
+ pi->cdata[cdata_len + len] = '\0';
+ }
+ else
+ {
+ recordError( pi, "CDATA buffer overrun in charDataHandler()." );
+ return;
+ }
+}
+#endif /* ndef EXPAT_DISABLED */
+
+/************************************************************************/
+/* _ecs_ParseCapabilities() */
+/************************************************************************/
+
+void ecs_ParseCapabilities( ecs_Client *cln, const char *cap_doc,
+ ecs_Result *result )
+
+{
+#ifdef EXPAT_DISABLED
+ ecs_SetError( result, 1,
+ "XML capabilities parsing disabled during compilation, parse fails." );
+#else
+ capParseInfo pi;
+ XML_Parser parser;
+ int i;
+
+ memset( &pi, 0, sizeof(pi) );
+
+ pi.cln = cln;
+ pi.layers = (ecs_LayerCapabilities **) calloc(1,sizeof(void*));
+
+/* -------------------------------------------------------------------- */
+/* Setup parser. */
+/* -------------------------------------------------------------------- */
+ parser = XML_ParserCreate(NULL);
+
+ XML_SetUserData( parser, &pi );
+ XML_SetElementHandler(parser, startElementHandler, endElementHandler);
+ XML_SetCharacterDataHandler(parser, charDataHandler);
+
+/* -------------------------------------------------------------------- */
+/* Parse whole document. */
+/* -------------------------------------------------------------------- */
+ XML_Parse( parser, cap_doc, strlen(cap_doc), TRUE );
+
+/* -------------------------------------------------------------------- */
+/* Report error. This will need to be substantially improved. */
+/* -------------------------------------------------------------------- */
+ if( pi.error != NULL )
+ {
+ ecs_SetError( result, 1, pi.error );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Apply captured information to the ecs_Client object. */
+/* -------------------------------------------------------------------- */
+ else
+ {
+ ecs_SetSuccess( result );
+ ecs_SetText( result, "" );
+
+ cln->have_server_capabilities = TRUE;
+ if( pi.version != NULL )
+ strcpy( cln->server_version_str, pi.version );
+ else
+ strcpy( cln->server_version_str, "3.0" );
+
+ cln->server_version = (int) (atof(cln->server_version_str)*1000 + 0.5);
+
+ if( cln->global_extensions != NULL )
+ {
+ for( i = 0; cln->global_extensions[i] != NULL; i++ )
+ free( cln->global_extensions[i] );
+ free( cln->global_extensions );
+ }
+
+ cln->global_extensions = pi.extensions;
+ pi.extensions = NULL;
+
+ cln->have_capabilities = pi.found_feature_type_list;
+
+ cln->layer_cap_count = pi.layer_count;
+ cln->layer_cap = pi.layers;
+
+ pi.layer_count = 0;
+ pi.layers = NULL;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Cleanup */
+/* -------------------------------------------------------------------- */
+ XML_ParserFree( parser );
+
+ if( pi.version )
+ free( pi.version );
+ if( pi.error )
+ free( pi.error );
+
+ if( pi.extensions )
+ {
+ for( i = 0; pi.extensions[i] != NULL; i++ )
+ free( pi.extensions[i] );
+ free( pi.extensions );
+ }
+
+ for( i = 0; i < pi.element_depth; i++ )
+ free( pi.element_stack[i] );
+
+ /*
+ * We should likely free layers in case of error, but that's complicated,
+ * so we will add this later perhaps with on centralized ecs_FreeLayerCap.
+ */
+#endif
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_dyna.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_dyna.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_dyna.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,206 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Functions for loading functions from DLLs / .so files.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecs_dyna.c,v $
+ * Revision 1.5 2007/02/12 18:06:31 cbalint
+ * Hide plugins from system libs path.
+ * Release versioning using sonames.
+ *
+ * Revision 1.4 2004/02/18 21:50:21 warmerda
+ * Added debug statement #ifdefed out.
+ *
+ * Revision 1.3 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecs_dyna.c,v 1.5 2007/02/12 18:06:31 cbalint Exp $");
+
+#if !defined(MISSING_DLFCN_H)
+#include <dlfcn.h>
+#endif
+
+
+/*
+ -------------------------------------------------
+
+ ecs_OpenDynamicLib: Open a dynamic link in a system
+
+ IN:
+ libname: A string with the dynamic library file name.
+ The dynamic library file could be without file extension.
+ OUT:
+ void *: A handle to a new link to a dynamic link. If NULL,
+ the dynamic link failed.
+
+ -------------------------------------------------
+ */
+
+void *ecs_OpenDynamicLib(libname)
+ char *libname;
+{
+ char *temp;
+#ifdef _WINDOWS
+ static HINSTANCE handle;
+
+ handle = LoadLibrary(libname);
+ if ((int) handle <= (int) HINSTANCE_ERROR) {
+ /* Try with the .dll extension */
+
+ if ((temp = (char *) malloc(strlen(libname)+5)) == NULL)
+ return NULL;
+ strcpy(temp,libname);
+ strcat(temp,".dll");
+
+ handle = LoadLibrary(temp);
+ free(temp);
+ if ((int) handle <= (int) HINSTANCE_ERROR) {
+ return NULL;
+ } else {
+ return (void *) handle;
+ }
+ } else {
+ return (void *) handle;
+ }
+#else
+#if !defined(MODULES_PATH)
+#define MODULES_PATH "/usr/lib/ogdi/"
+#endif
+ void *handle;
+
+ handle = dlopen(libname,RTLD_LAZY);
+ if (handle != NULL)
+ return handle;
+
+ if ((temp = (char *) malloc(strlen(MODULES_PATH)+strlen(libname)+1)) == NULL)
+ return NULL;
+ sprintf(temp,MODULES_PATH "%s",libname);
+ handle = dlopen(temp,RTLD_LAZY);
+ free(temp);
+ if (handle != NULL)
+ return handle;
+
+ if ((temp = (char *) malloc(strlen(MODULES_PATH)+strlen(libname)+7)) == NULL)
+ return NULL;
+ sprintf(temp,MODULES_PATH "lib%s.so",libname);
+ handle = dlopen(temp,RTLD_LAZY);
+ free(temp);
+
+ if (handle == NULL) {
+ /* Try with the .so extension */
+
+ if ((temp = (char *) malloc(strlen(libname)+7)) == NULL)
+ return NULL;
+ strcpy(temp,"lib");
+ strcat(temp,libname);
+ strcat(temp,".so");
+
+ handle = dlopen(temp,RTLD_LAZY);
+#ifdef notdef
+ printf( "dlopen(%s) error: %s\n", temp, dlerror() );
+#endif
+ free(temp);
+ }
+ return handle;
+
+#endif
+
+}
+
+/*
+ -------------------------------------------------
+
+ ecs_GetDynamicLibFunction: Initialise a pointer to
+ a function in the dynamic library.
+
+ IN:
+ handle : A link to dynamic library initialized by
+ ecs_OpenDynamicLib
+ functionname: A string with the function name
+
+ OUT:
+ void *: A pointer to the function. If NULL, an error
+ append during this operation.
+
+ -------------------------------------------------
+ */
+
+void *ecs_GetDynamicLibFunction(handle,functionname)
+ void *handle;
+ char *functionname;
+{
+ void *function;
+#ifndef _WINDOWS
+ char *temp;
+#endif
+
+ /* If the handle is NULL, return NULL */
+ if (handle == NULL)
+ return NULL;
+
+#ifdef _WINDOWS
+ function = (void *) GetProcAddress((HINSTANCE) handle, functionname);
+#else
+
+ function = (void *) dlsym(handle, functionname);
+ if (function == NULL) {
+ /* try with an underscore before the function name */
+ temp = (char *) malloc(strlen(functionname)+2);
+ if (temp == NULL)
+ return NULL;
+ strcpy(temp,"_");
+ strcat(temp,functionname);
+ function = (void *) dlsym(handle, functionname);
+ free(temp);
+ }
+#endif
+
+ return (void *) function;
+}
+
+/*
+ -------------------------------------------------
+
+ ecs_CloseDynamicLib: Open a dynamic link
+
+ IN:
+ handle : A link to dynamic library initialized by
+ ecs_OpenDynamicLib
+
+ -------------------------------------------------
+ */
+
+void ecs_CloseDynamicLib(handle)
+ void *handle;
+{
+ /* If the handle is NULL, end this operation */
+ if (handle == NULL)
+ return;
+
+#ifdef _WINDOWS
+ FreeLibrary((HINSTANCE) handle);
+#else
+ dlclose(handle);
+#endif
+
+ handle = NULL;
+ return;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_xdr.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_xdr.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_xdr.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,651 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "ecs.h"
+#include <ogdi_macro.h>
+
+bool_t
+xdr_ecs_Family(register XDR *xdrs, ecs_Family *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Region(register XDR *xdrs, ecs_Region *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_double(xdrs, &objp->north))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->south))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->east))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->west))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->ns_res))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->ew_res))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Resampling(register XDR *xdrs, ecs_Resampling *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Transformation(register XDR *xdrs, ecs_Transformation *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_RasterConversion(register XDR *xdrs, ecs_RasterConversion *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->coef.coef_val, (u_int *) &objp->coef.coef_len, ~0,
+ sizeof (double), (xdrproc_t) xdr_double))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->isProjEqual))
+ return (FALSE);
+ if (!xdr_ecs_Resampling(xdrs, &objp->r_method))
+ return (FALSE);
+ if (!xdr_ecs_Transformation(xdrs, &objp->t_method))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Coordinate(register XDR *xdrs, ecs_Coordinate *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_double(xdrs, &objp->x))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->y))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_FeatureRing(register XDR *xdrs, ecs_FeatureRing *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_ecs_Coordinate(xdrs, &objp->centroid))
+ return (FALSE);
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Area(register XDR *xdrs, ecs_Area *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->ring.ring_val, (u_int *) &objp->ring.ring_len, ~0,
+ sizeof (ecs_FeatureRing), (xdrproc_t) xdr_ecs_FeatureRing))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Line(register XDR *xdrs, ecs_Line *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Point(register XDR *xdrs, ecs_Point *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_ecs_Coordinate(xdrs, &objp->c))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Matrix(register XDR *xdrs, ecs_Matrix *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->x.x_val, (u_int *) &objp->x.x_len, ~0,
+ sizeof (u_int), (xdrproc_t) xdr_u_int))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Image(register XDR *xdrs, ecs_Image *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->x.x_val, (u_int *) &objp->x.x_len, ~0,
+ sizeof (u_int), (xdrproc_t) xdr_u_int))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Text(register XDR *xdrs, ecs_Text *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_string(xdrs, &objp->desc, ~0))
+ return (FALSE);
+ if (!xdr_ecs_Coordinate(xdrs, &objp->c))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Node(register XDR *xdrs, ecs_Node *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->containfaceid))
+ return (FALSE);
+ if (!xdr_ecs_Coordinate(xdrs, &objp->c))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Edge(register XDR *xdrs, ecs_Edge *objp)
+{
+
+ register int *buf;
+
+ if (xdrs->x_op == XDR_ENCODE) {
+ buf = XDR_INLINE(xdrs, 7 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->startnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->endnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfedgeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfedgeid))
+ return (FALSE);
+
+ } else {
+ ogdi_IXDR_PUT_LONG(buf, objp->id);
+ ogdi_IXDR_PUT_LONG(buf, objp->startnodeid);
+ ogdi_IXDR_PUT_LONG(buf, objp->endnodeid);
+ ogdi_IXDR_PUT_LONG(buf, objp->rightfaceid);
+ ogdi_IXDR_PUT_LONG(buf, objp->leftfaceid);
+ ogdi_IXDR_PUT_LONG(buf, objp->rightfedgeid);
+ ogdi_IXDR_PUT_LONG(buf, objp->leftfedgeid);
+ }
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+ } else if (xdrs->x_op == XDR_DECODE) {
+ buf = XDR_INLINE(xdrs, 7 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->startnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->endnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfedgeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfedgeid))
+ return (FALSE);
+
+ } else {
+ objp->id = IXDR_GET_LONG(buf);
+ objp->startnodeid = IXDR_GET_LONG(buf);
+ objp->endnodeid = IXDR_GET_LONG(buf);
+ objp->rightfaceid = IXDR_GET_LONG(buf);
+ objp->leftfaceid = IXDR_GET_LONG(buf);
+ objp->rightfedgeid = IXDR_GET_LONG(buf);
+ objp->leftfedgeid = IXDR_GET_LONG(buf);
+ }
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+ }
+
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->startnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->endnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfedgeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfedgeid))
+ return (FALSE);
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_TopoLevel(register XDR *xdrs, ecs_TopoLevel *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Face(register XDR *xdrs, ecs_Face *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_array(xdrs, (char **)&objp->edgeid.edgeid_val, (u_int *) &objp->edgeid.edgeid_len, ~0,
+ sizeof (int), (xdrproc_t) xdr_int))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_AreaPrim(register XDR *xdrs, ecs_AreaPrim *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_ecs_TopoLevel(xdrs, &objp->level))
+ return (FALSE);
+ switch (objp->level) {
+ case Level012:
+ if (!xdr_array(xdrs, (char **)&objp->ecs_AreaPrim_u.edgeid.edgeid_val, (u_int *) &objp->ecs_AreaPrim_u.edgeid.edgeid_len, ~0,
+ sizeof (int), (xdrproc_t) xdr_int))
+ return (FALSE);
+ break;
+ case Level3:
+ if (!xdr_array(xdrs, (char **)&objp->ecs_AreaPrim_u.fedgeid.fedgeid_val, (u_int *) &objp->ecs_AreaPrim_u.fedgeid.fedgeid_len, ~0,
+ sizeof (ecs_Face), (xdrproc_t) xdr_ecs_Face))
+ return (FALSE);
+ break;
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Geometry(register XDR *xdrs, ecs_Geometry *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_ecs_Family(xdrs, &objp->family))
+ return (FALSE);
+ switch (objp->family) {
+ case Area:
+ if (!xdr_ecs_Area(xdrs, &objp->ecs_Geometry_u.area))
+ return (FALSE);
+ break;
+ case Line:
+ if (!xdr_ecs_Line(xdrs, &objp->ecs_Geometry_u.line))
+ return (FALSE);
+ break;
+ case Point:
+ if (!xdr_ecs_Point(xdrs, &objp->ecs_Geometry_u.point))
+ return (FALSE);
+ break;
+ case Matrix:
+ if (!xdr_ecs_Matrix(xdrs, &objp->ecs_Geometry_u.matrix))
+ return (FALSE);
+ break;
+ case Image:
+ if (!xdr_ecs_Image(xdrs, &objp->ecs_Geometry_u.image))
+ return (FALSE);
+ break;
+ case Text:
+ if (!xdr_ecs_Text(xdrs, &objp->ecs_Geometry_u.text))
+ return (FALSE);
+ break;
+ case Node:
+ if (!xdr_ecs_Node(xdrs, &objp->ecs_Geometry_u.node))
+ return (FALSE);
+ break;
+ case Edge:
+ if (!xdr_ecs_Edge(xdrs, &objp->ecs_Geometry_u.edge))
+ return (FALSE);
+ break;
+ case Ring:
+ if (!xdr_ecs_AreaPrim(xdrs, &objp->ecs_Geometry_u.ring))
+ return (FALSE);
+ break;
+ case Face:
+ break;
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Object(register XDR *xdrs, ecs_Object *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_string(xdrs, &objp->Id, ~0))
+ return (FALSE);
+ if (!xdr_ecs_Geometry(xdrs, &objp->geom))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->attr, ~0))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->xmin))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->ymin))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->xmax))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->ymax))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_AttributeFormat(register XDR *xdrs, ecs_AttributeFormat *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_ObjAttribute(register XDR *xdrs, ecs_ObjAttribute *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_string(xdrs, &objp->name, ~0))
+ return (FALSE);
+ if (!xdr_ecs_AttributeFormat(xdrs, &objp->type))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->lenght))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->precision))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->nullable))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_ObjAttributeFormat(register XDR *xdrs, ecs_ObjAttributeFormat *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->oa.oa_val, (u_int *) &objp->oa.oa_len, ~0,
+ sizeof (ecs_ObjAttribute), (xdrproc_t) xdr_ecs_ObjAttribute))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Category(register XDR *xdrs, ecs_Category *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_long(xdrs, &objp->no_cat))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->r))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->g))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->b))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->label, ~0))
+ return (FALSE);
+ if (!xdr_u_long(xdrs, &objp->qty))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_RasterInfo(register XDR *xdrs, ecs_RasterInfo *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_long(xdrs, &objp->mincat))
+ return (FALSE);
+ if (!xdr_long(xdrs, &objp->maxcat))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->width))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->height))
+ return (FALSE);
+ if (!xdr_array(xdrs, (char **)&objp->cat.cat_val, (u_int *) &objp->cat.cat_len, ~0,
+ sizeof (ecs_Category), (xdrproc_t) xdr_ecs_Category))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Compression(register XDR *xdrs, ecs_Compression *objp)
+{
+
+ register int *buf;
+
+ if (xdrs->x_op == XDR_ENCODE) {
+ buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_u_int(xdrs, &objp->cachesize))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->ctype))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->cversion))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->clevel))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->cblksize))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->cfullsize))
+ return (FALSE);
+ } else {
+ ogdi_IXDR_PUT_U_LONG(buf, objp->cachesize);
+ ogdi_IXDR_PUT_U_LONG(buf, objp->ctype);
+ ogdi_IXDR_PUT_U_LONG(buf, objp->cversion);
+ ogdi_IXDR_PUT_U_LONG(buf, objp->clevel);
+ ogdi_IXDR_PUT_U_LONG(buf, objp->cblksize);
+ ogdi_IXDR_PUT_U_LONG(buf, objp->cfullsize);
+ }
+ return (TRUE);
+ } else if (xdrs->x_op == XDR_DECODE) {
+ buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_u_int(xdrs, &objp->cachesize))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->ctype))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->cversion))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->clevel))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->cblksize))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->cfullsize))
+ return (FALSE);
+ } else {
+ objp->cachesize = IXDR_GET_U_LONG(buf);
+ objp->ctype = IXDR_GET_U_LONG(buf);
+ objp->cversion = IXDR_GET_U_LONG(buf);
+ objp->clevel = IXDR_GET_U_LONG(buf);
+ objp->cblksize = IXDR_GET_U_LONG(buf);
+ objp->cfullsize = IXDR_GET_U_LONG(buf);
+ }
+ return (TRUE);
+ }
+
+ if (!xdr_u_int(xdrs, &objp->cachesize))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->ctype))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->cversion))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->clevel))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->cblksize))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->cfullsize))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_ResultType(register XDR *xdrs, ecs_ResultType *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_ResultUnion(register XDR *xdrs, ecs_ResultUnion *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_ecs_ResultType(xdrs, &objp->type))
+ return (FALSE);
+ switch (objp->type) {
+ case Object:
+ if (!xdr_ecs_Object(xdrs, &objp->ecs_ResultUnion_u.dob))
+ return (FALSE);
+ break;
+ case GeoRegion:
+ if (!xdr_ecs_Region(xdrs, &objp->ecs_ResultUnion_u.gr))
+ return (FALSE);
+ break;
+ case objAttributeFormat:
+ if (!xdr_ecs_ObjAttributeFormat(xdrs, &objp->ecs_ResultUnion_u.oaf))
+ return (FALSE);
+ break;
+ case RasterInfo:
+ if (!xdr_ecs_RasterInfo(xdrs, &objp->ecs_ResultUnion_u.ri))
+ return (FALSE);
+ break;
+ case AText:
+ if (!xdr_string(xdrs, &objp->ecs_ResultUnion_u.s, ~0))
+ return (FALSE);
+ break;
+ case MultiResult:
+ if (!xdr_array(xdrs, (char **)&objp->ecs_ResultUnion_u.results.results_val, (u_int *) &objp->ecs_ResultUnion_u.results.results_len, ~0,
+ sizeof (ecs_ResultUnion), (xdrproc_t) xdr_ecs_ResultUnion))
+ return (FALSE);
+ break;
+ case SimpleError:
+ break;
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Result_Work(register XDR *xdrs, ecs_Result *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_int(xdrs, &objp->error))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->message, ~0))
+ return (FALSE);
+ if (!xdr_ecs_ResultUnion(xdrs, &objp->res))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_LayerSelection(register XDR *xdrs, ecs_LayerSelection *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_string(xdrs, &objp->Select, ~0))
+ return (FALSE);
+ if (!xdr_ecs_Family(xdrs, &objp->F))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_ProxyCreateServer(register XDR *xdrs, ecs_ProxyCreateServer *objp)
+{
+
+// register long *buf;
+
+ if (!xdr_string(xdrs, &objp->server_name, ~0))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->server_url, ~0))
+ return (FALSE);
+ return (TRUE);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_xdrz.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_xdrz.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecs_xdrz.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,296 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: RPC/XDR support code for handling result values.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecs_xdrz.c,v $
+ * Revision 1.4 2007/02/12 15:52:57 cbalint
+ *
+ * Preliminary cleanup.
+ * Get rif of unitialized variables, and unused ones.
+ *
+ * Revision 1.3 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include <rpc/types.h>
+#include <rpc/xdr.h>
+
+#include "ecs.h"
+#include "zlib.h"
+
+ECS_CVSID("$Id: ecs_xdrz.c,v 1.4 2007/02/12 15:52:57 cbalint Exp $");
+
+/* Variables used for compression/decompression routines */
+static void *obuf = NULL;
+static unsigned int obufsize = 0;
+static int enough = 0;
+
+extern bool_t xdr_ecs_Result_Work(XDR *xdrs, ecs_Result *objp);
+
+bool_t
+xdr_ecs_Result_Free(XDR *xdrs, ecs_Result *objp)
+{
+ if (objp->compression.ctype == ECS_COMPRESS_NONE) {
+ return xdr_ecs_Result_Work(xdrs, objp);
+ }
+ if (objp->compression.ctype != ECS_COMPRESS_ZLIB) {
+ return (FALSE);
+ }
+ if (objp->compression.cblksize != 0) {
+ return xdr_ecs_Result_Work(xdrs, objp);
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Result_Decode(XDR *xdrs, ecs_Result *objp)
+{
+ XDR mem_xdrs;
+ void *zbuf;
+ z_stream z;
+ int status;
+ unsigned int size;
+
+ if (!xdr_u_int(xdrs, &objp->compression.cfullsize)) {
+ return FALSE;
+ }
+ if (objp->compression.ctype == ECS_COMPRESS_NONE) {
+ return xdr_ecs_Result_Work(xdrs, objp);
+ }
+ if (objp->compression.ctype != ECS_COMPRESS_ZLIB) {
+ return (FALSE);
+ }
+ if (objp->compression.cblksize == 0) {
+ return xdr_ecs_Result_Work(xdrs, objp);
+ }
+
+ if (obufsize < objp->compression.cfullsize) {
+ free(obuf);
+ obuf = malloc(objp->compression.cfullsize);
+ if (obuf == NULL) {
+ obufsize = 0;
+ return (FALSE);
+ }
+ obufsize = objp->compression.cfullsize;
+ }
+
+ zbuf = malloc(objp->compression.cblksize);
+ if (zbuf == NULL) {
+ return (FALSE);
+ }
+
+ /*
+ * First, read in the compressed data and decompress into obuf
+ */
+ xdrmem_create(&mem_xdrs, obuf, objp->compression.cfullsize, XDR_DECODE);
+ z.zalloc = NULL;
+ z.zfree = NULL;
+ z.opaque = NULL;
+ if (inflateInit(&z) != Z_OK) {
+ free(zbuf);
+ return (FALSE);
+ }
+ z.next_out = obuf;
+ z.avail_out = objp->compression.cfullsize;
+ do {
+ if (! xdr_bytes(xdrs, (char **) &zbuf, &size,
+ objp->compression.cblksize))
+ {
+ xdr_destroy(&mem_xdrs);
+ return (FALSE);
+ }
+ z.next_in = zbuf;
+ z.avail_in = objp->compression.cblksize;
+ status = inflate(&z, Z_NO_FLUSH);
+ xdrs->x_op = XDR_FREE;
+ xdr_bytes(xdrs, (char **) &zbuf, &size,
+ objp->compression.cblksize);
+ xdrs->x_op = XDR_DECODE;
+ if (status != Z_OK) {
+ break;
+ }
+ } while (size == (int) objp->compression.cblksize);
+
+ do {
+ status = inflate(&z, Z_FINISH);
+ } while (status == Z_OK);
+
+ /*
+ * Now, there should be a decompressed data stream in obuf.
+ * Run the standard xdr routines using a memory xdr now.
+ */
+
+ inflateEnd(&z);
+ free(zbuf);
+ xdr_destroy(&mem_xdrs);
+
+ xdrmem_create(&mem_xdrs, obuf, objp->compression.cfullsize, XDR_DECODE);
+ status = xdr_ecs_Result_Work(&mem_xdrs, objp);
+ xdr_destroy(&mem_xdrs);
+
+ return status;
+}
+
+
+bool_t
+xdr_ecs_Result_Encode(XDR *xdrs, ecs_Result *objp)
+{
+ XDR mem_xdrs;
+ int attempts;
+ void *zbuf;
+ z_stream z;
+ unsigned int count;
+ int status;
+
+ if (objp->compression.ctype == ECS_COMPRESS_NONE) {
+ if (!xdr_u_int(xdrs, &objp->compression.cfullsize)) {
+ return FALSE;
+ }
+ return xdr_ecs_Result_Work(xdrs, objp);
+ }
+ if (objp->compression.ctype != ECS_COMPRESS_ZLIB) {
+ return (FALSE);
+ }
+ if (objp->compression.cblksize == 0) {
+ if (!xdr_u_int(xdrs, &objp->compression.cfullsize)) {
+ return FALSE;
+ }
+ return xdr_ecs_Result_Work(xdrs, objp);
+ }
+ attempts = 0;
+ while (attempts < 7) {
+ if (enough == 0) {
+ obufsize = obufsize * 2 + 200000;
+ if (obuf) free(obuf);
+ obuf = malloc(obufsize);
+ if (obuf == NULL) {
+ obufsize = 0;
+ return (FALSE);
+ }
+ }
+ if (attempts > 0) {
+ xdr_destroy(&mem_xdrs);
+ }
+ xdrmem_create(&mem_xdrs, obuf, obufsize, XDR_ENCODE);
+
+ enough = xdr_ecs_Result_Work(&mem_xdrs, objp);
+ if (enough) {
+ break;
+ }
+ attempts++;
+ }
+ if (! enough) {
+ xdr_destroy(&mem_xdrs);
+ free(obuf);
+ obuf = NULL;
+ return (FALSE);
+ }
+ zbuf = malloc(objp->compression.cblksize);
+ if (zbuf == NULL) {
+ xdr_destroy(&mem_xdrs);
+ return (FALSE);
+ }
+
+ objp->compression.cfullsize = XDR_GETPOS(&mem_xdrs);
+ if (!xdr_u_int(xdrs, &objp->compression.cfullsize)) {
+ xdr_destroy(&mem_xdrs);
+ return FALSE;
+ }
+
+ /*
+ * Basic algorithm is this: call the compress routine until
+ * the output buffer has filled up with compression.cblksize
+ * bytes. Then write these bytes out with XDR_PUT_BYTES().
+ * Continue doing this until there are no more bytes left.
+ * The final block must be less than compression.cblksize bytes.
+ * If it is exactly equal to compression.cblksize bytes, then
+ * a final 0 length block needs to be sent with XDR_PUT_BYTES().
+ */
+ z.zalloc = NULL;
+ z.zfree = NULL;
+ z.opaque = NULL;
+ if (deflateInit(&z, objp->compression.clevel) != Z_OK) {
+ xdr_destroy(&mem_xdrs);
+ free(zbuf);
+ return (FALSE);
+ }
+
+ z.next_in = obuf;
+ z.avail_in = objp->compression.cfullsize;
+ while (1) {
+ z.next_out = zbuf;
+ z.avail_out = objp->compression.cblksize;
+ status = deflate(&z, Z_NO_FLUSH);
+ count = objp->compression.cblksize - z.avail_out;
+ if ((status != Z_OK)
+ || (count < (int)objp->compression.cblksize)) {
+ break;
+ }
+ xdr_bytes(xdrs, (char **) &zbuf, &count,
+ objp->compression.cblksize);
+ }
+ while (1) {
+ status = deflate(&z, Z_FINISH);
+ count = objp->compression.cblksize - z.avail_out;
+ if ((status != Z_OK)
+ || (count < (int) objp->compression.cblksize)) {
+ xdr_bytes(xdrs, (char **) &zbuf, &count,
+ objp->compression.cblksize);
+ if (count == (int) objp->compression.cblksize) {
+ count = 0;
+ xdr_bytes(xdrs, (char **) &zbuf, &count,
+ objp->compression.cblksize);
+ }
+ break;
+ }
+ xdr_bytes(xdrs, (char **) &zbuf, &count,
+ objp->compression.cblksize);
+ z.next_out = zbuf;
+ z.avail_out = objp->compression.cblksize;
+ }
+ deflateEnd(&z);
+ free(zbuf);
+ xdr_destroy(&mem_xdrs);
+
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Result(XDR *xdrs, ecs_Result *objp)
+{
+ if (!xdr_u_int(xdrs, &objp->compression.cachesize)) {
+ return FALSE;
+ }
+ if (!xdr_u_int(xdrs, &objp->compression.ctype)) {
+ return FALSE;
+ }
+ if (!xdr_u_int(xdrs, &objp->compression.cversion)) {
+ return FALSE;
+ }
+ if (!xdr_u_int(xdrs, &objp->compression.cblksize)) {
+ return FALSE;
+ }
+ if (xdrs->x_op == XDR_ENCODE) {
+ return xdr_ecs_Result_Encode(xdrs, objp);
+ } else if (xdrs->x_op == XDR_DECODE) {
+ return xdr_ecs_Result_Decode(xdrs, objp);
+ } else {
+ return xdr_ecs_Result_Free(xdrs, objp);
+ }
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsassoc.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsassoc.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsassoc.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,2053 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Code encapsulating memory allocation, and association of the
+ * structure ecs_Result.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecsassoc.c,v $
+ * Revision 1.2 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecsassoc.c,v 1.2 2001/04/09 15:04:34 warmerda Exp $");
+
+char memory_error[] = "not enough memory";
+
+#define ALLOCNULLSTRING(p) \
+if (p==NULL) { \
+ if ((p = malloc(1)) != NULL) { \
+ p[0] = '\0'; \
+ } \
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_assoc: The ecsassoc library encapsulate memory allocation and
+ association of the structure ecs_Result. This structure is use
+ to send complex information to client without major concern from
+ the server.
+
+ Each of these method work exactly the same way. They receive an
+ information to add in the ecs_Result and the information is add
+ in ecs_Result. If an error occur during this operation, the functions
+ will return an error code (FALSE). Otherwise, the function end the
+ operation and return TRUE. It is important to handle the error code
+ in the calling code, a quick return must be done in these cases. There
+ is no need from the calling function to call SetError if an error append
+ during association, an error code is automatically set and ready
+ to be sent to client.
+
+ ----------------------------------------------------------------------
+ */
+
+/*************************************************/
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetError
+
+ Set an error code and a message into ecs_Result. This function will
+ not reinitialize the ecs_Result structure.
+
+ IN
+ int errorcode: Error code to assign to ecs_Result. Usually 1.
+ 0 mean a success message.
+ char *error_message: The error message to assign to ecs_Result.
+ Could be a null value.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetError (r,errorcode,error_message)
+ ecs_Result *r;
+ int errorcode;
+ char *error_message;
+{
+ r->error = errorcode;
+ r->res.type = SimpleError;
+ if (r->message != NULL)
+ free(r->message);
+ if (error_message == NULL) {
+ r->message = NULL;
+ } else {
+ r->message = (char *) malloc(strlen(error_message)+1);
+ if (r->message == NULL)
+ return FALSE;
+ strcpy(r->message,error_message);
+ }
+
+ ecs_AdjustResult(r);
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_Success
+
+ Set an success code and flush the error message previously set.
+ This function will not reinitialize the ecs_Result structure.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetSuccess (r)
+ ecs_Result *r;
+{
+ r->error = 0;
+ if (r->message != NULL)
+ free(r->message);
+ r->message = NULL;
+
+ ecs_AdjustResult(r);
+
+ return TRUE;
+}
+
+
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_AdjustResult
+
+ This function is there to correct a deficiency of RPC about data
+ strings. If a string in ecs_Result is NULL, the software will crash.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_AdjustResult (r)
+ ecs_Result *r;
+{
+ int val,i;
+
+ ALLOCNULLSTRING(r->message);
+
+ switch(r->res.type) {
+ case Object:
+ {
+ ALLOCNULLSTRING(ECSRESULT(r).dob.Id);
+ ALLOCNULLSTRING(ECSRESULT(r).dob.attr);
+ if (ECSGEOMTYPE(r) == Text) {
+ ALLOCNULLSTRING(ECSGEOM(r).text.desc);
+ }
+ };
+ break;
+ case objAttributeFormat:
+ {
+ val = ECSRESULT(r).oaf.oa.oa_len;
+ if (ECSRESULT(r).oaf.oa.oa_val != NULL) {
+ for(i=0;i<val;i++) {
+ ALLOCNULLSTRING(ECSRESULT(r).oaf.oa.oa_val[i].name);
+ }
+ }
+ };
+ break;
+ case RasterInfo:
+ {
+ val = ECSRESULT(r).ri.cat.cat_len;
+ if (ECSRESULT(r).ri.cat.cat_val != NULL) {
+ for(i=0;i<val;i++) {
+ ALLOCNULLSTRING(ECSRESULT(r).ri.cat.cat_val[i].label);
+ }
+ }
+ };
+ break;
+ case AText:
+ {
+ ALLOCNULLSTRING(ECSRESULT(r).s);
+ };
+ break;
+ default:
+ break;
+ };
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetObjectId
+
+ Set the attribute Id in object. Before calling this function,
+ the caller must call ecs_SetGeomText, ecs_SetGeomPoint, ecs_SetGeomLine,
+ ecs_SetGeomArea, ecs_SetGeomMatrix or ecs_SetGeomImage to initialize the
+ geographic object.
+
+ IN
+ char *id: Identifier of the object. Must be different than NULL.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetObjectId (r,id)
+ ecs_Result *r;
+ char *id;
+{
+ if (r->res.type == Object) {
+ if (r->res.ecs_ResultUnion_u.dob.Id != NULL)
+ free(r->res.ecs_ResultUnion_u.dob.Id);
+ r->res.ecs_ResultUnion_u.dob.Id = (char *) malloc(strlen(id)+1);
+ if (r->res.ecs_ResultUnion_u.dob.Id == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ strcpy(r->res.ecs_ResultUnion_u.dob.Id,id);
+ }
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetObjectAttr
+
+ Set the attribute attr in object. Before calling this function,
+ the caller must call ecs_SetGeomText, ecs_SetGeomPoint, ecs_SetGeomLine,
+ ecs_SetGeomArea, ecs_SetGeomMatrix or ecs_SetGeomImage to initialize the
+ geographic object.
+
+ IN
+ char *attr: This string contain the attribute to set. This
+ argument must be different than NULL.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetObjectAttr (r,attr)
+ ecs_Result *r;
+ char *attr;
+{
+ if (r->res.type == Object) {
+ if (r->res.ecs_ResultUnion_u.dob.attr != NULL)
+ free(r->res.ecs_ResultUnion_u.dob.attr);
+ r->res.ecs_ResultUnion_u.dob.attr = (char *) malloc(strlen(attr)+1);
+ if (r->res.ecs_ResultUnion_u.dob.attr == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ strcpy(r->res.ecs_ResultUnion_u.dob.attr,attr);
+ }
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeoRegion
+
+ Set the geographic region. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN
+ double north, south, east, west, ns_res, ew_res: Geographic
+ region to set.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeoRegion (r,north,south,east,west,ns_res,ew_res)
+ ecs_Result *r;
+ double north;
+ double south;
+ double east;
+ double west;
+ double ns_res;
+ double ew_res;
+{
+ ecs_CleanUp(r);
+ ECSRESULTTYPE(r) = GeoRegion;
+ ECSRESULT(r).gr.north = north;
+ ECSRESULT(r).gr.south = south;
+ ECSRESULT(r).gr.east = east;
+ ECSRESULT(r).gr.west = west;
+ ECSRESULT(r).gr.ns_res = ns_res;
+ ECSRESULT(r).gr.ew_res = ew_res;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetText
+
+ Set the Atext item with a string. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN
+ char *text: Text to set in the structure
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetText (r,text)
+ ecs_Result *r;
+ char *text;
+{
+ ecs_CleanUp(r);
+
+ ECSRESULTTYPE(r) = AText;
+ ECSRESULT(r).s = (char *) malloc(strlen(text)+1);
+ if (ECSRESULT(r).s == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ strcpy(ECSRESULT(r).s, text);
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_AddText
+
+ Concatenate a text to Atext item. The function ecs_SetText must
+ be call before.
+
+ IN
+ char *text: Text to concatanate
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_AddText (r,text)
+ ecs_Result *r;
+ char *text;
+{
+ char *temp;
+ int code;
+
+ temp = ECSRESULT(r).s;
+ code = TRUE;
+ if ((ECSRESULTTYPE(r) == AText) &&
+ (temp != NULL)) {
+ ECSRESULT(r).s = NULL;
+ ECSRESULT(r).s = (char *) malloc(strlen(text)+strlen(temp)+1);
+ if (ECSRESULT(r).s == NULL) {
+ ECSRESULT(r).s = temp;
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ strcpy(ECSRESULT(r).s, temp);
+ strcat(ECSRESULT(r).s, text);
+ free(temp);
+ } else {
+ code = ecs_SetText(r,text);
+ }
+
+ return code;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ Set the RasterInfo attribute. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN
+ int width, height: Width and height of the raster
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetRasterInfo (r,width,height)
+ ecs_Result *r;
+ int width;
+ int height;
+{
+ ecs_CleanUp(r);
+
+ ECSRESULTTYPE(r) = RasterInfo;
+
+ /* It is impossible to have maxcat < mincat. In this
+ case, ecs_AddRasterInfoCategory will set both values
+ with the first value. */
+ ECSRESULT(r).ri.mincat = 1;
+ ECSRESULT(r).ri.maxcat = 0;
+ ECSRESULT(r).ri.width = width;
+ ECSRESULT(r).ri.height = height;
+ ECSRESULT(r).ri.cat.cat_len = 0;
+ ECSRESULT(r).ri.cat.cat_val = NULL;
+ return TRUE;
+}
+
+/*************************************************/
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_AddRasterInfoCategory
+
+ Add a raster info category. Must be called after ecs_SetRasterInfo
+
+ IN
+ long no_cat: Category number
+ unsigned int red,green,blue: Color of the category
+ char *label: Label of the category
+ unsigned long qty: Statistical informations about the
+ raster. (How many points)
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_AddRasterInfoCategory (r,no_cat,red,green,blue,label,qty)
+ ecs_Result *r;
+ long no_cat;
+ unsigned int red;
+ unsigned int green;
+ unsigned int blue;
+ char *label;
+ unsigned long qty;
+{
+ ecs_Category *ptr;
+
+ /* Allocate a new category */
+ ECSRESULT(r).ri.cat.cat_val =
+ (ecs_Category *) realloc(ECSRESULT(r).ri.cat.cat_val,
+ sizeof(ecs_Category)*(ECSRESULT(r).ri.cat.cat_len + 1));
+ if (ECSRESULT(r).ri.cat.cat_val == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ ECSRESULT(r).ri.cat.cat_len++;
+ ptr = &(ECSRESULT(r).ri.cat.cat_val[ECSRESULT(r).ri.cat.cat_len - 1]);
+
+ /* Update mincat and maxcat with no_cat */
+ if (ECSRESULT(r).ri.mincat > ECSRESULT(r).ri.maxcat) {
+ ECSRESULT(r).ri.mincat = no_cat;
+ ECSRESULT(r).ri.maxcat = no_cat;
+ } else {
+ if (ECSRESULT(r).ri.mincat > no_cat)
+ ECSRESULT(r).ri.mincat = no_cat;
+ if (ECSRESULT(r).ri.maxcat < no_cat)
+ ECSRESULT(r).ri.maxcat = no_cat;
+ }
+
+ ptr->no_cat = no_cat;
+ ptr->r = red;
+ ptr->g = green;
+ ptr->b = blue;
+ ptr->label = (char *) malloc(strlen(label)+1);
+ if (ptr->label == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ strcpy(ptr->label,label);
+ ptr->qty = qty;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetObjAttributeFormat
+
+ Set the objAttributeFormat attribute. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetObjAttributeFormat (r)
+ ecs_Result *r;
+{
+ ecs_CleanUp(r);
+
+ ECSRESULTTYPE(r) = objAttributeFormat;
+ ECSRESULT(r).oaf.oa.oa_len = 0;
+ ECSRESULT(r).oaf.oa.oa_val = NULL;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_AddAttributeFormat
+
+ Add an attribute format to objAttributeFormat attribute
+
+ IN
+ char *name: Name of the attribute
+ ecs_AttributeFormat type:
+ int lenght : Attribute format info
+ int precision : (ODBC)
+ int nullable :
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_AddAttributeFormat (r,name,type,lenght,precision,nullable)
+ ecs_Result *r;
+ char *name;
+ ecs_AttributeFormat type;
+ int lenght;
+ int precision;
+ int nullable;
+{
+ ecs_ObjAttribute *ptr;
+
+ /* Allocate a new attribute */
+ ECSRESULT(r).oaf.oa.oa_val =
+ (ecs_ObjAttribute *) realloc(ECSRESULT(r).oaf.oa.oa_val,
+ sizeof(ecs_ObjAttribute)*(ECSRESULT(r).oaf.oa.oa_len + 1));
+ if (ECSRESULT(r).oaf.oa.oa_val == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ ECSRESULT(r).oaf.oa.oa_len++;
+ ptr = &(ECSRESULT(r).oaf.oa.oa_val[ECSRESULT(r).oaf.oa.oa_len - 1]);
+
+ ptr->name = (char *) malloc(strlen(name)+1);
+ if (ptr->name == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ strcpy(ptr->name,name);
+ ptr->type = type;
+ ptr->lenght = lenght;
+ ptr->precision = precision;
+ ptr->nullable = nullable;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeomPoint
+
+ Set a point geographical object. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN
+ double x,y : Point to assign
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeomPoint (r,x,y)
+ ecs_Result *r;
+ double x;
+ double y;
+{
+ ecs_CleanUp(r);
+
+ ECSRESULTTYPE(r) = Object;
+ ECSGEOMTYPE(r) = Point;
+ r->res.ecs_ResultUnion_u.dob.Id = NULL;
+ r->res.ecs_ResultUnion_u.dob.attr = NULL;
+
+ ECSGEOM(r).point.c.x = x;
+ ECSGEOM(r).point.c.y = y;
+ r->res.ecs_ResultUnion_u.dob.xmin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.xmax = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymax = 0.0;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeomText
+
+ Set a text geographical object. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN
+ double x,y : Position of the text
+ char *desc: Description string
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeomText (r,x,y,desc)
+ ecs_Result *r;
+ double x;
+ double y;
+ char *desc;
+{
+ ecs_CleanUp(r);
+
+ ECSRESULTTYPE(r) = Object;
+ ECSGEOMTYPE(r) = Text;
+ r->res.ecs_ResultUnion_u.dob.Id = NULL;
+ r->res.ecs_ResultUnion_u.dob.attr = NULL;
+
+ ECSGEOM(r).text.c.x = x;
+ ECSGEOM(r).text.c.y = y;
+ r->res.ecs_ResultUnion_u.dob.xmin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.xmax = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymax = 0.0;
+ if (desc != NULL) {
+ ECSGEOM(r).text.desc = (char *) malloc(strlen(desc)+1);
+ if (ECSGEOM(r).text.desc == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ strcpy(ECSGEOM(r).text.desc,desc);
+ } else {
+ ECSGEOM(r).text.desc = NULL;
+ }
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeomLine
+
+ Set a line geographical object. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN
+ unsigned int lenght : Number of points in Polyline
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeomLine (r,lenght)
+ ecs_Result *r;
+ unsigned int lenght;
+{
+ ecs_CleanUp(r);
+ ECSRESULTTYPE(r) = Object;
+ ECSGEOMTYPE(r) = Line;
+ r->res.ecs_ResultUnion_u.dob.Id = NULL;
+ r->res.ecs_ResultUnion_u.dob.attr = NULL;
+ r->res.ecs_ResultUnion_u.dob.xmin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.xmax = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymax = 0.0;
+
+ ECSGEOM(r).line.c.c_len = lenght;
+ ECSGEOM(r).line.c.c_val = (ecs_Coordinate *) malloc(sizeof(ecs_Coordinate)*lenght);
+ if (ECSGEOM(r).line.c.c_val == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeomArea
+
+ Set a area geographical object. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN
+ unsigned int lenght : Number of rings in this area
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeomArea (r,lenght)
+ ecs_Result *r;
+ unsigned int lenght;
+{
+ ecs_CleanUp(r);
+ ECSRESULTTYPE(r) = Object;
+ ECSGEOMTYPE(r) = Area;
+ r->res.ecs_ResultUnion_u.dob.Id = NULL;
+ r->res.ecs_ResultUnion_u.dob.attr = NULL;
+ r->res.ecs_ResultUnion_u.dob.xmin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.xmax = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymax = 0.0;
+
+ ECSGEOM(r).area.ring.ring_len = lenght;
+ ECSGEOM(r).area.ring.ring_val = (ecs_FeatureRing *) malloc(sizeof(ecs_FeatureRing)*lenght);
+ if (ECSGEOM(r).line.c.c_val == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*************************************************/
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeomAreaRing
+
+ Set a ring into an area object.
+
+ IN
+ int position: Position in ring table
+ unsigned int lenght: Number of points in the ring
+ double centroid_x:
+ double centroid_y: Centroid of the ring
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeomAreaRing (r,position,lenght,centroid_x,centroid_y)
+ ecs_Result *r;
+ int position;
+ unsigned int lenght;
+ double centroid_x;
+ double centroid_y;
+{
+ ecs_FeatureRing *ptr;
+
+ ptr = &(ECSGEOM(r).area.ring.ring_val[position]);
+
+ ptr->centroid.x = centroid_x;
+ ptr->centroid.y = centroid_y;
+
+ ptr->c.c_len = lenght;
+ ptr->c.c_val = (ecs_Coordinate *) malloc(sizeof(ecs_Coordinate)*lenght);
+ if (ptr->c.c_val == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeomMatrixWithArray
+
+ Set a matrix geographical object with a array of unsigned int already
+ allocated. This function will make a clean up of ecs_Result and perform
+ his operation.
+
+ IN
+ int size: Size of array
+ unsigned int *array: Table of values
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeomMatrixWithArray (r, size, array)
+ ecs_Result *r;
+ int size;
+ unsigned int *array;
+{
+ ecs_CleanUp(r);
+ ECSRESULTTYPE(r) = Object;
+ ECSGEOMTYPE(r) = Matrix;
+ r->res.ecs_ResultUnion_u.dob.Id = NULL;
+ r->res.ecs_ResultUnion_u.dob.attr = NULL;
+ ECSGEOM(r).matrix.x.x_len = size;
+ ECSGEOM(r).matrix.x.x_val = (u_int *) malloc(sizeof(u_int)*size);
+ if (ECSGEOM(r).matrix.x.x_val == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ memcpy(ECSGEOM(r).matrix.x.x_val,array,sizeof(u_int)*size);
+ r->res.ecs_ResultUnion_u.dob.xmin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.xmax = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymax = 0.0;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeomMatrix
+
+ Set a matrix geographical object. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN
+ int size: Number of colums in this raster row
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeomMatrix (r, size)
+ ecs_Result *r;
+ int size;
+{
+ ecs_CleanUp(r);
+ ECSRESULTTYPE(r) = Object;
+ ECSGEOMTYPE(r) = Matrix;
+ r->res.ecs_ResultUnion_u.dob.Id = NULL;
+ r->res.ecs_ResultUnion_u.dob.attr = NULL;
+ ECSGEOM(r).matrix.x.x_len = size;
+ ECSGEOM(r).matrix.x.x_val = (u_int *) malloc(sizeof(u_int)*size);
+ if (ECSGEOM(r).matrix.x.x_val == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ r->res.ecs_ResultUnion_u.dob.xmin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.xmax = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymax = 0.0;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeomImageWithArray
+
+ Set a image geographical object with a array of unsigned int already
+ allocated. This function will make a clean up of ecs_Result and
+ perform his operation.
+
+ IN
+ int size: Size of array
+ unsigned int *array: Table of values
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeomImageWithArray (r, size, array)
+ ecs_Result *r;
+ int size;
+ unsigned int *array;
+{
+ ecs_CleanUp(r);
+ ECSRESULTTYPE(r) = Object;
+ ECSGEOMTYPE(r) = Image;
+ r->res.ecs_ResultUnion_u.dob.Id = NULL;
+ r->res.ecs_ResultUnion_u.dob.attr = NULL;
+ ECSGEOM(r).image.x.x_len = size;
+ ECSGEOM(r).image.x.x_val = (u_int *) malloc(sizeof(u_int)*size);
+ if (ECSGEOM(r).image.x.x_val == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ memcpy(ECSGEOM(r).image.x.x_val,array,sizeof(u_int)*size);
+ r->res.ecs_ResultUnion_u.dob.xmin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.xmax = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymax = 0.0;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_SetGeomImage
+
+ Set a image geographical object. This function will make a clean up
+ of ecs_Result and perform his operation.
+
+ IN
+ int size: Number of colums in this raster row
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_SetGeomImage(r, size)
+ ecs_Result *r;
+ int size;
+{
+ ecs_CleanUp(r);
+ ECSRESULTTYPE(r) = Object;
+ ECSGEOMTYPE(r) = Image;
+ r->res.ecs_ResultUnion_u.dob.Id = NULL;
+ r->res.ecs_ResultUnion_u.dob.attr = NULL;
+ ECSGEOM(r).image.x.x_len = size;
+ ECSGEOM(r).image.x.x_val = (u_int *) malloc(sizeof(u_int)*size);
+ if (ECSGEOM(r).image.x.x_val == NULL) {
+ ecs_SetError(r,1,memory_error);
+ return FALSE;
+ }
+ r->res.ecs_ResultUnion_u.dob.xmin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymin = 0.0;
+ r->res.ecs_ResultUnion_u.dob.xmax = 0.0;
+ r->res.ecs_ResultUnion_u.dob.ymax = 0.0;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_CleanUp
+
+ Will make a complete clean up and reinitialisation of ecs_Result.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+
+int ecs_CleanUp (r)
+ ecs_Result *r;
+{
+ r->error = 0;
+
+ if (r->message != NULL)
+ free(r->message);
+ r->message = NULL;
+
+ return ecs_CleanUpResultUnion (&r->res);
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_CleanUpResultUnion
+
+ Will make a complete clean up of the ResultUnion.
+
+ IN/OUT
+ ecs_ResultUnion *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+
+int ecs_CleanUpResultUnion (r)
+ ecs_ResultUnion *r;
+{
+ int val,i;
+
+ switch (r->type) {
+ case Object:
+ {
+ ecs_CleanUpObject(&r->ecs_ResultUnion_u.dob);
+ };
+ break;
+ case objAttributeFormat:
+ {
+ val = r->ecs_ResultUnion_u.oaf.oa.oa_len;
+ if (r->ecs_ResultUnion_u.oaf.oa.oa_val != NULL) {
+ for(i=0;i<val;i++) {
+ if (r->ecs_ResultUnion_u.oaf.oa.oa_val[i].name != NULL)
+ free(r->ecs_ResultUnion_u.oaf.oa.oa_val[i].name);
+ r->ecs_ResultUnion_u.oaf.oa.oa_val[i].name = NULL;
+ }
+ free(r->ecs_ResultUnion_u.oaf.oa.oa_val);
+ }
+ r->ecs_ResultUnion_u.oaf.oa.oa_val = NULL;
+ };
+ break;
+ case RasterInfo:
+ {
+ val = r->ecs_ResultUnion_u.ri.cat.cat_len;
+ if (r->ecs_ResultUnion_u.ri.cat.cat_val != NULL) {
+ for(i=0;i<val;i++) {
+ if (r->ecs_ResultUnion_u.ri.cat.cat_val[i].label != NULL)
+ free(r->ecs_ResultUnion_u.ri.cat.cat_val[i].label);
+ r->ecs_ResultUnion_u.ri.cat.cat_val[i].label = NULL;
+ }
+ free(r->ecs_ResultUnion_u.ri.cat.cat_val);
+ }
+ r->ecs_ResultUnion_u.ri.cat.cat_val = NULL;
+ };
+ break;
+ case AText:
+ {
+ if (r->ecs_ResultUnion_u.s != NULL)
+ free(r->ecs_ResultUnion_u.s);
+ r->ecs_ResultUnion_u.s = NULL;
+ };
+ break;
+ case MultiResult:
+ for (i = 0; i < (int) r->ecs_ResultUnion_u.results.results_len; i++) {
+ ecs_CleanUpResultUnion(&r->ecs_ResultUnion_u.results.results_val[i]);
+ }
+ free(r->ecs_ResultUnion_u.results.results_val);
+ break;
+ default:
+ break;
+ };
+ r->type = 0;
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_CleanUpObject
+
+ Will make a complete clean up and reinitialisation of ecs_Object in
+ ecs_Result.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will clean up the structure and put his information into it.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_CleanUpObject (obj)
+ ecs_Object *obj;
+{
+ int val,i;
+
+ if (obj->Id != NULL)
+ free(obj->Id);
+ obj->Id = NULL;
+
+ if (obj->attr != NULL)
+ free(obj->attr);
+ obj->attr = NULL;
+
+ switch (obj->geom.family) {
+ case Area:
+ {
+ val = obj->geom.ecs_Geometry_u.area.ring.ring_len;
+ if (obj->geom.ecs_Geometry_u.area.ring.ring_val != NULL) {
+ for(i=0;i<val;i++) {
+ if (obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val != NULL)
+ free(obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val);
+ obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val = NULL;
+ }
+ free(obj->geom.ecs_Geometry_u.area.ring.ring_val);
+ }
+ obj->geom.ecs_Geometry_u.area.ring.ring_val = NULL;
+ };
+ break;
+ case Line:
+ {
+ if (obj->geom.ecs_Geometry_u.line.c.c_val != NULL)
+ free(obj->geom.ecs_Geometry_u.line.c.c_val);
+ obj->geom.ecs_Geometry_u.line.c.c_val = NULL;
+ };
+ break;
+ case Matrix:
+ {
+ if (obj->geom.ecs_Geometry_u.matrix.x.x_val != NULL)
+ free(obj->geom.ecs_Geometry_u.matrix.x.x_val);
+ obj->geom.ecs_Geometry_u.matrix.x.x_val = NULL;
+ };
+ break;
+ case Image:
+ {
+ if (obj->geom.ecs_Geometry_u.image.x.x_val != NULL)
+ free(obj->geom.ecs_Geometry_u.image.x.x_val);
+ obj->geom.ecs_Geometry_u.image.x.x_val = NULL;
+ };
+ break;
+ case Text:
+ {
+ if (obj->geom.ecs_Geometry_u.text.desc != NULL)
+ free(obj->geom.ecs_Geometry_u.text.desc);
+ obj->geom.ecs_Geometry_u.text.desc = NULL;
+ };
+ break;
+ default:
+ break;
+ };
+
+ return TRUE;
+}
+
+/*************************************************/
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_ResultInit
+
+ First initialisation of ecs_Result. Perform when the structure
+ is create to initialise it.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_ResultInit (r)
+ ecs_Result *r;
+{
+ r->error = 0;
+ r->message = NULL;
+ r->res.type = 0;
+
+ return TRUE;
+
+}
+
+/*
+ ----------------------------------------------------------------------
+
+ ecs_CalcObjectMBR
+
+ Given a ecs_Result with a ecs_Object already define.
+ Found the bounding rectangle of this object and
+ assign it in ecs_Result.
+
+ IN
+ ecs_Server *s: Server structure contain some complement information
+ about region.
+
+ IN/OUT
+ ecs_Result *r: A pointer to a structure already defined. This
+ method will only update the contain of this structure.
+
+ OUT
+ return int: A error code. If a problem occur in the method,
+ "r" will be update to infor the user about the problem and
+ will return a FALSE value. The default return value is TRUE.
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_CalcObjectMBR (s,obj)
+ ecs_Server *s;
+ ecs_Object *obj;
+{
+ register unsigned int i,j,len;
+ register ecs_Coordinate *coord;
+
+ switch(obj->geom.family) {
+ case Point:
+ obj->xmin = obj->geom.ecs_Geometry_u.point.c.x;
+ obj->ymin = obj->geom.ecs_Geometry_u.point.c.y;
+ obj->xmax = obj->geom.ecs_Geometry_u.point.c.x;
+ obj->ymax = obj->geom.ecs_Geometry_u.point.c.y;
+ break;
+ case Text:
+ obj->xmin = obj->geom.ecs_Geometry_u.text.c.x;
+ obj->ymin = obj->geom.ecs_Geometry_u.text.c.y;
+ obj->xmax = obj->geom.ecs_Geometry_u.text.c.x;
+ obj->ymax = obj->geom.ecs_Geometry_u.text.c.y;
+ break;
+ case Line:
+ len = obj->geom.ecs_Geometry_u.line.c.c_len;
+ if (len > 0) {
+ obj->xmin = obj->geom.ecs_Geometry_u.line.c.c_val[0].x;
+ obj->ymin = obj->geom.ecs_Geometry_u.line.c.c_val[0].y;
+ obj->xmax = obj->geom.ecs_Geometry_u.line.c.c_val[0].x;
+ obj->ymax = obj->geom.ecs_Geometry_u.line.c.c_val[0].y;
+ }
+ for(i=1;i<len;i++) {
+ coord = &(obj->geom.ecs_Geometry_u.line.c.c_val[i]);
+ if (obj->xmin > coord->x)
+ obj->xmin = coord->x;
+ if (obj->ymin > coord->y)
+ obj->ymin = coord->y;
+ if (obj->xmax < coord->x)
+ obj->xmax = coord->x;
+ if (obj->ymax < coord->y)
+ obj->ymax = coord->y;
+ }
+ break;
+ case Area:
+ if ((obj->geom.ecs_Geometry_u.area.ring.ring_len > 0) &&
+ (obj->geom.ecs_Geometry_u.area.ring.ring_val[0].c.c_len > 0)) {
+ obj->xmin = obj->geom.ecs_Geometry_u.area.ring.ring_val[0].c.c_val[0].x;
+ obj->ymin = obj->geom.ecs_Geometry_u.area.ring.ring_val[0].c.c_val[0].y;
+ obj->xmax = obj->geom.ecs_Geometry_u.area.ring.ring_val[0].c.c_val[0].x;
+ obj->ymax = obj->geom.ecs_Geometry_u.area.ring.ring_val[0].c.c_val[0].y;
+ }
+ for(i=0;i<obj->geom.ecs_Geometry_u.area.ring.ring_len;i++) {
+ for(j=0;j<obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_len;j++) {
+ coord = &(obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val[j]);
+ if (obj->xmin > coord->x)
+ obj->xmin = coord->x;
+ if (obj->ymin > coord->y)
+ obj->ymin = coord->y;
+ if (obj->xmax < coord->x)
+ obj->xmax = coord->x;
+ if (obj->ymax < coord->y)
+ obj->ymax = coord->y;
+ }
+ }
+ break;
+ case Matrix:
+ case Image:
+ obj->xmin = s->currentRegion.west;
+ obj->ymin = s->currentRegion.south;
+ obj->xmax = s->currentRegion.east;
+ obj->ymax = s->currentRegion.north;
+ break;
+ default:
+ break;
+ }
+ return TRUE;
+}
+
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CopyResult: Copy an object contain in a ecs_Result structure.
+
+ IN
+ ecs_Result *source: Original object
+ OUT
+ ecs_Result *copy: Copied object
+ return int: Error message returned.
+ TRUE: Success
+ FALSE: Failure
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+int ecs_CopyResult(source,copy)
+ ecs_Result *source;
+ ecs_Result **copy;
+{
+ return ecs_CopyResultFromUnion(&source->res,copy);
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ * ecs_CopyResultFromUnion --
+ *
+ * Creates an ecs_Result structure from an ecs_ResultUnion
+ * structure.
+ *
+ * IN
+ * ecs_ResultUnion *source: Original object piece
+ * OUT
+ * ecs_Result **copy: Copied object piece with wrapping header
+ *
+ * Results:
+ * TRUE if successful.
+ * FALSE if unsuccessful.
+ *----------------------------------------------------------------------
+ */
+int
+ecs_CopyResultFromUnion(source,copy)
+ ecs_ResultUnion *source;
+ ecs_Result **copy;
+{
+ int returncode;
+ ecs_Object *obj;
+ ecs_Result *result;
+
+ returncode = TRUE;
+ if (source->type == Object) {
+ obj = &(source->ecs_ResultUnion_u.dob);
+
+ /* Allocate the new object */
+
+ if ((result = (ecs_Result *) malloc(sizeof(ecs_Result))) == NULL) {
+ returncode = FALSE;
+ }
+
+ /* Prepare the object structure */
+
+ result->error = 0;
+ result->message = NULL;
+
+ returncode = ecs_CopyResultUnionWork(source,&result->res);
+ if (returncode == FALSE) {
+ free(result);
+ result = NULL;
+ }
+ } else {
+ returncode = FALSE;
+ result = NULL;
+ }
+
+ *copy = result;
+ return returncode;
+}
+
+/*
+ *----------------------------------------------------------------------
+ * ecs_CopyResultUnion --
+ *
+ * Creates an ecs_Result structure from an ecs_ResultUnion
+ * structure.
+ *
+ * IN
+ * ecs_ResultUnion *source: Original object piece
+ * OUT
+ * ecs_Result **copy: Copied object piece with wrapping header
+ *
+ * Results:
+ * TRUE if successful.
+ * FALSE if unsuccessful.
+ *----------------------------------------------------------------------
+ */
+int
+ecs_CopyResultUnion(source,copy)
+ ecs_ResultUnion *source;
+ ecs_ResultUnion **copy;
+{
+ int returncode;
+ ecs_ResultUnion *result;
+
+ returncode = TRUE;
+ if (source->type == Object) {
+
+ /* Allocate the new object */
+
+ result = (ecs_ResultUnion *) malloc(sizeof(ecs_ResultUnion));
+ if (result == NULL) {
+ returncode = FALSE;
+ } else {
+ returncode = ecs_CopyResultUnionWork(source, result);
+ if (returncode == FALSE) {
+ free(result);
+ result = NULL;
+ }
+ }
+ } else {
+ returncode = FALSE;
+ result = NULL;
+ }
+
+ *copy = result;
+ return returncode;
+}
+
+/*
+ *----------------------------------------------------------------------
+ * ecs_CopyResultUnionWork --
+ *
+ * Sets one ecs_ResultUnion to be exactly like the other.
+ * Allocates any substructure that are needed.
+ *
+ * IN
+ * ecs_ResultUnion *source: Original object piece
+ * OUT
+ * ecs_ResultUnion *dest: Copied object piece
+ *
+ * Results:
+ * TRUE if successful.
+ * FALSE if unsuccessful.
+ *----------------------------------------------------------------------
+ */
+int
+ecs_CopyResultUnionWork(source,copy)
+ ecs_ResultUnion *source;
+ ecs_ResultUnion *copy;
+{
+ int returncode;
+ ecs_Object *obj;
+ ecs_Object *newobj;
+
+ returncode = TRUE;
+ if (source->type == Object) {
+ copy->type = Object;
+ obj = &(source->ecs_ResultUnion_u.dob);
+
+ newobj = ©->ecs_ResultUnion_u.dob;
+
+ /* Allocate in the new object Id and attr */
+
+ if ((returncode == TRUE) && (obj->Id != NULL) && ((newobj->Id = (char *) malloc(strlen(obj->Id)+1)) == NULL)) {
+ returncode = 1;
+ }
+
+ if ((returncode == TRUE) && (obj->attr != NULL) && ((newobj->attr = (char *) malloc(strlen(obj->attr)+1)) == NULL)) {
+ returncode = FALSE;
+ }
+
+ /* Fill the new ecs_Object structure with obj values */
+
+ if (obj->Id != NULL) {
+ strcpy(newobj->Id,obj->Id);
+ } else {
+ newobj->Id = NULL;
+ }
+ if (obj->attr != NULL) {
+ strcpy(newobj->attr,obj->attr);
+ } else {
+ newobj->attr = NULL;
+ }
+ newobj->xmin = obj->xmin;
+ newobj->ymin = obj->ymin;
+ newobj->xmax = obj->xmax;
+ newobj->ymax = obj->ymax;
+
+ /* Call ecs_CopyGeometry to fill the geom argument */
+
+ returncode = ecs_CopyGeometry(obj,newobj);
+
+ if (returncode == FALSE) {
+ ecs_FreeObject(newobj);
+ }
+ } else {
+ returncode = FALSE;
+ }
+
+ return returncode;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CopyObject: Copy an object contain in a ecs_Result structure.
+
+ IN
+ ecs_Object *obj: Original object
+ OUT
+ ecs_Object *copy: Copied object preallocated
+
+ return int: Error message returned.
+ TRUE: Success
+ FALSE: Failure
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+int ecs_CopyObject(obj,newobj)
+ ecs_Object *obj;
+ ecs_Object *newobj;
+{
+ int returncode;
+
+ returncode = TRUE;
+
+ /* Allocate in the new object Id and attr */
+
+ if ((returncode == TRUE) && (obj->Id != NULL) && ((newobj->Id = (char *) malloc(strlen(obj->Id)+1)) == NULL)) {
+ returncode = FALSE;
+ }
+
+ if ((returncode == TRUE) && (obj->attr != NULL) && ((newobj->attr = (char *) malloc(strlen(obj->attr)+1)) == NULL)) {
+ returncode = FALSE;
+ }
+
+ /* Fill the new ecs_Object structure with obj values */
+
+ if (obj->Id != NULL) {
+ strcpy(newobj->Id,obj->Id);
+ } else {
+ newobj->Id = NULL;
+ }
+ if (obj->attr != NULL) {
+ strcpy(newobj->attr,obj->attr);
+ } else {
+ newobj->attr = NULL;
+ }
+ newobj->xmin = obj->xmin;
+ newobj->ymin = obj->ymin;
+ newobj->xmax = obj->xmax;
+ newobj->ymax = obj->ymax;
+
+ /* Call ecs_CopyGeometry to fill the geom argument */
+
+ returncode = ecs_CopyGeometry(obj,newobj);
+
+ if (returncode == FALSE) {
+ ecs_FreeObject(newobj);
+ }
+
+ return returncode;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CopyGeometry: Copy an object geometry into a new object
+
+ IN
+ ecs_Object *source: Original object
+ IN/OUT
+ ecs_Object *copy: Copied object
+ OUT
+ return int: Error message returned.
+ TRUE: Success
+ FALSE: Failure
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+int ecs_CopyGeometry(source,copy)
+ ecs_Object *source;
+ ecs_Object *copy;
+{
+ int returncode;
+
+ returncode = TRUE;
+ copy->geom.family = source->geom.family;
+ switch(copy->geom.family) {
+ case Area:
+ returncode = ecs_CopyArea(&(source->geom.ecs_Geometry_u.area),
+ &(copy->geom.ecs_Geometry_u.area));
+ break;
+ case Line:
+ returncode = ecs_CopyLine(&(source->geom.ecs_Geometry_u.line),
+ &(copy->geom.ecs_Geometry_u.line));
+ break;
+ case Point:
+ returncode = ecs_CopyPoint(&(source->geom.ecs_Geometry_u.point),
+ &(copy->geom.ecs_Geometry_u.point));
+ break;
+ case Text:
+ returncode = ecs_CopyText(&(source->geom.ecs_Geometry_u.text),
+ &(copy->geom.ecs_Geometry_u.text));
+ break;
+ case Matrix:
+ returncode = ecs_CopyMatrix(&(source->geom.ecs_Geometry_u.matrix),
+ &(copy->geom.ecs_Geometry_u.matrix));
+ break;
+ case Image:
+ returncode = ecs_CopyImage(&(source->geom.ecs_Geometry_u.image),
+ &(copy->geom.ecs_Geometry_u.image));
+ break;
+ default:
+ break;
+ }
+
+ return returncode;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CopyArea: Copy the area from an original object to a copy
+
+ IN
+ ecs_Area *source: Pointer to the source area
+ IN/OUT
+ ecs_Area *copy: Pointer to the copy area
+ OUT
+ return int: Error message returned.
+ TRUE: Success
+ FALSE: Failure
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+int ecs_CopyArea(source,copy)
+ ecs_Area *source;
+ ecs_Area *copy;
+{
+ int i,j;
+
+ copy->ring.ring_len = source->ring.ring_len;
+ if (source->ring.ring_val != NULL) {
+ /* Allocate ring table */
+
+ copy->ring.ring_val = (ecs_FeatureRing *) malloc(sizeof(ecs_FeatureRing)*source->ring.ring_len);
+ if (copy->ring.ring_val == NULL) {
+ return FALSE;
+ }
+
+ /* Copy ring table containt */
+
+ for(i=0;i<(int) source->ring.ring_len;i++) {
+ copy->ring.ring_val[i].centroid.x = source->ring.ring_val[i].centroid.x;
+ copy->ring.ring_val[i].centroid.y = source->ring.ring_val[i].centroid.y;
+ copy->ring.ring_val[i].c.c_len = source->ring.ring_val[i].c.c_len;
+ if (source->ring.ring_val[i].c.c_val != NULL) {
+ /* Allocate c table */
+
+ copy->ring.ring_val[i].c.c_val = (ecs_Coordinate *) malloc(sizeof(ecs_Coordinate)*source->ring.ring_val[i].c.c_len);
+ if (copy->ring.ring_val[i].c.c_val == NULL) {
+ return FALSE;
+ }
+
+ /* Copy the c table contain */
+
+ for(j=0;j<(int) source->ring.ring_val[i].c.c_len;j++) {
+ copy->ring.ring_val[i].c.c_val[j].x = source->ring.ring_val[i].c.c_val[j].x;
+ copy->ring.ring_val[i].c.c_val[j].y = source->ring.ring_val[i].c.c_val[j].y;
+ }
+
+ } else {
+ copy->ring.ring_val[i].c.c_val = NULL;
+ }
+ }
+ } else {
+ copy->ring.ring_val = NULL;
+ }
+
+ return TRUE;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CopyLine: Copy the Line from an original object to a copy
+
+ IN
+ ecs_Line *source: Pointer to the source Line
+ IN/OUT
+ ecs_Line *copy: Pointer to the copy Line
+ OUT
+ return int: Error message returned.
+ TRUE: Success
+ FALSE: Failure
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+int ecs_CopyLine(source,copy)
+ ecs_Line *source;
+ ecs_Line *copy;
+{
+ int i;
+
+ copy->c.c_len = source->c.c_len;
+ if (source->c.c_val != NULL) {
+ /* Allocate c table */
+
+ copy->c.c_val = (ecs_Coordinate *) malloc(sizeof(ecs_Coordinate)*source->c.c_len);
+ if (copy->c.c_val == NULL) {
+ return FALSE;
+ }
+
+ /* Copy c table containt */
+
+ for(i=0;i<(int) source->c.c_len;i++) {
+ copy->c.c_val[i].x = source->c.c_val[i].x;
+ copy->c.c_val[i].y = source->c.c_val[i].y;
+ }
+ } else {
+ copy->c.c_val = NULL;
+ }
+
+ return TRUE;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CopyPoint: Copy the point from an original object to a copy
+
+ IN
+ ecs_Point *source: Pointer to the source point
+ IN/OUT
+ ecs_Point *copy: Pointer to the copy point
+ OUT
+ return int: Error message returned.
+ TRUE: Success
+ FALSE: Failure
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+int ecs_CopyPoint(source,copy)
+ ecs_Point *source;
+ ecs_Point *copy;
+{
+ copy->c.x = source->c.x;
+ copy->c.y = source->c.y;
+
+ return TRUE;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CopyText: Copy the text from an original object to a copy
+
+ IN
+ ecs_Text *source: Pointer to the source text
+ IN/OUT
+ ecs_Text *copy: Pointer to the copy text
+ OUT
+ return int: Error message returned.
+ TRUE: Success
+ FALSE: Failure
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+int ecs_CopyText(source,copy)
+ ecs_Text *source;
+ ecs_Text *copy;
+{
+ copy->c.x = source->c.x;
+ copy->c.y = source->c.y;
+
+ if (source->desc != NULL) {
+ copy->desc = (char *) malloc(strlen(source->desc)+1);
+ if (copy->desc == NULL) {
+ return FALSE;
+ }
+ strcpy(copy->desc,source->desc);
+ } else {
+ copy->desc = NULL;
+ }
+
+ return TRUE;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CopyMatrix: Copy the matrix from an original object to a copy
+
+ IN
+ ecs_Matrix *source: Pointer to the source matrix
+ IN/OUT
+ ecs_Matrix *copy: Pointer to the copy matrix
+ OUT
+ return int: Error message returned.
+ TRUE: Success
+ FALSE: Failure
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+int ecs_CopyMatrix(source,copy)
+ ecs_Matrix *source;
+ ecs_Matrix *copy;
+{
+ int i;
+
+ copy->x.x_len = source->x.x_len;
+ if (source->x.x_val != NULL) {
+ /* Allocate x table */
+
+ copy->x.x_val = (u_int *) malloc(sizeof(ecs_Coordinate)*source->x.x_len);
+ if (copy->x.x_val == NULL) {
+ return FALSE;
+ }
+
+ /* Copy x table containt */
+
+ for(i=0;i<(int) source->x.x_len;i++) {
+ copy->x.x_val[i] = source->x.x_val[i];
+ }
+ } else {
+ copy->x.x_val = NULL;
+ }
+
+ return TRUE;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CopyImage: Copy the image from an original object to a copy
+
+ IN
+ ecs_Image *source: Pointer to the source image
+ IN/OUT
+ ecs_Image *copy: Pointer to the copy image
+ OUT
+ return int: Error message returned.
+ TRUE: Success
+ FALSE: Failure
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+int ecs_CopyImage(source,copy)
+ ecs_Image *source;
+ ecs_Image *copy;
+{
+ int i;
+
+ copy->x.x_len = source->x.x_len;
+ if (source->x.x_val != NULL) {
+ /* Allocate x table */
+
+ copy->x.x_val = (u_int *) malloc(sizeof(ecs_Coordinate)*source->x.x_len);
+ if (copy->x.x_val == NULL) {
+ return FALSE;
+ }
+
+ /* Copy x table containt */
+
+ for(i=0;i<(int) source->x.x_len;i++) {
+ copy->x.x_val[i] = source->x.x_val[i];
+ }
+ } else {
+ copy->x.x_val = NULL;
+ }
+
+ return TRUE;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_FreeObject: Free an object
+
+ IN
+ ecs_Object *obj: object to be free
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+void ecs_FreeObject(obj)
+ ecs_Object *obj;
+{
+ int i;
+
+ if (obj != NULL) {
+ if (obj->Id != NULL)
+ free(obj->Id);
+ if (obj->attr != NULL)
+ free(obj->attr);
+ switch(obj->geom.family) {
+ case Area:
+ if (obj->geom.ecs_Geometry_u.area.ring.ring_val != NULL) {
+ for(i=0;i<(int) obj->geom.ecs_Geometry_u.area.ring.ring_len;i++) {
+ if (obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val != NULL)
+ free(obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val);
+ }
+ free(obj->geom.ecs_Geometry_u.area.ring.ring_val);
+ }
+ break;
+ case Line:
+ if (obj->geom.ecs_Geometry_u.line.c.c_val != NULL)
+ free(obj->geom.ecs_Geometry_u.line.c.c_val);
+ break;
+ case Text:
+ if (obj->geom.ecs_Geometry_u.text.desc != NULL)
+ free(obj->geom.ecs_Geometry_u.text.desc);
+ break;
+ case Matrix:
+ if (obj->geom.ecs_Geometry_u.matrix.x.x_val != NULL)
+ free(obj->geom.ecs_Geometry_u.matrix.x.x_val);
+ break;
+ case Image:
+ if (obj->geom.ecs_Geometry_u.image.x.x_val != NULL)
+ free(obj->geom.ecs_Geometry_u.image.x.x_val);
+ break;
+ default:
+ break;
+ }
+ }
+ return;
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsdist.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsdist.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsdist.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,603 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Functions for computing distances, centroids, and point-in-polygon.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecsdist.c,v $
+ * Revision 1.5 2001/04/12 19:25:27 warmerda
+ * added RGB<->Pixel functions
+ *
+ * Revision 1.4 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include <stdio.h>
+#include <math.h>
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecsdist.c,v 1.5 2001/04/12 19:25:27 warmerda Exp $");
+
+double currenttolerance = 0.0;
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_DistanceSegment: Calculate the distance between a point (posx,posy)
+ and a line segment (xl,yl), (xu,yu).
+
+ IN
+ xl,y1 : First point of segment
+ xu,yu : Second point of segment
+ posx,posy : Point position
+
+ OUT
+ return double : Calculated distance.
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+double ecs_DistanceSegment(xl,yl,xu,yu,posx,posy)
+ double xl;
+ double yl;
+ double xu;
+ double yu;
+ double posx;
+ double posy;
+{
+ double angle1;
+ double angle2;
+ double firstat;
+ double secondat;
+ double thirdat;
+ double quad1,quad2;
+ double distance;
+
+ if ((xu-xl)==0.0) {
+ if (yu>yl)
+ firstat = 1.5707963;
+ else
+ firstat = -1.5707963;
+ } else {
+ firstat = atan((yu-yl)/(xu-xl));
+ if (xu<xl)
+ firstat += 3.141592654;
+ }
+
+ if ((posx-xl)==0.0) {
+ if (posy>yl)
+ secondat = 1.5707963;
+ else
+ secondat = -1.5707963;
+ } else {
+ secondat = atan((posy-yl)/(posx-xl));
+ if (posx<xl)
+ secondat += 3.141592654;
+ }
+
+ if ((posx-xu)==0.0) {
+ if (posy>yu)
+ thirdat = 1.5707963;
+ else
+ thirdat = -1.5707963;
+ } else {
+ thirdat = atan((posy-yu)/(posx-xu));
+ if (posx<xu)
+ thirdat += 3.141592654;
+ }
+
+ /*
+ Calculate the quadrant of each angle. If they are
+ the same, the coordinate is not valid
+ */
+
+ angle1 = firstat - secondat;
+ angle2 = firstat - thirdat;
+
+ quad1 = 1;
+ if ((angle1 > 1.5707963) || (angle1 < -1.5707963))
+ quad1 = 2;
+ quad2 = 1;
+ if ((angle2 > 1.5707963) || (angle2 < -1.5707963))
+ quad2 = 2;
+
+ /* Check if the distance to the segment is a
+ distance to point1, a distance to point 2 or
+ the distance between the coordinate and
+ the segment itself */
+
+ if (quad1 == 2 && quad2 == 2) {
+ /* Calculate the distance to point (xl,yl) */
+ distance = sqrt(((posx-xl)*(posx-xl))+((posy-yl)*(posy-yl)));
+ } else if (quad1 == 1 && quad2 == 1) {
+ /* Calculate the distance to point (xu,yu) */
+ distance = sqrt(((posx-xu)*(posx-xu))+((posy-yu)*(posy-yu)));
+ } else {
+ /* Calculate the distance between the segment (xl,yl),(xu,yu) and
+ the point (posx,posy) */
+
+ distance = sin(angle1)*sqrt(((posx-xl)*(posx-xl))+((posy-yl)*(posy-yl)));
+ if (distance<0.0)
+ distance = -distance;
+ }
+ return distance;
+}
+
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_DistanceObject: Calculate the distance between a point (posx,posy)
+ and a ecs_Object
+
+ IN
+ ecs_Object *obj: Geographic object
+ posx,posy : Point position
+
+ OUT
+ return double : Calculated distance. If an error occur, the
+ function return a negative value.
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+
+double ecs_DistanceObject(obj,X,Y)
+ ecs_Object *obj;
+ double X;
+ double Y;
+{
+ int i,j;
+ double d1,d2;
+
+ if (obj==NULL)
+ return -1.0;
+
+ switch(obj->geom.family) {
+ case Area:
+ d2 = HUGE_VAL;
+
+ for(i=0;(int) i<(int) (obj->geom.ecs_Geometry_u.area.ring.ring_len); i++) {
+ for(j=0;(int) j<(int) (obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_len - 1); j++) {
+ d1 = ecs_DistanceSegment(obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val[j].x,
+ obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val[j].y,
+ obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val[j+1].x,
+ obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val[j+1].y,
+ X,Y);
+ if (d1<d2) d2 = d1;
+ }
+ }
+
+ if (ecs_IsPointInPolygon(obj->geom.ecs_Geometry_u.area.ring.ring_val[0].c.c_len,
+ obj->geom.ecs_Geometry_u.area.ring.ring_val[0].c.c_val,X,Y) == TRUE) {
+ if (obj->geom.ecs_Geometry_u.area.ring.ring_len > 1) {
+ for(i=0;(int) i<(int) (obj->geom.ecs_Geometry_u.area.ring.ring_len); i++) {
+ if (ecs_IsPointInPolygon(obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_len,
+ obj->geom.ecs_Geometry_u.area.ring.ring_val[i].c.c_val,X,Y) == TRUE) {
+ return d2;
+ }
+ }
+ }
+
+ return (d2/2.0);
+ }
+
+ return d2;
+ break;
+ case Line:
+ d2 = HUGE_VAL;
+ for(i=0;(int) i<(int) (obj->geom.ecs_Geometry_u.line.c.c_len - 1);i++) {
+ d1 = ecs_DistanceSegment(obj->geom.ecs_Geometry_u.line.c.c_val[i].x,
+ obj->geom.ecs_Geometry_u.line.c.c_val[i].y,
+ obj->geom.ecs_Geometry_u.line.c.c_val[i+1].x,
+ obj->geom.ecs_Geometry_u.line.c.c_val[i+1].y,
+ X,Y);
+ if (d1<d2) d2 = d1;
+ }
+ return d2;
+ break;
+ case Point:
+ return sqrt((X-obj->geom.ecs_Geometry_u.point.c.x)*(X-obj->geom.ecs_Geometry_u.point.c.x)+
+ (Y-obj->geom.ecs_Geometry_u.point.c.y)*(Y-obj->geom.ecs_Geometry_u.point.c.y));
+ break;
+ case Text:
+ return sqrt((X-obj->geom.ecs_Geometry_u.text.c.x)*(X-obj->geom.ecs_Geometry_u.text.c.x)+
+ (Y-obj->geom.ecs_Geometry_u.text.c.y)*(Y-obj->geom.ecs_Geometry_u.text.c.y));
+ break;
+ case Matrix:
+ return -1;
+ break;
+ case Image:
+ return -1;
+ break;
+ default:
+ return -1;
+ break;
+ }
+
+ return -1;
+}
+
+
+/*
+ ----------------------------------------------------------------------
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_DistanceObjectWithTolerance
+
+ DESCRIPTION
+ Calculate the distance between an object and a point with a
+ tolerance factor. The tolerance factor was previously calculated
+ in ecs_SetTolerance
+ END_DESCRIPTION
+
+ PARAMETERS
+ ecs_Object *obj: The geographic object
+ double *X: Pointer to X, the x coordinate of the geographic point to convert
+ double *Y: Pointer to Y, the y coordinate of the geographic point to convert
+ END_PARAMETERS
+
+ RETURN_VALUE
+ double: The result distance
+
+ END_FUNCTION_INFORMATION
+
+ ----------------------------------------------------------------------
+ */
+
+
+double ecs_DistanceObjectWithTolerance(obj,X,Y)
+ ecs_Object *obj;
+ double X;
+ double Y;
+{
+ double res;
+
+ res = ecs_DistanceObject(obj,X,Y);
+
+ if (res > currenttolerance && obj->geom.family != Area) {
+ res = HUGE_VAL;
+ }
+
+ return res;
+}
+
+
+/*
+ ----------------------------------------------------------------------
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_SetTolerance
+
+ DESCRIPTION
+ Calculate the tolerance of a given region.
+ END_DESCRIPTION
+
+ PARAMETERS
+ ecs_Region *reg: The geographic region
+ END_PARAMETERS
+
+ RETURN_VALUE
+ double: The result tolerance
+
+ END_FUNCTION_INFORMATION
+
+ ----------------------------------------------------------------------
+ */
+
+
+double ecs_SetTolerance(reg)
+ ecs_Region *reg;
+{
+ currenttolerance = ((reg->north - reg->south)*ECSTOLERANCE);
+ return currenttolerance;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_DistanceMBR: Calculate the distance between a point (posx,posy)
+ and a MBR
+
+ IN
+ xl,y1 : First corner of MBR
+ xu,yu : Second corner of MBR
+ posx,posy : Point position
+
+ OUT
+ return double : Calculated distance.
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+double ecs_DistanceMBR(xl,yl,xu,yu,posx,posy)
+ double xl;
+ double yl;
+ double xu;
+ double yu;
+ double posx;
+ double posy;
+{
+ double d1,d2;
+
+ d2 = HUGE_VAL;
+
+ if ((posx > xl) && (posx < xu) && (posy > yl) && (posy < yu))
+ return 0.0;
+
+ d1 = ecs_DistanceSegment(xl,yl,xl,yu,posx,posy);
+ if (d1<d2) d2 = d1;
+
+ d1 = ecs_DistanceSegment(xl,yu,xu,yu,posx,posy);
+ if (d1<d2) d2 = d1;
+
+ d1 = ecs_DistanceSegment(xu,yu,xu,yl,posx,posy);
+ if (d1<d2) d2 = d1;
+
+ d1 = ecs_DistanceSegment(xu,yl,xl,yl,posx,posy);
+ if (d1<d2) d2 = d1;
+
+ return d2;
+}
+
+/* ==================================================================
+ ==================================================================
+ ==================================================================
+ */
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_CalculateCentroid: Calculate the centroid of a polygon
+
+ IN
+ nb_segment : the number of segments
+ coord : an array of ecs_Coordinates
+ centroid : the returned value.
+
+ OUT
+ return TRUE
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+
+int ecs_CalculateCentroid(nb_segment,coord,centroid)
+ int nb_segment;
+ ecs_Coordinate *coord;
+ ecs_Coordinate *centroid;
+{
+ int i, j;
+ double *intersect;
+ int compar();
+ double m,b;
+ double xcent,minx,miny,maxx,maxy;
+
+ /* figure out the max, min, then centre of line */
+
+ minx = maxx = coord[0].x;
+ miny = maxy = coord[0].y;
+
+
+ for(i = 1; i < nb_segment; ++i) {
+ if (coord[i].x < minx) { minx= coord[i].x; }
+ if (coord[i].y < miny) { miny= coord[i].y; }
+ if (coord[i].x > maxx) { maxx= coord[i].x; }
+ if (coord[i].y > maxy) { maxy= coord[i].y; }
+ /* minx = min( minx, coord[i].x );
+ miny = min( miny, coord[i].y );*/
+ /* maxx = max( maxx, coord[i].x );
+ maxy = max( maxy, coord[i].y );*/
+ }
+
+ xcent = (minx + maxx) / 2.0;
+
+ intersect = (double *) malloc(sizeof(double)*(nb_segment+1));
+ if (intersect == NULL) {
+ centroid->x = 0.0;
+ centroid->y = 0.0;
+ return TRUE;
+ }
+
+ /* rechercher tous les segments dont les coord en x sont tel
+ que x1 < xcent < x2 ou x1 > xcent > x2
+ */
+
+ for (i = 0,j= 0; i < nb_segment - 1; ++i) {
+ if(((double) coord[i].x < xcent &&
+ (double) coord[i+1].x >= xcent) ||
+ ((double) coord[i].x > xcent &&
+ (double) coord[i+1].x <= xcent)) {
+
+ m = (double) (coord[i+1].y - coord[i].y) /
+ (double) (coord[i+1].x - coord[i].x);
+ b = (double) coord[i].y - m * (double) coord[i].x;
+ intersect[j++] = (double)(b + m * xcent);
+
+ }
+ }
+
+ /* Last segment */
+
+ if(((double) coord[nb_segment-1].x < xcent &&
+ (double) coord[0].x >= xcent) ||
+ ((double) coord[nb_segment-1].x > xcent &&
+ (double) coord[0].x <= xcent)) {
+
+ m = (double) (coord[nb_segment-1].y - coord[0].y) /
+ (double) (coord[nb_segment-1].x - coord[0].x);
+ b = (double) coord[0].y - m * (double) coord[0].x;
+ intersect[j++] = (double)(b + m * xcent);
+
+ }
+
+
+ /* tri les intersections en y */
+
+ qsort(intersect,j,sizeof(double),(*compar));
+
+ centroid->x = xcent;
+ centroid->y = (intersect[0] + intersect[1]) / 2.0;
+
+ free(intersect);
+ return TRUE;
+}
+
+int compar(s1,s2)
+ double *s1,*s2;
+{
+ if (*s1 > *s2)
+ return 1;
+ else if (*s1 == *s2)
+ return 0;
+ return -1;
+}
+
+
+/*
+ ----------------------------------------------------------------------
+
+ cln_IsPointInPolygon
+
+ Check if a point is in a polygon.
+
+ PARAMETERS
+ INPUT
+ int npoints: Indicate the point quantity in poly
+ ecs_Coordinate *poly: Polygon
+ double x: X coordinate of the point to check
+ double y: Y coordinate of the point to check
+
+ RETURN_VALUE
+ int : The boolean indication if the point is outside or inside the polygon
+
+ ----------------------------------------------------------------------
+ */
+
+int ecs_IsPointInPolygon(npoints,poly,x,y)
+ int npoints;
+ ecs_Coordinate *poly;
+ double x;
+ double y;
+{
+ int inside = 0;
+ double xnew,ynew;
+ double xold,yold;
+ double x1,y1;
+ double x2,y2;
+ int i;
+
+ if (npoints < 3)
+ return FALSE;
+
+ xold = poly[npoints-1].x;
+ yold = poly[npoints-1].y;
+ for(i=0;i<npoints;i++) {
+ xnew = poly[i].x;
+ ynew = poly[i].y;
+ if (xnew > xold) {
+ x1 = xold;
+ y1 = yold;
+ x2 = xnew;
+ y2 = ynew;
+ } else {
+ x2 = xold;
+ y2 = yold;
+ x1 = xnew;
+ y1 = ynew;
+ }
+ if ((xnew < x) == (x <= xold) &&
+ ((y-y1)*(x2-x1) < (y2-y1)*(x-x1)))
+ inside = !inside;
+ xold = xnew;
+ yold = ynew;
+ }
+
+ if (inside == 1) return TRUE;
+
+ return FALSE;
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_GetRGBFromPixel: Fetch RGB/t components from 32bit pixel value.
+
+ IN
+ unsigned int pixel: the source 32bit value.
+ unsigned char *t: location to set with transparency flag (1=opaque)
+ unsigned char *r: location to set with red component.
+ unsigned char *g: location to set with green component.
+ unsigned char *b: location to set with blue component.
+
+ OUT
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+void ecs_GetRGBFromPixel( unsigned int pixel,
+ unsigned char *transparent,
+ unsigned char *r,
+ unsigned char *g,
+ unsigned char *b )
+
+{
+ unsigned char *byte_pixel = (unsigned char *) &pixel;
+
+ if( transparent != NULL )
+ *transparent = byte_pixel[3];
+ *r = byte_pixel[0];
+ *g = byte_pixel[1];
+ *b = byte_pixel[2];
+}
+
+/*
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+ ecs_GetPixelFromRGB: Fetch 32bit pixel value from RGB components.
+
+ IN
+ int t: transparency flag (1=opaque,0=transparent)
+ int r: red component (0-255).
+ int g: green component (0-255).
+ int b: blue component (0-255).
+
+ OUT
+ 32bit pixel value.
+
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ */
+
+unsigned int ecs_GetPixelFromRGB( int t, int r, int g, int b )
+
+{
+ unsigned int pixel;
+ unsigned char *byte_pixel = (unsigned char *) &pixel;
+
+ byte_pixel[0] = r;
+ byte_pixel[1] = g;
+ byte_pixel[2] = b;
+ byte_pixel[3] = t;
+
+ return pixel;
+}
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsgeo.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsgeo.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsgeo.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,373 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Computing distances and areas related to feature objects.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecsgeo.c,v $
+ * Revision 1.3 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecsgeo.c,v 1.3 2001/04/09 15:04:34 warmerda Exp $");
+
+static double ecs_QA, ecs_QB, ecs_QC;
+static double ecs_QbarA, ecs_QbarB, ecs_QbarC, ecs_QbarD;
+static double ecs_AE; /* a^2(1-e^2) */
+static double ecs_Qp; /* Q at the north pole */
+static double ecs_E; /* area of the earth */
+static double ecs_TwoPI;
+
+/**************************************************************************/
+
+void ecs_begin_ellipsoid_polygon_area (a, e2)
+ double a, e2;
+{
+ double e4, e6;
+
+ /* Put default values if a and e2 are 0 */
+
+ if ((a==0.0) && (e2==0.0)) {
+ a = 6378206.4000000004;
+ e2 = 0.0067686580;
+ }
+
+ ecs_TwoPI = PI+PI;
+
+ e4 = e2 * e2;
+ e6 = e4 * e2;
+
+ ecs_AE = a * a * (1 - e2);
+
+ ecs_QA = (2.0/3.0)*e2;
+ ecs_QB = (3.0/5.0)*e4;
+ ecs_QC = (4.0/7.0)*e6;
+
+ ecs_QbarA = -1.0 - (2.0/3.0)*e2 - (3.0/5.0)*e4 - (4.0/7.0)*e6;
+ ecs_QbarB = (2.0/9.0)*e2 + (2.0/5.0)*e4 + (4.0/7.0)*e6;
+ ecs_QbarC = - (3.0/25.0)*e4 - (12.0/35.0)*e6;
+ ecs_QbarD = (4.0/49.0)*e6;
+
+ ecs_Qp = ecs_Q(PI/2);
+ ecs_E = 4 * PI * ecs_Qp * ecs_AE;
+ if (ecs_E < 0.0) ecs_E = -ecs_E;
+}
+
+
+/**************************************************************************/
+
+double ecs_Q(x)
+ double x;
+{
+ double sinx, sinx2;
+
+ sinx = sin(x);
+ sinx2 = sinx * sinx;
+
+ return sinx * (1 + sinx2 * (ecs_QA + sinx2 * (ecs_QB + sinx2 * ecs_QC)));
+}
+
+/**************************************************************************/
+
+double ecs_Qbar(x)
+ double x;
+{
+ double cosx, cosx2;
+
+ cosx = cos(x);
+ cosx2 = cosx * cosx;
+
+ return cosx * (ecs_QbarA + cosx2 * (ecs_QbarB + cosx2 * (ecs_QbarC + cosx2 * ecs_QbarD)));
+}
+
+/**************************************************************************/
+
+double ecs_planimetric_polygon_area(n,coord)
+ int n;
+ ecs_Coordinate *coord;
+{
+ double x1,y1,x2,y2;
+ double area;
+ int pos;
+
+ x2 = coord[n-1].x;
+ y2 = coord[n-1].y;
+
+ pos = 0;
+ area = 0;
+ while (--n >= 0) {
+ x1 = x2;
+ y1 = y2;
+
+ x2 = coord[pos].x;
+ y2 = coord[pos].y;
+ pos++;
+
+ area += (y2+y1)*(x2-x1);
+ }
+
+ if((area /= 2.0) < 0.0)
+ area = -area;
+
+ return area;
+}
+
+/**************************************************************************/
+
+double ecs_ellipsoid_polygon_area (n, coord)
+ int n;
+ ecs_Coordinate *coord;
+{
+ double x1,y1,x2,y2,dx,dy;
+ double Qbar1, Qbar2;
+ double area;
+ int pos;
+
+ x2 = coord[n-1].x * DEG_TO_RAD;
+ y2 = coord[n-1].y * DEG_TO_RAD;
+ Qbar2 = ecs_Qbar(y2);
+
+ area = 0.0;
+ pos = 0;
+ while (--n >= 0) {
+ x1 = x2;
+ y1 = y2;
+ Qbar1 = Qbar2;
+
+ x2 = coord[pos].x * DEG_TO_RAD;
+ y2 = coord[pos].y * DEG_TO_RAD;
+ pos++;
+ Qbar2 = ecs_Qbar(y2);
+
+ if (x1 > x2)
+ while (x1 - x2 > PI)
+ x2 += ecs_TwoPI;
+ else if (x2 > x1)
+ while (x2 - x1 > PI)
+ x1 += ecs_TwoPI;
+
+ dx = x2 - x1;
+ area += dx * (ecs_Qp - ecs_Q(y2));
+
+ if ((dy = y2 - y1) != 0.0)
+ area += dx * ecs_Q(y2) - (dx/dy)*(Qbar2-Qbar1);
+ }
+ if((area *= ecs_AE) < 0.0)
+ area = -area;
+
+ /* kludge - if polygon circles the south pole the area will be
+ * computed as if it cirlced the north pole. The correction is
+ * the difference between total surface area of the earth and
+ * the "north pole" area.
+ */
+ if (area > ecs_E)
+ area = ecs_E;
+ if (area > ecs_E/2)
+ area = ecs_E - area;
+
+ return area;
+}
+
+/**************************************************************************/
+
+/*
+ ------------------------------------------------------------
+
+ ecs_geodesic_distance --
+
+ Cette fonction calcule la distance en metres de deux
+ points en projection longitude/lattitude.
+
+ ------------------------------------------------------------
+ */
+
+double
+ecs_geodesic_distance (lon1, lat1, lon2, lat2)
+ double lon1, lat1, lon2, lat2;
+{
+ static double boa = 0.99660992469;
+ static double f = 0.003390075305;
+ static double ff64 = 0.0000001795720402425;
+ static double al = 6378206.4;
+ double result,newresult,pente,bo,nlat1,nlat2;
+
+ double a, cd, cdtm, ctm, d, dl, dtm, e,kk, kl, l;
+ double sd, sdlmr, sdtm, stm, t, t1r, t2r, tm, u, v, x, y;
+
+ while (lon1 > 180.0)
+ lon1 -= 360.0;
+ while (lon1 < -180.0)
+ lon1 += 360.0;
+ while (lon2 > 180.0)
+ lon2 -= 360.0;
+ while (lon2 < -180.0)
+ lon2 += 360.0;
+ if (lon1 > lon2) {
+ t = lon1;
+ lon1 = lon2;
+ lon2 = t;
+
+ t = lat1;
+ lat1 = lat2;
+ lat2 = t;
+ }
+
+ /* Calculer la pente et l'origine de la droite passant
+ a travers les deux points. */
+
+
+ if (fmod((lon2-lon1),180.0) == 0.0) {
+ lon1 += 0.01;
+ }
+
+ pente = (lat2-lat1)/(lon2-lon1);
+ bo = lat1-pente*lon1;
+
+ lat1=lat1*DEG_TO_RAD;
+ lon1=lon1*DEG_TO_RAD;
+ lat2=lat2*DEG_TO_RAD;
+ lon2=lon2*DEG_TO_RAD;
+
+ t1r=atan(boa*tan(lat1));
+ t2r=atan(boa*tan(lat2));
+
+ tm = (t1r+t2r)/2.0;
+ dtm = (t2r-t1r)/2.0;
+
+ stm = sin(tm);
+ ctm = cos(tm);
+ sdtm = sin(dtm);
+ cdtm = cos(dtm);
+
+ kl = stm*cdtm;
+ kk = sdtm*ctm;
+
+ sdlmr=sin((lon2-lon1)/2.0);
+ l=sdtm*sdtm+sdlmr*sdlmr*(cdtm*cdtm-stm*stm);
+
+ /* Si l = 0 ou l = 1, l'algorithme va necessairement donner
+ un resultat infini. */
+ if (l==1.0)
+ l -= 0.01;
+ if (l==0.0)
+ l+=0.01;
+ cd=1.0-2.0*l;
+ dl=acos(cd);
+ sd=sin(dl);
+ t=dl/sd;
+
+ u=2.0*kl*kl/(1.0-l);
+ v=2.0*kk*kk/l;
+ d=4.0*t*t;
+ x=u+v;
+ e=-2.0*cd;
+ y=u-v;
+ a=-d*e;
+
+ result = (al*sd*(t-f/4.0*(t*x-y)+ff64*(x*(a+(t-(a+e)/2.0)*x)+y*(-2.0*d+e*y)+d*x*y)));
+
+ /* Compensation si angle obtu */
+
+ if ((lon2-lon1) > PI) {
+ nlat1=-90.0*pente+bo;
+ nlat2=90.0*pente+bo;
+ newresult = ecs_geodesic_distance(-90.0,nlat1,90.0,nlat2);
+ result = 2*newresult-result;
+ }
+
+ return result;
+}
+
+/*
+ ------------------------------------------------------------
+
+ ecs_distance_meters --
+
+ Cette fonction calcule la distance en metres de deux
+ points dans la projection actuelle de l'affichage.
+ Retourne un negatif si c'est un cas d'erreur.
+
+ ------------------------------------------------------------
+ */
+
+double
+ecs_distance_meters (projection,X1, Y1, X2, Y2)
+ char *projection;
+ double X1,Y1,X2,Y2;
+{
+ PJ *proj;
+ char **argv;
+ int argc;
+ double lon1,lat1,lon2,lat2;
+ double result;
+ projUV data;
+
+ if (ecs_SplitList(projection,&argc,&argv)==FALSE) {
+ return -1;
+ }
+
+ if (strncmp(argv[0],PROJ_UNKNOWN,7) == 0) {
+ free(argv);
+ return -1;
+ }
+
+ if (strncmp(argv[0],PROJ_LONGLAT,13) != 0) {
+ if ((proj = pj_init(argc,argv)) == NULL) {
+ free(argv);
+ return -1;
+ }
+
+ data.u = X1;
+ data.v = Y1;
+ data = pj_inv(data,proj);
+ if ((data.u == HUGE_VAL) || (data.v == HUGE_VAL)) {
+ pj_free(proj);
+ free(argv);
+ return -1;
+ }
+ lon1 = data.u*RAD_TO_DEG;
+ lat1 = data.v*RAD_TO_DEG;
+
+ data.u = X2;
+ data.v = Y2;
+ data = pj_inv(data,proj);
+ if ((data.u == HUGE_VAL) || (data.v == HUGE_VAL)) {
+ pj_free(proj);
+ free(argv);
+ return -1;
+ }
+ lon2 = data.u*RAD_TO_DEG;
+ lat2 = data.v*RAD_TO_DEG;
+
+ pj_free(proj);
+ } else {
+ lon1 = X1;
+ lon2 = X2;
+ lat1 = Y1;
+ lat2 = Y2;
+ }
+
+ free(argv);
+
+ result = ecs_geodesic_distance(lon1,lat1,lon2,lat2);
+
+ return result;
+}
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecshash.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecshash.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecshash.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,931 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Implementation of in-memory hash tables for ecs and ecs-based
+ * applications.
+ *
+ ******************************************************************************
+ * Copyright (c) 1991-1993 The Regents of the University of California.
+ * Copyright (c) 1994 Sun Microsystems, Inc.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ ******************************************************************************
+ *
+ * $Log: ecshash.c,v $
+ * Revision 1.3 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecshash.c,v 1.3 2001/04/09 15:04:34 warmerda Exp $");
+
+/*
+ * When there are this many entries per bucket, on average, rebuild
+ * the hash table to make it larger.
+ */
+
+#define REBUILD_MULTIPLIER 3
+
+
+/*
+ * The following macro takes a preliminary integer hash value and
+ * produces an index into a hash tables bucket list. The idea is
+ * to make it so that preliminary values that are arbitrarily similar
+ * will end up in different buckets. The hash function was taken
+ * from a random-number generator.
+ */
+
+#define RANDOM_INDEX(tablePtr, i) (((((long) (i))*1103515245) >> (tablePtr)->downShift) & (tablePtr)->mask)
+
+/*
+ * Procedure prototypes for static procedures in this file:
+ */
+
+static ecs_HashEntry *ArrayFind _ANSI_ARGS_((ecs_HashTable *tablePtr,
+ char *key));
+static ecs_HashEntry* ArrayCreate _ANSI_ARGS_((ecs_HashTable *tablePtr,
+ char *key, int *newPtr));
+static ecs_HashEntry* BogusFind _ANSI_ARGS_((ecs_HashTable *tablePtr,
+ char *key));
+static ecs_HashEntry* BogusCreate _ANSI_ARGS_((ecs_HashTable *tablePtr,
+ char *key, int *newPtr));
+static unsigned int HashString _ANSI_ARGS_((char *string));
+static void RebuildTable _ANSI_ARGS_((ecs_HashTable *tablePtr));
+static ecs_HashEntry* StringFind _ANSI_ARGS_((ecs_HashTable *tablePtr,
+ char *key));
+static ecs_HashEntry* StringCreate _ANSI_ARGS_((ecs_HashTable *tablePtr,
+ char *key, int *newPtr));
+static ecs_HashEntry* OneWordFind _ANSI_ARGS_((ecs_HashTable *tablePtr,
+ char *key));
+static ecs_HashEntry* OneWordCreate _ANSI_ARGS_((ecs_HashTable *tablePtr,
+ char *key, int *newPtr));
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_InitHashTable --
+ *
+ * Given storage for a hash table, set up the fields to prepare
+ * the hash table for use.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * TablePtr is now ready to be passed to ecs_FindHashEntry and
+ * ecs_CreateHashEntry.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+ecs_InitHashTable(tablePtr, keyType)
+ register ecs_HashTable *tablePtr; /* Pointer to table record, which
+ * is supplied by the caller. */
+ int keyType; /* Type of keys to use in table:
+ * ECS_STRING_KEYS, ECS_ONE_WORD_KEYS,
+ * or an integer >= 2. */
+{
+ tablePtr->buckets = tablePtr->staticBuckets;
+ tablePtr->staticBuckets[0] = tablePtr->staticBuckets[1] = 0;
+ tablePtr->staticBuckets[2] = tablePtr->staticBuckets[3] = 0;
+ tablePtr->numBuckets = ECS_SMALL_HASH_TABLE;
+ tablePtr->numEntries = 0;
+ tablePtr->rebuildSize = ECS_SMALL_HASH_TABLE*REBUILD_MULTIPLIER;
+ tablePtr->downShift = 28;
+ tablePtr->mask = 3;
+ tablePtr->keyType = keyType;
+ if (keyType == ECS_STRING_KEYS) {
+ tablePtr->findProc = StringFind;
+ tablePtr->createProc = StringCreate;
+ } else if (keyType == ECS_ONE_WORD_KEYS) {
+ tablePtr->findProc = OneWordFind;
+ tablePtr->createProc = OneWordCreate;
+ } else {
+ tablePtr->findProc = ArrayFind;
+ tablePtr->createProc = ArrayCreate;
+ };
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ECS_DeleteHashEntry --
+ *
+ * Remove a single entry from a hash table.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The entry given by entryPtr is deleted from its table and
+ * should never again be used by the caller. It is up to the
+ * caller to free the clientData field of the entry, if that
+ * is relevant.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+ecs_DeleteHashEntry(entryPtr)
+ ecs_HashEntry *entryPtr;
+{
+ register ecs_HashEntry *prevPtr;
+
+ if (*entryPtr->bucketPtr == entryPtr) {
+ *entryPtr->bucketPtr = entryPtr->nextPtr;
+ } else {
+ for (prevPtr = *entryPtr->bucketPtr; ; prevPtr = prevPtr->nextPtr) {
+ if (prevPtr == NULL) {
+ }
+ if (prevPtr->nextPtr == entryPtr) {
+ prevPtr->nextPtr = entryPtr->nextPtr;
+ break;
+ }
+ }
+ }
+ entryPtr->tablePtr->numEntries--;
+ free((char *) entryPtr);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_DeleteHashTable --
+ *
+ * Free up everything associated with a hash table except for
+ * the record for the table itself.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The hash table is no longer useable.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+ecs_DeleteHashTable(tablePtr)
+ register ecs_HashTable *tablePtr; /* Table to delete. */
+{
+ register ecs_HashEntry *hPtr, *nextPtr;
+ int i;
+
+ /*
+ * Free up all the entries in the table.
+ */
+
+ for (i = 0; i < tablePtr->numBuckets; i++) {
+ hPtr = tablePtr->buckets[i];
+ while (hPtr != NULL) {
+ nextPtr = hPtr->nextPtr;
+ free((char *) hPtr);
+ hPtr = nextPtr;
+ }
+ }
+
+ /*
+ * Free up the bucket array, if it was dynamically allocated.
+ */
+
+ if (tablePtr->buckets != tablePtr->staticBuckets) {
+ free((char *) tablePtr->buckets);
+ }
+
+ /*
+ * Arrange for panics if the table is used again without
+ * re-initialization.
+ */
+
+ tablePtr->findProc = BogusFind;
+ tablePtr->createProc = BogusCreate;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_FirstHashEntry --
+ *
+ * Locate the first entry in a hash table and set up a record
+ * that can be used to step through all the remaining entries
+ * of the table.
+ *
+ * Results:
+ * The return value is a pointer to the first entry in tablePtr,
+ * or NULL if tablePtr has no entries in it. The memory at
+ * *searchPtr is initialized so that subsequent calls to
+ * ecs_NextHashEntry will return all of the entries in the table,
+ * one at a time.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_HashEntry *
+ecs_FirstHashEntry(tablePtr, searchPtr)
+ ecs_HashTable *tablePtr; /* Table to search. */
+ ecs_HashSearch *searchPtr; /* Place to store information about
+ * progress through the table. */
+{
+ searchPtr->tablePtr = tablePtr;
+ searchPtr->nextIndex = 0;
+ searchPtr->nextEntryPtr = NULL;
+ return ecs_NextHashEntry(searchPtr);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_NextHashEntry --
+ *
+ * Once a hash table enumeration has been initiated by calling
+ * ecs_FirstHashEntry, this procedure may be called to return
+ * successive elements of the table.
+ *
+ * Results:
+ * The return value is the next entry in the hash table being
+ * enumerated, or NULL if the end of the table is reached.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_HashEntry *
+ecs_NextHashEntry(searchPtr)
+ ecs_HashSearch *searchPtr; /* Place to store information about
+ * progress through the table. Must
+ * have been initialized by calling
+ * ecs_FirstHashEntry. */
+{
+ ecs_HashEntry *hPtr;
+
+ while (searchPtr->nextEntryPtr == NULL) {
+ if (searchPtr->nextIndex >= searchPtr->tablePtr->numBuckets) {
+ return NULL;
+ }
+ searchPtr->nextEntryPtr =
+ searchPtr->tablePtr->buckets[searchPtr->nextIndex];
+ searchPtr->nextIndex++;
+ }
+ hPtr = searchPtr->nextEntryPtr;
+ searchPtr->nextEntryPtr = hPtr->nextPtr;
+ return hPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_HashStats --
+ *
+ * Return statistics describing the layout of the hash table
+ * in its hash buckets.
+ *
+ * Results:
+ * The return value is a malloc-ed string containing information
+ * about tablePtr. It is the caller's responsibility to free
+ * this string.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+char *
+ecs_HashStats(tablePtr)
+ ecs_HashTable *tablePtr; /* Table for which to produce stats. */
+{
+#define NUM_COUNTERS 10
+ int count[NUM_COUNTERS], overflow, i, j;
+ double average, tmp;
+ register ecs_HashEntry *hPtr;
+ char *result, *p;
+
+ /*
+ * Compute a histogram of bucket usage.
+ */
+
+ for (i = 0; i < NUM_COUNTERS; i++) {
+ count[i] = 0;
+ }
+ overflow = 0;
+ average = 0.0;
+ for (i = 0; i < tablePtr->numBuckets; i++) {
+ j = 0;
+ for (hPtr = tablePtr->buckets[i]; hPtr != NULL; hPtr = hPtr->nextPtr) {
+ j++;
+ }
+ if (j < NUM_COUNTERS) {
+ count[j]++;
+ } else {
+ overflow++;
+ }
+ tmp = j;
+ average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0;
+ }
+
+ /*
+ * Print out the histogram and a few other pieces of information.
+ */
+
+ result = (char *) malloc((unsigned) ((NUM_COUNTERS*60) + 300));
+ sprintf(result, "%d entries in table, %d buckets\n",
+ tablePtr->numEntries, tablePtr->numBuckets);
+ p = result + strlen(result);
+ for (i = 0; i < NUM_COUNTERS; i++) {
+ sprintf(p, "number of buckets with %d entries: %d\n",
+ i, count[i]);
+ p += strlen(p);
+ }
+ sprintf(p, "number of buckets with %d or more entries: %d\n",
+ NUM_COUNTERS, overflow);
+ p += strlen(p);
+ sprintf(p, "average search distance for entry: %.1f", average);
+ return result;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * HashString --
+ *
+ * Compute a one-word summary of a text string, which can be
+ * used to generate a hash index.
+ *
+ * Results:
+ * The return value is a one-word summary of the information in
+ * string.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static unsigned int
+HashString(string)
+ register char *string; /* String from which to compute hash value. */
+{
+ register unsigned int result;
+ register int c;
+
+ /*
+ * I tried a zillion different hash functions and asked many other
+ * people for advice. Many people had their own favorite functions,
+ * all different, but no-one had much idea why they were good ones.
+ * I chose the one below (multiply by 9 and add new character)
+ * because of the following reasons:
+ *
+ * 1. Multiplying by 10 is perfect for keys that are decimal strings,
+ * and multiplying by 9 is just about as good.
+ * 2. Times-9 is (shift-left-3) plus (old). This means that each
+ * character's bits hang around in the low-order bits of the
+ * hash value for ever, plus they spread fairly rapidly up to
+ * the high-order bits to fill out the hash value. This seems
+ * works well both for decimal and non-decimal strings.
+ */
+
+ result = 0;
+ while (1) {
+ c = *string;
+ string++;
+ if (c == 0) {
+ break;
+ }
+ result += (result<<3) + c;
+ }
+ return result;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringFind --
+ *
+ * Given a hash table with string keys, and a string key, find
+ * the entry with a matching key.
+ *
+ * Results:
+ * The return value is a token for the matching entry in the
+ * hash table, or NULL if there was no matching entry.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static ecs_HashEntry *
+StringFind(tablePtr, key)
+ ecs_HashTable *tablePtr; /* Table in which to lookup entry. */
+ char *key; /* Key to use to find matching entry. */
+{
+ register ecs_HashEntry *hPtr;
+ register char *p1, *p2;
+ int index;
+
+ index = HashString(key) & tablePtr->mask;
+
+ /*
+ * Search all of the entries in the appropriate bucket.
+ */
+
+ for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
+ hPtr = hPtr->nextPtr) {
+ for (p1 = key, p2 = hPtr->key.string; ; p1++, p2++) {
+ if (*p1 != *p2) {
+ break;
+ }
+ if (*p1 == '\0') {
+ return hPtr;
+ }
+ }
+ }
+ return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringCreate --
+ *
+ * Given a hash table with string keys, and a string key, find
+ * the entry with a matching key. If there is no matching entry,
+ * then create a new entry that does match.
+ *
+ * Results:
+ * The return value is a pointer to the matching entry. If this
+ * is a newly-created entry, then *newPtr will be set to a non-zero
+ * value; otherwise *newPtr will be set to 0. If this is a new
+ * entry the value stored in the entry will initially be 0.
+ *
+ * Side effects:
+ * A new entry may be added to the hash table.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static ecs_HashEntry *
+StringCreate(tablePtr, key, newPtr)
+ ecs_HashTable *tablePtr; /* Table in which to lookup entry. */
+ char *key; /* Key to use to find or create matching
+ * entry. */
+ int *newPtr; /* Store info here telling whether a new
+ * entry was created. */
+{
+ register ecs_HashEntry *hPtr;
+ register char *p1, *p2;
+ int index;
+
+ index = HashString(key) & tablePtr->mask;
+
+ /*
+ * Search all of the entries in this bucket.
+ */
+
+ for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
+ hPtr = hPtr->nextPtr) {
+ for (p1 = key, p2 = hPtr->key.string; ; p1++, p2++) {
+ if (*p1 != *p2) {
+ break;
+ }
+ if (*p1 == '\0') {
+ *newPtr = 0;
+ return hPtr;
+ }
+ }
+ }
+
+ /*
+ * Entry not found. Add a new one to the bucket.
+ */
+
+ *newPtr = 1;
+ hPtr = (ecs_HashEntry *) malloc((unsigned)
+ (sizeof(ecs_HashEntry) + strlen(key) - (sizeof(hPtr->key) -1)));
+ hPtr->tablePtr = tablePtr;
+ hPtr->bucketPtr = &(tablePtr->buckets[index]);
+ hPtr->nextPtr = *hPtr->bucketPtr;
+ hPtr->clientData = 0;
+ strcpy(hPtr->key.string, key);
+ *hPtr->bucketPtr = hPtr;
+ tablePtr->numEntries++;
+
+ /*
+ * If the table has exceeded a decent size, rebuild it with many
+ * more buckets.
+ */
+
+ if (tablePtr->numEntries >= tablePtr->rebuildSize) {
+ RebuildTable(tablePtr);
+ }
+ return hPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * OneWordFind --
+ *
+ * Given a hash table with one-word keys, and a one-word key, find
+ * the entry with a matching key.
+ *
+ * Results:
+ * The return value is a token for the matching entry in the
+ * hash table, or NULL if there was no matching entry.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static ecs_HashEntry *
+OneWordFind(tablePtr, key)
+ ecs_HashTable *tablePtr; /* Table in which to lookup entry. */
+ register char *key; /* Key to use to find matching entry. */
+{
+ register ecs_HashEntry *hPtr;
+ int index;
+
+ index = RANDOM_INDEX(tablePtr, key);
+
+ /*
+ * Search all of the entries in the appropriate bucket.
+ */
+
+ for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
+ hPtr = hPtr->nextPtr) {
+ if (hPtr->key.oneWordValue == key) {
+ return hPtr;
+ }
+ }
+ return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * OneWordCreate --
+ *
+ * Given a hash table with one-word keys, and a one-word key, find
+ * the entry with a matching key. If there is no matching entry,
+ * then create a new entry that does match.
+ *
+ * Results:
+ * The return value is a pointer to the matching entry. If this
+ * is a newly-created entry, then *newPtr will be set to a non-zero
+ * value; otherwise *newPtr will be set to 0. If this is a new
+ * entry the value stored in the entry will initially be 0.
+ *
+ * Side effects:
+ * A new entry may be added to the hash table.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static ecs_HashEntry *
+OneWordCreate(tablePtr, key, newPtr)
+ ecs_HashTable *tablePtr; /* Table in which to lookup entry. */
+ register char *key; /* Key to use to find or create matching
+ * entry. */
+ int *newPtr; /* Store info here telling whether a new
+ * entry was created. */
+{
+ register ecs_HashEntry *hPtr;
+ int index;
+
+ index = RANDOM_INDEX(tablePtr, key);
+
+ /*
+ * Search all of the entries in this bucket.
+ */
+
+ for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
+ hPtr = hPtr->nextPtr) {
+ if (hPtr->key.oneWordValue == key) {
+ *newPtr = 0;
+ return hPtr;
+ }
+ }
+
+ /*
+ * Entry not found. Add a new one to the bucket.
+ */
+
+ *newPtr = 1;
+ hPtr = (ecs_HashEntry *) malloc(sizeof(ecs_HashEntry));
+ hPtr->tablePtr = tablePtr;
+ hPtr->bucketPtr = &(tablePtr->buckets[index]);
+ hPtr->nextPtr = *hPtr->bucketPtr;
+ hPtr->clientData = 0;
+ hPtr->key.oneWordValue = key;
+ *hPtr->bucketPtr = hPtr;
+ tablePtr->numEntries++;
+
+ /*
+ * If the table has exceeded a decent size, rebuild it with many
+ * more buckets.
+ */
+
+ if (tablePtr->numEntries >= tablePtr->rebuildSize) {
+ RebuildTable(tablePtr);
+ }
+ return hPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ArrayFind --
+ *
+ * Given a hash table with array-of-int keys, and a key, find
+ * the entry with a matching key.
+ *
+ * Results:
+ * The return value is a token for the matching entry in the
+ * hash table, or NULL if there was no matching entry.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static ecs_HashEntry *
+ArrayFind(tablePtr, key)
+ ecs_HashTable *tablePtr; /* Table in which to lookup entry. */
+ char *key; /* Key to use to find matching entry. */
+{
+ register ecs_HashEntry *hPtr;
+ int *arrayPtr = (int *) key;
+ register int *iPtr1, *iPtr2;
+ int index, count;
+
+ for (index = 0, count = tablePtr->keyType, iPtr1 = arrayPtr;
+ count > 0; count--, iPtr1++) {
+ index += *iPtr1;
+ }
+ index = RANDOM_INDEX(tablePtr, index);
+
+ /*
+ * Search all of the entries in the appropriate bucket.
+ */
+
+ for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
+ hPtr = hPtr->nextPtr) {
+ for (iPtr1 = arrayPtr, iPtr2 = hPtr->key.words,
+ count = tablePtr->keyType; ; count--, iPtr1++, iPtr2++) {
+ if (count == 0) {
+ return hPtr;
+ }
+ if (*iPtr1 != *iPtr2) {
+ break;
+ }
+ }
+ }
+ return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ArrayCreate --
+ *
+ * Given a hash table with one-word keys, and a one-word key, find
+ * the entry with a matching key. If there is no matching entry,
+ * then create a new entry that does match.
+ *
+ * Results:
+ * The return value is a pointer to the matching entry. If this
+ * is a newly-created entry, then *newPtr will be set to a non-zero
+ * value; otherwise *newPtr will be set to 0. If this is a new
+ * entry the value stored in the entry will initially be 0.
+ *
+ * Side effects:
+ * A new entry may be added to the hash table.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static ecs_HashEntry *
+ArrayCreate(tablePtr, key, newPtr)
+ ecs_HashTable *tablePtr; /* Table in which to lookup entry. */
+ register char *key; /* Key to use to find or create matching
+ * entry. */
+ int *newPtr; /* Store info here telling whether a new
+ * entry was created. */
+{
+ register ecs_HashEntry *hPtr;
+ int *arrayPtr = (int *) key;
+ register int *iPtr1, *iPtr2;
+ int index, count;
+
+ for (index = 0, count = tablePtr->keyType, iPtr1 = arrayPtr;
+ count > 0; count--, iPtr1++) {
+ index += *iPtr1;
+ }
+ index = RANDOM_INDEX(tablePtr, index);
+
+ /*
+ * Search all of the entries in the appropriate bucket.
+ */
+
+ for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
+ hPtr = hPtr->nextPtr) {
+ for (iPtr1 = arrayPtr, iPtr2 = hPtr->key.words,
+ count = tablePtr->keyType; ; count--, iPtr1++, iPtr2++) {
+ if (count == 0) {
+ *newPtr = 0;
+ return hPtr;
+ }
+ if (*iPtr1 != *iPtr2) {
+ break;
+ }
+ }
+ }
+
+ /*
+ * Entry not found. Add a new one to the bucket.
+ */
+
+ *newPtr = 1;
+ hPtr = (ecs_HashEntry *) malloc((unsigned) (sizeof(ecs_HashEntry)
+ + (tablePtr->keyType*sizeof(int)) - 4));
+ hPtr->tablePtr = tablePtr;
+ hPtr->bucketPtr = &(tablePtr->buckets[index]);
+ hPtr->nextPtr = *hPtr->bucketPtr;
+ hPtr->clientData = 0;
+ for (iPtr1 = arrayPtr, iPtr2 = hPtr->key.words, count = tablePtr->keyType;
+ count > 0; count--, iPtr1++, iPtr2++) {
+ *iPtr2 = *iPtr1;
+ }
+ *hPtr->bucketPtr = hPtr;
+ tablePtr->numEntries++;
+
+ /*
+ * If the table has exceeded a decent size, rebuild it with many
+ * more buckets.
+ */
+
+ if (tablePtr->numEntries >= tablePtr->rebuildSize) {
+ RebuildTable(tablePtr);
+ }
+ return hPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * BogusFind --
+ *
+ * This procedure is invoked when an ecs_FindHashEntry is called
+ * on a table that has been deleted.
+ *
+ * Results:
+ * If panic returns (which it shouldn't) this procedure returns
+ * NULL.
+ *
+ * Side effects:
+ * Generates a panic.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ /* ARGSUSED */
+static ecs_HashEntry *
+BogusFind(tablePtr, key)
+ ecs_HashTable *tablePtr; /* Table in which to lookup entry. */
+ char *key; /* Key to use to find matching entry. */
+{
+ (void) tablePtr;
+ (void) key;
+
+ return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * BogusCreate --
+ *
+ * This procedure is invoked when an ecs_CreateHashEntry is called
+ * on a table that has been deleted.
+ *
+ * Results:
+ * If panic returns (which it shouldn't) this procedure returns
+ * NULL.
+ *
+ * Side effects:
+ * Generates a panic.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ /* ARGSUSED */
+static ecs_HashEntry *
+BogusCreate(tablePtr, key, newPtr)
+ ecs_HashTable *tablePtr; /* Table in which to lookup entry. */
+ char *key; /* Key to use to find or create matching
+ * entry. */
+ int *newPtr; /* Store info here telling whether a new
+ * entry was created. */
+{
+ (void) tablePtr;
+ (void) key;
+ (void) newPtr;
+
+ return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * RebuildTable --
+ *
+ * This procedure is invoked when the ratio of entries to hash
+ * buckets becomes too large. It creates a new table with a
+ * larger bucket array and moves all of the entries into the
+ * new table.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Memory gets reallocated and entries get re-hashed to new
+ * buckets.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+RebuildTable(tablePtr)
+ register ecs_HashTable *tablePtr; /* Table to enlarge. */
+{
+ int oldSize, count, index;
+ ecs_HashEntry **oldBuckets;
+ register ecs_HashEntry **oldChainPtr, **newChainPtr;
+ register ecs_HashEntry *hPtr;
+
+ oldSize = tablePtr->numBuckets;
+ oldBuckets = tablePtr->buckets;
+
+ /*
+ * Allocate and initialize the new bucket array, and set up
+ * hashing constants for new array size.
+ */
+
+ tablePtr->numBuckets *= 4;
+ tablePtr->buckets = (ecs_HashEntry **) malloc((unsigned)
+ (tablePtr->numBuckets * sizeof(ecs_HashEntry *)));
+ for (count = tablePtr->numBuckets, newChainPtr = tablePtr->buckets;
+ count > 0; count--, newChainPtr++) {
+ *newChainPtr = NULL;
+ }
+ tablePtr->rebuildSize *= 4;
+ tablePtr->downShift -= 2;
+ tablePtr->mask = (tablePtr->mask << 2) + 3;
+
+ /*
+ * Rehash all of the existing entries into the new bucket array.
+ */
+
+ for (oldChainPtr = oldBuckets; oldSize > 0; oldSize--, oldChainPtr++) {
+ for (hPtr = *oldChainPtr; hPtr != NULL; hPtr = *oldChainPtr) {
+ *oldChainPtr = hPtr->nextPtr;
+ if (tablePtr->keyType == ECS_STRING_KEYS) {
+ index = HashString(hPtr->key.string) & tablePtr->mask;
+ } else if (tablePtr->keyType == ECS_ONE_WORD_KEYS) {
+ index = RANDOM_INDEX(tablePtr, hPtr->key.oneWordValue);
+ } else {
+ register int *iPtr;
+ int count;
+
+ for (index = 0, count = tablePtr->keyType,
+ iPtr = hPtr->key.words; count > 0; count--, iPtr++) {
+ index += *iPtr;
+ }
+ index = RANDOM_INDEX(tablePtr, index);
+ }
+ hPtr->bucketPtr = &(tablePtr->buckets[index]);
+ hPtr->nextPtr = *hPtr->bucketPtr;
+ *hPtr->bucketPtr = hPtr;
+ }
+ }
+
+ /*
+ * Free up the old bucket array, if it was dynamically allocated.
+ */
+
+ if (oldBuckets != tablePtr->staticBuckets) {
+ free((char *) oldBuckets);
+ }
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsinfo.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsinfo.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsinfo.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,651 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Implements reading and use of "default info" files.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecsinfo.c,v $
+ * Revision 1.4 2007/02/12 21:01:48 cbalint
+ * Fix win32 target. It build and works now. (tested with VC6)
+ *
+ * Revision 1.3 2007/02/12 16:09:06 cbalint
+ * * Add hook macros for all GNU systems, hook fread,fwrite,read,fgets.
+ * * Handle errors in those macro, if there are any.
+ * * Fix some includes for GNU systems.
+ * * Reduce remaining warnings, now we got zero warnings with GCC.
+ *
+ * Modified Files:
+ * config/unix.mak contrib/ogdi_import/dbfopen.c
+ * contrib/ogdi_import/shapefil.h contrib/ogdi_import/shpopen.c
+ * ogdi/c-api/ecs_xdr.c ogdi/c-api/ecsinfo.c ogdi/c-api/server.c
+ * ogdi/datum_driver/canada/nadconv.c ogdi/driver/adrg/adrg.c
+ * ogdi/driver/adrg/adrg.h ogdi/driver/adrg/object.c
+ * ogdi/driver/adrg/utils.c ogdi/driver/rpf/rpf.h
+ * ogdi/driver/rpf/utils.c ogdi/gltpd/asyncsvr.c
+ * ogdi/glutil/iofile.c vpflib/vpfprim.c vpflib/vpfspx.c
+ * vpflib/vpftable.c vpflib/vpftidx.c vpflib/xvt.h
+ *
+ * Revision 1.2 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+#include <ogdi_macro.h>
+
+ECS_CVSID("$Id: ecsinfo.c,v 1.4 2007/02/12 21:01:48 cbalint Exp $");
+
+#ifdef _WINDOWS
+#define strcasecmp(a,b) stricmp(a,b)
+#define strncasecmp(a,b,c) strnicmp(a,b,c)
+#endif
+int ecs_DefReadIndex(char *directory, char *url, char* urlfile, char *key, char** result);
+int ecs_DefReadFile(char* directory, char *filename, char *key, char **result);
+int ecs_DefGetDirectoryFromURL(char *directory, char *url, char *file);
+int ecs_DefReadALine(char *buf, char **key, char **value);
+char * ecs_strtrim(char * string, const char * set, size_t *index);
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_GetDefaultInfo
+
+ DESCRIPTION
+ access the default information database based on
+ a url and a key value.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ char* url string containing url
+ char* key string containing key value (e.g. NORTH)
+ OUTPUT
+ char** result string containing result. Mallocked
+ by the function; freed by calling routine.
+ Left as NULL if no key is found.
+
+ END_PARAMETERS
+
+ PRE_CONDITIONS
+ -none
+ END_PRE_CONDITIONS
+
+ POST_CONDITIONS
+ -none
+ END_POST_CONDITIONS
+
+ RETURN_VALUE
+ int: 0 if unsuccessful, 1 otherwise.
+ result: a mallocked char * if successful, NULL otherwise.
+ calling routine must free the memory.
+ END_RETURN_VALUE
+
+ PSEUDO_CODE
+ 2) verify if there is a DEFAULT_INFO user variable set
+ a) if yes, read the index file and search for key value
+ b) if value found, stop and return it.
+ 3) verify if there is a index file in the USRHOME
+ a) if yes, read the index file and search for key value
+ b) if value found, stop and return it.
+ 4) verify if there is a index file in the last directory of the URL.
+ a) if yes, read the index file and search for key value
+ b) if value found, stop and return it.
+ END_PSEUDO_CODE
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+
+int ecs_GetDefaultInfo(char* url, char* key, char** result) {
+
+ char *env;
+ char directory[512];
+ char *value;
+ char urlfile[256];
+
+ /* process the index if any from DEFAULT_INFO and set it up */
+
+ /* if this is remote, don't ignore the first two methods */
+ /*
+ if (strncasecmp("gltp://",url, 7) != 0) {
+ */
+ env=getenv("DEFAULT_INFO");
+ if (env) {
+ if (ecs_DefReadIndex(env, url, NULL, key, &value)) {
+ *result=value;
+ return TRUE;
+ }
+ }
+
+ /* process the index if any from USRHOME */
+
+ env=getenv("USRHOME");
+#ifdef INFO_DEBUG
+ fprintf(stderr,"looking at usrhome\n");
+#endif
+ if (env) {
+ if (ecs_DefReadIndex(env, url, NULL, key, &value)) {
+ *result=value;
+ return TRUE;
+ }
+ }
+ /*
+ }
+ */
+ /* get the directory from the url */
+#ifdef INFO_DEBUG
+ fprintf(stderr,"looking for directory in url\n");
+#endif
+ if (!ecs_DefGetDirectoryFromURL(directory, url, urlfile)) {
+ return FALSE;
+ }
+
+#ifdef INFO_DEBUG
+ fprintf(stderr,"looking in %s\n", directory);
+#endif
+ if (ecs_DefReadIndex(directory, url, urlfile, key, &value)) {
+
+ *result=value;
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_DefGetDirectoryFromURL
+
+ DESCRIPTION
+ private function: return the directory name based on the
+ url
+ END_DESCRIPTION
+
+ PARAMETERS
+ OUTPUT
+ char* directory directory of where to look for index
+ INPUT
+ char* url string containing url
+ END_PARAMETERS
+
+ PRE_CONDITIONS
+ -directory is pre-allocated, and is long enough to store the
+ name of the directory.
+ END_PRE_CONDITIONS
+
+ POST_CONDITIONS
+ -none
+ END_POST_CONDITIONS
+
+ RETURN_VALUE
+ int: 0 if unsuccessful, 1 otherwise.
+ result: directory name is placed in pre-allocated string "directory".
+ filename if url points to a file (or NULL if none) is
+ placed in file
+ END_RETURN_VALUE
+
+ PSEUDO_CODE
+ END_PSEUDO_CODE
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+
+int ecs_DefGetDirectoryFromURL(char *directory, char *url, char *file) {
+ char* dir;
+ char* tmp;
+ struct stat buf;
+
+ tmp=(char*) malloc (strlen(url)+1);
+ if (!tmp)
+ return FALSE;
+
+ strcpy(tmp,url);
+
+ if (strncasecmp("gltp://",tmp, 7) == 0) {
+ dir=&tmp[7];
+ dir=strchr(dir,'/')+1;
+ /* check for double slash */
+ if (dir[0]=='/') {
+ dir++;
+ }
+
+ dir=strchr(dir,'/');
+ } else {
+ dir=&tmp[6];
+ dir=strchr(dir,'/');
+ }
+
+ /* check for extra slash */
+ if (dir[1]=='/' || dir[2]==':')
+ dir++;
+
+ /* check if this is a file */
+ if (stat(dir, &buf)!= 0) {
+ free(tmp);
+ return FALSE;
+ }
+
+#ifdef _WINDOWS
+ if (_S_IFREG & (buf.st_mode))
+#else
+ if (S_ISREG(buf.st_mode))
+#endif
+ {
+ /* strip off the filename */
+ int i= strlen(dir)-1;
+
+ while (dir[i]!='/' && i>0)
+ i--;
+
+ /* return the filename in file */
+ strcpy(file, &dir[i+1]);
+ dir[i]='\0';
+ } else {
+ file[0]='\0';
+ }
+
+ strcpy(directory,dir);
+#ifdef INFO_DEBUG
+printf("Directory calculated from the URL : %s\n", directory);
+#endif
+ free(tmp);
+
+ return TRUE;
+}
+
+
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_DefReadIndex
+
+ DESCRIPTION
+ private function: read the index file, look for a match
+ to the url, then call the
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ char* directory directory of where to look for index
+ char* url string containing url
+ char* key string containing key value (e.g. NORTH)
+ OUTPUT
+ char** result string containing result. Mallocked
+ by the function; freed by calling routine.
+ Left as NULL if no key is found.
+
+ END_PARAMETERS
+
+ PRE_CONDITIONS
+ -none
+ END_PRE_CONDITIONS
+
+ POST_CONDITIONS
+ -result mallocked if successful, else NULL.
+ END_POST_CONDITIONS
+
+ RETURN_VALUE
+ int: 0 if unsuccessful, 1 otherwise.
+ result: a mallocked char * if successful, NULL otherwise.
+ calling routine must free the memory.
+ END_RETURN_VALUE
+
+ PSEUDO_CODE
+ END_PSEUDO_CODE
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+int ecs_DefReadIndex(char *directory, char *url, char *urlfile, char *key, char** result) {
+ FILE *fptr;
+ char *indexfile; /* the index file */
+ char *filename; /* name of database file to search */
+ char *tmpkey;
+ char buf[1024];
+ int found;
+
+ /* open the index file in the directory */
+
+ indexfile=(char *) malloc (strlen(directory) + 14);
+ if (!indexfile) {
+ return FALSE;
+ }
+
+ strcpy(indexfile, directory);
+ if (indexfile[strlen(indexfile)-1]!='/')
+ strcat(indexfile,"/");
+ strcat(indexfile, DEFAULTS_INDEX_FILE);
+
+#ifdef INFO_DEBUG
+printf ("The index file is %s \n", indexfile);
+#endif
+
+ fptr=fopen(indexfile, "r");
+ free(indexfile);
+
+ if (!fptr) {
+#ifdef INFO_DEBUG
+printf ("Could not open the index file \n");
+#endif
+ return FALSE;
+ }
+
+ /* read until we find a match for this url */
+
+ filename=NULL;
+ found=FALSE;
+ while (!feof(fptr)) {
+ ogdi_fgets(buf, MAX_DEF_LINE_LENGTH, fptr);
+ if (ecs_DefReadALine(buf,&tmpkey,&filename)) {
+#ifdef INFO_DEBUG
+ printf("read KEY=>%s< FILENAME=>%s<\n", tmpkey, filename);
+#endif
+ if (urlfile==NULL) {
+ /* this is a full url */
+ if (strcasecmp(url,tmpkey)== 0) {
+ found=TRUE;
+#ifdef INFO_DEBUG
+ printf("FOUND URL MATCH %s\n",tmpkey);
+ printf("value=%s\n", filename);
+#endif
+ break;
+ }
+ } else {
+#ifdef INFO_DEBUG
+ printf("comparing urlfile=%s to filename=%s\n",urlfile, tmpkey);
+#endif
+ if (strcasecmp(urlfile,tmpkey)== 0 || (strcmp(urlfile,"") == 0 && strcmp(tmpkey,"*")== 0)) {
+ found=TRUE;
+#ifdef INFO_DEBUG
+ printf("FOUND KEY %s\n",tmpkey);
+ printf("value=%s\n", filename);
+#endif
+ /* check the file */
+
+ break;
+ }
+ }
+ }
+ }
+ fclose(fptr);
+
+ if (!found) {
+ return FALSE;
+ }
+ /* if match found, read the file */
+
+ if (ecs_DefReadFile(directory, filename, key, result)) {
+ return TRUE;
+ } else {
+ *result=NULL;
+ return FALSE;
+ }
+
+ /* if no match found, return false */
+ return FALSE;
+
+}
+
+/*
+
+take the line in "buf", return a pointer to "key" and
+a pointer to the value". place a NULL after each string, so
+they can be copied out.
+
+PRECONDITION:
+destination must be writeable
+
+*/
+
+int ecs_DefReadALine(char *buf, char **key, char **value) {
+
+ int i=0;
+
+ /* ignore comments */
+ if (buf[0]=='#')
+ return FALSE;
+
+ if (buf[strlen(buf)-1]=='\n')
+ buf[strlen(buf)-1]='\0'; /* remove \n */
+
+
+ /* find key */
+ while(buf[i]==' ' || buf[i]=='\t') {
+ i++;
+ }
+
+ if (buf[i] == '\0')
+ return FALSE;
+
+ *key=&buf[i];
+
+ /* find end of key */
+ while(buf[i]!=' ' && buf[i] != '\t' && buf[i] !='\0')
+ i++;
+
+ if (buf[i] == '\0') {
+ *value=&buf[i];
+ return TRUE;
+ }
+
+ buf[i++]='\0';
+
+ /* find end of whitespace */
+ while(buf[i]==' ' || buf[i]=='\t')
+ i++;
+ *value=&buf[i];
+
+ return TRUE;
+
+}
+
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_DefReadFile
+
+ DESCRIPTION
+ private function: read the data file, look for a match
+ for the key, return the value (if any).
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ char* directory the directory of the file to read
+ char* filename the filename to look in
+ char* key string containing key value (e.g. NORTH)
+ OUTPUT
+ char** result string containing result. Mallocked
+ by the function; freed by calling routine.
+ Left as NULL if no key is found.
+
+ END_PARAMETERS
+
+ PRE_CONDITIONS
+ -none
+ END_PRE_CONDITIONS
+
+ POST_CONDITIONS
+ -result mallocked if successful, else NULL.
+ END_POST_CONDITIONS
+
+ RETURN_VALUE
+ int: 0 if unsuccessful, 1 otherwise.
+ result: a mallocked char * if successful, NULL otherwise.
+ calling routine must free the memory.
+ END_RETURN_VALUE
+
+ PSEUDO_CODE
+ END_PSEUDO_CODE
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+
+int ecs_DefReadFile(char *directory, char *filename, char *key, char **result) {
+ FILE *fptr;
+ char *indexfile;
+ char buf[1024];
+ char *tmpkey, *value, *tmpfile;
+ size_t len;
+
+ indexfile=(char *) malloc (strlen(directory) +strlen(filename)+3);
+ if (!indexfile) {
+ return FALSE;
+ }
+
+ strcpy(indexfile, directory);
+ if (indexfile[strlen(indexfile)-1]!='/')
+ strcat(indexfile,"/");
+ tmpfile=ecs_strtrim(filename," \t",&len);
+
+ strncat(indexfile, tmpfile, len);
+
+ fptr=fopen(indexfile, "r");
+ free(indexfile);
+
+ if (!fptr) {
+ return FALSE;
+ }
+
+ /* read until we find a match for this url */
+
+ filename=NULL;
+ while (!feof(fptr)) {
+ ogdi_fgets(buf, MAX_DEF_LINE_LENGTH, fptr);
+ if (ecs_DefReadALine(buf,&tmpkey,&value)) {
+#ifdef INFO_DEBUG
+ printf("read KEY=>%s< VALUE=>%s<\n", tmpkey, value);
+ printf("comparing tmpkey=%s to key=%s\n",tmpkey, key);
+#endif
+ if (strcmp(tmpkey,key)== 0) {
+#ifdef INFO_DEBUG
+ printf("FOUND KEY %s\n",tmpkey);
+ printf("value=%s\n", value);
+#endif
+
+ *result=(char *) malloc (strlen(value)+1);
+ if (!*result) {
+ fclose(fptr);
+ return FALSE;
+ }
+ strcpy(*result, value);
+ fclose(fptr);
+ return TRUE;
+
+ break;
+
+ }
+ }
+ }
+
+
+ fclose(fptr);
+
+
+ *result=NULL;
+ return FALSE;
+
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ strtrim
+
+ DESCRIPTION
+ trim a list of characters off both ends of a string
+
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ char * string: the string to be trimmed
+ const char * set: a string consisting of characters to be trimmed
+ OUTPUT
+ size_t *index: the length of the trimmed string. this is 0
+ if all the elements were stripped; it is strlen(string) if
+ nothing was stripped.
+
+ END_PARAMETERS
+
+ RETURN_VALUE
+ a pointer to the start of the string.
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+char * ecs_strtrim(char * string, const char * set, size_t *index) {
+
+ int begin, end, length;
+ char ok, *tmp;
+
+ begin=strspn(string,set);
+ if (begin==(int) strlen(string)) {
+ *index=0;
+ return string;
+ }
+
+ length=strlen(set);
+ end=strlen(string)-1;
+
+ while(1) {
+ ok=string[end];
+ if ((int)strcspn(set,&ok)==length) break;
+ end--;
+ if (end == 0) break;
+ }
+
+ *index=end-begin+1;
+ tmp=&string[begin];
+ return tmp;
+}
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecslist.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecslist.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecslist.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,459 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Handling of feature attribute list parsing.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecslist.c,v $
+ * Revision 1.2 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecslist.c,v 1.2 2001/04/09 15:04:34 warmerda Exp $");
+
+#define UCHAR(c) ((unsigned char) (c))
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_Backslash --
+ *
+ * Figure out how to handle a backslash sequence.
+ *
+ * Results:
+ * The return value is the character that should be substituted
+ * in place of the backslash sequence that starts at src. If
+ * readPtr isn't NULL then it is filled in with a count of the
+ * number of characters in the backslash sequence.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+char
+ecs_Backslash(src, readPtr)
+ char *src; /* Points to the backslash character of
+ * a backslash sequence. */
+ int *readPtr; /* Fill in with number of characters read
+ * from src, unless NULL. */
+{
+ register char *p = src+1;
+ char result;
+ int count;
+
+ count = 2;
+
+ switch (*p) {
+ case 'a':
+ result = 0x7; /* Don't say '\a' here, since some compilers */
+ break; /* don't support it. */
+ case 'b':
+ result = '\b';
+ break;
+ case 'f':
+ result = '\f';
+ break;
+ case 'n':
+ result = '\n';
+ break;
+ case 'r':
+ result = '\r';
+ break;
+ case 't':
+ result = '\t';
+ break;
+ case 'v':
+ result = '\v';
+ break;
+ case 'x':
+ if (isxdigit(UCHAR(p[1]))) {
+ char *end;
+
+ result = strtoul(p+1, &end, 16);
+ count = end - src;
+ } else {
+ count = 2;
+ result = 'x';
+ }
+ break;
+ case '\n':
+ do {
+ p++;
+ } while (isspace(UCHAR(*p)));
+ result = ' ';
+ count = p - src;
+ break;
+ case 0:
+ result = '\\';
+ count = 1;
+ break;
+ default:
+ if (isdigit(UCHAR(*p))) {
+ result = *p - '0';
+ p++;
+ if (!isdigit(UCHAR(*p))) {
+ break;
+ }
+ count = 3;
+ result = (result << 3) + (*p - '0');
+ p++;
+ if (!isdigit(UCHAR(*p))) {
+ break;
+ }
+ count = 4;
+ result = (result << 3) + (*p - '0');
+ break;
+ }
+ result = *p;
+ count = 2;
+ break;
+ }
+
+ if (readPtr != NULL) {
+ *readPtr = count;
+ }
+ return result;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_FindElement --
+ *
+ * Given a pointer into a list, locate the first (or next)
+ * element in the list.
+ *
+ * Results:
+ * The return value is normally TRUE, which means that the
+ * element was successfully located. If FALSE is returned
+ * it means that list didn't have proper list structure;
+ *
+ * If TRUE is returned, then *elementPtr will be set to point
+ * to the first element of list, and *nextPtr will be set to point
+ * to the character just after any white space following the last
+ * character that's part of the element. If this is the last argument
+ * in the list, then *nextPtr will point to the NULL character at the
+ * end of list. If sizePtr is non-NULL, *sizePtr is filled in with
+ * the number of characters in the element. If the element is in
+ * braces, then *elementPtr will point to the character after the
+ * opening brace and *sizePtr will not include either of the braces.
+ * If there isn't an element in the list, *sizePtr will be zero, and
+ * both *elementPtr and *termPtr will refer to the null character at
+ * the end of list. Note: this procedure does NOT collapse backslash
+ * sequences.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int ecs_FindElement(list, elementPtr, nextPtr, sizePtr, bracePtr)
+ register char *list; /* String containing Tcl list with zero
+ * or more elements (possibly in braces). */
+ char **elementPtr; /* Fill in with location of first significant
+ * character in first element of list. */
+ char **nextPtr; /* Fill in with location of character just
+ * after all white space following end of
+ * argument (i.e. next argument or end of
+ * list). */
+ int *sizePtr; /* If non-zero, fill in with size of
+ * element. */
+ int *bracePtr; /* If non-zero fill in with non-zero/zero
+ * to indicate that arg was/wasn't
+ * in braces. */
+{
+ register char *p;
+ int openBraces = 0;
+ int inQuotes = 0;
+ int size;
+
+ /*
+ * Skim off leading white space and check for an opening brace or
+ * quote. Note: use of "isascii" below and elsewhere in this
+ * procedure is a temporary hack (7/27/90) because Mx uses characters
+ * with the high-order bit set for some things. This should probably
+ * be changed back eventually, or all of Tcl should call isascii.
+ */
+
+ while (isspace(UCHAR(*list))) {
+ list++;
+ }
+ if (*list == '{') {
+ openBraces = 1;
+ list++;
+ } else if (*list == '"') {
+ inQuotes = 1;
+ list++;
+ }
+ if (bracePtr != 0) {
+ *bracePtr = openBraces;
+ }
+ p = list;
+
+ /*
+ * Find the end of the element (either a space or a close brace or
+ * the end of the string).
+ */
+
+ while (1) {
+ switch (*p) {
+
+ /*
+ * Open brace: don't treat specially unless the element is
+ * in braces. In this case, keep a nesting count.
+ */
+
+ case '{':
+ if (openBraces != 0) {
+ openBraces++;
+ }
+ break;
+
+ /*
+ * Close brace: if element is in braces, keep nesting
+ * count and quit when the last close brace is seen.
+ */
+
+ case '}':
+ if (openBraces == 1) {
+ char *p2;
+
+ size = p - list;
+ p++;
+ if (isspace(UCHAR(*p)) || (*p == 0)) {
+ goto done;
+ }
+ for (p2 = p; (*p2 != 0) && (!isspace(UCHAR(*p2)))
+ && (p2 < p+20); p2++) {
+ /* null body */
+ }
+ return FALSE;
+ } else if (openBraces != 0) {
+ openBraces--;
+ }
+ break;
+
+ /*
+ * Backslash: skip over everything up to the end of the
+ * backslash sequence.
+ */
+
+ case '\\': {
+ int size;
+
+ (void) ecs_Backslash(p, &size);
+ p += size - 1;
+ break;
+ }
+
+ /*
+ * Space: ignore if element is in braces or quotes; otherwise
+ * terminate element.
+ */
+
+ case ' ':
+ case '\f':
+ case '\n':
+ case '\r':
+ case '\t':
+ case '\v':
+ if ((openBraces == 0) && !inQuotes) {
+ size = p - list;
+ goto done;
+ }
+ break;
+
+ /*
+ * Double-quote: if element is in quotes then terminate it.
+ */
+
+ case '"':
+ if (inQuotes) {
+ char *p2;
+
+ size = p-list;
+ p++;
+ if (isspace(UCHAR(*p)) || (*p == 0)) {
+ goto done;
+ }
+ for (p2 = p; (*p2 != 0) && (!isspace(UCHAR(*p2)))
+ && (p2 < p+20); p2++) {
+ /* null body */
+ }
+ return FALSE;
+ }
+ break;
+
+ /*
+ * End of list: terminate element.
+ */
+
+ case 0:
+ /* return FALSE;*/
+ size = p - list;
+ goto done;
+ }
+ p++;
+ }
+
+ done:
+ while (isspace(UCHAR(*p))) {
+ p++;
+ }
+ *elementPtr = list;
+ *nextPtr = p;
+ if (sizePtr != 0) {
+ *sizePtr = size;
+ }
+ return TRUE;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_CopyAndCollapse --
+ *
+ * Copy a string and eliminate any backslashes that aren't in braces.
+ *
+ * Results:
+ * There is no return value. Count chars. get copied from src
+ * to dst. Along the way, if backslash sequences are found outside
+ * braces, the backslashes are eliminated in the copy.
+ * After scanning count chars. from source, a null character is
+ * placed at the end of dst.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+ecs_CopyAndCollapse(count, src, dst)
+ int count; /* Total number of characters to copy
+ * from src. */
+ register char *src; /* Copy from here... */
+ register char *dst; /* ... to here. */
+{
+ register char c;
+ int numRead;
+
+ for (c = *src; count > 0; src++, c = *src, count--) {
+ if (c == '\\') {
+ *dst = ecs_Backslash(src, &numRead);
+ dst++;
+ src += numRead-1;
+ count -= numRead-1;
+ } else {
+ *dst = c;
+ dst++;
+ }
+ }
+ *dst = 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_SplitList --
+ *
+ * Splits a list up into its constituent fields.
+ *
+ * Results
+ * The return value is normally TRUE, which means that
+ * the list was successfully split up. If FALSE is
+ * returned, it means that "list" didn't have proper list
+ * structure; interp->result will contain a more detailed
+ * error message.
+ *
+ * *argvPtr will be filled in with the address of an array
+ * whose elements point to the elements of list, in order.
+ * *argcPtr will get filled in with the number of valid elements
+ * in the array. A single block of memory is dynamically allocated
+ * to hold both the argv array and a copy of the list (with
+ * backslashes and braces removed in the standard way).
+ * The caller must eventually free this memory by calling free()
+ * on *argvPtr. Note: *argvPtr and *argcPtr are only modified
+ * if the procedure returns normally.
+ *
+ * Side effects:
+ * Memory is allocated.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int ecs_SplitList(list, argcPtr, argvPtr)
+ char *list; /* Pointer to string with list structure. */
+ int *argcPtr; /* Pointer to location to fill in with
+ * the number of elements in the list. */
+ char ***argvPtr; /* Pointer to place to store pointer to array
+ * of pointers to list elements. */
+{
+ char **argv;
+ register char *p;
+ int size, i, result, elSize, brace;
+ char *element;
+
+ /*
+ * Figure out how much space to allocate. There must be enough
+ * space for both the array of pointers and also for a copy of
+ * the list. To estimate the number of pointers needed, count
+ * the number of space characters in the list.
+ */
+
+ for (size = 1, p = list; *p != 0; p++) {
+ if (isspace(UCHAR(*p))) {
+ size++;
+ }
+ }
+ size++; /* Leave space for final NULL pointer. */
+ argv = (char **) malloc((unsigned)
+ ((size * sizeof(char *)) + (p - list) + 1));
+ for (i = 0, p = ((char *) argv) + size*sizeof(char *); *list != 0; i++) {
+ result = ecs_FindElement(list, &element, &list, &elSize, &brace);
+ if (result != TRUE) {
+ free((char *) argv);
+ return result;
+ }
+ if (*element == 0) {
+ break;
+ }
+ if (i >= size) {
+ free((char *) argv);
+ return FALSE;
+ }
+ argv[i] = p;
+ if (brace) {
+ strncpy(p, element, (size_t) elSize);
+ p += elSize;
+ *p = 0;
+ p++;
+ } else {
+ ecs_CopyAndCollapse(elSize, element, p);
+ p += elSize+1;
+ }
+ }
+
+ argv[i] = NULL;
+ *argvPtr = argv;
+ *argcPtr = i;
+ return TRUE;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsregex.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsregex.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecsregex.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1329 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Regular expression handling.
+ *
+ ******************************************************************************
+ * Copyright (c) 1986 by University of Toronto.
+ * Written by Henry Spencer. Not derived from licensed software.
+ *
+ * Permission is granted to anyone to use this software for any
+ * purpose on any computer system, and to redistribute it freely,
+ * subject to the following restrictions:
+ *
+ * 1. The author is not responsible for the consequences of use of
+ * this software, no matter how awful, even if they arise
+ * from defects in it.
+ *
+ * 2. The origin of this software must not be misrepresented, either
+ * by explicit claim or by omission.
+ *
+ * 3. Altered versions must be plainly marked as such, and must not
+ * be misrepresented as being the original software.
+ *
+ ******************************************************************************
+ *
+ * $Log: ecsregex.c,v $
+ * Revision 1.2 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+/*
+ * EcsRegComp and EcsRegExec -- EcsRegSub is elsewhere
+ *
+ * Beware that some of this code is subtly aware of the way operator
+ * precedence is structured in regular expressions. Serious changes in
+ * regular-expression syntax might require a total rethink.
+ *
+ * *** NOTE: this code has been altered slightly for use in Ecs: ***
+ * *** 1. Use ckalloc and ckfree instead of malloc and free. ***
+ * *** 2. Add extra argument to regexp to specify the real ***
+ * *** start of the string separately from the start of the ***
+ * *** current search. This is needed to search for multiple ***
+ * *** matches within a string. ***
+ * *** 3. Names have been changed, e.g. from regcomp to ***
+ * *** EcsRegComp, to avoid clashes with other ***
+ * *** regexp implementations used by applications. ***
+ * *** 4. Added errMsg declaration and EcsRegError procedure ***
+ * *** 5. Various lint-like things, such as casting arguments ***
+ * *** in procedure calls. ***
+ *
+ * *** NOTE: This code has been altered for use in MT-Sturdy Ecs ***
+ * *** 1. All use of static variables has been changed to access ***
+ * *** fields of a structure. ***
+ * *** 2. This in addition to changes to EcsRegError makes the ***
+ * *** code multi-thread safe. ***
+ */
+
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecsregex.c,v 1.2 2001/04/09 15:04:34 warmerda Exp $");
+
+/*
+ * The variable below is set to NULL before invoking regexp functions
+ * and checked after those functions. If an error occurred then EcsRegError
+ * will set the variable to point to a (static) error message. This
+ * mechanism unfortunately does not support multi-threading, but the
+ * procedures EcsRegError and EcsGetRegError can be modified to use
+ * thread-specific storage for the variable and thereby make the code
+ * thread-safe.
+ */
+
+static char *errMsg = NULL;
+
+/*
+ * The "internal use only" fields in regexp.h are present to pass info from
+ * compile to execute that permits the execute phase to run lots faster on
+ * simple cases. They are:
+ *
+ * regstart char that must begin a match; '\0' if none obvious
+ * reganch is the match anchored (at beginning-of-line only)?
+ * regmust string (pointer into program) that match must include, or NULL
+ * regmlen length of regmust string
+ *
+ * Regstart and reganch permit very fast decisions on suitable starting points
+ * for a match, cutting down the work a lot. Regmust permits fast rejection
+ * of lines that cannot possibly match. The regmust tests are costly enough
+ * that EcsRegComp() supplies a regmust only if the r.e. contains something
+ * potentially expensive (at present, the only such thing detected is * or +
+ * at the start of the r.e., which can involve a lot of backup). Regmlen is
+ * supplied because the test in EcsRegExec() needs it and EcsRegComp() is
+ * computing it anyway.
+ */
+
+/*
+ * Structure for regexp "program". This is essentially a linear encoding
+ * of a nondeterministic finite-state machine (aka syntax charts or
+ * "railroad normal form" in parsing technology). Each node is an opcode
+ * plus a "next" pointer, possibly plus an operand. "Next" pointers of
+ * all nodes except BRANCH implement concatenation; a "next" pointer with
+ * a BRANCH on both ends of it is connecting two alternatives. (Here we
+ * have one of the subtle syntax dependencies: an individual BRANCH (as
+ * opposed to a collection of them) is never concatenated with anything
+ * because of operator precedence.) The operand of some types of node is
+ * a literal string; for others, it is a node leading into a sub-FSM. In
+ * particular, the operand of a BRANCH node is the first node of the branch.
+ * (NB this is *not* a tree structure: the tail of the branch connects
+ * to the thing following the set of BRANCHes.) The opcodes are:
+ */
+
+/* definition number opnd? meaning */
+#define END 0 /* no End of program. */
+#define BOL 1 /* no Match "" at beginning of line. */
+#define EOL 2 /* no Match "" at end of line. */
+#define ANY 3 /* no Match any one character. */
+#define ANYOF 4 /* str Match any character in this string. */
+#define ANYBUT 5 /* str Match any character not in this string. */
+#define BRANCH 6 /* node Match this alternative, or the next... */
+#define BACK 7 /* no Match "", "next" ptr points backward. */
+#define EXACTLY 8 /* str Match this string. */
+#define NOTHING 9 /* no Match empty string. */
+#define STAR 10 /* node Match this (simple) thing 0 or more times. */
+#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
+#define OPEN 20 /* no Mark this point in input as start of #n. */
+ /* OPEN+1 is number 1, etc. */
+#define CLOSE 30 /* no Analogous to OPEN. */
+
+/*
+ * Opcode notes:
+ *
+ * BRANCH The set of branches constituting a single choice are hooked
+ * together with their "next" pointers, since precedence prevents
+ * anything being concatenated to any individual branch. The
+ * "next" pointer of the last BRANCH in a choice points to the
+ * thing following the whole choice. This is also where the
+ * final "next" pointer of each individual branch points; each
+ * branch starts with the operand node of a BRANCH node.
+ *
+ * BACK Normal "next" pointers all implicitly point forward; BACK
+ * exists to make loop structures possible.
+ *
+ * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
+ * BRANCH structures using BACK. Simple cases (one character
+ * per match) are implemented with STAR and PLUS for speed
+ * and to minimize recursive plunges.
+ *
+ * OPEN,CLOSE ...are numbered at compile time.
+ */
+
+/*
+ * A node is one char of opcode followed by two chars of "next" pointer.
+ * "Next" pointers are stored as two 8-bit pieces, high order first. The
+ * value is a positive offset from the opcode of the node containing it.
+ * An operand, if any, simply follows the node. (Note that much of the
+ * code generation knows about this implicit relationship.)
+ *
+ * Using two bytes for the "next" pointer is vast overkill for most things,
+ * but allows patterns to get big without disasters.
+ */
+#define OP(p) (*(p))
+#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
+#define OPERAND(p) ((p) + 3)
+
+/*
+ * See regmagic.h for one further detail of program structure.
+ */
+
+
+/*
+ * Utility definitions.
+
+#ifndef CHARBITS
+#define UCHARAT(p) ((int)*(unsigned char *)(p))
+#else
+#define UCHARAT(p) ((int)*(p)&CHARBITS)
+#endif
+ */
+
+#define UCHARAT(p) ((int)*(unsigned char *)(p))
+
+#define FAIL(m) { EcsRegError(m); return(NULL); }
+#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
+#define META "^$.[()|?+*\\"
+
+/*
+ * Flags to be passed up and down.
+ */
+#define HASWIDTH 01 /* Known never to match null string. */
+#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
+#define SPSTART 04 /* Starts with * or +. */
+#define WORST 0 /* Worst case. */
+
+/*
+ * Global work variables for EcsRegComp().
+ */
+struct regcomp_state {
+ char *regparse; /* Input-scan pointer. */
+ int regnpar; /* () count. */
+ char *regcode; /* Code-emit pointer; ®dummy = don't. */
+ long regsize; /* Code size. */
+};
+
+static char regdummy;
+
+/*
+ * The first byte of the regexp internal "program" is actually this magic
+ * number; the start node begins in the second byte.
+ */
+#define MAGIC 0234
+
+
+/*
+ * Forward declarations for EcsRegComp()'s friends.
+ */
+#ifndef STATIC
+#define STATIC static
+#endif
+STATIC char *reg();
+STATIC char *regbranch();
+STATIC char *regpiece();
+STATIC char *regatom();
+STATIC char *regnode();
+STATIC char *regnext();
+STATIC void regc();
+STATIC void reginsert();
+STATIC void regtail();
+STATIC void regoptail();
+#ifdef STRCSPN
+STATIC int strcspn();
+#endif
+
+/*
+ - EcsRegComp - compile a regular expression into internal code
+ *
+ * We can't allocate space until we know how big the compiled form will be,
+ * but we can't compile it (and thus know how big it is) until we've got a
+ * place to put the code. So we cheat: we compile it twice, once with code
+ * generation turned off and size counting turned on, and once "for real".
+ * This also means that we don't allocate space until we are sure that the
+ * thing really will compile successfully, and we never have to move the
+ * code and thus invalidate pointers into it. (Note that it has to be in
+ * one piece because free() must be able to free it all.)
+ *
+ * Beware that the optimization-preparation code in here knows about some
+ * of the structure of the compiled regexp.
+ */
+ecs_regexp *
+EcsRegComp(exp)
+char *exp;
+{
+ register ecs_regexp *r;
+ register char *scan;
+ register char *longest;
+ register int len;
+ int flags;
+ struct regcomp_state state;
+ struct regcomp_state *rcstate= &state;
+
+ if (exp == NULL)
+ FAIL("NULL argument");
+
+ /* First pass: determine size, legality. */
+ rcstate->regparse = exp;
+ rcstate->regnpar = 1;
+ rcstate->regsize = 0L;
+ rcstate->regcode = ®dummy;
+ regc(MAGIC, rcstate);
+ if (reg(0, &flags, rcstate) == NULL)
+ return(NULL);
+
+ /* Small enough for pointer-storage convention? */
+ if (rcstate->regsize >= 32767L) /* Probably could be 65535L. */
+ FAIL("ecs_regexp too big");
+
+ /* Allocate space. */
+ r = (ecs_regexp *)malloc(sizeof(ecs_regexp) + (unsigned)rcstate->regsize);
+ if (r == NULL)
+ FAIL("out of space");
+
+ /* Second pass: emit code. */
+ rcstate->regparse = exp;
+ rcstate->regnpar = 1;
+ rcstate->regcode = r->program;
+ regc(MAGIC, rcstate);
+ if (reg(0, &flags, rcstate) == NULL)
+ return(NULL);
+
+ /* Dig out information for optimizations. */
+ r->regstart = '\0'; /* Worst-case defaults. */
+ r->reganch = 0;
+ r->regmust = NULL;
+ r->regmlen = 0;
+ scan = r->program+1; /* First BRANCH. */
+ if (OP(regnext(scan)) == END) { /* Only one top-level choice. */
+ scan = OPERAND(scan);
+
+ /* Starting-point info. */
+ if (OP(scan) == EXACTLY)
+ r->regstart = *OPERAND(scan);
+ else if (OP(scan) == BOL)
+ r->reganch++;
+
+ /*
+ * If there's something expensive in the r.e., find the
+ * longest literal string that must appear and make it the
+ * regmust. Resolve ties in favor of later strings, since
+ * the regstart check works with the beginning of the r.e.
+ * and avoiding duplication strengthens checking. Not a
+ * strong reason, but sufficient in the absence of others.
+ */
+ if (flags&SPSTART) {
+ longest = NULL;
+ len = 0;
+ for (; scan != NULL; scan = regnext(scan))
+ if (OP(scan) == EXACTLY && ((int) strlen(OPERAND(scan))) >= len) {
+ longest = OPERAND(scan);
+ len = strlen(OPERAND(scan));
+ }
+ r->regmust = longest;
+ r->regmlen = len;
+ }
+ }
+
+ return(r);
+}
+
+/*
+ - reg - regular expression, i.e. main body or parenthesized thing
+ *
+ * Caller must absorb opening parenthesis.
+ *
+ * Combining parenthesis handling with the base level of regular expression
+ * is a trifle forced, but the need to tie the tails of the branches to what
+ * follows makes it hard to avoid.
+ */
+static char *
+reg(paren, flagp, rcstate)
+int paren; /* Parenthesized? */
+int *flagp;
+struct regcomp_state *rcstate;
+{
+ register char *ret;
+ register char *br;
+ register char *ender;
+ register int parno = 0;
+ int flags;
+
+ *flagp = HASWIDTH; /* Tentatively. */
+
+ /* Make an OPEN node, if parenthesized. */
+ if (paren) {
+ if (rcstate->regnpar >= NSUBEXP)
+ FAIL("too many ()");
+ parno = rcstate->regnpar;
+ rcstate->regnpar++;
+ ret = regnode(OPEN+parno,rcstate);
+ } else
+ ret = NULL;
+
+ /* Pick up the branches, linking them together. */
+ br = regbranch(&flags,rcstate);
+ if (br == NULL)
+ return(NULL);
+ if (ret != NULL)
+ regtail(ret, br); /* OPEN -> first. */
+ else
+ ret = br;
+ if (!(flags&HASWIDTH))
+ *flagp &= ~HASWIDTH;
+ *flagp |= flags&SPSTART;
+ while (*rcstate->regparse == '|') {
+ rcstate->regparse++;
+ br = regbranch(&flags,rcstate);
+ if (br == NULL)
+ return(NULL);
+ regtail(ret, br); /* BRANCH -> BRANCH. */
+ if (!(flags&HASWIDTH))
+ *flagp &= ~HASWIDTH;
+ *flagp |= flags&SPSTART;
+ }
+
+ /* Make a closing node, and hook it on the end. */
+ ender = regnode((paren) ? CLOSE+parno : END,rcstate);
+ regtail(ret, ender);
+
+ /* Hook the tails of the branches to the closing node. */
+ for (br = ret; br != NULL; br = regnext(br))
+ regoptail(br, ender);
+
+ /* Check for proper termination. */
+ if (paren && *rcstate->regparse++ != ')') {
+ FAIL("unmatched ()");
+ } else if (!paren && *rcstate->regparse != '\0') {
+ if (*rcstate->regparse == ')') {
+ FAIL("unmatched ()");
+ } else
+ FAIL("junk on end"); /* "Can't happen". */
+ /* NOTREACHED */
+ }
+
+ return(ret);
+}
+
+/*
+ - regbranch - one alternative of an | operator
+ *
+ * Implements the concatenation operator.
+ */
+static char *
+regbranch(flagp, rcstate)
+int *flagp;
+struct regcomp_state *rcstate;
+{
+ register char *ret;
+ register char *chain;
+ register char *latest;
+ int flags;
+
+ *flagp = WORST; /* Tentatively. */
+
+ ret = regnode(BRANCH,rcstate);
+ chain = NULL;
+ while (*rcstate->regparse != '\0' && *rcstate->regparse != '|' &&
+ *rcstate->regparse != ')') {
+ latest = regpiece(&flags, rcstate);
+ if (latest == NULL)
+ return(NULL);
+ *flagp |= flags&HASWIDTH;
+ if (chain == NULL) /* First piece. */
+ *flagp |= flags&SPSTART;
+ else
+ regtail(chain, latest);
+ chain = latest;
+ }
+ if (chain == NULL) /* Loop ran zero times. */
+ (void) regnode(NOTHING,rcstate);
+
+ return(ret);
+}
+
+/*
+ - regpiece - something followed by possible [*+?]
+ *
+ * Note that the branching code sequences used for ? and the general cases
+ * of * and + are somewhat optimized: they use the same NOTHING node as
+ * both the endmarker for their branch list and the body of the last branch.
+ * It might seem that this node could be dispensed with entirely, but the
+ * endmarker role is not redundant.
+ */
+static char *
+regpiece(flagp, rcstate)
+int *flagp;
+struct regcomp_state *rcstate;
+{
+ register char *ret;
+ register char op;
+ register char *next;
+ int flags;
+
+ ret = regatom(&flags,rcstate);
+ if (ret == NULL)
+ return(NULL);
+
+ op = *rcstate->regparse;
+ if (!ISMULT(op)) {
+ *flagp = flags;
+ return(ret);
+ }
+
+ if (!(flags&HASWIDTH) && op != '?')
+ FAIL("*+ operand could be empty");
+ *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
+
+ if (op == '*' && (flags&SIMPLE))
+ reginsert(STAR, ret, rcstate);
+ else if (op == '*') {
+ /* Emit x* as (x&|), where & means "self". */
+ reginsert(BRANCH, ret, rcstate); /* Either x */
+ regoptail(ret, regnode(BACK,rcstate)); /* and loop */
+ regoptail(ret, ret); /* back */
+ regtail(ret, regnode(BRANCH,rcstate)); /* or */
+ regtail(ret, regnode(NOTHING,rcstate)); /* null. */
+ } else if (op == '+' && (flags&SIMPLE))
+ reginsert(PLUS, ret, rcstate);
+ else if (op == '+') {
+ /* Emit x+ as x(&|), where & means "self". */
+ next = regnode(BRANCH,rcstate); /* Either */
+ regtail(ret, next);
+ regtail(regnode(BACK,rcstate), ret); /* loop back */
+ regtail(next, regnode(BRANCH,rcstate)); /* or */
+ regtail(ret, regnode(NOTHING,rcstate)); /* null. */
+ } else if (op == '?') {
+ /* Emit x? as (x|) */
+ reginsert(BRANCH, ret, rcstate); /* Either x */
+ regtail(ret, regnode(BRANCH,rcstate)); /* or */
+ next = regnode(NOTHING,rcstate); /* null. */
+ regtail(ret, next);
+ regoptail(ret, next);
+ }
+ rcstate->regparse++;
+ if (ISMULT(*rcstate->regparse))
+ FAIL("nested *?+");
+
+ return(ret);
+}
+
+/*
+ - regatom - the lowest level
+ *
+ * Optimization: gobbles an entire sequence of ordinary characters so that
+ * it can turn them into a single node, which is smaller to store and
+ * faster to run. Backslashed characters are exceptions, each becoming a
+ * separate node; the code is simpler that way and it's not worth fixing.
+ */
+static char *
+regatom(flagp, rcstate)
+int *flagp;
+struct regcomp_state *rcstate;
+{
+ register char *ret;
+ int flags;
+
+ *flagp = WORST; /* Tentatively. */
+
+ switch (*rcstate->regparse++) {
+ case '^':
+ ret = regnode(BOL,rcstate);
+ break;
+ case '$':
+ ret = regnode(EOL,rcstate);
+ break;
+ case '.':
+ ret = regnode(ANY,rcstate);
+ *flagp |= HASWIDTH|SIMPLE;
+ break;
+ case '[': {
+ register int clss;
+ register int classend;
+
+ if (*rcstate->regparse == '^') { /* Complement of range. */
+ ret = regnode(ANYBUT,rcstate);
+ rcstate->regparse++;
+ } else
+ ret = regnode(ANYOF,rcstate);
+ if (*rcstate->regparse == ']' || *rcstate->regparse == '-')
+ regc(*rcstate->regparse++,rcstate);
+ while (*rcstate->regparse != '\0' && *rcstate->regparse != ']') {
+ if (*rcstate->regparse == '-') {
+ rcstate->regparse++;
+ if (*rcstate->regparse == ']' || *rcstate->regparse == '\0')
+ regc('-',rcstate);
+ else {
+ clss = UCHARAT(rcstate->regparse-2)+1;
+ classend = UCHARAT(rcstate->regparse);
+ if (clss > classend+1)
+ FAIL("invalid [] range");
+ for (; clss <= classend; clss++)
+ regc(clss,rcstate);
+ rcstate->regparse++;
+ }
+ } else
+ regc(*rcstate->regparse++,rcstate);
+ }
+ regc('\0',rcstate);
+ if (*rcstate->regparse != ']')
+ FAIL("unmatched []");
+ rcstate->regparse++;
+ *flagp |= HASWIDTH|SIMPLE;
+ }
+ break;
+ case '(':
+ ret = reg(1, &flags, rcstate);
+ if (ret == NULL)
+ return(NULL);
+ *flagp |= flags&(HASWIDTH|SPSTART);
+ break;
+ case '\0':
+ case '|':
+ case ')':
+ FAIL("internal urp"); /* Supposed to be caught earlier. */
+ /* NOTREACHED */
+ break;
+ case '?':
+ case '+':
+ case '*':
+ FAIL("?+* follows nothing");
+ /* NOTREACHED */
+ break;
+ case '\\':
+ if (*rcstate->regparse == '\0')
+ FAIL("trailing \\");
+ ret = regnode(EXACTLY,rcstate);
+ regc(*rcstate->regparse++,rcstate);
+ regc('\0',rcstate);
+ *flagp |= HASWIDTH|SIMPLE;
+ break;
+ default: {
+ register int len;
+ register char ender;
+
+ rcstate->regparse--;
+ len = strcspn(rcstate->regparse, META);
+ if (len <= 0)
+ FAIL("internal disaster");
+ ender = *(rcstate->regparse+len);
+ if (len > 1 && ISMULT(ender))
+ len--; /* Back off clear of ?+* operand. */
+ *flagp |= HASWIDTH;
+ if (len == 1)
+ *flagp |= SIMPLE;
+ ret = regnode(EXACTLY,rcstate);
+ while (len > 0) {
+ regc(*rcstate->regparse++,rcstate);
+ len--;
+ }
+ regc('\0',rcstate);
+ }
+ break;
+ }
+
+ return(ret);
+}
+
+/*
+ - regnode - emit a node
+ */
+static char * /* Location. */
+regnode(op, rcstate)
+char op;
+struct regcomp_state *rcstate;
+{
+ register char *ret;
+ register char *ptr;
+
+ ret = rcstate->regcode;
+ if (ret == ®dummy) {
+ rcstate->regsize += 3;
+ return(ret);
+ }
+
+ ptr = ret;
+ *ptr++ = op;
+ *ptr++ = '\0'; /* Null "next" pointer. */
+ *ptr++ = '\0';
+ rcstate->regcode = ptr;
+
+ return(ret);
+}
+
+/*
+ - regc - emit (if appropriate) a byte of code
+ */
+static void
+regc(b, rcstate)
+char b;
+struct regcomp_state *rcstate;
+{
+ if (rcstate->regcode != ®dummy)
+ *rcstate->regcode++ = b;
+ else
+ rcstate->regsize++;
+}
+
+/*
+ - reginsert - insert an operator in front of already-emitted operand
+ *
+ * Means relocating the operand.
+ */
+static void
+reginsert(op, opnd, rcstate)
+char op;
+char *opnd;
+struct regcomp_state *rcstate;
+{
+ register char *src;
+ register char *dst;
+ register char *place;
+
+ if (rcstate->regcode == ®dummy) {
+ rcstate->regsize += 3;
+ return;
+ }
+
+ src = rcstate->regcode;
+ rcstate->regcode += 3;
+ dst = rcstate->regcode;
+ while (src > opnd)
+ *--dst = *--src;
+
+ place = opnd; /* Op node, where operand used to be. */
+ *place++ = op;
+ *place++ = '\0';
+ *place++ = '\0';
+}
+
+/*
+ - regtail - set the next-pointer at the end of a node chain
+ */
+static void
+regtail(p, val)
+char *p;
+char *val;
+{
+ register char *scan;
+ register char *temp;
+ register int offset;
+
+ if (p == ®dummy)
+ return;
+
+ /* Find last node. */
+ scan = p;
+ for (;;) {
+ temp = regnext(scan);
+ if (temp == NULL)
+ break;
+ scan = temp;
+ }
+
+ if (OP(scan) == BACK)
+ offset = scan - val;
+ else
+ offset = val - scan;
+ *(scan+1) = (offset>>8)&0377;
+ *(scan+2) = offset&0377;
+}
+
+/*
+ - regoptail - regtail on operand of first argument; nop if operandless
+ */
+static void
+regoptail(p, val)
+char *p;
+char *val;
+{
+ /* "Operandless" and "op != BRANCH" are synonymous in practice. */
+ if (p == NULL || p == ®dummy || OP(p) != BRANCH)
+ return;
+ regtail(OPERAND(p), val);
+}
+
+/*
+ * EcsRegExec and friends
+ */
+
+/*
+ * Global work variables for EcsRegExec().
+ */
+struct regexec_state {
+ char *reginput; /* String-input pointer. */
+ char *regbol; /* Beginning of input, for ^ check. */
+ char **regstartp; /* Pointer to startp array. */
+ char **regendp; /* Ditto for endp. */
+};
+
+/*
+ * Forwards.
+ */
+STATIC int regtry();
+STATIC int regmatch();
+STATIC int regrepeat();
+
+#ifdef DEBUG
+int regnarrate = 1;
+void regdump();
+STATIC char *regprop();
+#endif
+
+/*
+ - EcsRegExec - match a ecs_regexp against a string
+ */
+int
+EcsRegExec(prog, string, start)
+register ecs_regexp *prog;
+register char *string;
+char *start;
+{
+ register char *s;
+ struct regexec_state state;
+ struct regexec_state *restate= &state;
+
+ /* Be paranoid... */
+ if (prog == NULL || string == NULL) {
+ EcsRegError("NULL parameter");
+ return(0);
+ }
+
+ /* Check validity of program. */
+
+ /*
+ if (UCHARAT(prog->program) != MAGIC) {
+ EcsRegError("corrupted program");
+ return(0);
+ }
+ */
+
+ /* If there is a "must appear" string, look for it. */
+ if (prog->regmust != NULL) {
+ s = string;
+ while ((s = strchr(s, prog->regmust[0])) != NULL) {
+ if (strncmp(s, prog->regmust, (size_t) prog->regmlen)
+ == 0)
+ break; /* Found it. */
+ s++;
+ }
+ if (s == NULL) /* Not present. */
+ return(0);
+ }
+
+ /* Mark beginning of line for ^ . */
+ restate->regbol = start;
+
+ /* Simplest case: anchored match need be tried only once. */
+ if (prog->reganch)
+ return(regtry(prog, string, restate));
+
+ /* Messy cases: unanchored match. */
+ s = string;
+ if (prog->regstart != '\0')
+ /* We know what char it must start with. */
+ while ((s = strchr(s, prog->regstart)) != NULL) {
+ if (regtry(prog, s, restate))
+ return(1);
+ s++;
+ }
+ else
+ /* We don't -- general case. */
+ do {
+ if (regtry(prog, s, restate))
+ return(1);
+ } while (*s++ != '\0');
+
+ /* Failure. */
+ return(0);
+}
+
+/*
+ - regtry - try match at specific point
+ */
+static int /* 0 failure, 1 success */
+regtry(prog, string, restate)
+ecs_regexp *prog;
+char *string;
+struct regexec_state *restate;
+{
+ register int i;
+ register char **sp;
+ register char **ep;
+
+ restate->reginput = string;
+ restate->regstartp = prog->startp;
+ restate->regendp = prog->endp;
+
+ sp = prog->startp;
+ ep = prog->endp;
+ for (i = NSUBEXP; i > 0; i--) {
+ *sp++ = NULL;
+ *ep++ = NULL;
+ }
+ if (regmatch(prog->program + 1,restate)) {
+ prog->startp[0] = string;
+ prog->endp[0] = restate->reginput;
+ return(1);
+ } else
+ return(0);
+}
+
+/*
+ - regmatch - main matching routine
+ *
+ * Conceptually the strategy is simple: check to see whether the current
+ * node matches, call self recursively to see whether the rest matches,
+ * and then act accordingly. In practice we make some effort to avoid
+ * recursion, in particular by going through "ordinary" nodes (that don't
+ * need to know whether the rest of the match failed) by a loop instead of
+ * by recursion.
+ */
+static int /* 0 failure, 1 success */
+regmatch(prog, restate)
+char *prog;
+struct regexec_state *restate;
+{
+ register char *scan; /* Current node. */
+ char *next; /* Next node. */
+
+ scan = prog;
+#ifdef DEBUG
+ if (scan != NULL && regnarrate)
+ fprintf(stderr, "%s(\n", regprop(scan));
+#endif
+ while (scan != NULL) {
+#ifdef DEBUG
+ if (regnarrate)
+ fprintf(stderr, "%s...\n", regprop(scan));
+#endif
+ next = regnext(scan);
+
+ switch (OP(scan)) {
+ case BOL:
+ if (restate->reginput != restate->regbol)
+ return(0);
+ break;
+ case EOL:
+ if (*restate->reginput != '\0')
+ return(0);
+ break;
+ case ANY:
+ if (*restate->reginput == '\0')
+ return(0);
+ restate->reginput++;
+ break;
+ case EXACTLY: {
+ register int len;
+ register char *opnd;
+
+ opnd = OPERAND(scan);
+ /* Inline the first character, for speed. */
+ if (*opnd != *restate->reginput)
+ return(0);
+ len = strlen(opnd);
+ if (len > 1 && strncmp(opnd, restate->reginput, (size_t) len) != 0)
+ return(0);
+ restate->reginput += len;
+ }
+ break;
+ case ANYOF:
+ if (*restate->reginput == '\0' || strchr(OPERAND(scan), *restate->reginput) == NULL)
+ return(0);
+ restate->reginput++;
+ break;
+ case ANYBUT:
+ if (*restate->reginput == '\0' || strchr(OPERAND(scan), *restate->reginput) != NULL)
+ return(0);
+ restate->reginput++;
+ break;
+ case NOTHING:
+ break;
+ case BACK:
+ break;
+ case OPEN+1:
+ case OPEN+2:
+ case OPEN+3:
+ case OPEN+4:
+ case OPEN+5:
+ case OPEN+6:
+ case OPEN+7:
+ case OPEN+8:
+ case OPEN+9: {
+ register int no;
+ register char *save;
+
+ no = OP(scan) - OPEN;
+ save = restate->reginput;
+
+ if (regmatch(next,restate)) {
+ /*
+ * Don't set startp if some later
+ * invocation of the same parentheses
+ * already has.
+ */
+ if (restate->regstartp[no] == NULL)
+ restate->regstartp[no] = save;
+ return(1);
+ } else
+ return(0);
+ }
+ /* NOTREACHED */
+ break;
+ case CLOSE+1:
+ case CLOSE+2:
+ case CLOSE+3:
+ case CLOSE+4:
+ case CLOSE+5:
+ case CLOSE+6:
+ case CLOSE+7:
+ case CLOSE+8:
+ case CLOSE+9: {
+ register int no;
+ register char *save;
+
+ no = OP(scan) - CLOSE;
+ save = restate->reginput;
+
+ if (regmatch(next,restate)) {
+ /*
+ * Don't set endp if some later
+ * invocation of the same parentheses
+ * already has.
+ */
+ if (restate->regendp[no] == NULL)
+ restate->regendp[no] = save;
+ return(1);
+ } else
+ return(0);
+ }
+ /* NOTREACHED */
+ break;
+ case BRANCH: {
+ register char *save;
+
+ if (OP(next) != BRANCH) /* No choice. */
+ next = OPERAND(scan); /* Avoid recursion. */
+ else {
+ do {
+ save = restate->reginput;
+ if (regmatch(OPERAND(scan),restate))
+ return(1);
+ restate->reginput = save;
+ scan = regnext(scan);
+ } while (scan != NULL && OP(scan) == BRANCH);
+ return(0);
+ /* NOTREACHED */
+ }
+ }
+ /* NOTREACHED */
+ break;
+ case STAR:
+ case PLUS: {
+ register char nextch;
+ register int no;
+ register char *save;
+ register int min;
+
+ /*
+ * Lookahead to avoid useless match attempts
+ * when we know what character comes next.
+ */
+ nextch = '\0';
+ if (OP(next) == EXACTLY)
+ nextch = *OPERAND(next);
+ min = (OP(scan) == STAR) ? 0 : 1;
+ save = restate->reginput;
+ no = regrepeat(OPERAND(scan),restate);
+ while (no >= min) {
+ /* If it could work, try it. */
+ if (nextch == '\0' || *restate->reginput == nextch)
+ if (regmatch(next,restate))
+ return(1);
+ /* Couldn't or didn't -- back up. */
+ no--;
+ restate->reginput = save + no;
+ }
+ return(0);
+ }
+ /* NOTREACHED */
+ break;
+ case END:
+ return(1); /* Success! */
+ /* NOTREACHED */
+ break;
+ default:
+ EcsRegError("memory corruption");
+ return(0);
+ /* NOTREACHED */
+ break;
+ }
+
+ scan = next;
+ }
+
+ /*
+ * We get here only if there's trouble -- normally "case END" is
+ * the terminating point.
+ */
+ EcsRegError("corrupted pointers");
+ return(0);
+}
+
+/*
+ - regrepeat - repeatedly match something simple, report how many
+ */
+static int
+regrepeat(p, restate)
+char *p;
+struct regexec_state *restate;
+{
+ register int count = 0;
+ register char *scan;
+ register char *opnd;
+
+ scan = restate->reginput;
+ opnd = OPERAND(p);
+ switch (OP(p)) {
+ case ANY:
+ count = strlen(scan);
+ scan += count;
+ break;
+ case EXACTLY:
+ while (*opnd == *scan) {
+ count++;
+ scan++;
+ }
+ break;
+ case ANYOF:
+ while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
+ count++;
+ scan++;
+ }
+ break;
+ case ANYBUT:
+ while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
+ count++;
+ scan++;
+ }
+ break;
+ default: /* Oh dear. Called inappropriately. */
+ EcsRegError("internal foulup");
+ count = 0; /* Best compromise. */
+ break;
+ }
+ restate->reginput = scan;
+
+ return(count);
+}
+
+/*
+ - regnext - dig the "next" pointer out of a node
+ */
+static char *
+regnext(p)
+register char *p;
+{
+ register int offset;
+
+ if (p == ®dummy)
+ return(NULL);
+
+ offset = NEXT(p);
+ if (offset == 0)
+ return(NULL);
+
+ if (OP(p) == BACK)
+ return(p-offset);
+ else
+ return(p+offset);
+}
+
+#ifdef DEBUG
+
+STATIC char *regprop();
+
+/*
+ - regdump - dump a ecs_regexp onto stdout in vaguely comprehensible form
+ */
+void
+regdump(r)
+ecs_regexp *r;
+{
+ register char *s;
+ register char op = EXACTLY; /* Arbitrary non-END op. */
+ register char *next;
+
+
+ s = r->program + 1;
+ while (op != END) { /* While that wasn't END last time... */
+ op = OP(s);
+ printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
+ next = regnext(s);
+ if (next == NULL) /* Next ptr. */
+ printf("(0)");
+ else
+ printf("(%d)", (s-r->program)+(next-s));
+ s += 3;
+ if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
+ /* Literal string, where present. */
+ while (*s != '\0') {
+ putchar(*s);
+ s++;
+ }
+ s++;
+ }
+ putchar('\n');
+ }
+
+ /* Header fields of interest. */
+ if (r->regstart != '\0')
+ printf("start `%c' ", r->regstart);
+ if (r->reganch)
+ printf("anchored ");
+ if (r->regmust != NULL)
+ printf("must have \"%s\"", r->regmust);
+ printf("\n");
+}
+
+/*
+ - regprop - printable representation of opcode
+ */
+static char *
+regprop(op)
+char *op;
+{
+ register char *p;
+ static char buf[50];
+
+ (void) strcpy(buf, ":");
+
+ switch (OP(op)) {
+ case BOL:
+ p = "BOL";
+ break;
+ case EOL:
+ p = "EOL";
+ break;
+ case ANY:
+ p = "ANY";
+ break;
+ case ANYOF:
+ p = "ANYOF";
+ break;
+ case ANYBUT:
+ p = "ANYBUT";
+ break;
+ case BRANCH:
+ p = "BRANCH";
+ break;
+ case EXACTLY:
+ p = "EXACTLY";
+ break;
+ case NOTHING:
+ p = "NOTHING";
+ break;
+ case BACK:
+ p = "BACK";
+ break;
+ case END:
+ p = "END";
+ break;
+ case OPEN+1:
+ case OPEN+2:
+ case OPEN+3:
+ case OPEN+4:
+ case OPEN+5:
+ case OPEN+6:
+ case OPEN+7:
+ case OPEN+8:
+ case OPEN+9:
+ sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
+ p = NULL;
+ break;
+ case CLOSE+1:
+ case CLOSE+2:
+ case CLOSE+3:
+ case CLOSE+4:
+ case CLOSE+5:
+ case CLOSE+6:
+ case CLOSE+7:
+ case CLOSE+8:
+ case CLOSE+9:
+ sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
+ p = NULL;
+ break;
+ case STAR:
+ p = "STAR";
+ break;
+ case PLUS:
+ p = "PLUS";
+ break;
+ default:
+ EcsRegError("corrupted opcode");
+ break;
+ }
+ if (p != NULL)
+ (void) strcat(buf, p);
+ return(buf);
+}
+#endif
+
+/*
+ * The following is provided for those people who do not have strcspn() in
+ * their C libraries. They should get off their butts and do something
+ * about it; at least one public-domain implementation of those (highly
+ * useful) string routines has been published on Usenet.
+ */
+#ifdef STRCSPN
+/*
+ * strcspn - find length of initial segment of s1 consisting entirely
+ * of characters not from s2
+ */
+
+static int
+strcspn(s1, s2)
+char *s1;
+char *s2;
+{
+ register char *scan1;
+ register char *scan2;
+ register int count;
+
+ count = 0;
+ for (scan1 = s1; *scan1 != '\0'; scan1++) {
+ for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */
+ if (*scan1 == *scan2++)
+ return(count);
+ count++;
+ }
+ return(count);
+}
+#endif
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * EcsRegError --
+ *
+ * This procedure is invoked by the ecs_regexp code when an error
+ * occurs. It saves the error message so it can be seen by the
+ * code that called Spencer's code.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The value of "string" is saved in "errMsg".
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+EcsRegError(string)
+ char *string; /* Error message. */
+{
+ errMsg = string;
+}
+
+char *
+EcsGetRegError()
+{
+ return errMsg;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecssplit.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecssplit.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecssplit.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,178 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: High level URL splitting functions.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecssplit.c,v $
+ * Revision 1.3 2003/08/27 05:27:21 warmerda
+ * Modified ecs_SplitURL() so that calling with a NULL url indicates it
+ * should free the resources associated with the static regular expressions.
+ * This makes memory leak debugging with OGDI more convenient.
+ *
+ * Revision 1.2 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecssplit.c,v 1.3 2003/08/27 05:27:21 warmerda Exp $");
+
+/*
+ -------------------------------------------------
+
+ ecs_freeSplitURL: deallocate all the string used in
+ SplitURL operation.
+
+ IN/OUT:
+ type:
+ machine:
+ path: the three string to deallocate
+
+ -------------------------------------------------
+ */
+
+void ecs_freeSplitURL(type,machine,path)
+ char **type;
+ char **machine;
+ char **path;
+{
+ if (*type != NULL) {
+ free(*type);
+ *type = NULL;
+ }
+ if (*machine != NULL) {
+ free(*machine);
+ *machine = NULL;
+ }
+ if (*path != NULL) {
+ free(*path);
+ *path = NULL;
+ }
+}
+
+/*
+ -------------------------------------------------
+
+ ecs_GetRegex: Allocate and set a string with the
+ values contained in the regex.
+
+ IN:
+ ecs_regexp *reg: A pointer to ecs_regexp structure
+ (initialize in ecs_SplitURL).
+ int index: Index of the table contained in ecs_regexp
+ OUT:
+ char **chaine: String returned value
+ return int: Error code
+ TRUE: success
+ FALSE: failure
+
+ -------------------------------------------------
+ */
+
+int ecs_GetRegex(reg,index,chaine)
+ ecs_regexp *reg;
+ int index;
+ char **chaine;
+{
+ int chaine_len;
+
+ chaine_len = reg->endp[index] - reg->startp[index] ;
+ *chaine = (char *) malloc(chaine_len+1);
+ if (*chaine ==NULL)
+ return FALSE;
+ strncpy(*chaine,reg->startp[index],chaine_len);
+ (*chaine)[chaine_len] = '\0';
+ return TRUE;
+}
+
+/*
+ -------------------------------------------------
+
+ ecs_SplitURL: Extract information from the URL
+ and return it in the arguments.
+
+ IN:
+ char *url: This string contain the URL
+
+ OUT:
+ machine: Machine addresses contain in the URL. If NULL,
+ the server is local
+ server: The server type of the DLL to load
+ path: The string used by the dynamic database library to
+ set the database server. Specific to each kind of
+ server.
+ return int: A error message
+ TRUE: success
+ FALSE: failure
+
+ -------------------------------------------------
+ */
+
+int ecs_SplitURL(url,machine,server,path)
+ char *url;
+ char **machine;
+ char **server;
+ char **path;
+{
+ static int compiled = 0;
+ static ecs_regexp *local,*remote;
+ int msg;
+
+ if( url == NULL ) { /* Cleanup */
+ if( compiled ) {
+ compiled = 0;
+ free( local );
+ free( remote );
+ local = NULL;
+ remote = NULL;
+ }
+ return FALSE;
+ }
+
+ if (!compiled) {
+ remote = EcsRegComp("gltp://([0-9a-zA-Z\\.\\-]+)/([0-9a-zA-Z\\.]+)(.*)");
+ local = EcsRegComp("gltp:/([0-9a-zA-Z\\.]+)(.*)");
+ compiled = 1;
+ }
+
+ *machine = NULL;
+ *server = NULL;
+ *path = NULL;
+
+ if (strncmp(url,"gltp://",7) != 0) {
+ if (EcsRegExec(local,url,NULL) == 0)
+ return FALSE;
+ if (((msg = ecs_GetRegex(local,1,server)) == FALSE) ||
+ ((msg = ecs_GetRegex(local,2,path)) == FALSE)) {
+ ecs_freeSplitURL(machine,server,path);
+ return msg;
+ }
+ } else {
+ if (EcsRegExec(remote,url,NULL) == 0)
+ return FALSE;
+ if (((msg = ecs_GetRegex(remote,1,machine)) == FALSE) ||
+ ((msg = ecs_GetRegex(remote,2,server)) == FALSE) ||
+ ((msg = ecs_GetRegex(remote,3,path)) == FALSE)) {
+ ecs_freeSplitURL(machine,server,path);
+ return msg;
+ }
+ }
+
+ return TRUE;
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecstile.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecstile.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ecstile.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1021 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Raster tile caching implementation.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecstile.c,v $
+ * Revision 1.5 2007/02/12 15:52:57 cbalint
+ *
+ * Preliminary cleanup.
+ * Get rif of unitialized variables, and unused ones.
+ *
+ * Revision 1.4 2001/04/19 05:09:17 warmerda
+ * fixed round off errors in calculation of t->linelength, and placed
+ * coord.x/y at center of pixel instead of the corner.
+ *
+ * Revision 1.3 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecstile.c,v 1.5 2007/02/12 15:52:57 cbalint Exp $");
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_TileInitialize
+
+ DESCRIPTION
+ -allows driver to describe the tile structure
+ END_DESCRIPTION
+
+ POSTCONDITIONS
+ -tile structure allocated in ecs_Server, or error
+ -t->index == -1
+ END_POSTCONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_Server *server: the server structure.
+ ecs_Region *region: the region of the database
+ int xtiles: the number of tiles along x axis
+ int ytiles: the number of tiles along y axis
+ int callbackFunc(): the callback for i,j values
+ int tileDimFunc(): the callback for tile dimension.
+ (pass NULL if none)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ <
+ returns TRUE or FALSE if successful or not
+ >
+ PSEUDOCODE
+ 1) initialize the tile layout.
+ 2) ecs_TileStructure allocated, added to ecs_Result.
+ 3) callback, closeTile procedures are registered.
+ END_PSEUDOCODE
+
+
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+
+*/
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ ecs_TileInitialize
+
+DESCRIPTION
+
+ allows driver to describe the tile structure
+
+END_DESCRIPTION
+
+POSTCONDITIONS
+
+ -tile structure allocated in ecs_Server, or error
+ -t->index == -1
+
+END_POSTCONDITIONS
+
+PARAMETERS
+INPUT
+
+ ecs_Server *s: the server structure.
+ ecs_TileStructure *t: The pointer to tile information.
+ ecs_Region *region: the region of the database
+ int xtiles: the number of tiles along x axis
+ int ytiles: the number of tiles along y axis
+ int tilewidth: The tile width
+ int tileheight: The tile height
+ int callbackFunc(): the callback for i,j values
+ int tileDimFunc(): the callback for tile dimension.
+ (pass NULL if none)
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ returns TRUE or FALSE if successful or not
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ 1) initialize the tile layout.
+ 2) ecs_TileStructure allocated, added to ecs_Result.
+ 3) callback, closeTile procedures are registered.
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+int ecs_TileInitialize (s, t, region, xtiles, ytiles, tilewidth, tileheight, callbackFunc, tileDimFunc)
+ ecs_Server *s;
+ ecs_TileStructure *t;
+ ecs_Region *region;
+ int xtiles;
+ int ytiles;
+ int tilewidth;
+ int tileheight;
+ tile_func *callbackFunc;
+ tile_func *tileDimFunc;
+{
+ /* static dirty=0;
+
+ if (dirty) {
+ ecs_TileDeleteAllLines(t);
+ }
+ dirty=1;
+ */
+
+ (void) s;
+
+ t->width=tilewidth;
+ t->height=tileheight;
+
+ t->nb_lines=0;
+ t->index = -1;
+ t->offValue=0;
+ t->uninitializedValue=-1;
+ t->currentTile.none=1;
+ t->callback=callbackFunc;
+ t->tileDimCallback=tileDimFunc;
+ t->linelength= -1;
+ t->region.north=region->north;
+ t->region.south=region->south;
+ t->region.east=region->east;
+ t->region.west=region->west;
+ t->region.ew_res=region->ew_res;
+ t->region.ns_res=region->ns_res;
+ t->regionwidth = (int) ((t->region.east - t->region.west) / t->region.ew_res);
+ t->regionheight = (int) ((t->region.north - t->region.south) / t->region.ns_res);
+ t->linebuffer=NULL;
+ t->xtiles=xtiles;
+ t->ytiles=ytiles;
+
+ return TRUE;
+}
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_TileGetLine
+
+ DESCRIPTION
+ -allows driver to retrieve a line.
+ END_DESCRIPTION
+
+ PRECONDITIONS:
+ -callback must have been registered
+ -the length of a line must have been put into TileData
+ POSTCONDITIONS
+ tile structure allocated in ecs_Server, or error
+ END_POSTCONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_TileStructure *server: the tile structure.
+ ecs_Coordinate *start; the start geog coordinate
+ ecs_Coordinate *end; the ending geog coordinate
+ END_PARAMETERS
+
+ RETURN_VALUE
+ <
+ returns TRUE or FALSE if successful or not
+ >
+ PSEUDOCODE
+ 1) determines the last point (if any) that has been set by
+ previous calls to ecs_TileGetLine (the part which is sitting in the
+ buffer)
+ 2) examines remainder of the line to determine the tiles it crosses.
+ 2a) for each point in the matrix,
+ 2a1) if it is outside the tiles, add the "no_data" value.
+ 2a2) else call the callback for each point in the line for
+ each of these tiles,
+ 2a3) read the rest of the tile into the buffer for future lines.
+ 3) goto (2) for each tile that intersects with the line until the easternmost
+ point is reached.
+ 4) pad extra values with offValue
+ 5) return an ecs_Result with a line (or error)
+
+ END_PSEUDOCODE
+
+
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+*/
+
+int ecs_TileGetLine(s,t,start,end)
+ ecs_Server *s;
+ ecs_TileStructure *t;
+ ecs_Coordinate *start;
+ ecs_Coordinate *end;
+{
+ int count, tmp, cat;
+ register int y, i, j, firsttime, pix_x, pix_y;
+ ecs_TileBufferLine *tbuf;
+ ecs_Coordinate coord;
+ ecs_TileID tile_id;
+ ecs_Layer *l;
+ double ew_res, ns_res;
+ register int offsetx,offsety;
+ register double ratio_x,ratio_y;
+ int posidres;
+
+ offsetx = (int) ((s->currentRegion.west - t->region.west)/t->region.ew_res);
+ offsety = (int) ((t->region.north - s->currentRegion.north)/t->region.ns_res);
+
+ ratio_x = s->currentRegion.ew_res/t->region.ew_res;
+ ratio_y = s->currentRegion.ns_res/t->region.ns_res;
+
+ l=&(s->layer[s->currentLayer]);
+ /* get the id of this line */
+ if (start->x >= end->x) {
+ ecs_SetError(&(s->result), 1, "Coordinates are invalid");
+ ecs_TileDeleteAllLines(t);
+ return FALSE;
+ }
+
+ /* calculate linelength */
+ if (t->linelength<0) {
+
+ t->linelength = (int) (((end->x-start->x) / s->currentRegion.ew_res)+0.5);
+
+ } else {
+ tmp=(int) (((end->x - start->x) / s->currentRegion.ew_res)+0.5);
+
+ /* check if resolution has changed */
+ if (tmp!=t->linelength) {
+ ecs_TileDeleteAllLines(t);
+ };
+ t->linelength=tmp;
+ }
+
+ /* initialize the ecs_result */
+ ecs_SetGeomMatrix(&(s->result), t->linelength);
+
+ /* if the line is not the first in the buffer, it isn't there, so
+ it must be created. */
+
+ /* the y value of this point */
+ /* y=(int) ((s->currentRegion.north- start->y) / s->currentRegion.ns_res); */
+
+ y=l->index;
+
+ /* if the first line of the buffer isn't the current line, add it to the buffer */
+ if (t->index != y) {
+ ecs_TileAddLine(t,t->linelength, y, &tbuf);
+ }
+
+ firsttime=1;
+
+ /* scan the first line of the buffer for uninitialized pixels. */
+ for (count=0; count< t->linelength; count++) {
+ if (t->linebuffer->linebuffer[count]==t->uninitializedValue) {
+ if (s->rasterconversion.isProjEqual) {
+ i=y;
+ j=count;
+ } else {
+ i = ECSGETI(s,((double) y),((double) count));
+ j = ECSGETJ(s,((double) y),((double) count));
+ }
+
+ if (t->tileDimCallback!=NULL) {
+ coord.x=s->currentRegion.west+(j+0.5)*s->currentRegion.ew_res;
+ coord.y=s->currentRegion.north-(i+0.5)*s->currentRegion.ns_res;
+ t->tileDimCallback(s, t, coord.x, coord.y, &(t->width), &(t->height));
+ ew_res=1.0 / (double) t->width;
+ ns_res=1.0 / (double) t->height;
+ pix_x = (int) ((coord.x - t->region.west) / ew_res);
+ pix_y = (int) ((t->region.north-coord.y) / ns_res);
+ posidres = ecs_GetTileId(s, t, &coord, &tile_id);
+ } else {
+ pix_x = ((int) (j*ratio_x))+offsetx;
+ pix_y = ((int) (i*ratio_y))+offsety;
+ posidres = ecs_GetTileIdFromPos(s, t, pix_x, pix_y, &tile_id);
+ }
+
+ if (posidres) {
+ if (!firsttime) {
+ /* if the tile_id changes, try to read the next line in the old tile */
+ if (! ecs_TileCompare(&(t->currentTile),&tile_id)) {
+ /* read the rest of the tile */
+ ecs_TileFill(s, t, y, &(t->currentTile));
+ }
+ }
+ firsttime=0;
+ ecs_SetTile(&(t->currentTile), &tile_id);
+
+ if (tile_id.x < 0 || tile_id.x >= t->xtiles ||
+ tile_id.y < 0 || tile_id.y >= t->ytiles) {
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),count,t->offValue);
+ } else {
+ if (t->callback(s, t, tile_id.x, tile_id.y, pix_x % t->width, pix_y % t->height, &cat)) {
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),count,cat);
+ } else {
+ ecs_TileDeleteAllLines(t);
+ printf("can't read pixel (%d,%d) in tile (%d,%d)\n", pix_x, pix_y, tile_id.x, tile_id.y);
+ ecs_SetError(&(s->result),1,"Unable to read matrix value");
+ return FALSE;
+ }
+ }
+ } else { /* out of bounds */
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),count,t->offValue);
+ }
+ } else {
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),count,t->linebuffer->linebuffer[count]);
+ }
+ }
+
+ ecs_TileDeleteLine(t);
+ ecs_SetSuccess(&(s->result));
+ return TRUE;
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ ecs_ClearTileBuffer
+
+DESCRIPTION
+
+ Public function called by the driver during Select Layer
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ ecs_TileInitialize must have been called first.
+
+END_PRECONDITIONS
+
+PARAMETERS
+
+ INPUT
+ ecs_TileStructure *t;
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ none
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ 1) call the destroyalllines procedure
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+void ecs_TileClearBuffer(ecs_TileStructure *t) {
+
+ ecs_TileDeleteAllLines(t);
+ return;
+}
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_TileFill
+
+ DESCRIPTION
+ fill the buffer with data from a single tile.
+ END_DESCRIPTION
+
+ PRECONDITIONS
+ -there is at least one line in the buffer already.
+ -the "index" position in the matrix has already been
+ filled.
+ END_PRECONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_TileStructure *s: the server structure.
+ ecs_TileID *tile_id: the tile_id of the tile to fill.
+ int index: the y position in the matrix
+ END_PARAMETERS
+
+ RETURN_VALUE
+ <
+ returns TRUE or FALSE if successful or not
+ >
+ PSEUDOCODE
+ 1) start at line index+2, position "last" (i.e. start from
+ the first unfilled pixel on the next line)
+ 2) If the first pixel is in another tile, return. (This means
+ that either the tile border has a negative slope (\) and the
+ left tile hasn't been filled, or that the tile has been completed).
+ 3) Read the line until the end of the tile, then recurse.
+ END_PSEUDOCODE
+
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+
+*/
+
+int ecs_TileFill(ecs_Server *s, ecs_TileStructure *t, int index, ecs_TileID *current_tile_id) {
+
+ register int i,j, bufptr, pix_x, pix_y;
+ int cat,count;
+ short firsttime=1;
+ ecs_Coordinate coord;
+ ecs_TileBufferLine *tbuf;
+ ecs_TileID tile_id;
+ double ew_res, ns_res;
+ register int offsetx,offsety;
+ register double ratio_x,ratio_y;
+ int posidres;
+
+ bufptr=index+1; /* the number of the next line in the buffer */
+
+ offsetx = (int) ((s->currentRegion.west - t->region.west)/t->region.ew_res);
+ offsety = (int) ((t->region.north - s->currentRegion.north)/t->region.ns_res);
+ ratio_x = s->currentRegion.ew_res/t->region.ew_res;
+ ratio_y = s->currentRegion.ns_res/t->region.ns_res;
+
+ /* if the line isn't in the buffer, add it. */
+ if (! ecs_TileFindBuffer(t, bufptr, &tbuf)) {
+ if (! ecs_TileAddLine(t,t->linelength, bufptr, &tbuf)) {
+ return FALSE;
+ }
+ }
+
+ /* return 1; */
+
+ for (count=tbuf->last+1; count< t->linelength; count++) {
+ if (tbuf->linebuffer[count]==t->uninitializedValue) {
+
+ if (s->rasterconversion.isProjEqual) {
+
+ j = count;
+ i = bufptr;
+
+ } else { /* if s->rasterconversion */
+
+ i = ECSGETI(s,((double) bufptr),((double) count));
+ j = ECSGETJ(s,((double) bufptr),((double) count));
+
+ }
+
+ if (t->tileDimCallback!=NULL) {
+ coord.x=s->currentRegion.west+j*s->currentRegion.ew_res;
+ coord.y=s->currentRegion.north-i*s->currentRegion.ns_res;
+ t->tileDimCallback(s, t, coord.x, coord.y, &(t->width), &(t->height));
+ ew_res=1.0 / (double) t->width;
+ ns_res=1.0 / (double) t->height;
+ pix_x = (int) ((coord.x - t->region.west) / ew_res);
+ pix_y = (int) ((t->region.north-coord.y) / ns_res);
+ posidres = ecs_GetTileId(s, t, &coord, &tile_id);
+ } else {
+ pix_x = ((int) (j*ratio_x))+offsetx;
+ pix_y = ((int) (i*ratio_y))+offsety;
+ posidres = ecs_GetTileIdFromPos(s, t, pix_x, pix_y, &tile_id);
+ }
+
+ if (posidres) {
+
+ /* if the tile_id changes, try to read the next line in the same tile,
+ unless this is the first pixel in the line. */
+ if (! ecs_TileCompare(current_tile_id,&tile_id)) {
+ if (firsttime) {
+ /* the first value is not in the tile, so return. */
+ return TRUE;
+ }
+ /* we're done this line, so read the rest of the tile recursively */
+ return (ecs_TileFill(s, t, bufptr, current_tile_id));
+
+ } /* ecs_TileCompare */
+ firsttime=0; /* i.e. we've found a valid pixel */
+
+ /* ecs_SetTile(&(t->currentTile), &tile_id); */
+
+ /* i and j are BOGUS values for testing */
+
+ if (tile_id.x < 0 || tile_id.x >= t->xtiles ||
+ tile_id.y < 0 || tile_id.y >= t->ytiles) {
+ tbuf->linebuffer[++(tbuf->last)]=t->offValue;
+ } else {
+ if (t->callback(s, t, tile_id.x, tile_id.y, pix_x % t->width, pix_y %t->height, &cat)) {
+ tbuf->linebuffer[++(tbuf->last)]=cat;
+ } else {
+ ecs_TileDeleteAllLines(t);
+ ecs_SetError(&(s->result),1,"Unable to read matrix value");
+ return FALSE;
+ }
+ }
+ } else { /* out of bounds */
+ tbuf->linebuffer[++(tbuf->last)]=t->offValue;
+ }
+ } else { /* t->linebuffer... is uninitialized */
+#if TILE_DEBUG
+ printf("**** point redone. ***********\n");
+#endif
+ }
+ }
+ return TRUE;
+
+}
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_GetTileId
+
+ DESCRIPTION
+ Determine which tile a pair of matrix coords fit in.
+ END_DESCRIPTION
+
+ PRECONDITIONS:
+ ecs_TileStructure is initialized
+ END_PRECONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_TileStructure *s: the server structure.
+ int x_pixel: the pixel values of the point
+ int y_pixel:
+
+ END_PARAMETERS
+
+ RETURN_VALUE
+ <
+ returns TRUE or FALSE if successful or not
+ >
+ PSEUDOCODE
+
+
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+
+*/
+
+int ecs_GetTileId(ecs_Server *s, ecs_TileStructure *t, ecs_Coordinate *coord, ecs_TileID *tile_id) {
+
+ (void) s;
+
+ if (coord->x < t->region.west || coord->x > t->region.east ||
+ coord->y < t->region.south || coord->y > t->region.north) {
+ tile_id->none=1;
+ return FALSE;
+ }
+
+ tile_id->x=(int) ((coord->x-t->region.west) / (t->region.east
+ - t->region.west) * t->xtiles);
+ tile_id->y=(int) ((t->region.north - coord->y) / (t->region.north
+ - t->region.south) * t->ytiles);
+ tile_id->none=0;
+
+ return TRUE;
+
+}
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_GetTileIdFromPos
+
+ DESCRIPTION
+ Determine which tile a pair of matrix coords fit in.
+ END_DESCRIPTION
+
+ PRECONDITIONS:
+ ecs_TileStructure is initialized
+ END_PRECONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_TileStructure *s: the server structure.
+ int x_pixel: the pixel values of the point
+ int y_pixel:
+
+ END_PARAMETERS
+
+ RETURN_VALUE
+ <
+ returns TRUE or FALSE if successful or not
+ >
+ PSEUDOCODE
+
+
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+
+*/
+
+int ecs_GetTileIdFromPos(ecs_Server *s, ecs_TileStructure *t, int x, int y, ecs_TileID *tile_id) {
+
+ (void) s;
+
+ if (x < 0 || x > t->regionwidth ||
+ y < 0 || y > t->regionheight) {
+ tile_id->none=1;
+ return FALSE;
+ }
+
+ tile_id->x=(int) ((x * t->xtiles) / t->regionwidth);
+ tile_id->y=(int) ((y * t->ytiles) / t->regionheight);
+ tile_id->none=0;
+
+ return TRUE;
+
+}
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_TileFindBuffer
+
+ DESCRIPTION
+ private function which finds a line in the buffer if it exists,
+ and returns a pointer to it.
+ END_DESCRIPTION
+
+ PRECONDITIONS:
+ ecs_TileStructure structure has been initialized.
+ END_PRECONDITIONS
+
+ POSTCONDITIONS
+ END_POSTCONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_TileStructure *tile: the server structure.
+ int bufptr the index of the line in the buffer
+ OUTPUT
+ tbuf pointer to the new line buffer.
+ END_PARAMETERS
+
+ RETURN_VALUE
+ <
+ returns TRUE or FALSE if successful or not
+ >
+ PSEUDOCODE
+ 1) determine if the line is in the list.
+ 2) if no, return FALSE.
+ 3) set tbuf to point to the buffer line, return TRUE
+
+ END_PSEUDOCODE
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+*/
+
+int ecs_TileFindBuffer(ecs_TileStructure *t, int bufptr, ecs_TileBufferLine **tbuf) {
+ ecs_TileBufferLine *tptr;
+
+ if ( t->nb_lines <= 0) {
+ tbuf=NULL;
+ return FALSE;
+ }
+
+ if (bufptr < t->index || bufptr > t->index + t->nb_lines -1) {
+ tbuf=NULL;
+ return FALSE;
+ }
+
+ tptr=t->linebuffer;
+ while (tptr!=NULL) {
+ if (tptr->index==bufptr) {
+ *tbuf=tptr;
+ return TRUE;
+ }
+ tptr=tptr->next;
+ }
+#ifdef TILE_DEBUG
+ printf(" can't find buffer line %d; it's supposed to be there.\n",bufptr);
+#endif
+ tbuf=NULL;
+ return FALSE;
+}
+
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_TileAddLine
+
+ DESCRIPTION
+ private function which adds a buffered line to the ecs_TileStructure structure
+ END_DESCRIPTION
+
+ PRECONDITIONS:
+ ecs_TileStructure structure has been initialized.
+ END_PRECONDITIONS
+
+ POSTCONDITIONS
+ extra line has been mallocked. All values are set to the "uninitialized"
+ value.
+ END_POSTCONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_TileStructure *tile: the server structure.
+ int length the length of the buffer.
+ int index the index of the line.
+ OUTPUT
+ tbuf pointer to the new line buffer.
+ END_PARAMETERS
+
+ RETURN_VALUE
+ <
+ returns TRUE or FALSE if successful or not
+ >
+ PSEUDOCODE
+ 1) malloc a line; set next pointers accordingly.
+ 2) place line in ecs_tile
+ 3) set last=-1, index to the y matrix (map pixel) value.
+ 4) set all values to "uninitialized"
+ END_PSEUDOCODE
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+
+*/
+
+int ecs_TileAddLine(ecs_TileStructure *t, int length, int index, ecs_TileBufferLine **tbuf) {
+ /* malloc buffer */
+ register int i;
+ ecs_TileBufferLine *tmp, *last=NULL;
+
+#if 0
+ printf("+++adding a line %d to buffer\n",index);
+#endif
+ /* insert new line at tail of list (FIFO)*/
+
+ tmp=t->linebuffer;
+
+ /* find the last buffer line */
+ while (tmp != NULL) {
+ last=tmp;
+ tmp=tmp->next;
+ }
+
+ /* allocate the buffer */
+ tmp=(ecs_TileBufferLine *) malloc (sizeof (ecs_TileBufferLine));
+ if (!tmp) {
+ return FALSE;
+ }
+ if (t->linebuffer==NULL) {
+ t->linebuffer=tmp;
+ t->index=index;
+ } else {
+ last->next=tmp;
+ }
+
+ /* allocate the space for the pixels */
+ tmp->linebuffer=(int *) malloc (sizeof (int) * length);
+ if (!tmp->linebuffer) {
+ return FALSE;
+ }
+
+ tmp->next=NULL;
+ tmp->index=index;
+ tmp->last=-1;
+
+ t->nb_lines++;
+
+ /* set all values to "uninitialized" */
+ for (i=0; i<length; i++) {
+ tmp->linebuffer[i]=t->uninitializedValue;
+ }
+ *tbuf=tmp;
+ return TRUE;
+
+}
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_TileDeleteLine
+
+ DESCRIPTION
+ removes a line from the buffer
+ END_DESCRIPTION
+
+ PRECONDITIONS:
+ The t->linebuffer *must* have been initialized before,
+ at least so it points to NULL.
+ END_PRECONDITIONS
+
+ POSTCONDITIONS
+ deletes top line from the buffer.
+ decreases t->nb_lines by 1
+ END_POSTCONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_TileStructure *tile: the server structure.
+ int length the length of the buffer.
+
+ END_PARAMETERS
+
+ RETURN_VALUE
+ returns TRUE if a line was deleted. Else return FALSE.
+ PSEUDOCODE
+ 1) remove the top line from the buffer and free memory.
+ If none, return "FALSE"
+ END_PSEUDOCODE
+
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+
+*/
+
+int ecs_TileDeleteLine(ecs_TileStructure *t) {
+ ecs_TileBufferLine *tmp;
+
+ /* free buffer if any */
+ if (t->nb_lines==0) {
+ return FALSE;
+ }
+#if 0
+ fprintf(stdout, "---deleting line %d from buffer\n", t->index);
+#endif
+ t->nb_lines--;
+ tmp=t->linebuffer->next;
+ if (tmp != NULL) {
+ t->index=tmp->index;
+ } else {
+ t->index = -1;
+ }
+ free(t->linebuffer->linebuffer);
+ free(t->linebuffer);
+ t->linebuffer=tmp;
+
+ return TRUE;
+}
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_TileDeleteAllLines
+
+ DESCRIPTION
+ removes all lines from the buffer
+ END_DESCRIPTION
+
+ PRECONDITIONS:
+ none
+ END_PRECONDITIONS
+
+ POSTCONDITIONS:
+ t->nb_lines is 0
+ END_POSTCONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_TileStructure *tile: the tile structure.
+
+ END_PARAMETERS
+
+ RETURN_VALUE
+ none
+ PSEUDOCODE
+ 1) Keep calling ecs_TileDeleteLine until it returns FALSE.
+ END_PSEUDOCODE
+
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+
+*/
+
+
+void ecs_TileDeleteAllLines (ecs_TileStructure *t) {
+ /* fprintf(stdout, "removing buffer\n"); */
+ while (ecs_TileDeleteLine(t)) {};
+ t->nb_lines=0;
+
+ return;
+}
+
+/*
+ *******************************************************************
+
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_TileFind
+
+ DESCRIPTION
+ returns true if within current tiles
+ END_DESCRIPTION
+
+ PRECONDITIONS:
+ none
+ END_PRECONDITIONS
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: the server structure
+ ecs_Coordinate *coord: the coordinate to locate
+ OUTPUT
+ ecs_TileId *tile: the tiling structure.
+ END_PARAMETERS
+
+ RETURN_VALUE
+ none
+ PSEUDOCODE
+ 1) Keep calling ecs_TileDeleteLine until it returns FALSE.
+ END_PSEUDOCODE
+
+ END_FUNCTION_INFORMATION
+
+ *******************************************************************
+
+*/
+
+
+int ecs_TileCompare (ecs_TileID *id1, ecs_TileID *id2) {
+
+ if (id1->none || id2->none)
+ return FALSE;
+
+ if (id1->x==id2->x && id1->y==id2->y)
+ return TRUE;
+ return FALSE;
+}
+
+int ecs_SetTile (ecs_TileID *destination, ecs_TileID *source) {
+ /* determine which tile x and y are in */
+
+ destination->none=source->none;
+ destination->x=source->x;
+ destination->y=source->y;
+ return TRUE;
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/gmath.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/gmath.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/gmath.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,943 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Double precision matrix inverse, allocation, multiplication,
+ * and print routines.
+ *
+ ******************************************************************************
+ * Derived from Numerical methods in C.
+ *
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: gmath.c,v $
+ * Revision 1.2 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+/* ------------------------------------------------------------------ */
+
+#include "ecs.h"
+#include "gmath.h" /* include this header in your code too */
+
+ECS_CVSID("$Id: gmath.c,v 1.2 2001/04/09 15:04:34 warmerda Exp $");
+
+/* set stack to a large value (turbo c only)*/
+
+#ifdef __TURBOC__
+extern unsigned _stklen = 20000;
+#endif
+
+/* ------------------------------------------------------------------ */
+/*
+ GMATUTIL.C
+
+ Double precision matrix inverse, allocation, multiplication,
+ and print routines.
+
+ These use double pointers, matricies sent to these
+ routines must be allocated with alloc_matrix
+
+ Derived from Numerical methods in C
+
+ When using these routines, you must allocate your matricies
+ with alloc_matrix (double pointers).
+
+ Example:
+
+ mat=alloc_matrix( rows, cols, sizeof(double));
+
+ (this routine will exit on error)
+
+ Using,
+ double mat[50][50];
+ is not the same because this method uses single pointers not
+ double pointers.
+
+ Individual elements can be access just like regular arrays
+ eg: mat[3][4] = 3.0;
+
+ Modifications by Christian Larouche: June 1994.
+*/
+
+/*******************************************************************
+ SUBROUTINE: COPY_MATRIX - Copies a matrix from a static double
+ Dimension array to a double pointer
+ array allocated with alloc_matrix().
+
+ Static arrarys are allocated as follows:
+ double matrix[20][20];
+ Double pointer arrays are allocated as follows;
+ double **matrix;
+
+ matrix = alloc_matrix( cols,rows,sizeof(double) );
+
+ warning: this routine will only work if rows and cols are the
+ same as the dimensioned values if src
+*/
+
+void copy_dmatrix( dest, src, rows, cols )
+ double **dest;
+ double *src;
+ int rows;
+ int cols;
+{
+ int i,j;
+
+ for( i=0; i<rows; ++i )
+ for( j=0; j<cols; ++j )
+ dest[i][j] = *(src + i*cols + j );
+}
+
+
+
+/**************************************************************************
+ SUBROUTINE: CLEAR_MATRIX - fills a matrix with zeros
+
+ INPUT: mat - matrix
+ rows - rows
+ cols - cols
+ size - size of each element (use sizeof)
+
+**************************************************************************/
+
+void clear_matrix( mat, rows, cols, size )
+ void **mat;
+ int rows;
+ int cols;
+ int size;
+{
+ unsigned int i,len;
+
+ len = cols * size;
+
+ for( i=0; (int) i<rows; ++i )
+ memset( (void *) mat[i], 0, len );
+}
+
+
+
+/**************************************************************************
+ SUBROUTINE: CLEAR_DMATRIX - fills a double precision matrix with zeros
+
+ INPUT: mat - matrix
+ rows - rows
+ cols - cols
+ size - size of each element (use sizeof)
+
+**************************************************************************/
+
+void clear_dmatrix(mat, rows, cols)
+ double **mat;
+ int rows;
+ int cols;
+{
+ unsigned int i,len;
+
+ len = cols * sizeof(double);
+
+ for( i=0; (int) i<rows; ++i )
+ memset( (void *) mat[i], 0, len );
+}
+
+
+
+/**************************************************************************
+ SUBROUTINE: CLEAR_VECTOR - Fills a vector with zeros
+
+ INPUT: vec - vector
+ num - number of elements
+ size - size of each element (use sizeof)
+
+**************************************************************************/
+
+void clear_vector( vec,num,size )
+ void *vec;
+ int num;
+ int size;
+{
+ memset( vec, 0, size*num );
+}
+
+
+/**************************************************************************
+
+ PRINT_DMATRIX SUBROUTINE (DOUBLE ONLY) - OUTPUTS MATRIX TO A FILE
+ INPUT: mat - dimension n,m
+ n - number of rows
+ m - number of columns
+ ffout - file pointer (use stdout for screen)
+ form - format (const char string)
+ eg. " %10.3lf"
+ if you are not sure use DEF_FMT
+ title - character string
+
+**************************************************************************/
+
+void print_dmatrix(mat,n,m,ffout,form,title)
+ double **mat;
+ int n;
+ int m;
+ FILE *ffout;
+ char *form;
+ char *title;
+{
+ int i,j;
+
+ fprintf(ffout,"\n %s\n\n",title);
+
+ for( i=0; i<n; i++)
+ {
+ for( j=0; j<m; j++)
+ fprintf(ffout,form, mat[i][j] );
+
+ fprintf(ffout,"\n");
+ }
+
+ fprintf(ffout,"\n");
+}
+
+
+
+/**************************************************************************
+
+ PRINT_DVECTOR SUBROUTINE (DOUBLE ONLY) - OUTPUTS VECTOR TO A FILE
+ INPUT: vec - dimension n
+ n - number of rows
+ ffout - file pointer (use stdout for screen)
+ form - format (const char string)
+ eg. " %10.3lf"
+ if you are not sure use DEF_FMT
+ title - character string
+
+**************************************************************************/
+
+void print_dvector(vec,n,ffout,form,title)
+ double *vec;
+ int n;
+ FILE *ffout;
+ char *form;
+ char *title;
+{
+ int i;
+
+ fprintf(ffout,"\n %s\n\n",title);
+
+ for( i=0; i<n; i++)
+ {
+ fprintf(ffout,form, vec[i] );
+ fprintf(ffout,"\n");
+ }
+ fprintf(ffout,"\n");
+}
+
+
+
+
+/********************************************************************
+
+ SUBROUTINE: MULT_DMATRIX - Multiplies two matrices together
+
+ INPUT: a_mat - first matrix
+ arows - number of rows in a
+ acols - number of columns in a
+ b_mat - seconds matrix
+ brows - number of rows in b
+ bcols - number of rows in b
+ c_mat - result matrix (must be dimentioned properly)
+ op - Operations
+ AA - a_mat * b_mat
+ ATA - a_matT * b_mat
+ AAT - a_mat * b_matT
+
+********************************************************************/
+
+
+int mult_dmatrix( a_mat, arow, acol, b_mat, brow, bcol, c_mat, op)
+ double **a_mat;
+ int arow;
+ int acol;
+ double **b_mat;
+ int brow;
+ int bcol;
+ double **c_mat;
+ int op;
+{
+ int i,j,k;
+
+ switch( op )
+ {
+ case AA:
+ if( acol != brow )
+ {
+ return FALSE;
+ }
+
+ clear_dmatrix( c_mat, arow, bcol );
+
+ for( i=0; i<arow; ++i )
+ {
+ for( j=0; j<bcol; ++j )
+ {
+ for( k=0; k<acol; ++k )
+ c_mat[i][j] += a_mat[i][k] * b_mat[k][j];
+ }
+ }
+
+ break;
+
+ case ATA:
+ if( arow != brow )
+ {
+ return FALSE;
+ }
+
+ clear_dmatrix( c_mat, acol, bcol );
+
+ for( i=0; i<acol; ++i )
+ {
+ for( j=0; j<bcol; ++j )
+ {
+ for( k=0; k<arow; ++k )
+ c_mat[i][j] += a_mat[k][i] * b_mat[k][j];
+ }
+ }
+
+ break;
+
+ case AAT:
+ if( acol != bcol )
+ {
+ return FALSE;
+ }
+
+ clear_dmatrix( c_mat, arow, brow );
+
+ for( i=0; i<arow; ++i )
+ {
+ for( j=0; j<brow; ++j )
+ {
+ for( k=0; k<acol; ++k )
+ c_mat[i][j] += a_mat[i][k] * b_mat[j][k];
+ }
+ }
+
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/********************************************************************
+
+ SUBROUTINE: MULT_DMATVEC - Multiplies a matrix by a vector
+
+ INPUT: a_mat - first matrix
+ arows - number of rows in a
+ acols - number of columns in a
+ b_vect - second vector
+ brows - number of rows in b (same as acols)
+ c_vect - result vector (must be dimenstioned arows)
+
+********************************************************************/
+
+int mult_dmatvec(a_mat, arow, acol, b_vect, brow, c_vect)
+ double **a_mat;
+ int arow;
+ int acol;
+ double *b_vect;
+ int brow;
+ double *c_vect;
+{
+ int i,j;
+
+ if( acol != brow )
+ {
+ return FALSE;
+ }
+
+ memset( (void *)c_vect, 0, (unsigned int) sizeof(double) * arow );
+
+ for( i=0; i<arow; ++i )
+ {
+ for( j=0; j<acol; ++j )
+ c_vect[i] += a_mat[i][j] * b_vect[j];
+ }
+
+ return TRUE;
+}
+
+
+/*********************************************************************
+ SUBROUTINE: INVERT_ERROR - Prints the error message of the
+ following invert_dmatrix routine
+
+ INPUT: error number
+ */
+
+int invert_error( num )
+ int num;
+{
+ switch( num )
+ {
+ case 0:
+ return TRUE;
+
+ case 1:
+ return FALSE;
+
+ case 2:
+ return FALSE;
+
+ case 3:
+ return FALSE;
+
+ case 4:
+ return FALSE;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/* *******************************************************************
+
+ SUBROUTINE: INVERT_DMATRIX
+
+ INVERT BY CHOLESKY DECOMP
+ RETURNS A DOUBLE POINTER TO INVERTED NORMALS
+ NORMALS ARE DESTROYED
+ BUT THE WHOLE DAMNED INVERSE IS RETURNED...
+
+ RETURNS DIAGONAL ON WHICH SIGULARITY OCCURRED OR ZERO
+ IF SUCCESSFULL
+
+ N IS THE SIZE OF THE SQUARE MATRIX IF THE OFFSET WERE 1
+ INSTEAD OF ZERO I.E. THE SIZE YOU WOULD DIMENSION IF FORTRAN
+
+ this inversion requires less memory than the above one, but
+ it is slightly slower (~1.5 times as slow)
+
+ RETURN: 0 - success
+ else one of the follwing errors will be printed - then exit
+ 1 - matrix not positive definite
+ 2 - Singularity
+ 3 - Can't sqrt a neg. number
+ 4 - Can't divide by zero
+
+
+*********************************************************************** */
+
+int invert_dmatrix(mat,n)
+ double **mat;
+ int n;
+{
+ int i, j, k;
+
+ if( !n ) return(0);
+
+ /* Check for Positive definiteness */
+ for( i = 0; i < n; i++)
+ {
+ if( mat[i][i] < 0.0) invert_error(1);
+ if( fabs(mat[i][i]) < 1.0e-12 ) invert_error(2);
+ }
+
+ /* Perform Choleski decomposition */
+ for( j = 0; j < n; j++)
+ {
+ for( k = 0; k < j; k++)
+ mat[j][j] -= mat[j][k]*mat[j][k];
+
+ if( mat[j][j] < 0.0 ) invert_error(3);
+ mat[j][j] = sqrt(mat[j][j]);
+
+ for( i = j+1; i < n; i++)
+ {
+ for( k = 0; k < j; k++)
+ mat[i][j] -= mat[i][k]*mat[j][k];
+
+ if( fabs( mat[j][j] ) < 1.0e-12 ) invert_error(4);
+ mat[i][j] /= mat[j][j];
+ }
+ }
+
+ /* Inversion of lower trianglar matrix */
+ for( j = 0; j < n; j++)
+ {
+ mat[j][j] = 1.0/mat[j][j];
+
+ for( i = j + 1; i < n; i++)
+ {
+ mat[i][j] = -mat[i][j]*mat[j][j]/mat[i][i];
+ for( k = j + 1; k < i; k++)
+ mat[i][j] -= mat[i][k]*mat[k][j]/mat[i][i];
+ }
+ }
+
+ /* Construction of lower trianglar inverse matrix */
+ for( j = 0; j < n; j++)
+ {
+ for( i = j; i < n; i++)
+ {
+ mat[i][j] = mat[i][i]*mat[i][j];
+ for( k = i + 1; k < n; k++)
+ mat[i][j] += mat[k][i]*mat[k][j];
+ }
+ }
+
+ /* fill upper diagonal */
+ for( i = 1; i < n; i++ )
+ {
+ for( j = 0; j < i; j++ )
+ mat[j][i] = mat[i][j];
+ }
+
+ return(0);
+}
+/* End Invert*/
+
+
+
+
+
+
+/***********************************************************
+
+ ALLOC_MATRIX : ALLOCATES A MATRIX
+
+ range: rows & cols
+
+ exits IF NOT ENOUGH MEMORY
+
+ From Numerical Recipes in C
+
+ alloc_matrix first allocates an array of pointers (one for
+ each row), then for each row pointer it allocates an array
+ of double values (cols).
+
+ size - size of each element (sizeof(double))
+
+
+************************************************************/
+
+
+double **alloc_dmatrix( rows, cols )
+ int rows;
+ int cols;
+{
+ unsigned i,j;
+ double **m;
+
+ if( !rows || !cols ) {
+ return NULL;
+ }
+
+ m = (double **) malloc((unsigned) rows*sizeof(double *));
+ if( m==NULL ) {
+ return NULL;
+ }
+
+ for ( i=0; (int) i<rows; i++ ) {
+ m[i] = (double *) malloc(sizeof(double)*cols);
+
+ if( m[i]==NULL ) {
+ for(j=0;j<i;j++)
+ free(m[j]);
+ free(m);
+ return NULL;
+ }
+ }
+
+ return m;
+}
+
+/***********************************************************
+
+ ALLOC_MATRIX_FLOAT : ALLOCATES A MATRIX OF FLOAT ELEMENTS
+
+ range: rows & cols
+
+ exits IF NOT ENOUGH MEMORY
+
+ From Numerical Recipes in C
+
+ alloc_matrix first allocates an array of pointers (one for
+ each row), then for each row pointer it allocates an array
+ of float values (cols).
+
+ size - size of each element (sizeof(float))
+
+************************************************************/
+
+
+float **alloc_matrix_float( rows, cols)
+ int rows;
+ int cols;
+{
+ unsigned i,j;
+ float **m;
+
+ if( !rows || !cols )
+ {
+ return NULL;
+ }
+
+ m = (float **) malloc((unsigned) rows*sizeof(float *));
+ if( m==NULL )
+ {
+ return NULL;
+ }
+
+ for ( i=0; (int) i<rows; i++ )
+ {
+ m[i] = (float *) malloc(sizeof(float)*cols);
+
+ if( m[i]==NULL )
+ {
+ for(j=0;j<i;j++)
+ free(m[j]);
+ free(m);
+ return NULL;
+ }
+ }
+
+ return m;
+}
+
+
+
+/***********************************************************
+
+ ALLOC_DMATRIX : ALLOCATES A DOUBLE MATRIX
+
+ range: rows & cols
+
+ exits IF NOT ENOUGH MEMORY
+
+ From Numerical Recipes in C
+
+ alloc_matrix first allocates an array of pointers (one for
+ each row), then for each row pointer it allocates an array
+ of double values (cols).
+
+ size - size of each element (sizeof(double))
+
+************************************************************/
+
+
+void **alloc_matrix( rows, cols, size )
+ int rows;
+ int cols;
+ int size;
+{
+ unsigned i,j;
+ void **m;
+
+ if( !rows || !cols || !size )
+ {
+ return NULL;
+ }
+
+ m = (void **) malloc((unsigned) rows*sizeof(void *));
+ if( m==NULL )
+ {
+ return NULL;
+ }
+
+ for ( i=0; (int) i<rows; i++ )
+ {
+ m[i] = (void *) malloc(size*cols);
+
+ if( m[i]==NULL )
+ {
+ for(j=0;j<i;j++)
+ free(m[j]);
+ free(m);
+ return NULL;
+ }
+ }
+
+ return m;
+}
+
+/************************************************************
+ ALLOC_MATRIX_CHAR : ALLOCATES A CHAR MATRIX
+
+ range: rows & cols
+
+ exits IF NOT ENOUGH MEMORY
+
+ From Numerical Recipes in C
+
+ alloc_matrix first allocates an array of pointers (one for
+ each row), then for each row pointer it allocates an array
+ of char values (cols).
+
+ size - size of each element (sizeof(double))
+
+************************************************************/
+
+
+unsigned char **alloc_matrix_char( rows, cols )
+ int rows;
+ int cols;
+{
+ unsigned i,j;
+ unsigned char **m;
+
+ if( !rows || !cols )
+ {
+ return NULL;
+ }
+
+ m = (unsigned char **) malloc((unsigned) rows*sizeof(unsigned char *));
+ if( m==NULL )
+ {
+ return NULL;
+ }
+
+ for ( i=0; (int) i<rows; i++ )
+ {
+ m[i] = (unsigned char *) malloc(sizeof(unsigned char)*cols);
+
+ if( m[i]==NULL )
+ {
+ for(j=0;j<i;j++)
+ free(m[j]);
+ free(m);
+ return NULL;
+ }
+ }
+
+ return m;
+}
+
+
+
+/******************************************************************
+
+ FREE_MATRIX : FREES A MATRIX ALLOCATED WITH ALLOC_MATRIX
+
+ From: Numerical Recipes in C
+
+******************************************************************/
+
+void free_matrix(m, rows)
+ void **m; int rows;
+{
+ int i;
+
+ for ( i=rows-1; i>=0; i-- )
+ free( m[i] );
+
+ if( m )
+ free( m );
+}
+
+/******************************************************************
+
+ FREE_MATRIX_CHAR : FREES A MATRIX ALLOCATED WITH ALLOC_MATRIX
+
+ From: Numerical Recipes in C
+
+******************************************************************/
+
+unsigned char free_matrix_char(m,rows)
+ unsigned char **m;
+ int rows;
+{
+ int i;
+
+ for ( i=rows-1; i>=0; i-- )
+ free( m[i] );
+
+ if( m ) free( m );
+
+ return 0;
+}
+
+/******************************************************************
+
+ FREE_DMATRIX : FREES A DOUBLE MATRIX ALLOCATED WITH ALLOC_MATRIX
+
+ From: Numerical Recipes in C
+
+******************************************************************/
+
+void free_dmatrix( m, rows)
+ double **m; int rows;
+{
+ int i;
+
+ for ( i=rows-1; i>=0; i-- )
+ free( m[i] );
+
+ if( m )
+ free( m );
+}
+
+/******************************************************************
+
+ FREE_MATRIX_FLOAT : FREES A FLOAT MATRIX ALLOCATED WITH
+ ALLOC_MATRIX_FLOAT
+
+ From: Numerical Recipes in C
+
+******************************************************************/
+
+void free_matrix_float( m, rows)
+ float **m;
+ int rows;
+{
+ int i;
+
+ for ( i=rows-1; i>=0; i-- )
+ free( m[i] );
+
+ if( m ) free( m );
+}
+
+
+
+/******************************************************************
+ SUBROUTINE: ALLOC_VECTOR - Allocates a vector
+
+ INPUT: num - number of elements
+ size - size of each element
+
+ OUTPUT: Pointer to vector
+*/
+
+void *alloc_vector(num, size)
+ int num;
+ int size;
+{
+ void *v;
+
+ if( !num || !size )
+ {
+ return FALSE;
+ }
+
+ if( (v=malloc(num*size)) == NULL )
+ {
+ return FALSE;
+ }
+
+ return(v);
+}
+
+
+/******************************************************************
+ SUBROUTINE: ALLOC_VECTOR_CHAR - Allocates a vector
+
+ INPUT: num - number of elements
+ size - size of each element
+
+ OUTPUT: Pointer to vector
+*/
+
+unsigned char *alloc_vector_char( num, size)
+ int num;
+ int size;
+{
+ unsigned char *v;
+
+ if( !num || !size )
+ {
+ return FALSE;
+ }
+
+ if( (v=(unsigned char *)malloc(num*size)) == NULL )
+ {
+ return FALSE;
+ }
+
+ return(v);
+}
+
+
+/******************************************************************
+ SUBROUTINE: ALLOC_VECTOR_INT - Allocates a vector
+
+ INPUT: num - number of elements
+ size - size of each element
+
+ OUTPUT: Pointer to vector
+*/
+
+unsigned int *alloc_vector_int(num, size)
+ int num;
+ int size;
+{
+ unsigned int *v;
+
+ if( !num || !size )
+ {
+ return FALSE;
+ }
+
+ if( (v=(unsigned int *)malloc(num*size)) == NULL )
+ {
+ return FALSE;
+ }
+
+ return(v);
+}
+
+/******************************************************************
+ SUBROUTINE: FREE_VECTOR - Frees the memory of a vector
+
+ INPUT: v - pointer to vector
+*/
+
+void free_vector(v)
+ void *v;
+{
+ free(v);
+}
+
+/******************************************************************
+ SUBROUTINE: FREE_VECTOR_CHAR - Frees the memory of a vector
+
+ INPUT: v - pointer to vector
+*/
+
+unsigned char free_vector_char( v )
+ unsigned char *v;
+{
+ free(v);
+ return 0;
+}
+
+/******************************************************************
+ SUBROUTINE: FREE_VECTOR_INT - Frees the memory of a vector
+
+ INPUT: v - pointer to vector
+*/
+
+unsigned int free_vector_int( v )
+ unsigned int *v;
+{
+ free(v);
+ return 0;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/gmath.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/gmath.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/gmath.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Double precision matrix inverse, allocation, multiplication,
+ * and print routines.
+ *
+ ******************************************************************************
+ * Derived from Numerical methods in C.
+ *
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: gmath.h,v $
+ * Revision 1.2 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+/* GMATUTIL.H - Header file for GMATUTIL.C
+
+ Include this file when using matrix routines
+*/
+
+#include <stdio.h> /* for FILE structure */
+
+/* Use these for sending to matrix multiplication routines */
+#define AA 0 /* A * A */
+#define ATA 1 /* AT * A Where: AT = transpose(A) */
+#define AAT 2 /* A * AT */
+
+#define DEF_FMT " %9.2le" /* Useful format for mat-print */
+
+
+
+/* function prototypes */
+void copy_dmatrix( double **dest, double *src, int rows, int cols );
+void clear_matrix( void **mat, int rows, int cols, int size );
+void clear_dmatrix( double **mat, int rows, int cols );
+void clear_vector( void *vec, int num, int size );
+void print_dmatrix(double **mat,int n,int m,FILE *ffout,char *form,char *title );
+void print_dvector(double *vec,int n,FILE *ffout,char *form,char *title );
+int mult_dmatrix( double **a_mat, int arow, int acol,
+ double **b_mat, int brow, int bcol,
+ double **c_mat, int op );
+int mult_dmatvec( double **a_mat, int arow, int acol,
+ double *b_vect, int brow, double *c_vect );
+int invert_error( int num );
+int invert_dmatrix( double **mat, int n);
+void **alloc_matrix( int rows, int cols, int size );
+double **alloc_dmatrix( int rows, int cols );
+
+float **alloc_matrix_float( int rows, int cols );
+void free_matrix_float( float **m, int rows );
+
+void free_matrix( void **m, int rows );
+void free_dmatrix( double **m, int rows );
+void *alloc_vector( int num, int size );
+void free_vector( void *v );
+
+unsigned char **alloc_matrix_char( int rows, int cols );
+unsigned char free_matrix_char( unsigned char **m, int rows );
+unsigned char *alloc_vector_char( int num, int size );
+unsigned char free_vector_char( unsigned char *v );
+unsigned int *alloc_vector_int( int num, int size );
+unsigned int free_vector_int( unsigned int *v );
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,61 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = ogdi
+
+ifeq ($(TARGET),Linux)
+TARGETGEN=$(SHRDGEN)
+else
+TARGETGEN=$(DYNAGEN)
+endif
+
+SOURCES = ecs_dyna.c ecsregex.c ecssplit.c \
+ ecsassoc.c ecshash.c ecstile.c server.c ecsdist.c \
+ ecslist.c ecsinfo.c ecsgeo.c ecs_xdr.c ecs_xdrz.c\
+ matrix.c client.c ecs_capabilities.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) \
+ $(GRASS_INCLUDE) $(ZLIB_INCLUDE) $(PROJ_INCLUDE) \
+ $(EXPAT_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS) -DMODULES_PATH="\"$(INST_LIB)/ogdi/\""
+
+LINK_LIBS= $(RPC_LINKLIB) $(ZLIB_LINKLIB) $(EXPAT_LINKLIB) $(WIN_LINKLIB) \
+ $(PROJ_STATICLIB) $(MATH_LINKLIB)
+
+EXTRA_INSTALL_TARGETS = install-so-link
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR ecs_xdr.c
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+ $(COPY_LOCAL)
+
+#
+# Because the RPCGEN process doesn't work too well on many
+# platforms we disable it by default, and make people do a "make rpcgen"
+# to regenerate ecs_xdr.c explicitly.
+#
+#ecs_xdr.c: ../include/ecs.x
+
+rpcgen:
+ -$(RM) -f ecs.x
+ -$(RM) -f $@.raw
+ -$(RM) -f $@
+ $(FILECOPY) ../include/ecs.x ecs.x
+ rpcgen -C -c -o $@.raw ecs.x
+ perl ../scripts/xdr_clean.pl -o $@ $@.raw
+ $(RM) -f ecs.x
+
+clean: default-clean
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/matrix.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/matrix.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/matrix.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,233 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Double precision matrix inverse, allocation, multiplication,
+ * and print routines.
+ *
+ ******************************************************************************
+ */
+#include <math.h>
+
+#include "ecs.h"
+#include "matrix.h"
+
+#define EPSILON 1.0e-16
+
+/*
+ * initialize values within a matrix.
+ */
+void mat_init(double **matrix, int height, int width)
+{
+ int i=0, j=0;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ matrix[i][j]=0;
+ }
+ }
+}
+
+/**
+ * mat_mult_direct - multiply directly two 2D matrixes
+ *
+ */
+void mat_mul_direct (matrix_a, height_a, width_a, matrix_b, height_b, width_b, matrix_result)
+ double **matrix_a;
+ int height_a;
+ int width_a;
+ double **matrix_b;
+ int height_b;
+ int width_b;
+ double **matrix_result;
+{
+
+ /* initialize loop iterators */
+ int i=0, j=0, k=0;
+
+ /* compute multiply of each elements into destination matrix */
+ for ( i = 0 ; i< height_a; i++ )
+ for ( j = 0 ; j< width_b; j++ )
+ for ( k = 0 ; k< width_a; k++ )
+ matrix_result[i][j] += matrix_a[i][k]*matrix_b[k][j];
+ return;
+}
+
+/**
+ * mat_mult_traspose - multiply traspose of first 2D matrix
+ * transposed with second 2D matrix
+ */
+void mat_mul_transposed (matrix_a, height_a, width_a, matrix_b, height_b, width_b, matrix_result)
+ double **matrix_a;
+ int height_a;
+ int width_a;
+ double **matrix_b;
+ int height_b;
+ int width_b;
+ double **matrix_result;
+{
+ /* initialize loop iterators */
+ int i=0, j=0, k=0;
+
+ /* compute multiply of each elements into destination matrix */
+ for ( i = 0 ; i< height_a; i++ )
+ for ( j = 0 ; j< width_b; j++ )
+ for ( k = 0 ; k< width_a; k++ )
+ matrix_result[i][j] += matrix_a[i][k]*matrix_b[j][k];
+ return;
+}
+
+/*
+ * inverse: invert a square matrix (puts pivot elements on main diagonal).
+ * returns arg2 as the inverse of arg1.
+ *
+ * This routine is based on a routine found in Andrei Rogers, "Matrix
+ * Methods in Urban and Regional Analysis", (1971), pp. 143-153.
+ */
+int mat_inverse (double **matrix,int n)
+{
+ int i, j, k, l, ir=0, ic=0 ;
+ int ipivot[n], itemp[n][2];
+ double pivot[n], t;
+ double fabs();
+
+ /* initialization */
+ for (i = 0; i < n; i++)
+ ipivot[i] = 0;
+
+ for (i = 0; i < n; i++)
+ {
+ t = 0.0; /* search for pivot element */
+
+ for (j = 0; j < n; j++)
+ {
+ if (ipivot[j] == 1) /* found pivot */
+ continue;
+
+ for (k = 0; k < n; k++)
+ switch (ipivot[k]-1)
+ {
+ case 0:
+ break;
+ case -1:
+ if (fabs (t) < fabs (matrix[j][k]))
+ {
+ ir = j;
+ ic = k;
+ t = matrix[j][k];
+ }
+ break;
+ case 1:
+ return (-1);
+ break;
+ default: /* shouldn't get here */
+ return (-1);
+ break;
+ }
+ }
+
+ ipivot[ic] += 1;
+ if (ipivot[ic] > 1) /* check for dependency */
+ {
+ return (-1);
+ }
+
+ /* interchange rows to put pivot element on diagonal */
+ if (ir != ic)
+ for (l = 0; l < n; l++)
+ {
+ t = matrix[ir][l];
+ matrix[ir][l] = matrix[ic][l];
+ matrix[ic][l] = t;
+ }
+
+ itemp[i][0] = ir;
+ itemp[i][1] = ic;
+ pivot[i] = matrix[ic][ic];
+
+ /* check for zero pivot */
+ if (fabs (pivot[i]) < EPSILON)
+ {
+ return (-1);
+ }
+
+ /* divide pivot row by pivot element */
+ matrix[ic][ic] = 1.0;
+
+ for (j = 0; j < n; j++)
+ matrix[ic][j] /= pivot[i];
+
+ /* reduce nonpivot rows */
+ for (k = 0; k < n; k++)
+ if (k != ic)
+ {
+ t = matrix[k][ic];
+ matrix[k][ic] = 0.0;
+
+ for (l = 0; l < n; l++)
+ matrix[k][l] -= (matrix[ic][l] * t);
+ }
+ }
+
+ /* interchange columns */
+ for (i = 0; i < n; i++)
+ {
+ l = n - i - 1;
+ if (itemp[l][0] == itemp[l][1])
+ continue;
+
+ ir = itemp[l][0];
+ ic = itemp[l][1];
+
+ for (k = 0; k < n; k++)
+ {
+ t = matrix[k][ir];
+ matrix[k][ir] = matrix[k][ic];
+ matrix[k][ic] = t;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * allocate memory for a 2D matrix with type of double elements.
+ * returns NULL on failure.
+ */
+double **mat_malloc(int height,int width)
+{
+ unsigned i=0;
+ double **matrix=NULL;
+
+ matrix = (double **)malloc(height*sizeof(double *));
+ if(matrix == NULL) {
+ printf("Allocating memory for matrix computation pointers failed. \n");
+ free(matrix);
+ exit(1);
+ }
+
+ for (i=0;i < width;i++) {
+ matrix[i] = (double *)malloc(width * sizeof(double));
+ if(matrix == NULL) {
+ printf("Allocating memory for matrix data failed. \n");
+ free(matrix);
+ exit(1);
+ }
+ }
+ /* initialize values in matrix */
+ mat_init(matrix,height,width);
+
+ /* matrix created, return it */
+ return matrix;
+}
+
+/*
+ * unallocate memory for a 2D matrix.
+ */
+void mat_free(double **matrix, int height)
+{
+ int i=0;
+ for (i=0; i<height; i++)
+ free(matrix[i]);
+ /* free root on witdh > 1 type matrix only.*/
+ if (matrix)
+ free(matrix);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/matrix.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/matrix.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/matrix.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,26 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Double precision matrix inverse, allocation, multiplication,
+ * and print routines.
+ *
+ ******************************************************************************
+ */
+
+
+/* linear algebra matrix routines */
+int mat_inverse(double **matrix, int n);
+
+void mat_mul_direct (double **matrix_a,int height_a,int width_a,
+ double **matrix_b,int height_b,int width_b,
+ double **matrix_result);
+
+void mat_mul_transposed (double **matrix_a,int height_a,int width_a,
+ double **matrix_b,int height_b,int width_b,
+ double **matrix_result);
+
+/* matrix memory allocation routine */
+
+double **mat_malloc(int heigth, int width);
+
+void mat_free(double **matrix, int height);
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ogdi.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ogdi.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/ogdi.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,155 @@
+EXPORTS
+ cln_CreateClient
+ cln_DestroyClient
+ cln_SelectLayer
+ cln_ReleaseLayer
+ cln_BroadCloseLayers
+ cln_SelectRegion
+ cln_SelectMask
+ cln_UnSelectMask
+ cln_GetDictionary
+ cln_GetAttributesFormat
+ cln_GetNextObject
+ cln_GetRasterInfo
+ cln_GetObject
+ cln_GetObjectIdFromCoord
+ cln_UpdateDictionary
+ cln_GetGlobalBound
+ cln_SetServerLanguage
+ cln_GetServerProjection
+ cln_SetServerProjection
+ cln_SetClientProjection
+ cln_SetTclProc
+ cln_GetTclProc
+ cln_GetClientIdFromURL
+ cln_GetURLList
+ cln_SetRegionCaches
+ cln_LoadCache
+ cln_ReleaseCache
+ cln_SetCompression
+ EcsRegComp
+ EcsRegExec
+ EcsRegError
+ EcsGetRegError
+ ecs_DistanceObject
+ ecs_DistanceObjectWithTolerance
+ ecs_SetTolerance
+ ecs_DistanceMBR
+ ecs_DistanceSegment
+ ecs_SetError
+ ecs_SetSuccess
+ ecs_AdjustResult
+ ecs_SetGeoRegion
+ ecs_SetText
+ ecs_AddText
+ ecs_SetRasterInfo
+ ecs_AddRasterInfoCategory
+ ecs_SetObjAttributeFormat
+ ecs_AddAttributeFormat
+ ecs_SetGeomPoint
+ ecs_SetGeomText
+ ecs_SetGeomLine
+ ecs_SetGeomArea
+ ecs_SetGeomAreaRing
+ ecs_SetGeomMatrix
+ ecs_SetGeomMatrixWithArray
+ ecs_SetGeomImage
+ ecs_SetGeomImageWithArray
+ ecs_SetObjectId
+ ecs_SetObjectAttr
+ ecs_CleanUp
+ ecs_CleanUpObject
+ ecs_ResultInit
+ ecs_CalcObjectMBR
+ ecs_freeSplitURL
+ ecs_GetRegex
+ ecs_SplitURL
+ ecs_Backslash
+ ecs_FindElement
+ ecs_CopyAndCollapse
+ ecs_SplitList
+ svr_CreateServer
+ svr_DestroyServer
+ svr_SelectLayer
+ svr_ReleaseLayer
+ svr_SelectRegion
+ svr_GetDictionary
+ svr_GetAttributesFormat
+ svr_GetNextObject
+ svr_GetRasterInfo
+ svr_GetObject
+ svr_GetObjectIdFromCoord
+ svr_UpdateDictionary
+ svr_GetServerProjection
+ svr_GetGlobalBound
+ svr_SetServerLanguage
+ svr_SetServerProjection
+ svr_SetRasterConversion
+ svr_CloseLayer
+ svr_BroadCloseLayers
+ ecs_SetLayer
+ ecs_GetLayer
+ ecs_FreeLayer
+ ecs_RemoveDir
+ ecs_GetDefaultInfo
+ xdr_ecs_Family
+ xdr_ecs_Region
+ xdr_ecs_Coordinate
+ xdr_ecs_FeatureRing
+ xdr_ecs_Area
+ xdr_ecs_Line
+ xdr_ecs_Point
+ xdr_ecs_Matrix
+ xdr_ecs_Image
+ xdr_ecs_Text
+ xdr_ecs_Node
+ xdr_ecs_Edge
+ xdr_ecs_TopoLevel
+ xdr_ecs_Face
+ xdr_ecs_AreaPrim
+ xdr_ecs_Geometry
+ xdr_ecs_Object
+ xdr_ecs_AttributeFormat
+ xdr_ecs_ObjAttribute
+ xdr_ecs_ObjAttributeFormat
+ xdr_ecs_Category
+ xdr_ecs_RasterInfo
+ xdr_ecs_ResultType
+ xdr_ecs_ResultUnion
+ xdr_ecs_Result
+ xdr_ecs_LayerSelection
+ xdr_ecs_RasterConversion
+ xdr_ecs_Compression
+ xdr_ecs_ProxyCreateServer
+ ecs_begin_ellipsoid_polygon_area
+ ecs_planimetric_polygon_area
+ ecs_ellipsoid_polygon_area
+ ecs_geodesic_distance
+ ecs_distance_meters
+ ecs_CalculateCentroid
+ ecs_CopyObject
+ ecs_CopyResult
+ ecs_FreeObject
+ pj_free
+ pj_init
+ pj_inv
+ pj_fwd
+ rtodms
+ ecs_InitHashTable
+ ecs_DeleteHashEntry
+ ecs_DeleteHashTable
+ ecs_FirstHashEntry
+ ecs_NextHashEntry
+ ecs_HashStats
+ set_rtodms
+ ecs_TileInitialize
+ ecs_TileGetLine
+ ecs_TileClearBuffer
+ cln_BlockOGDI
+ cln_UnBlockOGDI
+ cln_GetVersion
+ cln_CheckExtension
+ cln_GetLayerCapabilities
+ cln_LoadCapabilities
+ ecs_GetRGBFromPixel
+ ecs_GetPixelFromRGB
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/opendir.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/opendir.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/opendir.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,302 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Implementation of BSD directory routines for MS-DOS.
+ *
+ ******************************************************************************
+ * @(#)dir.c 1.4 87/11/06 Public Domain.
+ *
+ * A public domain implementation of BSD directory routines for
+ * MS-DOS. Written by Michael Rendell ({uunet,utai}michael at garfield),
+ * August 1897
+ * Ported to OS/2 by Kai Uwe Rommel
+ * December 1989, February 1990
+ * Ported to Windows NT 22 May 91
+ * other mods Summer '92 brianmo at microsoft.com
+ * opendirx() was horribly written, very inefficient, and did not take care
+ * of all cases. It is still not too clean, but it is far more efficient.
+ * Changes made by Gordon Chaffee (chaffee at bugs-bunny.cs.berkeley.edu)
+ ******************************************************************************
+ *
+ * $Log: opendir.c,v $
+ * Revision 1.2 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+/*
+ dir.c for MS-DOS by Samuel Lam <skl at van-bc.UUCP>, June/87
+*/
+
+/* #ifdef WIN32 */
+
+
+#ifdef _WINDOWS
+
+/*Includes:
+ * crt
+ */
+#include <windows.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "opendir.h"
+
+#define stat _stat
+
+/*
+ * NT specific
+ */
+#include <stdio.h>
+
+/*
+ * random typedefs
+ */
+#define HDIR HANDLE
+#define HFILE HANDLE
+#define PHFILE PHANDLE
+
+/*
+ * local functions
+ */
+static char *getdirent(char *);
+static void free_dircontents(struct _dircontents *);
+
+static HDIR FindHandle;
+static WIN32_FIND_DATA FileFindData;
+
+static struct dirent dp;
+
+DIR *opendirx(char *name, char *pattern)
+{
+ struct stat statb;
+ DIR *dirp;
+ char c;
+ char *s;
+ struct _dircontents *dp;
+ int len;
+ int unc;
+ char path[ OFS_MAXPATHNAME ];
+ register char *ip, *op;
+
+ for (ip = name, op = path; ; op++, ip++) {
+ *op = *ip;
+ if (*ip == '\0') {
+ break;
+ }
+ }
+ len = ip - name;
+ if (len > 0) {
+ unc = ((path[0] == '\\' || path[0] == '/') &&
+ (path[1] == '\\' || path[1] == '/'));
+ c = path[len - 1];
+ if (unc) {
+ if (c != '\\' && c != '/') {
+ path[len] = '/';
+ len++;
+ path[len] ='\0';
+ }
+ } else {
+ if ((c == '\\' || c == '/') && (len > 1)) {
+ len--;
+ path[len] = '\0';
+
+ if (path[len - 1] == ':' ) {
+ path[len] = '/'; len++;
+ path[len] = '.'; len++;
+ path[len] = '\0';
+ }
+ } else if (c == ':' ) {
+ path[len] = '.';
+ len++;
+ path[len] ='\0';
+ }
+ }
+ } else {
+ unc = 0;
+ path[0] = '.';
+ path[1] = '\0';
+ len = 1;
+ }
+
+ if (stat(path, &statb) < 0 || (statb.st_mode & S_IFMT) != S_IFDIR) {
+ return NULL;
+ }
+
+ dirp = malloc(sizeof(DIR));
+ if (dirp == NULL) {
+ return dirp;
+ }
+
+ c = path[len - 1];
+ if (c == '.' ) {
+ if (len == 1) {
+ len--;
+ } else {
+ c = path[len - 2];
+ if (c == '\\' || c == ':') {
+ len--;
+ } else {
+ path[len] = '/';
+ len++;
+ }
+ }
+ } else if (!unc && ((len != 1) || (c != '\\' && c != '/'))) {
+ path[len] = '/';
+ len++;
+ }
+ strcpy(path + len, pattern);
+
+ dirp -> dd_loc = 0;
+ dirp -> dd_contents = dirp -> dd_cp = NULL;
+
+ if ((s = getdirent(path)) == NULL) {
+ return dirp;
+ }
+
+ do
+ {
+ if (((dp = malloc(sizeof(struct _dircontents))) == NULL) ||
+ ((dp -> _d_entry = malloc(strlen(s) + 1)) == NULL) )
+ {
+ if (dp)
+ free(dp);
+ free_dircontents(dirp -> dd_contents);
+
+ return NULL;
+ }
+
+ if (dirp -> dd_contents)
+ dirp -> dd_cp = dirp -> dd_cp -> _d_next = dp;
+ else
+ dirp -> dd_contents = dirp -> dd_cp = dp;
+
+ strcpy(dp -> _d_entry, s);
+ dp -> _d_next = NULL;
+
+ }
+ while ((s = getdirent(NULL)) != NULL);
+
+ dirp -> dd_cp = dirp -> dd_contents;
+ return dirp;
+}
+
+DIR *opendir(char *name)
+{
+ return opendirx(name, "*");
+}
+
+void closedir(DIR * dirp)
+{
+ free_dircontents(dirp -> dd_contents);
+ free(dirp);
+}
+
+struct dirent *readdir(DIR * dirp)
+{
+ /* static struct dirent dp; */
+ if (dirp -> dd_cp == NULL)
+ return NULL;
+
+ /*strcpy(dp.d_name,dirp->dd_cp->_d_entry); */
+
+ dp.d_name = dirp->dd_cp->_d_entry;
+
+ dp.d_namlen = dp.d_reclen =
+ strlen(dp.d_name);
+
+ dp.d_ino = dirp->dd_loc+1; /* fake the inode */
+
+ dirp -> dd_cp = dirp -> dd_cp -> _d_next;
+ dirp -> dd_loc++;
+
+
+ return &dp;
+}
+
+void seekdir(DIR * dirp, long off)
+{
+ long i = off;
+ struct _dircontents *dp;
+
+ if (off >= 0)
+ {
+ for (dp = dirp -> dd_contents; --i >= 0 && dp; dp = dp -> _d_next);
+
+ dirp -> dd_loc = off - (i + 1);
+ dirp -> dd_cp = dp;
+ }
+}
+
+
+long telldir(DIR * dirp)
+{
+ return dirp -> dd_loc;
+}
+
+static void free_dircontents(struct _dircontents * dp)
+{
+ struct _dircontents *odp;
+
+ while (dp)
+ {
+ if (dp -> _d_entry)
+ free(dp -> _d_entry);
+
+ dp = (odp = dp) -> _d_next;
+ free(odp);
+ }
+}
+/* end of "free_dircontents" */
+
+static char *getdirent(char *dir)
+{
+ int got_dirent;
+
+ if (dir != NULL)
+ { /* get first entry */
+ if ((FindHandle = FindFirstFile( dir, &FileFindData ))
+ == (HDIR)0xffffffff)
+ {
+ return NULL;
+ }
+ got_dirent = 1;
+ }
+ else /* get next entry */
+ got_dirent = FindNextFile( FindHandle, &FileFindData );
+
+ if (got_dirent)
+ return FileFindData.cFileName;
+ else
+ {
+ FindClose(FindHandle);
+ return NULL;
+ }
+}
+/* end of getdirent() */
+
+struct passwd * _cdecl
+getpwnam(char *name)
+{
+ return NULL;
+}
+
+struct passwd * _cdecl
+getpwuid(int uid)
+{
+ return NULL;
+}
+
+int
+getuid()
+{
+ return 0;
+}
+
+void _cdecl
+endpwent(void)
+{
+}
+
+#endif /* WINDOWS */
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/opendir.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/opendir.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/opendir.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Implementation of BSD directory routines for MS-DOS.
+ *
+ ******************************************************************************
+ * @(#) dirent.h 2.0 17 Jun 91 Public Domain.
+ *
+ * A public domain implementation of BSD directory routines for
+ * MS-DOS. Written by Michael Rendell ({uunet,utai}michael at garfield),
+ * August 1987
+ *
+ * Enhanced and ported to OS/2 by Kai Uwe Rommel; added scandir() prototype
+ * December 1989, February 1990
+ * Change of MAXPATHLEN for HPFS, October 1990
+ *
+ * Unenhanced and ported to Windows NT by Bill Gallagher
+ * 17 Jun 91
+ * changed d_name to char * instead of array, removed non-std extensions
+ *
+ * Cleanup, other hackery, Summer '92, Brian Moran , brianmo at microsoft.com
+ ******************************************************************************
+ *
+ * $Log: opendir.h,v $
+ * Revision 1.2 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#ifndef _DIRENT
+#define _DIRENT
+
+#ifndef _WINDOWS
+#include <sys/dir.h>
+
+#define dirent direct
+
+#else
+
+#include <direct.h>
+
+struct dirent
+{
+ long d_ino; /* a bit of a farce */
+ short d_reclen; /* more farce */
+ short d_namlen; /* length of d_name */
+ char *d_name;
+};
+
+struct _dircontents
+{
+ char *_d_entry;
+ struct _dircontents *_d_next;
+};
+
+typedef struct _dirdesc
+{
+ int dd_id; /* uniquely identify each open directory*/
+ long dd_loc; /* where we are in directory entry */
+ struct _dircontents *dd_contents; /* pointer to contents of dir */
+ struct _dircontents *dd_cp; /* pointer to current position */
+}
+DIR;
+
+extern DIR *opendir(char *);
+extern struct dirent *readdir(DIR *);
+extern void seekdir(DIR *, long);
+extern long telldir(DIR *);
+extern void closedir(DIR *);
+#define rewinddir(dirp) seekdir(dirp, 0L)
+
+#endif /* _WINDOWS */
+#endif /* _DIRENT */
+
+/* end of dirent.h */
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/server.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/server.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/c-api/server.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,3395 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Control to dynamic geographic database driver.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: server.c,v $
+ * Revision 1.9 2007/02/12 21:01:48 cbalint
+ * Fix win32 target. It build and works now. (tested with VC6)
+ *
+ * Revision 1.8 2007/02/12 16:09:06 cbalint
+ * * Add hook macros for all GNU systems, hook fread,fwrite,read,fgets.
+ * * Handle errors in those macro, if there are any.
+ * * Fix some includes for GNU systems.
+ * * Reduce remaining warnings, now we got zero warnings with GCC.
+ *
+ * Modified Files:
+ * config/unix.mak contrib/ogdi_import/dbfopen.c
+ * contrib/ogdi_import/shapefil.h contrib/ogdi_import/shpopen.c
+ * ogdi/c-api/ecs_xdr.c ogdi/c-api/ecsinfo.c ogdi/c-api/server.c
+ * ogdi/datum_driver/canada/nadconv.c ogdi/driver/adrg/adrg.c
+ * ogdi/driver/adrg/adrg.h ogdi/driver/adrg/object.c
+ * ogdi/driver/adrg/utils.c ogdi/driver/rpf/rpf.h
+ * ogdi/driver/rpf/utils.c ogdi/gltpd/asyncsvr.c
+ * ogdi/glutil/iofile.c vpflib/vpfprim.c vpflib/vpfspx.c
+ * vpflib/vpftable.c vpflib/vpftidx.c vpflib/xvt.h
+ *
+ * Revision 1.7 2001/04/09 15:04:34 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+#ifdef _WINDOWS
+#include <string.h>
+#include <io.h>
+#include <direct.h>
+#include <stdio.h>
+#else
+#include <stdio.h>
+#endif
+
+#include <ogdi_macro.h>
+
+ECS_CVSID("$Id: server.c,v 1.9 2007/02/12 21:01:48 cbalint Exp $");
+
+ecs_Result svr_dummy_result;
+
+/* MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21 */
+/* Description: Remove unused grass driver specific stuff. */
+/* Addition of declaration of private functions used */
+/* in this module to avoid some warnings. */
+static ecs_Result *GetOneNextObjectAttributes(ecs_Server *s,ecs_Result *msg,int *isSelected);
+static ecs_Result *GetOneNextObject(ecs_Server *s);
+static ecs_Result *GetRasterInfoAttributes(ecs_Server *s,ecs_Result *msg);
+static ecs_Result *GetObjectAttributes(ecs_Server *s,ecs_Result *msg);
+
+/*#define TESTOGDIINTERFACE 1*/
+
+#ifdef TESTOGDIINTERFACE
+ FILE *testfile = NULL;
+#endif
+
+/* Error string list */
+
+char *svr_messages[] = {
+ /* 0 */ "",
+ "not able to understand this URL",
+ "not able to open more than one local server GRASS",
+ "not able to open the dynamic library",
+ "not able to open the function dyn_CreateServer in the dynamic library",
+ /* 5 */ "not enough memory",
+ "SelectLayer not present in dynamic library",
+ "ReleaseLayer not present in dynamic library",
+ "SelectRegion not present in dynamic library",
+ "GetDictionary not present in dynamic library",
+ /* 10 */ "GetAttributesFormat not present in dynamic library",
+ "GetNextObject not present in dynamic library",
+ "GetRasterInfo not present in dynamic library",
+ "GetObject not present in dynamic library",
+ "GetObjectIdFromCoord not present in dynamic library",
+ /* 15 */ "UpdateDictionary not present in dynamic library",
+ "GetServerProjection not present in dynamic library",
+ "GetGlobalBound not present in dynamic library",
+ "SetServerLanguage not present in dynamic library",
+ "Can't use GetAttributesFormat, no layer selected",
+ /* 20 */ "Can't use GetNextObject, no layer selected",
+ "Can't use GetRasterInfo, no layer selected",
+ "Can't use GetRasterInfo, the layer selected is not a raster",
+ "Can't use GetObject, no layer selected",
+ "Can't use GetObjectIdFromCoord, no layer selected",
+ /* 25 */ "This point is outside the current region",
+ "The file specified in OGDILINK don't exist",
+ "One of the attributes specified in the list is not define",
+ "Could not link the attribute driver",
+ "Invalid attribute driver dll",
+ /* 30 */ "Invalid SQL request",
+ "SetCompression not present in dynamic library",
+ "OGDILINK is not in the correct format"
+};
+
+/*
+ --------------------------------------------------------
+ Server creation. Will create a new server
+
+ IN
+ s: Pointer to ecs_Server structure (given by caller)
+ url: This string is used to create a new server
+ isLocal: Indicate if server is used as a remote server
+ or a local server.
+
+ OUT
+ ecs_Result: Operation result
+
+ MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+ Description: Remove unused grass driver specific stuff.
+ Addition of an error handling message to indicate
+ that the remote driver cannot be found instead of
+ reporting in that case the s->servertype cannot
+ be found.
+
+ --------------------------------------------------------
+ */
+
+ecs_Result *svr_CreateServer(s,url,isLocal)
+ ecs_Server *s;
+ char *url;
+ int isLocal;
+{
+ ecs_Result *res, *msg;
+ char buffer[128];
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_CreateServer %s %d\n",url,isLocal);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ /* Initialize server arguments */
+
+ s->priv = NULL;
+ s->nblayer = 0;
+ s->layer = NULL;
+ s->layer_tablesize = 0;
+ s->currentLayer = -1;
+ s->handle = NULL;
+ s->projection = NULL;
+ s->createserver = NULL;
+ s->destroyserver = NULL;
+ s->selectlayer = NULL;
+ s->releaselayer = NULL;
+ s->closelayer = NULL;
+ s->selectregion = NULL;
+ s->getdictionary = NULL;
+ s->getattrformat = NULL;
+ s->getnextobject = NULL;
+ s->getrasterinfo = NULL;
+ s->getobject = NULL;
+ s->getobjectid = NULL;
+ s->updatedictionary =NULL;
+ s->getserverprojection = NULL;
+ s->getglobalbound = NULL;
+ s->setserverlanguage = NULL;
+ s->setserverprojection = NULL;
+ s->setrasterconversion = NULL;
+ s->isRemote = FALSE;
+ s->localClient = isLocal;
+ s->AttributeListQty = 0;
+ s->AttributeList = NULL;
+ s->compression.ctype = isLocal ? ECS_COMPRESS_NONE : ECS_COMPRESS_ZLIB;
+ s->compression.cversion = isLocal ? 0 : ECS_ZLIB_VERSION;
+ s->compression.clevel = isLocal ? 0 : ECS_ZLIB_LEVEL_DEFAULT;
+ s->compression.cblksize = isLocal ? 0 : ECS_ZLIB_BLKSIZE_DEFAULT;
+ s->compression.cfullsize = 0;
+ s->compression.cachesize = ECS_CACHE_DEFAULT;
+
+ /* initialise raster conversion */
+
+ s->rasterconversion.coef.coef_len = 0;
+ s->rasterconversion.coef.coef_val = NULL;
+
+ /* Extract information from url */
+
+ s->url = malloc(strlen(url)+1);
+ if (s->url == NULL) {
+ res = &svr_dummy_result;
+ ecs_SetError(res,1,svr_messages[5]);
+ return res;
+ }
+ strcpy(s->url,url);
+
+ if (!ecs_SplitURL(url,&(s->hostname),&(s->server_type),&(s->pathname))) {
+ res = &svr_dummy_result;
+ ecs_SetError(res,1,svr_messages[1]);
+ return res;
+ }
+
+ /* Open the dynamic library. If the server is remote, do no open
+ the server remote again. */
+
+ if (isLocal == 0) {
+ /* is a remote server */
+ s->handle = ecs_OpenDynamicLib(s->server_type);
+ } else {
+ /* is a local server */
+ if ((s->hostname) != NULL) {
+ s->handle = ecs_OpenDynamicLib("remote");
+ if (s->handle == NULL) {
+ res = &svr_dummy_result;
+ sprintf(buffer,"Could not find the dynamic library \"remote\"");
+ ecs_SetError(res,1,buffer);
+ return res;
+ }
+ s->isRemote = TRUE;
+ } else {
+ s->handle = ecs_OpenDynamicLib(s->server_type);
+ }
+ }
+ /* if the driver is not found, then look for the script driver */
+ if (s->handle == NULL) {
+ s->handle = ecs_OpenDynamicLib("script");
+ }
+
+ /* if the script driver is not found, then return error message */
+ if (s->handle == NULL) {
+ res = &svr_dummy_result;
+ sprintf(buffer,"Could not find the dynamic library \"%s\"",s->server_type);
+ ecs_SetError(res,1,buffer);
+ return res;
+ }
+
+ s->createserver = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_CreateServer");
+ if (s->createserver == NULL) {
+ res = &svr_dummy_result;
+ ecs_SetError(res,1,svr_messages[4]);
+ return res;
+ }
+ s->destroyserver = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_DestroyServer");
+ s->selectlayer = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_SelectLayer");
+ s->releaselayer = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_ReleaseLayer");
+ s->closelayer = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_CloseLayer");
+ s->selectregion = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_SelectRegion");
+ s->getdictionary = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_GetDictionary");
+ s->getattrformat = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_GetAttributesFormat");
+ s->getnextobject = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_GetNextObject");
+ s->getrasterinfo = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_GetRasterInfo");
+ s->getobject = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_GetObject");
+ s->getobjectid = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_GetObjectIdFromCoord");
+ s->updatedictionary = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_UpdateDictionary");
+ s->getserverprojection = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_GetServerProjection");
+ s->getglobalbound = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_GetGlobalBound");
+ s->setserverlanguage = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_SetServerLanguage");
+ s->setserverprojection = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_SetServerProjection");
+ s->setrasterconversion = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_SetRasterConversion");
+ s->setcompression = (dynfunc *) ecs_GetDynamicLibFunction(s->handle,"dyn_SetCompression");
+
+ /* Initialise ecs_Result in "s" */
+
+ ecs_ResultInit(&(s->result));
+
+ /* Call the dynamic function dyn_CreateServer */
+
+ res = s->createserver(s,url);
+ if (res == NULL) {
+ res = &svr_dummy_result;
+ sprintf(buffer,"A memory error occured when creating the server for the URL \"%s\"", url);
+ ecs_SetError(res,1,buffer);
+ return res;
+ }
+ if (res->error) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,res->message);
+
+/* if (s->isRemote || (s->hostname == NULL))
+ ecs_CloseDynamicLib(s->handle);
+*/
+
+ ecs_freeSplitURL(&(s->hostname),&(s->server_type),&(s->pathname));
+ return msg;
+ }
+
+ ecs_GetLateralDBConnectionCtrlFile(s);
+
+ return res;
+}
+
+/*
+ --------------------------------------------------------
+ Server destruction. Will destroy the server and unlink
+ the program with the dynamic library
+
+ IN
+ s: Pointer to ecs_Server structure (given by caller)
+
+ OUT
+ ecs_Result: Operation result
+
+ MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+ Description: Remove unused grass driver specific stuff
+
+ --------------------------------------------------------
+ */
+
+ecs_Result *svr_DestroyServer(s)
+ ecs_Server *s;
+{
+ ecs_Result *msg;
+ int i;
+
+ ecs_CleanUp(&(s->result));
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_DestroyServer %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ if (s->handle != NULL && s->destroyserver != NULL) {
+ msg = s->destroyserver(s);
+ ecs_CleanUp(msg);
+ }
+
+ if (s->url != NULL)
+ free (s->url);
+ if (s->projection != NULL)
+ free(s->projection);
+ if (s->hostname != NULL)
+ free(s->hostname);
+ if (s->server_type != NULL)
+ free(s->server_type);
+ if (s->pathname != NULL)
+ free(s->pathname);
+
+ msg = &svr_dummy_result;
+ ecs_SetSuccess(msg);
+
+ s->priv = NULL;
+ s->projection = NULL;
+ s->hostname = NULL;
+ s->server_type = NULL;
+ s->pathname = NULL;
+ s->createserver = NULL;
+ s->destroyserver = NULL;
+ s->selectlayer = NULL;
+ s->releaselayer = NULL;
+ s->closelayer = NULL;
+ s->selectregion = NULL;
+ s->getdictionary = NULL;
+ s->getattrformat = NULL;
+ s->getnextobject = NULL;
+ s->getrasterinfo = NULL;
+ s->getobject = NULL;
+ s->getobjectid = NULL;
+ s->updatedictionary = NULL;
+ s->getserverprojection = NULL;
+ s->getglobalbound = NULL;
+ s->setserverlanguage = NULL;
+ s->setserverprojection = NULL;
+ s->setrasterconversion = NULL;
+ s->setcompression = NULL;
+
+ if (s->AttributeList != NULL) {
+ for(i=0;i<s->AttributeListQty;i++) {
+ free(s->AttributeList[i].url);
+ free(s->AttributeList[i].layer);
+ free(s->AttributeList[i].DriverType);
+ free(s->AttributeList[i].InformationSource);
+ free(s->AttributeList[i].UserDescription);
+ free(s->AttributeList[i].AutorizationDescription);
+ free(s->AttributeList[i].SelectionRequest);
+ }
+ free(s->AttributeList);
+ }
+ s->AttributeListQty = 0;
+ s->AttributeList = NULL;
+
+ if (s->rasterconversion.coef.coef_val != NULL)
+ free(s->rasterconversion.coef.coef_val);
+
+ if (s->layer != NULL) {
+ free(s->layer);
+ s->layer = NULL;
+ }
+
+ if (s->isRemote || (s->hostname == NULL))
+/* ecs_CloseDynamicLib(s->handle);*/
+
+ s->handle = NULL;
+
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * svr_SelectLayer
+ *
+ * DESCRIPTION
+ * Make the selection of a layer in a driver.
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * ecs_LayerSelection *ls: Layer selection
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Clean up the result structure
+ *
+ * 2. If the handle is valid to the driver and the function selectlayer
+ * exist.
+ * Begin
+ *
+ * 2.1. Call SetAttributeLinkWithRequest with the LayerSelection
+ *
+ * 2.2. Call SelectLayer in the geographic driver. If an error occur,
+ * return the error message.
+ *
+ * 2.3. Found the position of the layer in the layer table currentLayer
+ * variable
+ *
+ * 2.4. Call SetAttributeQuery with this layer
+ *
+ * End
+ *
+ * 3. Else return a error message indicating the function don't exist.
+ *
+ * 4. return the message returned by SelectLayer
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *svr_SelectLayer(s,ls)
+ ecs_Server *s;
+ ecs_LayerSelection *ls;
+{
+ ecs_Result *msg;
+ char *error;
+ ecs_Region region = {0,0,0,0,0,0};
+ int regionset = FALSE;
+
+ ecs_CleanUp(&(s->result));
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_SelectLayer %s %s %d\n",s->url,ls->Select,ls->F);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ if (s->handle != NULL && s->selectlayer != NULL) {
+ ecs_SetAttributeLinkWithRequest(s,ls->Select,ls->F);
+ ecs_UnstackRequest(s,&(ls->Select));
+ msg = s->selectlayer(s,ls);
+
+ if (ECSSUCCESS(msg) && s->currentLayer >= 0) {
+ if (msg->res.type == GeoRegion) {
+ region.north = msg->res.ecs_ResultUnion_u.gr.north;
+ region.south = msg->res.ecs_ResultUnion_u.gr.south;
+ region.east = msg->res.ecs_ResultUnion_u.gr.east;
+ region.west = msg->res.ecs_ResultUnion_u.gr.west;
+ region.ns_res = msg->res.ecs_ResultUnion_u.gr.ns_res;
+ region.ew_res = msg->res.ecs_ResultUnion_u.gr.ew_res;
+ regionset = TRUE;
+ }
+
+ if (ecs_SetAttributeQuery(s,&(s->layer[s->currentLayer]),&error)!=0) {
+ msg = s->releaselayer(s,ls);
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ } else {
+ msg = &svr_dummy_result;
+
+ if (regionset == TRUE) {
+ ecs_SetGeoRegion(msg,region.north, region.south,
+ region.east, region.west, region.ns_res,
+ region.ew_res);
+ }
+ ecs_SetSuccess(msg);
+ }
+ }
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[6]);
+ }
+
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * svr_ReleaseLayer
+ *
+ * DESCRIPTION
+ * Release the link to a layer
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * ecs_LayerSelection *ls: Layer selection
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Clean up the result structure
+ *
+ * 2. If the handle is valid to the driver and the function releaselayer
+ * exist.
+ * Begin
+ *
+ * 2.1. Found the position of the layer in the layer table with the
+ * LayerSelection information.
+ *
+ * 2.2. Call ReleaseAttributeQuery with this layer
+ *
+ * 2.3. Call ReleaseLayer in the geographic driver.
+ *
+ * 2.2. Call ReleaseAttributeLinkWithRequest with the LayerSelection
+ *
+ * End
+ *
+ * 3. Else return a error message indicating the function don't exist.
+ *
+ * 4. return the message returned by ReleaseLayer
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *svr_ReleaseLayer(s,ls)
+ ecs_Server *s;
+ ecs_LayerSelection *ls;
+{
+ ecs_Result *msg;
+ int i;
+ char *error;
+ char *temp;
+ ecs_Family F;
+
+ ecs_CleanUp(&(s->result));
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_ReleaseLayer %s %s %d\n",s->url,ls->Select,ls->F);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ if (s->handle != NULL && s->releaselayer != NULL) {
+ for(i=0;i<s->nblayer;i++) {
+ if (strcmp(ls->Select,s->layer[i].sel.Select) == 0 &&
+ ls->F == s->layer[i].sel.F) {
+ if (ecs_ReleaseAttributeQuery(s,&(s->layer[i]),&error)!=0) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ return msg;
+ }
+ break;
+ }
+ }
+ temp = malloc(strlen(ls->Select)+1);
+ if (temp == NULL) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[5]);
+ return msg;
+ }
+ strcpy(temp,ls->Select);
+ F = ls->F;
+ ecs_UnstackRequest(s,&(ls->Select));
+ msg = s->releaselayer(s,ls);
+ ecs_RemoveAttributeLinkWithRequest(s,temp,F);
+ free(temp);
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[7]);
+ }
+
+ return msg;
+}
+
+/****************************************************************/
+
+void svr_BroadCloseLayers(s)
+ ecs_Server *s;
+{
+ void *handle;
+ dynfunc *func;
+
+ if (!(s->isRemote)) {
+ handle = ecs_OpenDynamicLib("ecs");
+ if (handle!=NULL) {
+ func = (dynfunc *) ecs_GetDynamicLibFunction(handle,"cln_BroadCloseLayers");
+ func();
+ ecs_CloseDynamicLib(func);
+ }
+ } else {
+ s->closelayer(s);
+ }
+}
+
+/****************************************************************/
+
+void svr_CloseLayer(s)
+ ecs_Server *s;
+{
+ if (s->handle != NULL && s->closelayer != NULL) {
+ s->closelayer(s);
+ }
+}
+
+/****************************************************************/
+
+ecs_Result *svr_SelectRegion(s,gr)
+ ecs_Server *s;
+ ecs_Region *gr;
+{
+ ecs_Result *msg;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_SelectRegion %s %f %f %f %f %f %f\n",s->url,gr->north,gr->south,gr->east,gr->west,gr->ns_res, gr->ew_res);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->selectregion != NULL) {
+ msg = s->selectregion(s,gr);
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[8]);
+ }
+
+ return msg;
+}
+
+/****************************************************************/
+
+ecs_Result *svr_GetDictionary(s)
+ ecs_Server *s;
+{
+ ecs_Result *msg;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_GetDictionary %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->getdictionary != NULL) {
+ msg = s->getdictionary(s);
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[9]);
+ }
+
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * svr_GetAttributesFormat
+ *
+ * DESCRIPTION
+ * Get the attribute format list of all the possibles attributes
+ * of a geographic object.
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Clean up the result structure
+ *
+ * 2. If the handle is valid to the driver and the function GetAttributeFormat
+ * exist.
+ * Begin
+ *
+ * 2.1. If it's not a remote driver and the currentlayer is selected
+ * Begin
+ *
+ * 2.1.1. Call GetAttributeFormat in the geographical driver
+ *
+ * 2.1.2. If the AttributeDriverHandle is not null
+ * Begin
+ *
+ * 2.1.2.1. Call GetColumnInfo to retreave the
+ * attribute driver attribute info.
+ *
+ * 2.1.2.2. If no error append during GetColumnInfo, merge the
+ * attribute driver attribute info with the elements in
+ * the result of GetAttributeFormat
+ *
+ * End
+ *
+ * End
+ *
+ * 2.2. Else return an error indicating that the layer is not selected.
+ *
+ * End
+ *
+ * 3. Else return a error message indicating the function don't exist.
+ *
+ * 4. return the message returned by GetAttributeFormat
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *svr_GetAttributesFormat(s)
+ ecs_Server *s;
+{
+ int columns_qty;
+ ecs_ObjAttribute *attr;
+ char *error;
+ ecs_Result *msg;
+ int i;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_GetAttributesFormat %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->getattrformat != NULL) {
+ if ((!(s->isRemote)) &&
+ (s->currentLayer == -1)) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[19]);
+ } else {
+ msg = s->getattrformat(s);
+ if (ECSSUCCESS(msg) && s->currentLayer >= 0 && s->layer[s->currentLayer].AttributeDriverHandle != NULL) {
+ if ((s->layer[s->currentLayer].GetColumnsInfoFuncPtr)(s,&(s->layer[s->currentLayer]),&columns_qty,&attr,&error) == 0) {
+ for(i=0;i<columns_qty;i++) {
+ ecs_AddAttributeFormat(msg,attr[i].name,attr[i].type,attr[i].lenght,attr[i].precision,attr[i].nullable);
+ }
+ ecs_SetSuccess(msg);
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ }
+ }
+ }
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[10]);
+ }
+
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * GetOneNextObjectAttributes
+ *
+ * DESCRIPTION
+ * When using an attribute driver, use it to get the attributes
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * ecs_Result *msg: The result up until now.
+ * OUTPUT
+ * int *isSelected: Was this object selected
+ * return ecs_Result
+ *
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Set a tables of characters containing the attributes
+ * with ecs_SetBindListForVector.
+ * 2. Call SelectAttributes with this table.
+ * 3. If there is an error in SelectAttributes, return.
+ * 4. Call IsSelected in the attribute driver
+ * 5. If the result of IsSelected is TRUE
+ * Begin
+ * 5.1. Set the selected variable to TRUE
+ * 5.2. Call GetAttributes in the attribute driver
+ * 5.3. Concatenate this string with the attributes
+ * of the object (don't forget the space between both strings
+ * End
+ *
+ *----------------------------------------------------------------------
+ */
+
+static ecs_Result *
+GetOneNextObjectAttributes(s, msg, isSelected)
+ ecs_Server *s;
+ ecs_Result *msg;
+ int *isSelected;
+{
+ int attribute_qty;
+ char **attribute_list;
+ char *error;
+ short objSelected;
+ char *temp,*attributes;
+ ecs_Family family;
+
+ *isSelected = FALSE;
+ family = s->layer[s->currentLayer].sel.F;
+ attribute_qty = s->layer[s->currentLayer].SelectionAttributeListQty;
+
+ /*
+ * Set the table of characters
+ */
+
+ if (ecs_SetBindListForVector(s,&(s->layer[s->currentLayer]),msg,&attribute_list,&error) != 0) {
+
+ /*
+ The bind don't work for this object. It's usually because the
+ object is incomplete.
+ */
+
+ *isSelected = FALSE;
+ return msg;
+ }
+
+ /*
+ * Select the attributes
+ */
+
+ if ((s->layer[s->currentLayer].SelectAttributesFuncPtr)(s,&(s->layer[s->currentLayer]),attribute_qty,attribute_list,&error) != 0) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ return msg;
+ }
+
+ /*
+ * Check if the object, accordingly to the selection, is selected
+ */
+
+ if ((s->layer[s->currentLayer].IsSelectedFuncPtr)(s,&(s->layer[s->currentLayer]),&objSelected,&error) != 0) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ return msg;
+ }
+
+ if (! objSelected) {
+ return msg;
+ }
+
+ /*
+ * If the object is selected, get the new attributes of the object
+ */
+
+ *isSelected = TRUE;
+ if ((s->layer[s->currentLayer].GetSelectedAttributesFuncPtr)(s,&(s->layer[s->currentLayer]),&attributes,&error) != 0) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ return msg;
+ }
+
+ temp = malloc(strlen(attributes)+strlen(ECSOBJECTATTR(msg))+2);
+ if (temp != NULL) {
+ strcpy(temp,ECSOBJECTATTR(msg));
+ strcat(temp," ");
+ strcat(temp,attributes);
+ ecs_SetObjectAttr(msg,temp);
+ free(temp);
+ }
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * GetOneNextObject
+ *
+ * DESCRIPTION
+ * Extract the geographical object from the driver like from a stack
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Clean up the result structure and set the "selected" variable to FALSE
+ * Begin
+ * 1.1. While selected is FALSE
+ * Begin
+ * 1.1.1. Call GetNextObject in the geographical driver
+ * 1.1.2. If the AttributeDriverHandle and there is no error
+ * in GetNextObject and the family is a vector (Area, Point,
+ * Text or Line)
+ * Begin
+ * 1.1.2.1. Call GetOneNextObjectAttributes
+ * End
+ * 1.1.3. Else, Set the selected variable to TRUE
+ * End
+ * End
+ * 2. Else return an error indicating that the layer is not selected.
+ * 3. return the message
+ *
+ *----------------------------------------------------------------------
+ */
+static ecs_Result *
+GetOneNextObject(s)
+ ecs_Server *s;
+{
+ ecs_Result *msg;
+ int isSelected;
+
+ ecs_CleanUp(&(s->result));
+ isSelected = FALSE;
+
+ while (!isSelected) {
+ msg = s->getnextobject(s);
+ if (!ECSSUCCESS(msg)) {
+ return msg;
+ }
+ if (s->currentLayer >= 0 && s->layer[s->currentLayer].AttributeDriverHandle != NULL &&
+ (s->layer[s->currentLayer].sel.F == Area || s->layer[s->currentLayer].sel.F == Line ||
+ s->layer[s->currentLayer].sel.F == Point || s->layer[s->currentLayer].sel.F == Text)) {
+ msg = GetOneNextObjectAttributes(s, msg, &isSelected);
+ } else {
+ isSelected = TRUE;
+ }
+ }
+
+ if ((!(s->isRemote)) &&
+ (msg->res.type == Object) &&
+ (msg->res.ecs_ResultUnion_u.dob.xmin == 0.0) &&
+ (msg->res.ecs_ResultUnion_u.dob.ymin == 0.0) &&
+ (msg->res.ecs_ResultUnion_u.dob.xmax == 0.0) &&
+ (msg->res.ecs_ResultUnion_u.dob.ymax == 0.0)) {
+ ecs_CalcObjectMBR(s,&msg->res.ecs_ResultUnion_u.dob);
+ }
+
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * svr_GetNextObject
+ *
+ * DESCRIPTION
+ * Extract the geographical object from the driver like from a stack
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. If the handle to the driver is invalid or the function GetNextObject
+ * does not exist, return an error.
+ * 2. If it's not a remote driver and the currentlayer isn't selected,
+ * return an error.
+ * 3. If no caching is occurring, just return the next object.
+ * 4. If caching is occurring, grab an object at a time to fill up
+ * the array of objects.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *svr_GetNextObject(s)
+ ecs_Server *s;
+{
+ ecs_Result *msg;
+ ecs_ResultUnion *array, *ru;
+ int count;
+ int result;
+ int num;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_GetNextObject %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ if (s->handle == NULL || s->getnextobject == NULL) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[11]);
+ return msg;
+ }
+
+ if (!s->isRemote && (s->currentLayer == -1)) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[20]);
+ return msg;
+ }
+
+ num = s->compression.cachesize;
+
+ /* Do not grab multiple objects where the client is local */
+ if (s->localClient || num == 1) {
+ return GetOneNextObject(s);
+ }
+
+ array = (ecs_ResultUnion *) malloc(sizeof(ecs_ResultUnion) * num);
+ if (array == NULL) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[5]);
+ return msg;
+ }
+
+ ru = array;
+ count = 0;
+
+ do {
+ msg = GetOneNextObject(s);
+ if (msg->error != 0) {
+ break;
+ }
+ result = ecs_CopyResultUnionWork(&msg->res, ru);
+ if (result == FALSE) {
+ /*
+ * Let ecs_Cleanup() take care of this
+ */
+ s->result.res.type = MultiResult;
+ s->result.res.ecs_ResultUnion_u.results.results_len = count;
+ s->result.res.ecs_ResultUnion_u.results.results_val = array;
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[5]);
+ return msg;
+ }
+ count++;
+ ru++;
+ } while (count < num && msg->error == 0);
+
+ if (count > 0) {
+ s->result.res.ecs_ResultUnion_u.results.results_len = count;
+ s->result.res.ecs_ResultUnion_u.results.results_val = array;
+ s->result.res.type = MultiResult;
+ }
+
+ return msg;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * GetRasterInfoAttributes --
+ *
+ * DESCRIPTION
+ * When using an AttributeDriver, fixup the results.
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * Begin
+ * 1. For each category in the object
+ * Begin
+ * 1.1. Set a tables of characters containing
+ * the id or the category number or category descriptor
+ * to bind describe in the list of selection attribute
+ * (SelectionAttributeList in the ecs_Layer structure)
+ * 1.2. Call SelectAttributes with this table.
+ * 1.3. If there is no error in SelectAttributes
+ * Begin
+ * 1.3.1. Call IsSelected in the attribute driver
+ * 1.3.2. If the result of IsSelected is TRUE
+ * Begin
+ * 1.3.2.1. Call GetAttributes in the attribute driver
+ * 1.3.2.2. Concatenate this string with the attributes
+ * of the object (don't forget the space between both strings
+ * End
+ * 1.3.3. Else
+ * Begin
+ * 1.3.3.1. Remove the category from the list.
+ * End
+ * End
+ * End
+ * End
+ *
+ *----------------------------------------------------------------------
+ */
+static ecs_Result *
+GetRasterInfoAttributes(s, msg)
+ ecs_Server *s;
+ ecs_Result *msg;
+{
+ int attribute_qty,i;
+ ecs_Category *ptr;
+ char **attribute_list;
+ char *error;
+ char *temp;
+ short objSelected;
+ char *attributes;
+
+ attribute_qty = s->layer[s->currentLayer].SelectionAttributeListQty;
+#if 0 /* XXX: Note from Gordon. This next line doesn't compile as written */
+ ecs_SetRasterInfo(&(svr_dummy_result),msg->res.ecs_ResultUnion_u.ri.width,msg->res.ecs_ResultUnion_u.ri.height);
+#endif
+ for(i=0; i < (int) ECSRASTERINFONB(msg); i++) {
+
+ ptr = &(ECSRASTERINFOCAT(msg,i));
+
+ /*
+ * Set the table of characters
+ */
+
+ if (ecs_SetBindListForMatrix(s,&(s->layer[s->currentLayer]),ptr,&attribute_list,&error) != 0) {
+ ecs_SetError(&svr_dummy_result,1,error);
+ } else {
+
+ /*
+ * Select the attributes
+ */
+
+ if ((s->layer[s->currentLayer].SelectAttributesFuncPtr)(s,&(s->layer[s->currentLayer]),attribute_qty,attribute_list,&error) != 0) {
+ ecs_SetError(&svr_dummy_result,1,error);
+ } else {
+
+ /*
+ * Check if the object, accordingly to the selection, is
+ * selected
+ */
+
+ if ((s->layer[s->currentLayer].IsSelectedFuncPtr)(s,&(s->layer[s->currentLayer]),&objSelected,&error) != 0) {
+ ecs_SetError(&svr_dummy_result,1,error);
+ } else {
+ if (objSelected) {
+
+ /*
+ * If the category is selected, get the new attributes
+ * of the category descriptor. Else,
+ * the category is removed from the list.
+ */
+
+ if ((s->layer[s->currentLayer].GetSelectedAttributesFuncPtr)(s,&(s->layer[s->currentLayer]),&attributes,&error) != 0) {
+ ecs_SetError(&svr_dummy_result,1,error);
+ } else {
+ temp = malloc(strlen(attributes)+strlen(ptr->label)+2);
+ if (temp != NULL) {
+ strcpy(temp,ptr->label);
+ strcat(temp," ");
+ strcat(temp,attributes);
+ ecs_AddRasterInfoCategory(&(svr_dummy_result),ptr->no_cat,ptr->r,ptr->g,ptr->b,temp,ptr->qty);
+ free(temp);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ msg = &svr_dummy_result;
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * ecs_GetRasterInfo
+ *
+ * DESCRIPTION
+ * Get the current selected raster information
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Clean up the result structure
+ * 2. If the handle is valid to the driver and the function GetRasterInfo
+ * exist.
+ * Begin
+ * 2.1. If it's not a remote driver and the currentlayer is selected
+ * Begin
+ * 2.1.1. Call GetRasterInfo in the geographical driver
+ * 2.1.2. If the AttributeDriverHandle is not null
+ * Begin
+ * 2.1.2.1. Call GetRasterInfoAttributes
+ * End
+ * End
+ * 2.2. Else return an error indicating that the layer is not selected.
+ * End
+ * 3. Else return a error message indicating the function don't exist.
+ * 4. return the message returned by GetAttributeFormat
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *svr_GetRasterInfo(s)
+ ecs_Server *s;
+{
+ ecs_Result *msg;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_GetRasterInfo %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->getrasterinfo != NULL) {
+ if ((!(s->isRemote)) &&
+ (s->currentLayer == -1)) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[21]);
+ } else {
+ if ((s->isRemote) ||
+ (s->layer[s->currentLayer].sel.F == Matrix) ||
+ (s->layer[s->currentLayer].sel.F == Image)) {
+ msg = s->getrasterinfo(s);
+ if (s->currentLayer >= 0 && ECSSUCCESS(msg) && s->layer[s->currentLayer].AttributeDriverHandle != NULL) {
+ msg = GetRasterInfoAttributes(s, msg);
+ }
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[22]);
+ }
+ }
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[12]);
+ }
+
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * GetObjectAttributes
+ *
+ * DESCRIPTION
+ * When using a attribute driver, get the object attributes
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * ecs_Result *msg: The result to be used if no matching attributes
+ * are found
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Set a tables of characters containing the attributes
+ * to bind describe in the list of selection attribute
+ * (SelectionAttributeList in the ecs_Layer structure)
+ * 2. Call SelectAttributes with this table.
+ * 3. If there is an error in SelectAttributes, return
+ * 4. Call GetAttributes in the attribute driver
+ * 5. Concatenate this string with the attributes
+ * of the object (don't forget the space between both strings
+ *
+ *----------------------------------------------------------------------
+ */
+
+static ecs_Result *
+GetObjectAttributes(s, msg)
+ ecs_Server *s;
+ ecs_Result *msg;
+{
+ int attribute_qty;
+ char **attribute_list;
+ char *error;
+ short objSelected;
+ char *temp,*attributes;
+
+ attribute_qty = s->layer[s->currentLayer].SelectionAttributeListQty;
+
+ /*
+ * Set the table of characters
+ */
+
+ if (ecs_SetBindListForVector(s,&(s->layer[s->currentLayer]),msg,&attribute_list,&error) != 0) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ return msg;
+ }
+
+ /*
+ * Select the attributes
+ */
+
+ if ((s->layer[s->currentLayer].SelectAttributesFuncPtr)(s,&(s->layer[s->currentLayer]),attribute_qty,attribute_list,&error) != 0) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ return msg;
+ }
+
+ /*
+ * Check if the object, accordingly to the selection, is selected
+ */
+
+ if ((s->layer[s->currentLayer].IsSelectedFuncPtr)(s,&(s->layer[s->currentLayer]),&objSelected,&error) != 0) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ return msg;
+ }
+
+ if (! objSelected) {
+ return msg;
+ }
+
+ /*
+ * If the object is selected, get the new attributes of the object
+ */
+
+ if ((s->layer[s->currentLayer].GetSelectedAttributesFuncPtr)(s,&(s->layer[s->currentLayer]),&attributes,&error) != 0) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,error);
+ return msg;
+ }
+
+ temp = malloc(strlen(attributes)+strlen(ECSOBJECTATTR(msg))+2);
+ if (temp != NULL) {
+ strcpy(temp,ECSOBJECTATTR(msg));
+ strcat(temp," ");
+ strcat(temp,attributes);
+ ecs_SetObjectAttr(msg,temp);
+ free(temp);
+ }
+ return msg;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FUNCTION_INFORMATION
+ *
+ * NAME
+ * svr_GetObject
+ *
+ * DESCRIPTION
+ * Get an geographic object knowing the
+ * END_DESCRIPTION
+ *
+ * PARAMETERS
+ * INPUT
+ * ecs_Server *s: Server object attributes
+ * char *Id: The id of the object wanted
+ * END_PARAMETERS
+ *
+ * RETURN_VALUE
+ * ecs_Result *: A structure with the result information
+ *
+ * END_FUNCTION_INFORMATION
+ *
+ * PSEUDO_CODE
+ *
+ * 1. Clean up the result structure and set the "selected" variable to FALSE
+ * 2. If the handle is valid to the driver and the function GetObject
+ * exist.
+ * Begin
+ * 2.1. If it's not a remote driver and the currentlayer is selected
+ * Begin
+ * 2.1.1. Call GetObject in the geographical driver with Id
+ * 2.1.2. If the AttributeDriverHandle and there is no error
+ * in GetObject and the family is a vector (Area, Point, Text,Line)
+ * Begin
+ * 2.1.2.1 Call GetObjectAttributes
+ * End
+ * End
+ * 2.2. Else return an error indicating that the layer is not selected.
+ * End
+ * 3. Else return a error message indicating the function don't exist.
+ * 4. return the message
+ *
+ *----------------------------------------------------------------------
+ */
+
+ecs_Result *svr_GetObject(s,Id)
+ ecs_Server *s;
+ char *Id;
+{
+ ecs_Result *msg;
+ ecs_Family family;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_GetObject %s %s\n",s->url,Id);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->getobject != NULL) {
+ if ((!(s->isRemote)) &&
+ (s->currentLayer == -1)) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[23]);
+ } else {
+ msg = s->getobject(s,Id);
+ family = s->layer[s->currentLayer].sel.F;
+ if (s->currentLayer >= 0 && ECSSUCCESS(msg) && s->layer[s->currentLayer].AttributeDriverHandle != NULL &&
+ (family == Area || family == Line || family == Point || family == Text)) {
+ msg = GetObjectAttributes(s,msg);
+ }
+ }
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[13]);
+ }
+
+ if (!(s->isRemote)) {
+ if (msg->res.type == Object) {
+ ecs_Object *obj = &msg->res.ecs_ResultUnion_u.dob;
+ if ((obj->xmin == 0.0) && (obj->ymin == 0.0) &&
+ (obj->xmax == 0.0) && (obj->ymax == 0.0)) {
+ ecs_CalcObjectMBR(s,&msg->res.ecs_ResultUnion_u.dob);
+ }
+ }
+ }
+
+ return msg;
+}
+
+/****************************************************************/
+
+ecs_Result *svr_GetObjectIdFromCoord(s,coord)
+ ecs_Server *s;
+ ecs_Coordinate *coord;
+{
+ ecs_Result *msg;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_GetObjectIdFromCoord %s %f %f\n",s->url,coord->x,coord->y);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ /* Check if the coordinate is inside the current region */
+
+ if ((s->currentRegion.north < coord->y) ||
+ (s->currentRegion.south > coord->y) ||
+ (s->currentRegion.east < coord->x) ||
+ (s->currentRegion.west > coord->x)) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[25]);
+ } else {
+
+ /* Call the getobjectid of the current driver */
+
+ if (s->handle != NULL && s->getobjectid != NULL) {
+ if ((!(s->isRemote)) &&
+ (s->currentLayer == -1)) {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[24]);
+ } else {
+ /* Set the tolerance accordingly to the current region */
+
+ ecs_SetTolerance(&(s->currentRegion));
+
+ msg = s->getobjectid(s,coord);
+ }
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[14]);
+ }
+ }
+
+ return msg;
+}
+
+/****************************************************************/
+
+ecs_Result *svr_UpdateDictionary(s,info)
+ ecs_Server *s;
+ char *info;
+{
+ ecs_Result *msg;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_UpdateDictionary %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->updatedictionary != NULL) {
+ msg = s->updatedictionary(s,info);
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[15]);
+ }
+
+ return msg;
+}
+
+/****************************************************************/
+
+ecs_Result *svr_GetServerProjection(s)
+ ecs_Server *s;
+{
+ ecs_Result *msg;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_GetServerProjection %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->getserverprojection != NULL) {
+ msg = s->getserverprojection(s);
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[16]);
+ }
+
+ return msg;
+}
+
+/****************************************************************/
+
+ecs_Result *svr_GetGlobalBound(s)
+ ecs_Server *s;
+{
+ ecs_Result *msg;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_GetGlobalBound %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->getglobalbound != NULL) {
+ msg = s->getglobalbound(s);
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[17]);
+ }
+
+ return msg;
+}
+
+/****************************************************************/
+
+ecs_Result *svr_SetServerLanguage(s,language)
+ ecs_Server *s;
+ u_int language;
+{
+ ecs_Result *msg;
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->setserverlanguage != NULL) {
+ msg = s->setserverlanguage(s,language);
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[18]);
+ }
+
+ return msg;
+}
+
+
+/****************************************************************/
+
+ecs_Result *svr_SetServerProjection(s,projection)
+ ecs_Server *s;
+ char *projection;
+{
+ ecs_Result *msg;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_SetServerProjection %s %s\n",s->url,projection);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->setserverprojection != NULL) {
+ msg = s->setserverprojection(s,projection);
+ } else {
+ msg = &svr_dummy_result;
+
+ if (s->projection != NULL) {
+ free(s->projection);
+ }
+ s->projection = (char *) malloc(strlen(projection)+1);
+ if (s->projection == NULL) {
+ ecs_SetError(msg,1,svr_messages[5]);
+ } else {
+ strcpy(s->projection,projection);
+ ecs_SetSuccess(msg);
+ }
+ }
+ return msg;
+}
+
+
+/****************************************************************/
+
+ecs_Result *svr_SetRasterConversion(s,rc)
+ ecs_Server *s;
+ ecs_RasterConversion *rc;
+{
+ ecs_Result *msg;
+ int i;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_SetRasterConversion %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->setrasterconversion != NULL) {
+ msg = s->setrasterconversion(s,rc);
+ } else {
+ msg = &svr_dummy_result;
+
+ if (s->rasterconversion.coef.coef_val != NULL)
+ free(s->rasterconversion.coef.coef_val);
+ s->rasterconversion.coef.coef_val = NULL;
+
+ s->rasterconversion.coef.coef_len = rc->coef.coef_len;
+ s->rasterconversion.coef.coef_val = (double *) malloc(sizeof(double)*rc->coef.coef_len);
+ if (s->rasterconversion.coef.coef_val == NULL) {
+ ecs_SetError(msg,1,svr_messages[5]);
+ return msg;
+ } else {
+ for (i=0;(int) i< (int) rc->coef.coef_len;i++) {
+ s->rasterconversion.coef.coef_val[i] = rc->coef.coef_val[i];
+ }
+ }
+ s->rasterconversion.isProjEqual = rc->isProjEqual;
+ s->rasterconversion.r_method = rc->r_method;
+ s->rasterconversion.t_method = rc->t_method;
+ }
+
+ ecs_SetSuccess(msg);
+ return msg;
+}
+
+/*
+ --------------------------------------------------------
+ ecs_SetLayer: Add a new layer to layer list in ecs_Server.
+
+ IN
+ s: Pointer to ecs_Server structure (given by caller)
+ sel: Layer selection structure
+
+ OUT
+ return int: Layer position in table. If an error occur
+ during allocation, a negative value is return.
+
+ --------------------------------------------------------
+ */
+
+int ecs_SetLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ ecs_Layer *temp;
+
+ if ((s->nblayer + 1) >= s->layer_tablesize) {
+ temp = malloc(sizeof(ecs_Layer)*(s->layer_tablesize+OGDILAYERINC));
+ if (temp == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate layer private data");
+ return -1;
+ }
+ if (s->layer != NULL) {
+ memcpy(temp,s->layer,(sizeof(ecs_Layer)*s->layer_tablesize));
+ free(s->layer);
+ }
+ s->layer = temp;
+ s->layer_tablesize += OGDILAYERINC;
+ }
+
+ s->layer[s->nblayer].sel.Select = (char *) malloc(strlen(sel->Select)+1);
+ if (s->layer[s->nblayer].sel.Select == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate layer private data");
+ return -1;
+ }
+
+ strcpy(s->layer[s->nblayer].sel.Select,sel->Select);
+ s->layer[s->nblayer].sel.F = sel->F;
+ s->layer[s->nblayer].index = 0;
+ s->layer[s->nblayer].nbfeature = 0;
+ s->layer[s->nblayer].priv = 0;
+ s->layer[s->nblayer].AttributeDriverLinkPtr = NULL;
+ s->layer[s->nblayer].attribute_priv = NULL;
+ s->layer[s->nblayer].InitializeDBLinkFuncPtr = NULL;
+ s->layer[s->nblayer].DeinitializeDBLinkFuncPtr = NULL;
+ s->layer[s->nblayer].GetColumnsInfoFuncPtr = NULL;
+ s->layer[s->nblayer].SelectAttributesFuncPtr = NULL;
+ s->layer[s->nblayer].IsSelectedFuncPtr = NULL;
+ s->layer[s->nblayer].GetSelectedAttributesFuncPtr = NULL;
+ s->layer[s->nblayer].AttributeDriverHandle = NULL;
+ s->layer[s->nblayer].SelectionAttributeListQty = 0;
+ s->layer[s->nblayer].SelectionAttributeList = NULL;
+ s->layer[s->nblayer].AttrRequest = NULL;
+
+ (s->nblayer)++;
+ return (s->nblayer)-1;
+}
+
+/*
+ --------------------------------------------------------
+ ecs_GetLayer: Found a layer in layer attribute of ecs_Server
+ for a certain selection.
+
+ IN
+ s: Pointer to ecs_Server structure (given by caller)
+ sel: Layer selection structure
+
+ OUT
+ return int: Layer position in table. If the layer don't exist,
+ this value will be negative.
+
+ --------------------------------------------------------
+ */
+
+int ecs_GetLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int i;
+
+ for(i=0;i<s->nblayer;i++) {
+ if ((strcmp(s->layer[i].sel.Select,sel->Select) == 0) &&
+ (s->layer[i].sel.F == sel->F)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+/*
+ --------------------------------------------------------
+ ecs_FreeLayer: Free a certain layer
+
+ IN
+ s: Pointer to ecs_Server structure (given by caller)
+ layer: Layer position
+
+ --------------------------------------------------------
+ */
+
+void ecs_FreeLayer(s,layer)
+ ecs_Server *s;
+ int layer;
+{
+ int i;
+
+ /* Check if the current layer is the one to destroy */
+ if (s->currentLayer == layer)
+ s->currentLayer = -1;
+
+ if (s->layer[layer].sel.Select != NULL)
+ free(s->layer[layer].sel.Select);
+ if (s->layer[layer].attribute_priv != NULL)
+ free(s->layer[layer].attribute_priv);
+ s->layer[layer].SelectionAttributeListQty = 0;
+ if (s->layer[layer].SelectionAttributeList != NULL)
+ free(s->layer[layer].SelectionAttributeList);
+ if (s->layer[layer].AttrRequest != NULL)
+ free(s->layer[layer].AttrRequest);
+
+ /* repositionate all the following layers */
+
+ for(i=layer;i<(s->nblayer)-1;i++) {
+ s->layer[i].sel.Select = s->layer[i+1].sel.Select;
+ s->layer[i].sel.F = s->layer[i+1].sel.F;
+ s->layer[i].index = s->layer[i+1].index;
+ s->layer[i].nbfeature = s->layer[i+1].nbfeature;
+ s->layer[i].priv = s->layer[i+1].priv;
+ s->layer[i].AttributeDriverLinkPtr = s->layer[i+1].AttributeDriverLinkPtr;
+ s->layer[i].attribute_priv = s->layer[i+1].attribute_priv;
+ s->layer[i].InitializeDBLinkFuncPtr = s->layer[i+1].InitializeDBLinkFuncPtr;
+ s->layer[i].DeinitializeDBLinkFuncPtr = s->layer[i+1].DeinitializeDBLinkFuncPtr;
+ s->layer[i].GetColumnsInfoFuncPtr = s->layer[i+1].GetColumnsInfoFuncPtr;
+ s->layer[i].SelectAttributesFuncPtr = s->layer[i+1].SelectAttributesFuncPtr;
+ s->layer[i].IsSelectedFuncPtr = s->layer[i+1].IsSelectedFuncPtr;
+ s->layer[i].GetSelectedAttributesFuncPtr = s->layer[i+1].GetSelectedAttributesFuncPtr;
+ s->layer[i].AttributeDriverHandle = s->layer[i+1].AttributeDriverHandle;
+ s->layer[i].SelectionAttributeListQty = s->layer[i+1].SelectionAttributeListQty;
+ s->layer[i].SelectionAttributeList = s->layer[i+1].SelectionAttributeList;
+ s->layer[i].AttrRequest = s->layer[i+1].AttrRequest;
+ }
+ (s->nblayer)--;
+
+
+ if (s->nblayer < (s->layer_tablesize - OGDILAYERINC)) {
+ s->layer_tablesize -= OGDILAYERINC;
+ if (s->nblayer <= 0) {
+ free(s->layer);
+ s->layer = NULL;
+ } else {
+ s->layer = realloc(s->layer,sizeof(ecs_Layer)*s->layer_tablesize);
+ }
+ }
+
+ return;
+}
+
+/****************************************************************/
+
+ecs_Result *svr_SetCompression(s,compression)
+ ecs_Server *s;
+ ecs_Compression *compression;
+{
+ ecs_Result *msg;
+
+#ifdef TESTOGDIINTERFACE
+ if (testfile == NULL) {
+ testfile = fopen("testinterface.txt","a");
+ }
+ if (testfile != NULL) {
+ fprintf(testfile,"svr_SetCompression %s\n",s->url);
+ fclose(testfile);
+ testfile = NULL;
+ }
+#endif
+
+ ecs_CleanUp(&(s->result));
+
+ if (s->handle != NULL && s->setcompression != NULL) {
+ msg = s->setcompression(s,compression);
+ } else {
+ msg = &svr_dummy_result;
+ ecs_SetError(msg,1,svr_messages[31]);
+ }
+
+ return msg;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ * ecs_RemoveDir
+ *
+ * Empty a directory (delete all *.* files) and remove the directory
+ *
+ * Results:
+ * A int (1 = done, 0 = error
+ *
+ *----------------------------------------------------------------------
+ */
+int ecs_RemoveDir(path)
+ char *path;
+{
+#ifdef _WINDOWS
+ struct _finddata_t c_file;
+ long hfile;
+ char current_dir[_MAX_PATH];
+
+ if (_getcwd(current_dir,_MAX_PATH) == NULL) {
+ return 0;
+ }
+
+ if (_chdir(path)) {
+ return 0;
+ }
+
+ if ((hfile = _findfirst("*.*", &c_file)) == -1L) {
+ return 0;
+ } else {
+ do {
+ unlink(c_file.name);
+ }
+ while(_findnext(hfile, &c_file) == 0);
+ _findclose(hfile);
+ }
+
+
+ _chdir(current_dir);
+
+ return (int) RemoveDirectory(path);
+#else
+ char buffer[256];
+
+ sprintf(buffer,"rm -r %s",path);
+ ogdi_system(buffer);
+ return 1;
+#endif
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_GetLateralDBConnection
+
+ DESCRIPTION
+ Put the contain of the Attribute Connection file in the Attribute
+ List.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Get the value of the environment variable OGDILINK with
+ the command getenv. If it's don't exist, return 0, no file
+ is found but no error encounter.
+
+ 2. Open the file specified in OGDILINK. If the file don't
+ open, return an error code indicating the OGDILINK is not
+ a valid file (code 26).
+
+ 3. While we are not in the end of the file
+ Begin
+
+ 3.1. Read the nine next line and set with each of them the
+ following structure attributes: url, layer, family, DriverType,
+ InformationSource, UserDescription, AutorizationDescription,
+ and SelectionRequest. The last line don't contain usefull
+ information.
+
+ 3.2. Call AddAttributeLink
+
+ End
+
+ 4. close the file
+
+ ********************************************************************
+ */
+
+int ecs_GetLateralDBConnectionCtrlFile(s)
+ ecs_Server *s;
+{
+ char *gl = NULL;
+ FILE *attr;
+ char *url = NULL;
+ char *layer = NULL;
+ ecs_Family family = 0;
+ char *drivertype = NULL;
+ char *informationSource = NULL;
+ char *user = NULL;
+ char *passwrd = NULL;
+ char *request = NULL;
+ int count;
+ int code = 0;
+ char chaine[200];
+ int size,i;
+
+ gl = getenv("OGDILINK");
+ if (gl == NULL)
+ return 0;
+
+ attr = fopen(gl,"rb");
+ if (attr == NULL) {
+ return 26;
+ }
+
+ count = 0;
+
+ while ( fgets(chaine,200,attr) != NULL ) {
+ size = strlen(chaine)+1;
+ for(i=0;i<size-1;i++) {
+ if (chaine[i] == '\n' || chaine[i] == '\r') {
+ chaine[i] = '\0';
+ size = i+1;
+ break;
+ }
+ }
+ count++;
+ switch(count) {
+ case 1:
+ url = malloc(size);
+ if (url == NULL)
+ goto GetLateralDBConnectionCtrlFileError;
+ strcpy(url,chaine);
+ break;
+ case 2:
+ layer = malloc(size);
+ if (layer == NULL)
+ goto GetLateralDBConnectionCtrlFileError;
+ strcpy(layer,chaine);
+ break;
+ case 3:
+ family = 0;
+ if (strcmp(chaine,"Area") == 0 || strcmp(chaine,"AREA") == 0)
+ family = Area;
+ else
+ if (strcmp(chaine,"Line") == 0 || strcmp(chaine,"LINE") == 0)
+ family = Line;
+ else
+ if (strcmp(chaine,"Point") == 0 || strcmp(chaine,"POINT") == 0)
+ family = Point;
+ else
+ if (strcmp(chaine,"Text") == 0 || strcmp(chaine,"TEXT") == 0)
+ family = Text;
+ else
+ if (strcmp(chaine,"Matrix") == 0 || strcmp(chaine,"MATRIX") == 0)
+ family = Matrix;
+ else
+ if (strcmp(chaine,"Image") == 0 || strcmp(chaine,"IMAGE") == 0)
+ family = Image;
+ else {
+ code = 32;
+ goto GetLateralDBConnectionCtrlFileError;
+ }
+ if (family == 0) {
+ goto GetLateralDBConnectionCtrlFileError;
+ }
+ break;
+ case 4:
+ drivertype = malloc(size);
+ if (drivertype == NULL)
+ goto GetLateralDBConnectionCtrlFileError;
+ strcpy(drivertype,chaine);
+ break;
+ case 5:
+ informationSource = malloc(size);
+ if (informationSource == NULL)
+ goto GetLateralDBConnectionCtrlFileError;
+ strcpy(informationSource,chaine);
+ break;
+ case 6:
+ user = malloc(size);
+ if (user == NULL)
+ goto GetLateralDBConnectionCtrlFileError;
+ strcpy(user,chaine);
+ break;
+ case 7:
+ passwrd = malloc(size);
+ if (passwrd == NULL)
+ goto GetLateralDBConnectionCtrlFileError;
+ strcpy(passwrd,chaine);
+ break;
+ case 8:
+ request = malloc(size);
+ if (request == NULL)
+ goto GetLateralDBConnectionCtrlFileError;
+ strcpy(request,chaine);
+
+ ecs_AddAttributeLink(s,url,layer,family,drivertype,informationSource,user,passwrd,request);
+
+ if (url != NULL) free(url);
+ if (layer != NULL) free(layer);
+ if (drivertype != NULL) free(drivertype);
+ if (informationSource != NULL) free(informationSource);
+ if (user != NULL) free(user);
+ if (passwrd != NULL) free(passwrd);
+ if (request != NULL) free(request);
+
+ url = NULL;
+ layer = NULL;
+ drivertype = NULL;
+ informationSource = NULL;
+ user = NULL;
+ passwrd = NULL;
+ request = NULL;
+
+ break;
+ case 9:
+ count = 0;
+ }
+ }
+
+ fclose(attr);
+
+ return 0;
+
+GetLateralDBConnectionCtrlFileError:
+ if (url != NULL) free(url);
+ if (layer != NULL) free(layer);
+ if (drivertype != NULL) free(drivertype);
+ if (informationSource != NULL) free(informationSource);
+ if (user != NULL) free(user);
+ if (passwrd != NULL) free(passwrd);
+ if (request != NULL) free(request);
+ if (code == 0)
+ return 5;
+ else return code;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_SetAttributeLinkWithRequest
+
+ DESCRIPTION
+ Check a request and if it contain a attribute link descriptor,
+ add it in the attribute link list. It place it in the beginning
+ of the list. When the SetAttributeQuery will be call, the search
+ in the list will lead to this item an the layer will be link with
+ it. If more than one link is define in the request, use the last
+ one.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ char *request: The request to use in creation
+ Family family: The family of the geographic object
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Extract from the request the link information (if it there are some)
+ with ecs_ExtractRequestInformation. If there is no request information
+ about a attribute driver link, return 0.
+
+ 2. Call AddAttributeLink with these values
+
+ ********************************************************************
+ */
+
+int ecs_SetAttributeLinkWithRequest(s,request,family)
+ ecs_Server *s;
+ char *request;
+ ecs_Family family;
+{
+ char *ExtractRequest;
+ char *DriverType;
+ char *InformationSource;
+ char *UserDescription;
+ char *AutorizationDescription;
+ char *SelectionRequest;
+
+ if (ecs_ExtractRequestInformation(request,&ExtractRequest,&DriverType,&InformationSource,
+ &UserDescription,&AutorizationDescription,&SelectionRequest) == 0) {
+ ecs_AddAttributeLink(s,s->url,ExtractRequest,family,DriverType,
+ InformationSource,UserDescription,AutorizationDescription,SelectionRequest);
+
+ free(ExtractRequest);
+ free(DriverType);
+ free(InformationSource);
+ free(UserDescription);
+ free(AutorizationDescription);
+ free(SelectionRequest);
+ }
+
+ return 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_RemoveAttributeLinkWithRequest
+
+ DESCRIPTION
+ Remove the item specified in the request from the AttributeLink list.
+ All the link to this attribute link must be remove before.
+ If more than one link is define in the request, use the fist one.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ char *request: The request to use in creation
+ ecs_Family family: The family of the geographic object
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Extract from the request the link information (if it there are some)
+ with ecs_ExtractRequestInformation. If there is no request information
+ about a attribute driver link, return 0.
+
+ 2. Search in the list to found a position with the same information.
+ If you found none, return 0.
+
+ 3. Destroy this position and shift the list in a way to fill the gap.
+
+ 4. Return 0
+
+ ********************************************************************
+ */
+
+int ecs_RemoveAttributeLinkWithRequest(s,request,family)
+ ecs_Server *s;
+ char *request;
+ ecs_Family family;
+{
+ char *ExtractRequest;
+ char *DriverType;
+ char *InformationSource;
+ char *UserDescription;
+ char *AutorizationDescription;
+ char *SelectionRequest;
+ int i,j;
+
+ if (ecs_ExtractRequestInformation(request,&ExtractRequest,&DriverType,&InformationSource,
+ &UserDescription,&AutorizationDescription,&SelectionRequest) == 0) {
+ for(i=0;i<s->AttributeListQty;i++) {
+ if (strcmp(s->url,s->AttributeList[i].url) == 0 &&
+ strcmp(ExtractRequest,s->AttributeList[i].layer) == 0 &&
+ family == s->AttributeList[i].family &&
+ strcmp(DriverType,s->AttributeList[i].DriverType) == 0 &&
+ strcmp(InformationSource,s->AttributeList[i].InformationSource) == 0 &&
+ strcmp(UserDescription,s->AttributeList[i].UserDescription) == 0 &&
+ strcmp(AutorizationDescription,s->AttributeList[i].AutorizationDescription) == 0 &&
+ strcmp(SelectionRequest,s->AttributeList[i].SelectionRequest) == 0) {
+
+ free(s->AttributeList[i].url);
+ free(s->AttributeList[i].layer);
+ free(s->AttributeList[i].DriverType);
+ free(s->AttributeList[i].InformationSource);
+ free(s->AttributeList[i].UserDescription);
+ free(s->AttributeList[i].AutorizationDescription);
+ free(s->AttributeList[i].SelectionRequest);
+
+ for(j=i;j<s->AttributeListQty-1;j++) {
+ s->AttributeList[j].url = s->AttributeList[j+1].url;
+ s->AttributeList[j].layer = s->AttributeList[j+1].layer;
+ s->AttributeList[j].family = s->AttributeList[j+1].family;
+ s->AttributeList[j].DriverType = s->AttributeList[j+1].DriverType;
+ s->AttributeList[j].InformationSource = s->AttributeList[j+1].InformationSource;
+ s->AttributeList[j].UserDescription = s->AttributeList[j+1].UserDescription;
+ s->AttributeList[j].AutorizationDescription = s->AttributeList[j+1].AutorizationDescription;
+ s->AttributeList[j].SelectionRequest = s->AttributeList[j+1].SelectionRequest;
+ }
+
+ (s->AttributeListQty)--;
+
+ break;
+ }
+ }
+ }
+
+ free(ExtractRequest);
+ free(DriverType);
+ free(InformationSource);
+ free(UserDescription);
+ free(AutorizationDescription);
+ free(SelectionRequest);
+ return 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_AddAttributeLink
+
+ DESCRIPTION
+ Add in the attribute link list an attribute link.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ char *url: URL
+ char *layer: Layer
+ Family family: Family
+ char *drivertype: Driver type
+ char *infosource: Information source
+ char *userdesc: User description
+ char *autorization: Autorization description
+ char *request: Selection request
+
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Initialize and add to the last position of attribute list a link
+ 2. Return 0
+
+ ********************************************************************
+ */
+
+int ecs_AddAttributeLink(s,url,layer,family,drivertype,infosource,userdesc,autorization,request)
+ ecs_Server *s;
+ char *url;
+ char *layer;
+ ecs_Family family;
+ char *drivertype;
+ char *infosource;
+ char *userdesc;
+ char *autorization;
+ char *request;
+{
+ ecs_AttributeLink *ptr;
+
+ s->AttributeList = realloc(s->AttributeList,(s->AttributeListQty+1)*sizeof(ecs_AttributeLink));
+ if (s->AttributeList == NULL) {
+ return 5;
+ }
+
+ ptr = &(s->AttributeList[s->AttributeListQty]);
+
+ ptr->url = NULL;
+ ptr->layer = NULL;
+ ptr->DriverType = NULL;
+ ptr->InformationSource = NULL;
+ ptr->UserDescription = NULL;
+ ptr->AutorizationDescription = NULL;
+ ptr->SelectionRequest = NULL;
+
+ if ((ptr->url = malloc(strlen(url)+1)) == NULL)
+ goto AddAttributeLinkError;
+ if ((ptr->layer = malloc(strlen(layer)+1)) == NULL)
+ goto AddAttributeLinkError;
+ if ((ptr->DriverType = malloc(strlen(drivertype)+1)) == NULL)
+ goto AddAttributeLinkError;
+ if ((ptr->InformationSource = malloc(strlen(infosource)+1)) == NULL)
+ goto AddAttributeLinkError;
+ if ((ptr->UserDescription = malloc(strlen(userdesc)+1)) == NULL)
+ goto AddAttributeLinkError;
+ if ((ptr->AutorizationDescription = malloc(strlen(autorization)+1)) == NULL)
+ goto AddAttributeLinkError;
+ if ((ptr->SelectionRequest = malloc(strlen(request)+1)) == NULL)
+ goto AddAttributeLinkError;
+
+ strcpy(ptr->url,url);
+ strcpy(ptr->layer,layer);
+ ptr->family = family;
+ strcpy(ptr->DriverType,drivertype);
+ strcpy(ptr->InformationSource,infosource);
+ strcpy(ptr->UserDescription,userdesc);
+ strcpy(ptr->AutorizationDescription,autorization);
+ strcpy(ptr->SelectionRequest,request);
+
+ (s->AttributeListQty)++;
+
+ return 0;
+
+AddAttributeLinkError:
+ if (ptr->url != NULL)
+ free(ptr->url);
+ if (ptr->layer != NULL)
+ free(ptr->layer);
+ if (ptr->DriverType != NULL)
+ free(ptr->DriverType);
+ if (ptr->InformationSource != NULL)
+ free(ptr->InformationSource);
+ if (ptr->UserDescription != NULL)
+ free(ptr->UserDescription);
+ if (ptr->AutorizationDescription != NULL)
+ free(ptr->AutorizationDescription);
+ if (ptr->SelectionRequest != NULL)
+ free(ptr->SelectionRequest);
+ return 5;
+}
+
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_ExtractRequestInformation
+
+ DESCRIPTION
+ Extract the attribute link information if this information exist.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ char *request: Request string
+ OUTPUT
+ char **ExtractRequest: Substring of the request without the request information
+ char **DriverType: Driver type
+ char **InformationSource: Information source
+ char **UserDescription: User description
+ char **AutorizationDescription: Autorization description
+ char **SelectionRequest: Selection Request (usually a SQL request)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Check for the '&' character. If it's it's not in the string,
+ then there is no link define. Set all the output to null and return 1.
+
+ 2. Replace all the /SPACE/ string in the request by a real space
+
+ 3. Positionnate a cursor to the sixth last '&' in request
+
+ 4. Extract the string between this '&' and the next one. Put the
+ string in DriverType. Set the cursor to the next '&'.
+
+ 5. Extract the string between this '&' and the next one. Put the
+ string in UserDescription. Set the cursor to the next '&'.
+
+ 6. Extract the string between this '&' and the next one. Put the
+ string in AutorizationDescription. Set the cursor to the next '&'.
+
+ 7. Extract the string between this '&' and the next one. Put the
+ string in SelectionRequest.
+
+ 8. Return 0
+
+ ********************************************************************
+ */
+
+int ecs_ExtractRequestInformation(request,ExtractRequest,DriverType,InformationSource,UserDescription,AutorizationDescription,SelectionRequest)
+ char *request;
+ char **ExtractRequest;
+ char **DriverType;
+ char **InformationSource;
+ char **UserDescription;
+ char **AutorizationDescription;
+ char **SelectionRequest;
+{
+ int count,i,j;
+ char *temp,*ptr;
+ char character[2];
+ int candlist[13];
+
+ *ExtractRequest = NULL;
+ *DriverType = NULL;
+ *InformationSource = NULL;
+ *UserDescription = NULL;
+ *AutorizationDescription = NULL;
+ *SelectionRequest = NULL;
+
+ /* Convert /SPACE/ to ' ' */
+
+ temp = malloc(strlen(request)+1);
+ if (temp == NULL)
+ return 5;
+
+ j=0;
+ strcpy(temp,"");
+ for(i=0,ptr = request;i<(int) strlen(request);i++,ptr++) {
+ if(strncmp(ptr,"/SPACE/",7) == 0) {
+ strcat(temp," ");
+ ptr+=6;
+ i+=6;
+ } else {
+ character[0] = ptr[0];
+ character[1] = '\0';
+ strcat(temp,character);
+ }
+ }
+
+ /* Count the quantity of & in request and keep the position of each of it */
+ count = 0;
+ for(i=0;i<(int) strlen(temp);i++) {
+ if (temp[i] == '&') {
+ candlist[count] = i;
+ count++;
+ }
+ }
+
+ if ( !(count == 6 || count == 11) ) {
+ free(temp);
+ return 1;
+ }
+
+ /*
+ Extract the string between the fifth lastest '&' and the next one. Put the
+ string in DriverType.
+ */
+
+ *ExtractRequest = malloc(candlist[count-6]+2);
+ *DriverType = malloc(candlist[count-5]-candlist[count-6]+1);
+ *InformationSource = malloc(candlist[count-4]-candlist[count-5]+1);
+ *UserDescription = malloc(candlist[count-3]-candlist[count-4]+1);
+ *AutorizationDescription = malloc(candlist[count-2]-candlist[count-3]+1);
+ *SelectionRequest = malloc(candlist[count-1]-candlist[count-2]+1);
+
+ if (*ExtractRequest == NULL || *DriverType == NULL ||
+ *InformationSource == NULL || *UserDescription == NULL ||
+ *AutorizationDescription == NULL || *SelectionRequest == NULL) {
+ if (*ExtractRequest != NULL) free(*ExtractRequest);
+ if (*DriverType != NULL) free(*DriverType);
+ if (*InformationSource != NULL) free(*InformationSource);
+ if (*UserDescription != NULL) free(*UserDescription);
+ if (*AutorizationDescription != NULL) free(*AutorizationDescription);
+ if (*SelectionRequest != NULL) free(*SelectionRequest);
+ if (temp != NULL) free(temp);
+ return 5;
+ }
+
+ if (count == 6) {
+ strncpy(*ExtractRequest,temp,candlist[count-6]);
+ (*ExtractRequest)[candlist[count-6]] = '\0';
+ ptr = &(temp[candlist[count-6]+1]);
+ } else {
+ strncpy(*ExtractRequest,temp,candlist[count-6]+1);
+ (*ExtractRequest)[candlist[count-6]+1] = '\0';
+ ptr = &(temp[candlist[count-6]+1]);
+ }
+
+ strncpy(*DriverType,ptr,candlist[count-5]-candlist[count-6]-1);
+ (*DriverType)[candlist[count-5]-candlist[count-6]-1] = '\0';
+ ptr = &(temp[candlist[count-5]+1]);
+
+ strncpy(*InformationSource,ptr,candlist[count-4]-candlist[count-5]-1);
+ (*InformationSource)[candlist[count-4]-candlist[count-5]-1] = '\0';
+ ptr = &(temp[candlist[count-4]+1]);
+
+ strncpy(*UserDescription,ptr,candlist[count-3]-candlist[count-4]-1);
+ (*UserDescription)[candlist[count-3]-candlist[count-4]-1] = '\0';
+ ptr = &(temp[candlist[count-3]+1]);
+
+ strncpy(*AutorizationDescription,ptr,candlist[count-2]-candlist[count-3]-1);
+ (*AutorizationDescription)[candlist[count-2]-candlist[count-3]-1] = '\0';
+ ptr = &(temp[candlist[count-2]+1]);
+
+ strncpy(*SelectionRequest,ptr,candlist[count-1]-candlist[count-2]-1);
+ (*SelectionRequest)[candlist[count-1]-candlist[count-2]-1] = '\0';
+
+ return 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_SetAttributeQuery
+
+ DESCRIPTION
+ Scan the attribute link list to see if a link is possible
+ with an attribute driver. If it found one, it link it to the
+ layer and initialize the link to the attribute driver.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer object attributes
+ OUTPUT
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Search in the AttributeLink list a link for with the url, layer
+ and family of this query. If there is none, return 0.
+
+ 2. Load the dll specified in DriverType and put the handle in AttributeDriverHandle.
+ If it's not possible, return the code to indicate an error in the connection of the
+ dll.
+
+ 3. Create the links to the functions of the attribute driver and put it in the
+ pointers in the layer information. If one of the links is not possible, return the
+ code to indicate this is impossible to open a link.
+
+ 4. Replace the elements of the SQL request between interrogation marks with
+ only one interrogation marks. These elements are attributes to be replaced during
+ selection. Check if these attributes exist really with GetAttributesFormat and
+ simply set a list of the attributes positions in the layer for later retreaval.
+ The positions simply indicate the position in the attributes string of the
+ attributes to be sent in SelectAttributes in the attribute driver.
+
+ 5. Call InitializeDBLink to initialize the attribute link. If it's not possible,
+ return the error code from this command.
+
+ 6. Return 0
+
+ MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+ Description: The result of ecs_GetDynamicLibFunction() has been cast
+ to type (attrfunc *). The original cast to (void *)
+ seems incorrect.
+
+ ********************************************************************
+ */
+
+int ecs_SetAttributeQuery(s,l,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char **error;
+{
+ int i,j,count,k,pos;
+ ecs_AttributeLink *link;
+ char **ptr,*request;
+ ecs_Result *res = NULL;
+ char buffer[100];
+ int isAttributes;
+ char *temp,*ptr1;
+ char character[2];
+ int code;
+
+ if (l->AttributeDriverHandle != NULL)
+ return 0;
+
+ temp = malloc(strlen(l->sel.Select)+1);
+ if (temp == NULL) {
+ *error = svr_messages[5];
+ return 1;
+ }
+ j=0;
+ strcpy(temp,"");
+ for(i=0,ptr1 = l->sel.Select;i<(int) strlen(l->sel.Select);i++,ptr1++) {
+ if(strncmp(ptr1,"/SPACE/",7) == 0) {
+ strcat(temp," ");
+ ptr1+=6;
+ i+=6;
+ } else {
+ character[0] = ptr1[0];
+ character[1] = '\0';
+ strcat(temp,character);
+ }
+ }
+
+ /*
+ 1. Search in the AttributeLink list a link for with the url, layer
+ and family of this query. If there is none, return 0.
+ */
+
+ link = NULL;
+ for(i=(s->AttributeListQty-1);i>=0;i--) {
+ if (strcmp(s->url,s->AttributeList[i].url) == 0 &&
+ strcmp(temp,s->AttributeList[i].layer) == 0 &&
+ l->sel.F == s->AttributeList[i].family) {
+ link = &(s->AttributeList[i]);
+ break;
+ }
+ }
+ free(temp);
+
+ if (link == NULL) {
+ return 0;
+ }
+
+ l->AttributeDriverLinkPtr = link;
+
+ /*
+ 2. Load the dll specified in DriverType and put the handle in AttributeDriverHandle.
+ If it's not possible, return the code to indicate an error in the connection of the
+ dll.
+ */
+
+ l->AttributeDriverHandle = ecs_OpenDynamicLib(link->DriverType);
+ if (l->AttributeDriverHandle == NULL) {
+ *error = svr_messages[28];
+ return 1;
+ }
+
+ /*
+ 3. Create the links to the functions of the attribute driver and put it in the
+ pointers in the layer information. If one of the links is not possible, return the
+ code to indicate this is impossible to open a link.
+ */
+
+/**MOD START**/
+ l->InitializeDBLinkFuncPtr = (attrfunc *) ecs_GetDynamicLibFunction(l->AttributeDriverHandle,"dyn_InitializeDBLink");
+ l->DeinitializeDBLinkFuncPtr = (attrfunc *) ecs_GetDynamicLibFunction(l->AttributeDriverHandle,"dyn_DeinitializeDBLink");
+ l->GetColumnsInfoFuncPtr = (attrfunc *) ecs_GetDynamicLibFunction(l->AttributeDriverHandle,"dyn_GetColumnsInfo");
+ l->SelectAttributesFuncPtr = (attrfunc *) ecs_GetDynamicLibFunction(l->AttributeDriverHandle,"dyn_SelectAttributes");
+ l->IsSelectedFuncPtr = (attrfunc *) ecs_GetDynamicLibFunction(l->AttributeDriverHandle,"dyn_IsSelected");
+ l->GetSelectedAttributesFuncPtr = (attrfunc *) ecs_GetDynamicLibFunction(l->AttributeDriverHandle,"dyn_GetSelectedAttributes");
+/**MOD END**/
+
+ if (l->InitializeDBLinkFuncPtr == NULL ||
+ l->DeinitializeDBLinkFuncPtr == NULL ||
+ l->GetColumnsInfoFuncPtr == NULL ||
+ l->SelectAttributesFuncPtr == NULL ||
+ l->IsSelectedFuncPtr == NULL ||
+ l->GetSelectedAttributesFuncPtr == NULL) {
+ ecs_CloseDynamicLib(l->AttributeDriverHandle);
+ *error = svr_messages[28];
+ return 1;
+ }
+
+ /*
+ 4. Replace the elements of the SQL request between interrogation marks with
+ only one interrogation marks. These elements are attributes to be replaced during
+ selection. Check if these attributes exist really with GetAttributesFormat and
+ simply set a list of the attributes positions in the layer for later retreaval.
+ The positions simply indicate the position in the attributes string of the
+ attributes to be sent in SelectAttributes in the attribute driver.
+ */
+
+ request = l->AttributeDriverLinkPtr->SelectionRequest;
+ count = 0;
+ for(i=0;i<(int) strlen(request);i++) {
+ if (request[i] == '?')
+ count++;
+ }
+ ptr = malloc((count+1)*sizeof(char *));
+ if (ptr == NULL) {
+ ecs_CloseDynamicLib(l->AttributeDriverHandle);
+ *error = svr_messages[28];
+ return 1;
+ }
+
+ k=0;
+ for(i=0;i<(int) strlen(request);i++) {
+ if (request[i] == '?') {
+ ptr[k] = &(request[i]);
+ k++;
+ }
+ }
+
+ if (count%2 == 1) {
+ ecs_CloseDynamicLib(l->AttributeDriverHandle);
+ free(ptr);
+ *error = svr_messages[29];
+ return 1;
+ }
+
+ l->SelectionAttributeListQty = count/2;
+ l->SelectionAttributeList = malloc(sizeof(int)*l->SelectionAttributeListQty);
+ if (l->SelectionAttributeList == NULL) {
+ free(ptr);
+ ecs_CloseDynamicLib(l->AttributeDriverHandle);
+ *error = svr_messages[5];
+ return 1;
+ }
+
+ l->AttrRequest = malloc(strlen(request)+2);
+ if (l->AttrRequest == NULL) {
+ free(ptr);
+ ecs_CloseDynamicLib(l->AttributeDriverHandle);
+ *error = svr_messages[5];
+ return 1;
+ }
+
+ /* Fill the selection attribute list */
+
+ isAttributes = FALSE;
+ if (s->handle != NULL && s->getattrformat != NULL) {
+ if (!((!(s->isRemote)) &&
+ (s->currentLayer == -1))) {
+ res = s->getattrformat(s);
+ if (ECSSUCCESS(res)) {
+ isAttributes=TRUE;
+ }
+ }
+ }
+
+ if (count > 0) {
+ pos = (int) (ptr[0]-request);
+ strncpy(l->AttrRequest,request,pos);
+ l->AttrRequest[pos]='\0';
+
+ for(i=0;i<count;i+=2) {
+ /*
+ Extract the element pointed in i
+ */
+
+ strncpy(buffer,ptr[i]+1,ptr[i+1]-ptr[i]-1);
+ buffer[ptr[i+1]-ptr[i]-1] = '\0';
+
+ if (strncmp(buffer,"OGDI.ID",7) == 0)
+ l->SelectionAttributeList[i/2] = OGDIID;
+ else if (strncmp(buffer,"OGDI.DESC",9) == 0)
+ l->SelectionAttributeList[i/2] = OGDIDESC;
+ else if (strncmp(buffer,"OGDI.CAT",8) == 0)
+ l->SelectionAttributeList[i/2] = OGDICAT;
+ else if (!isAttributes) {
+ free(ptr);
+ ecs_CloseDynamicLib(l->AttributeDriverHandle);
+ *error = svr_messages[29];
+ return 1;
+ } else {
+ l->SelectionAttributeList[i/2] = -1;
+ for(j=0;j<(int) ECSRESULT(res).oaf.oa.oa_len;j++) {
+ if(strcmp(buffer,ECSRESULT(res).oaf.oa.oa_val[j].name) == 0) {
+ l->SelectionAttributeList[i/2] = j;
+ break;
+ }
+ }
+ if (l->SelectionAttributeList[i/2] == -1) {
+ free(ptr);
+ ecs_CloseDynamicLib(l->AttributeDriverHandle);
+ *error = svr_messages[27];
+ return 1;
+ }
+ }
+ strcat(l->AttrRequest,"?");
+
+
+ if(i+2<count) {
+ strncat(l->AttrRequest,ptr[i+1],ptr[i+2]-ptr[i+1]);
+ }
+ }
+ strcat(l->AttrRequest,ptr[count-1]+1);
+
+ /*
+ 5. Call InitializeDBLink to initialize the attribute link. If it's not possible,
+ return the error code from this command.
+ */
+
+ free(ptr);
+ } else {
+ strcpy(l->AttrRequest,request);
+ }
+
+ code = (l->InitializeDBLinkFuncPtr)(s,l,error);
+ return code;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_ReleaseAttributeQuery
+
+ DESCRIPTION
+ Release the link to the attribute driver.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer object attributes
+ OUTPUT
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Call DeinitializeDBLink to deinitialize the attribute link.
+
+ 2. Unload the attribute driver dll.
+
+ 3. Set AttributeDriverHandle to NULL.
+
+ ********************************************************************
+ */
+
+int ecs_ReleaseAttributeQuery(s,l,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char **error;
+{
+ int code = 0;
+
+ if (l->AttributeDriverHandle != NULL) {
+ code = (l->DeinitializeDBLinkFuncPtr)(s,l,error);
+ ecs_CloseDynamicLib(l->AttributeDriverHandle);
+ l->AttributeDriverHandle = NULL;
+ }
+ return 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_UnstackRequest
+
+ DESCRIPTION
+ Remove the attribute link information from the request string
+ (if it's the case). If there is more than one of these links,
+ remove the last one.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ IN/OUT
+ char **request: Request
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Check if there is a '&' in the request. If not, return 0.
+
+ 2. Found the position of the sixth last position of & in request
+ and put a end of string there.
+
+ 3. Return 0
+
+ ********************************************************************
+ */
+
+int ecs_UnstackRequest(s,request)
+ ecs_Server *s;
+ char **request;
+{
+ int count,i;
+ int candlist[13];
+
+ (void) s;
+
+ /* Count the quantity of & in request and keep the position of each of it */
+ count = 0;
+ for(i=0;i<(int) strlen(*request);i++) {
+ if ((*request)[i] == '&') {
+ candlist[count] = i;
+ count++;
+ }
+ }
+
+ if ( !(count == 6 || count == 11) ) {
+ return 1;
+ }
+
+ if (count == 6) {
+ (*request)[candlist[count-6]] = '\0';
+ } else {
+ (*request)[candlist[count-6]+1] = '\0';
+ }
+
+ return 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_SetBindListForVector
+
+ DESCRIPTION
+ With the information retrieved from the geographic object vector,
+ initialize a list of bind.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer info
+ ecs_Result *msg: The geographic object
+ OUTPUT
+ char **BindList: The result bind list
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Allocate the attribute list with the bind information
+ 2. If the allocation in 1. is a success
+ Begin
+ 2.1. Initialize the attribute list table with nulls
+ 2.2. Split the list of attributes in the object
+ 2.3. If the split work correctly
+ Begin
+ 2.3.1. For each attribute i in the attribute list
+ Begin
+ 2.3.1.1. If the attribute is suppose to be the object id
+ Begin
+ 2.3.1.1.1. Initialize the position i in the attribute list
+ with the id. If an error occur, the code is 5 (not enough
+ memory) and go to 99.
+ End
+ 2.3.1.2. Else
+ Begin
+ 2.3.1.2.1. Check if the attribute is in a impossible position
+ (less then 0 or greater than the quantity of attributes
+ in the list). If it's the case, the code is 27 (One of the
+ attributes specified in the list is not define) and go to 99.
+ 2.3.1.2.2. Initialize the position i in the attribute list
+ with the attribute index. If an error occur, the code
+ is 5 (not enough memory) and go to 99.
+ End
+ End
+ End
+ 2.4. Else
+ Begin
+ The code is 5 and go to 99.
+ End
+ End
+ 3. Else
+ Begin
+ The code is 5 and go to 99.
+ End
+
+ 99. ErrorCase, Free all the memory and return the error message
+ related to a code.
+
+ ********************************************************************
+ */
+
+int ecs_SetBindListForVector(s,l,msg,BindList,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Result *msg;
+ char ***BindList;
+ char **error;
+{
+ int attribute_qty,i;
+ int code;
+ char **attribute_list;
+ int argc;
+ char **argv;
+
+ (void) s;
+
+ attribute_qty = l->SelectionAttributeListQty;
+
+ code = 0;
+ attribute_list = (char **) malloc(sizeof(char **)*(attribute_qty+1));
+ if (attribute_list != NULL) {
+ for(i=0;i>attribute_qty;i++)
+ attribute_list[i] = NULL;
+ if (ecs_SplitList(ECSOBJECT(msg).attr,&argc,&argv)) {
+ for(i=0;i<attribute_qty;i++) {
+ if (l->SelectionAttributeList[i] == OGDIID) {
+ attribute_list[i] = malloc(strlen(ECSOBJECT(msg).Id)+1);
+ if (attribute_list[i] == NULL) {
+ code = 5;
+ goto SetBindListForVectorError;
+ }
+ strcpy(attribute_list[i],ECSOBJECT(msg).Id);
+ } else {
+ if (l->SelectionAttributeList[i] > argc ||
+ l->SelectionAttributeList[i] < 0 ||
+ argc <= 0) {
+ code = 27;
+ goto SetBindListForVectorError;
+ }
+ attribute_list[i] = malloc(strlen(argv[l->SelectionAttributeList[i]])+1);
+ if (attribute_list[i] == NULL) {
+ code = 5;
+ goto SetBindListForVectorError;
+ }
+ strcpy(attribute_list[i],argv[l->SelectionAttributeList[i]]);
+ }
+ }
+ } else {
+ code = 5;
+ goto SetBindListForVectorError;
+ }
+ } else {
+ code = 5;
+ goto SetBindListForVectorError;
+ }
+
+ *BindList = attribute_list;
+ *error = NULL;
+ free(argv);
+ return 0;
+
+SetBindListForVectorError:
+ for(i=0;i>attribute_qty;i++)
+ if (attribute_list[i] != NULL)
+ free(attribute_list[i]);
+ free(argv);
+ free(attribute_list);
+ *error = svr_messages[code];
+ return 1;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ ecs_SetBindListForMatrix
+
+ DESCRIPTION
+ With the information retrieved from a category, contruct
+ the bind list information for a matrix.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server object attributes
+ ecs_Layer *l: Layer info
+ ecs_Category *ptr: The geographic object
+ OUTPUT
+ char **BindList: The result bind list
+ char **error: Error message (if it's the case)
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. 0 if the operation is a success. a code if the operation failed.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Allocate the attribute list with the bind information
+ 2. If the allocation in 1. is a success
+ Begin
+ 2.1. Initialize the attribute list table with nulls
+ 2.2. For each attribute i in the attribute list
+ Begin
+ 2.2.1. If the attribute is suppose to be the category number
+ Begin
+ 2.2.1.1. Initialize the position i in the attribute list
+ with the category number. If an error occur, the code is 5 (not enough
+ memory) and go to 99.
+ End
+ 2.2.2. Else
+ Begin
+ 2.2.2.1. If the attribute is suppose to be the category description
+ Begin
+ 2.2.2.1.1. Initialize the position i in the attribute list
+ with the category description. If an error occur, the code is 5 (not enough
+ memory) and go to 99.
+ End
+ 2.2.2.2. Else
+ Begin
+ The code is 27 and go to 99.
+ End
+ End
+ End
+ End
+ 3. Else
+ Begin
+ The code is 5 and go to 99.
+ End
+
+ 99. ErrorCase, Free all the memory and return the error message
+ related to a code.
+
+ ********************************************************************
+ */
+
+int ecs_SetBindListForMatrix(s,l,ptr,BindList,error)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Category *ptr;
+ char ***BindList;
+ char **error;
+{
+ int attribute_qty,i;
+ int code;
+ char temp[100];
+ char **attribute_list;
+
+ (void) s;
+
+ attribute_qty = l->SelectionAttributeListQty;
+
+ code = 0;
+ attribute_list = (char **) malloc(sizeof(char **)*(attribute_qty+1));
+ if (attribute_list != NULL) {
+ for(i=0;i>attribute_qty;i++)
+ attribute_list[i] = NULL;
+ for(i=0;i<attribute_qty;i++) {
+ switch(l->SelectionAttributeList[i]) {
+ case OGDICAT:
+ sprintf(temp,"%ld",ptr->no_cat);
+ attribute_list[i] = malloc(strlen(temp)+1);
+ if (attribute_list[i] == NULL) {
+ code = 5;
+ goto SetBindListForMatrixError;
+ }
+ strcpy(attribute_list[i],temp);
+ break;
+ case OGDIDESC:
+ attribute_list[i] = malloc(strlen(ptr->label)+1);
+ if (attribute_list[i] == NULL) {
+ code = 5;
+ goto SetBindListForMatrixError;
+ }
+ strcpy(attribute_list[i],ptr->label);
+ break;
+ default:
+ code = 27;
+ goto SetBindListForMatrixError;
+ }
+ }
+ } else {
+ code = 5;
+ goto SetBindListForMatrixError;
+ }
+
+ *BindList = attribute_list;
+ *error = NULL;
+ return 0;
+
+SetBindListForMatrixError:
+ for(i=0;i>attribute_qty;i++)
+ if (attribute_list[i] != NULL)
+ free(attribute_list[i]);
+ free(attribute_list);
+ *error = svr_messages[5];
+ return 1;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/dtcanada.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/dtcanada.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/dtcanada.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,326 @@
+/*********************************************************************
+
+ CSOURCE_INFORMATION
+
+ NAME
+ dtcanada.c
+
+ DESCRIPTION
+ Module used to convert geographics point from nad27 to nad83. Interface
+ between nadconv module and the c_interface.
+ END_DESCRIPTION
+
+ END_CSOURCE_INFORMATION
+
+ Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ ********************************************************************/
+
+#include "ecs.h"
+#include "nadconv.h"
+
+NAD_DATA *dtptr = NULL;
+int nad_count = 0;
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_nad_init
+
+ DESCRIPTION
+ Prepare the nad converter to convert points in Canada.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ char *table: The table name (not used)
+ IN/OUT
+ void **privdata: Private data pointer
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : Contain the result of the operation. Success if TRUE,
+ failure if FALSE.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Increment nad_count. If nad_count value is 1
+ Begin
+ 1.1. Check the OGDIDATUM environment variable. If it's not there,
+ return FALSE
+
+ 1.2. Get the OGDIDATUM and concatenate NTV2_0.GSB to form a file path
+
+ 1.3. Call NAD_init in the library with the file path found in 2. and
+ the arguments "NAD27" and "NAD83". Get the returned code.
+
+ 1.4. If the code is an error, return FALSE.
+
+ 1.5. Set dtptr to the value retuned by NAD_init
+ End
+
+ 2. Set privdata to dtptr
+
+ 3. Return TRUE
+
+ ********************************************************************
+ */
+
+int dyn_nad_init(privdata, table)
+ void **privdata;
+ char *table;
+{
+ char *pathfile;
+
+ (void) table;
+
+ *privdata = NULL;
+ nad_count++;
+
+ if (nad_count == 1) {
+ if (getenv("OGDIDATUM") == NULL) {
+ nad_count--;
+ return FALSE;
+ }
+
+ pathfile = malloc(strlen(getenv("OGDIDATUM"))+12);
+ if (pathfile == NULL) {
+ nad_count--;
+ return FALSE;
+ }
+ strcpy(pathfile,getenv("OGDIDATUM"));
+ strcat(pathfile,"/NTV2_0.GSB");
+
+ dtptr = NAD_Init(pathfile,"NAD27","NAD83");
+ if (dtptr == NULL) {
+ nad_count--;
+ return FALSE;
+ }
+ free(pathfile);
+
+ } else {
+ if (dtptr == NULL) {
+ nad_count=1;
+ return FALSE;
+ }
+ }
+
+ *privdata = (void *) dtptr;
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_nad_close
+
+ DESCRIPTION
+ Free the allocated structure dtptr
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ void *privdata: The private data of the driver
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : Contain the result of the operation. Success if TRUE,
+ failure if FALSE.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Decrement count
+
+ 2. If count is lower or equal to zero
+ Begin
+ 2.1. Close the pointer dtptr with NAD_Close and set it to NULL
+ End
+
+ 3. Return TRUE
+
+ ********************************************************************
+ */
+
+int dyn_nad_close(privdata)
+ void *privdata;
+{
+ (void) privdata;
+ nad_count--;
+ if (nad_count <= 0) {
+ NAD_Close(dtptr);
+ dtptr = NULL;
+ }
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_nad_forward
+
+ DESCRIPTION
+ Convert a point in the NAD27 datum to NAD83. If an error occur,
+ don't make any convertion.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ void *privdata: The private data of the driver
+ IN/OUT
+ double *x: lattitude of the geographical coordinate
+ double *y: longitude of the geographical coordinate
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : Contain the result of the operation. Success if TRUE,
+ failure if FALSE. In this case, it's always success.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Copy the x and y coordinates in temp_x and temp_y
+
+ 2. Call NAD_Forward with temp_x and temp_y
+
+ 3. If the previous operation is a success, put in x and y
+ the contain of temp_x and temp_y.
+
+ 4. Return TRUE
+
+ ********************************************************************
+ */
+
+int dyn_nad_forward(privdata,x,y)
+ void *privdata;
+ double *x;
+ double *y;
+{
+ double temp_x,temp_y;
+
+ (void) privdata;
+
+ if (dtptr == NULL)
+ return TRUE;
+
+ temp_x = *x * -3600.0;
+ temp_y = *y * 3600.0;
+
+ if (NAD_Forward(dtptr,&temp_x,&temp_y) == NAD_OK) {
+ *x = temp_x / -3600.0;
+ *y = temp_y / 3600.0;
+ }
+
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_nad_reverse
+
+ DESCRIPTION
+ Convert a point in the NAD83 datum to NAD27. If an error occur,
+ don't make any convertion.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ void *privdata: The private data of the driver
+ IN/OUT
+ double *x: lattitude of the geographical coordinate
+ double *y: longitude of the geographical coordinate
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : Contain the result of the operation. Success if TRUE,
+ failure if FALSE. In this case, it's always success.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Copy the x and y coordinates in temp_x and temp_y
+
+ 2. Call NAD_Reverse with temp_x and temp_y
+
+ 3. If the previous operation is a success, put in x and y
+ the contain of temp_x and temp_y.
+
+ 4. Return TRUE
+
+ ********************************************************************
+ */
+
+int dyn_nad_reverse(privdata,x,y)
+ void *privdata;
+ double *x;
+ double *y;
+{
+ double temp_x,temp_y;
+
+ (void) privdata;
+
+ if (dtptr == NULL)
+ return TRUE;
+
+ temp_x = *x * -3600.0;
+ temp_y = *y * 3600.0;
+
+ if (NAD_Reverse(dtptr,&temp_x,&temp_y) == NAD_OK) {
+ *x = temp_x / -3600.0;
+ *y = temp_y / 3600.0;
+ }
+
+ return TRUE;
+}
+
+
+#ifdef _WINDOWS
+/*
+ * When the DLL is being unloaded, make sure to destroy all of
+ * the clients that remain open.
+ */
+BOOL WINAPI
+DllMain( HINSTANCE hinstDLL, // handle of DLL module
+ DWORD fdwReason, // reason for calling function
+ LPVOID lpvReserved)
+{
+ switch (fdwReason) {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ break;
+ case DLL_PROCESS_DETACH:
+ nad_count=1;
+ dyn_nad_close((void *) dtptr);
+ break;
+ }
+ return TRUE;
+}
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/dtcanada.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/dtcanada.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/dtcanada.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,12 @@
+LIBRARY dtcanada
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_nad_init
+ dyn_nad_close
+ dyn_nad_forward
+ dyn_nad_reverse
+ DllMain
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = dtcanada
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = nadconv.c dtcanada.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS=
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/nadconv.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/nadconv.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/nadconv.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,757 @@
+/*
+ * NAD to NAD conversion program.
+ *
+ * This package has four functions:
+ * NAD_DATA* NAD_Init(char *filename, char *fdatum, char *tdatum)
+ * - Pass this routine the name of the binary grid data
+ * file that contains the adjustment data.
+ * - The routine returns a pointer to a structure containing
+ * lookups to the adjustment subgrids.
+ * - Checks that the adjustment file really contains the
+ * requested datums (source datum == fdatum and target data == tdatum).
+ * If not returns a NULL;
+ * - Returns NULL on any other error.
+ * int NAD_Forward(NAD_DATA *nadPtr, double *lat, double *lon)
+ * - Pass a lat/long pair and it will adjust forward according
+ * to the adjustments in the file.
+ * - Converted values are returned in place.
+ * - Returns NAD_OK upon success.
+ * int NAD_Reverse(NAD_DATA *nadPtr, double *lat, double *lon)
+ * - Similar to NAD_Reverse, but performs reverse correction.
+ * void NAD_Close(NAD_DATA *nadPtr)
+ * - Closes grid file and frees memory.
+ *
+ * Note that the conversion routines convert lat/long values
+ * specifed as decimal seconds:
+ * D*3600 + M*60 + seconds/60
+ *
+ * Tom Moore, March 1997
+ * William Lau, January 1997
+ *
+ * Based on the Fortran program INTGRID.
+ *
+ *
+ * Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+
+
+/*
+ ************************************************************
+ *
+ * Include files
+ *
+ ************************************************************
+ */
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#ifdef _WINDOWS
+#include <io.h>
+#endif
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <ogdi_macro.h>
+
+
+
+
+
+/*
+ ************************************************************
+ *
+ * Defines and macros
+ *
+ ************************************************************
+ */
+#define INTGRID_INT
+
+#ifdef sun
+#define NEED_TO_SWAP
+#endif
+
+#ifdef NEED_TO_SWAP
+#define BYTESWAP(BUFFER, SIZE, COUNT) byteswap(BUFFER, SIZE, COUNT)
+#else
+#define BYTESWAP(BUFFER, SIZE, COUNT)
+#endif
+
+
+
+/*
+ ************************************************************
+ *
+ * Structures
+ *
+ ************************************************************
+ */
+
+
+typedef struct subGridType {
+ double alimit[6];
+ int agscount, astart;
+ char anameg[8], apgrid[8];
+} subGridType;
+
+typedef struct NAD_DATA {
+ int fd2;
+ int fd;
+ int norecs; /* # overview header records */
+ int nsrecs; /* # subfile header records */
+ int nfiles; /* # of subfiles */
+ int offset; /* total offset for the file */
+ subGridType *subGrid;
+
+ int limflag; /* value on grid limit */
+ char typout[10]; /* grid shift units */
+ char version[10]; /* version id */
+ char fdatum[10]; /* from datum name */
+ char tdatum[10]; /* to datum name */
+ double tellips[2]; /* major/minor to axis */
+ double fellips[2]; /* major/minor from axis */
+ double diflat; /* interpolated lat shifts */
+ double diflon; /* interpolated lon shifts */
+
+#ifdef ACCURACIES
+ double varx; /* interpolated lat accuracy */
+ double vary; /* interpolated lon accuracy */
+#endif
+
+} NAD_DATA;
+
+typedef struct gridDataType {
+ char title[8];
+ union {
+ double d;
+ int i;
+ char c[8];
+ } value;
+} gridDataType;
+
+
+
+
+/*
+ ************************************************************
+ *
+ * Prototypes
+ *
+ ************************************************************
+ */
+#include "nadconv.h"
+static int gridint(NAD_DATA *nadPtr, double lat, double lon, int filen);
+static int fgrid(NAD_DATA *nadPtr, double lat, double lon);
+
+
+
+
+
+
+/*
+ ************************************************************
+ *
+ * Functions and procedures
+ *
+ ************************************************************
+ */
+
+
+#ifdef NEED_TO_SWAP
+/*
+ * Byte swapping routines required for binary compatibility
+ * between platforms. The ntv2_0.gsb file is in intel byte order.
+ */
+
+static void byteswap(void* buffer, int size, int count);
+
+void
+byteswap( buf, size, num )
+ void *buf;
+ short int size;
+ short int num;
+{
+ /*
+ * History: 11/92 Todd Stellhorn - original coding
+ */
+ short int i, j;
+ unsigned char *p, tmp;
+
+ p = ( unsigned char * ) buf;
+ for (i = 0; i < num; i++) {
+ for (j = 0; j < ( size >> 1 ); j++) {
+ tmp = p[j];
+ p[j] = p[size - j - 1];
+ p[size - j - 1] = tmp;
+ }
+ p += size;
+ }
+}
+#endif
+
+
+/*
+ * Search the subgrid hierarchy to determine the subgrid that
+ * the point falls into.
+ */
+static int
+fgrid(nadPtr,lat,lon)
+ NAD_DATA *nadPtr;
+ double lat,lon;
+{
+ int i;
+ int filen;
+ int onlimit;
+ int ifnd[4];
+ char oldnam[12];
+ char name[12];
+
+ strcpy(name,"NONE");
+ filen = 0;
+
+
+ /*
+ * Search down through the hierarchical list of
+ * sub-grids until a final match is found.
+ */
+ do {
+ strcpy(oldnam,name);
+ onlimit = 0;
+ for(i=0; i<4; i++)
+ ifnd[i] = -1;
+
+ /*
+ * At each iteration, search the entire list.
+ */
+ for(i=0;i<nadPtr->nfiles;i++) {
+
+ /*
+ * Match on an indentical sub-grid name, and always
+ * match on the first record (which contains
+ * the boundary of the entire area).
+ */
+ if((!strncmp(name,nadPtr->subGrid[i].apgrid,6)) ||
+ (nadPtr->nfiles == 1)) {
+
+ /*
+ * A simple box test to see if the point is within this
+ * sub-grid.
+ */
+ if((lat >= nadPtr->subGrid[i].alimit[0]) &&
+ (lat <= nadPtr->subGrid[i].alimit[1]) &&
+ (lon >= nadPtr->subGrid[i].alimit[2]) &&
+ (lon <= nadPtr->subGrid[i].alimit[3])) {
+
+ /*
+ * Determine if the point falls on a boundary, give
+ * priority to sub-grids where the point is not
+ * on a boundary.
+ */
+ if ((lat < nadPtr->subGrid[i].alimit[1]) &&
+ (lon < nadPtr->subGrid[i].alimit[3])) {
+ onlimit = 0;
+ }
+ else if ((lat == nadPtr->subGrid[i].alimit[1]) &&
+ (lon < nadPtr->subGrid[i].alimit[3])) {
+ onlimit = 1;
+ }
+ else if ((lat < nadPtr->subGrid[i].alimit[1]) &&
+ (lon == nadPtr->subGrid[i].alimit[3])) {
+ onlimit = 2;
+ }
+ else {
+ onlimit = 3;
+ }
+
+ if (ifnd[onlimit] == -1) {
+ ifnd[onlimit] = i;
+ }
+ else {
+ return -1;
+ }
+ }
+ }
+ }
+
+ /*
+ * Now choose the grid that has the best fit for this point.
+ */
+ for (i=0; i<4; i++) {
+ if(ifnd[i] > -1) {
+ filen = ifnd[i];
+ nadPtr->limflag = i;
+ strncpy(nadPtr->subGrid[filen].anameg, name, 8);
+ break;
+ }
+ }
+
+ } while (strncmp(oldnam,name,8) != 0);
+
+ return filen;
+}
+
+
+/*
+ * Interpolate an adjustment within a subgrid.
+ */
+static int
+gridint(nadPtr,lat,lon,filen)
+ NAD_DATA *nadPtr;
+ double lat, lon;
+ int filen;
+{
+ double n; /* distance north se corner */
+ double w; /* distance west se corner */
+ static double alat=0.0; /* se grid value lat sec */
+ static double blat=0.0; /* sw grid value lat sec */
+ static double clat=0.0; /* ne grid value lat sec */
+ static double dlat=0.0; /* nw grid value lat sec */
+ static double along=0.0; /* se grid value long sec */
+ static double blong=0.0; /* sw grid value long sec */
+ static double clong=0.0; /* ne grid value long sec */
+ static double dlong=0.0; /* nw grid value long sec */
+#ifdef ACCURACIES
+ static double avarx; /* accuracy lat point a meters */
+ static double avary; /* accuracy long point a meters */
+ static double bvarx; /* accuracy lat point b meters */
+ static double bvary; /* accuracy long point b meters */
+ static double cvarx; /* accuracy lat point c meters */
+ static double cvary; /* accuracy long point c meters */
+ static double dvarx; /* accuracy lat point d meters */
+ static double dvary; /* accuracy long point d meters */
+#endif
+
+ int nlon; /* # of lines of long in grid */
+ int header; /* # recs before first grid shift rec */
+ static int prev=0; /* # previous rec transformed */
+ int i; /* # lines lat to input point */
+ int j; /* # lined long to input point */
+ int irow,iread,jread;
+ float buff[4];
+
+#define EXPON 1e-12
+#define GET_REAL(REC, VAR) \
+ if (lseek(nadPtr->fd, ((REC)-1)*16, SEEK_SET) == -1) return NAD_ERROR; \
+ if (read(nadPtr->fd, &VAR, 16) != 16) return NAD_ERROR; \
+ BYTESWAP(&VAR, sizeof(VAR), 1);
+
+ if (!nadPtr)
+ return NAD_ERROR;
+
+/*
+ * compute number of lines of longitude in grid
+ */
+ nlon = ((int)(((nadPtr->subGrid[filen].alimit[3] -
+ nadPtr->subGrid[filen].alimit[2]) /
+ nadPtr->subGrid[filen].alimit[5]) + EXPON)) + 1;
+
+/*
+ * computes grid points and checks if they are in memory
+ */
+ i = ((int)((lat - nadPtr->subGrid[filen].alimit[0]) /
+ nadPtr->subGrid[filen].alimit[4] + EXPON)) + 1;
+ j = ((int)((lon - nadPtr->subGrid[filen].alimit[2]) /
+ nadPtr->subGrid[filen].alimit[5] + EXPON)) + 1;
+ header = nadPtr->subGrid[filen].astart - 1;
+
+
+ /*
+ * search within grid for closest 4 grid points and interpolate
+ * latitude and longitude and interpolate accuracies for lat and lon
+ */
+ irow = (i-1) * nlon;
+ if ((j == 0) || (j > nlon)) {
+ iread = irow + nlon;
+ jread = irow + 1;
+ }
+ else {
+ iread = irow + j;
+ jread = iread + 1;
+ }
+
+
+ /*
+ * If the adjustment record is in memory, then don't read
+ * it again.
+ */
+ if (prev != (iread + header)) {
+
+ /*
+ * Determine the number of observations to read based on
+ * proximity to the subgrid edge.
+ * limflag
+ * 0 = Interior point, get four observations
+ * 1 = lat on edge, get two observations
+ * 2 = long on edge, get two observations
+ * 3 = both on edge, get one observation
+ */
+ if (nadPtr->limflag == 0) {
+ GET_REAL(iread+header, buff);
+ alat = buff[0];
+ along = buff[1];
+#ifdef ACCURACIES
+ avarx = buff[2];
+ avary = buff[3];
+#endif
+
+ GET_REAL(jread+header, buff);
+ blat = buff[0];
+ blong = buff[1];
+#ifdef ACCURACIES
+ bvarx = buff[2];
+ bvary = buff[3];
+#endif
+
+ prev = iread + header;
+
+ iread += nlon;
+ jread += nlon;
+
+ GET_REAL(iread+header, buff);
+ clat = buff[0];
+ clong = buff[1];
+#ifdef ACCURACIES
+ cvarx = buff[2];
+ cvary = buff[3];
+#endif
+
+ GET_REAL(jread+header, buff);
+ dlat = buff[0];
+ dlong = buff[1];
+#ifdef ACCURACIES
+ dvarx = buff[2];
+ dvary = buff[3];
+#endif
+ }
+
+ else if (nadPtr->limflag == 1) {
+ GET_REAL(iread+header, buff);
+ alat = buff[0];
+ along = buff[1];
+#ifdef ACCURACIES
+ avarx = buff[2];
+ avary = buff[3];
+#endif
+
+ GET_REAL(jread+header, buff);
+ blat = buff[0];
+ blong = buff[1];
+#ifdef ACCURACIES
+ bvarx = buff[2];
+ bvary = buff[3];
+#endif
+
+ prev = iread + header;
+
+ clat = alat;
+ clong = along;
+ dlat = blat;
+ dlong = blong;
+#ifdef ACCURACIES
+ cvarx = avarx;
+ cvary = avary;
+ dvarx = bvarx;
+ dvary = bvary;
+#endif
+ }
+ else if (nadPtr->limflag == 2) {
+ GET_REAL(iread+header, buff);
+ alat = buff[0];
+ along = buff[1];
+#ifdef ACCURACIES
+ avarx = buff[2];
+ avary = buff[3];
+#endif
+
+ prev = iread + header;
+
+ blat = alat;
+ blong = along;
+#ifdef ACCURACIES
+ bvarx = avarx;
+ bvary = avary;
+#endif
+
+ iread += nlon;
+
+ GET_REAL(iread+header, buff);
+ clat = buff[0];
+ clong = buff[1];
+#ifdef ACCURACIES
+ cvarx = buff[2];
+ cvary = buff[3];
+#endif
+
+ dlat = clat;
+ dlong = clong;
+#ifdef ACCURACIES
+ dvarx = cvarx;
+ dvary = cvary;
+#endif
+ }
+ else if (nadPtr->limflag == 3) {
+ GET_REAL(iread+header, buff);
+ alat = buff[0];
+ along = buff[1];
+#ifdef ACCURACIES
+ avarx = buff[2];
+ avary = buff[3];
+#endif
+
+ prev = iread + header;
+
+ blat = alat;
+ blong = along;
+ clat = alat;
+ clong = along;
+ dlat = alat;
+ dlong = along;
+
+#ifdef ACCURACIES
+ bvarx = avarx;
+ bvary = avary;
+ cvarx = avarx;
+ cvary = avary;
+ dvarx = avarx;
+ dvary = avary;
+#endif
+ }
+ }
+
+ /*
+ * interpolate new position
+ */
+ n = (lat - (nadPtr->subGrid[filen].alimit[0] +
+ (i-1) * nadPtr->subGrid[filen].alimit[4])) /
+ nadPtr->subGrid[filen].alimit[4];
+
+ w = (lon - (nadPtr->subGrid[filen].alimit[2] +
+ (j-1) * nadPtr->subGrid[filen].alimit[5])) /
+ nadPtr->subGrid[filen].alimit[5];
+
+ nadPtr->diflat = alat + (clat - alat) * n + (blat - alat) *
+ w + (alat - blat - clat + dlat) * n * w;
+
+ nadPtr->diflon = along + (clong - along) * n + (blong - along) *
+ w + (along - blong - clong + dlong) * n * w;
+
+#ifdef ACCURACIES
+ /*
+ * interpolation for accuracies
+ */
+ nadPtr->varx = avarx + (cvarx - avarx) * n +
+ (bvarx - avarx) * w + (avarx - bvarx - cvarx + dvarx) * n * w;
+
+ nadPtr->vary = avary + (cvary - avary) * n +
+ (bvary - avary) * w + (avary - bvary - cvary + dvary) * n * w;
+#endif
+
+ return NAD_OK;
+}
+
+
+/*
+ * Perform a forward adjustment of the point.
+ */
+int
+NAD_Forward(nadPtr, lat, lon)
+ NAD_DATA *nadPtr;
+ double *lat, *lon;
+{
+ int filen;
+
+ if (!nadPtr)
+ return NAD_ERROR;
+
+ if ((filen = fgrid(nadPtr, *lat, *lon)) < 0)
+ return NAD_ERROR;
+
+ if (gridint(nadPtr, *lat, *lon, filen) != NAD_OK)
+ return NAD_ERROR;
+
+ *lat = *lat + nadPtr->diflat;
+ *lon = *lon + nadPtr->diflon;
+
+ return NAD_OK;
+}
+
+
+/*
+ * Perform a reverse adjustment of the point.
+ */
+int
+NAD_Reverse(nadPtr, lat, lon)
+ NAD_DATA *nadPtr;
+ double *lat, *lon;
+{
+ int filen, i;
+ double tlat, tlong;
+
+ if (!nadPtr)
+ return NAD_ERROR;
+
+ if ((filen = fgrid(nadPtr, *lat, *lon)) < 0)
+ return NAD_ERROR;
+
+ nadPtr->diflat = 0.0;
+ nadPtr->diflon = 0.0;
+
+ for (i=0; i<4; i++) {
+ tlat = *lat - nadPtr->diflat;
+ tlong = *lon - nadPtr->diflon;
+ if (i>0) {
+ if ((filen = fgrid(nadPtr, tlat, tlong)) < 0)
+ return NAD_ERROR;
+ }
+ if (gridint(nadPtr, tlat, tlong, filen) != NAD_OK)
+ return NAD_ERROR;
+ }
+
+ *lat = *lat - nadPtr->diflat;
+ *lon = *lon - nadPtr->diflon;
+
+ return NAD_OK;
+}
+
+
+#define GET_INT(REC, VAR) \
+ lseek(nadPtr->fd, ((REC)-1)*16, SEEK_SET); \
+ ogdi_read(nadPtr->fd, &buff, 16); \
+ VAR = buff.value.i; \
+ BYTESWAP(&VAR, sizeof(VAR), 1);
+
+#define GET_CHAR(REC, VAR) \
+ lseek(nadPtr->fd, ((REC)-1)*16, SEEK_SET); \
+ ogdi_read(nadPtr->fd, &buff, 16); \
+ strncpy(VAR, buff.value.c, 8); \
+ {char *s; for(s=(VAR)+7; s>=(VAR) && (*s==0 || *s == ' '); *s--=0);}
+
+#define GET_DBL(REC, VAR) \
+ lseek(nadPtr->fd, ((REC)-1)*16, SEEK_SET); \
+ ogdi_read(nadPtr->fd, &buff, 16); \
+ VAR = buff.value.d; \
+ BYTESWAP(&VAR,sizeof(VAR),1);
+
+/*
+ * Initialize the conversion by reading in the subgrid headers.
+ */
+NAD_DATA*
+NAD_Init(filename, fdatum, tdatum)
+ char *filename;
+ char *fdatum;
+ char *tdatum;
+{
+ NAD_DATA *nadPtr;
+ int i, j, count;
+ gridDataType buff;
+
+ nadPtr = calloc(1,sizeof(NAD_DATA));
+ if (!nadPtr) {
+ return NULL;
+ }
+ nadPtr->subGrid = NULL;
+
+#ifdef _WINDOWS
+ nadPtr->fd = open(filename, O_RDONLY | O_BINARY);
+#else
+ nadPtr->fd = open(filename, O_RDONLY );
+#endif
+ if (nadPtr->fd < 0) {
+ free(nadPtr);
+ return NULL;
+ }
+
+ nadPtr->offset = 0;
+
+ GET_INT(1,nadPtr->norecs);
+ GET_INT(2,nadPtr->nsrecs);
+ GET_INT(3,nadPtr->nfiles);
+ GET_CHAR(4,nadPtr->typout);
+ GET_CHAR(5,nadPtr->version);
+ GET_CHAR(6,nadPtr->fdatum);
+ GET_CHAR(7,nadPtr->tdatum);
+ GET_DBL(8,nadPtr->fellips[0]);
+ GET_DBL(9,nadPtr->fellips[1]);
+ GET_DBL(10,nadPtr->tellips[0]);
+ GET_DBL(11,nadPtr->tellips[1]);
+
+ /*
+ * Confirm that the source and target datums are correct.
+ */
+ if ((strncmp(fdatum, nadPtr->fdatum, 8) != 0) ||
+ (strncmp(tdatum, nadPtr->tdatum, 8) != 0)) {
+ NAD_Close(nadPtr);
+ return NULL;
+ }
+
+ /*
+ * Allocate space to hold the subgrid records.
+ */
+ nadPtr->subGrid = calloc(nadPtr->nfiles, sizeof(subGridType));
+ if (!nadPtr->subGrid) {
+ NAD_Close(nadPtr);
+ return NULL;
+ }
+
+ /*
+ * Loop through all of the subgrid header records. Skip
+ * over the actual adjustment data (don't read the detail until
+ * later).
+ */
+ count = nadPtr->norecs;
+ for(i=0;i<nadPtr->nfiles;i++) {
+ count++;
+ /*
+ * Read the name of the sub grid, and validate that this
+ * is a correct record.
+ */
+ GET_CHAR(count, nadPtr->subGrid[i].anameg);
+ if (strncmp(buff.title, "SUB_NAME", 8) != 0) {
+ NAD_Close(nadPtr);
+ return NULL;
+ }
+ count++;
+ GET_CHAR(count, nadPtr->subGrid[i].apgrid);
+ count += 3;
+ /*
+ * Read the limits of this subgrid.
+ */
+ for (j=0; j<6; j++) {
+ GET_DBL(count, nadPtr->subGrid[i].alimit[j]);
+ count++;
+ }
+ GET_INT(count, nadPtr->subGrid[i].agscount);
+ nadPtr->subGrid[i].astart = count + 1;
+ count += nadPtr->subGrid[i].agscount;
+ }
+
+ return nadPtr;
+}
+
+
+/*
+ * Close the grid file and release memory.
+ */
+void
+NAD_Close(nadPtr)
+ NAD_DATA *nadPtr;
+{
+ if (!nadPtr)
+ return;
+ if (nadPtr->fd)
+ close(nadPtr->fd);
+ if (nadPtr->subGrid)
+ free(nadPtr->subGrid);
+ free(nadPtr);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/nadconv.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/nadconv.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/nadconv.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,99 @@
+/*
+ * NAD to NAD conversion program.
+ *
+ * This package has four functions:
+ * NAD_DATA* NAD_Init(char *filename, char *fdatum, char *tdatum)
+ * - Pass this routine the name of the binary grid data
+ * file that contains the adjustment data.
+ * - The routine returns a pointer to a structure containing
+ * lookups to the adjustment subgrids.
+ * - Checks that the adjustment file really contains the
+ * requested datums (source datum == fdatum and target data == tdatum).
+ * If not returns a NULL;
+ * - Returns NULL on any other error.
+ * int NAD_Forward(NAD_DATA *nadPtr, double *lat, double *lon)
+ * - Pass a lat/long pair and it will adjust forward according
+ * to the adjustments in the file.
+ * - Converted values are returned in place.
+ * - Returns NAD_OK upon success.
+ * int NAD_Reverse(NAD_DATA *nadPtr, double *lat, double *lon)
+ * - Similar to NAD_Reverse, but performs reverse correction.
+ * void NAD_Close(NAD_DATA *nadPtr)
+ * - Closes grid file and frees memory.
+ *
+ * Note that the conversion routines convert lat/long values
+ * specifed as decimal seconds:
+ * D*3600 + M*60 + seconds/60
+ *
+ * Tom Moore, March 1997
+ * William Lau, January 1997
+ *
+ * Based on the Fortran program INTGRID.
+ *
+ *
+ * Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ */
+
+#ifndef INTGRID_H
+#define INTGRID_H
+
+
+/*
+ ************************************************************
+ *
+ * Defines and macros
+ *
+ ************************************************************
+ */
+#define NAD_OK 0
+#define NAD_ERROR 1
+
+
+
+/*
+ ************************************************************
+ *
+ * Structures
+ *
+ ************************************************************
+ */
+/*
+ * Declare an opaque pointer to the private data structure
+ */
+#ifndef INTGRID_INT
+typedef void* NAD_DATA;
+#endif
+
+/*
+ ************************************************************
+ *
+ * Prototypes
+ *
+ ************************************************************
+ */
+NAD_DATA * NAD_Init(char *filename, char *fdatum, char *tdatum);
+void NAD_Close(NAD_DATA *nadPtr);
+int NAD_Forward(NAD_DATA *nadPtr, double *lat, double *lon);
+int NAD_Reverse(NAD_DATA *nadPtr, double *lat, double *lon);
+
+#endif
+
+typedef struct N_COORD {
+ int dlatn; /* output latitude degrees */
+ int dlonn; /* output longitude degrees */
+ int mlatn; /* output latitude minutes */
+ int mlonn; /* output longitude minutes */
+ double slatn; /* output latitude */
+ double slonn; /* output longitude */
+
+} N_COORD;
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/sdms.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/sdms.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/sdms.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,94 @@
+/*
+ sdms.c
+
+ This program will convert from second back into degrees, minutes and
+ seconds.
+
+ Copyright (C) 1996 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ Author: William Lau
+*/
+#include <stdio.h>
+#include <math.h>
+
+#include "nadconv.h"
+
+#define TIMED 3600.000
+#define TIMEM 60.000
+
+N_COORD* sdms(n_lat,n_lon)
+ double n_lat,n_lon;
+{
+ double rn[6] = {0.5,0.05,0.005,0.0005,0.00005,0.00005};
+ double ga,gb,ilat,ilon;
+ N_COORD *n_cd;
+
+ n_cd = calloc(1,sizeof(N_COORD));
+ if (!n_cd) {
+ printf("cannot initialize the new coordinate table");
+ return NULL;
+ }
+
+ ga = fabs(n_lat);
+ gb = fabs(n_lon);
+/*
+ if((k < 0) || (k >= 6))
+ k = 5;
+ ga = ga - rn[k];
+ gb = gb - rn[k];
+*/
+ ilat = fmod(ga,TIMED);
+ ilon = fmod(gb,TIMED);
+
+ n_cd->dlatn = abs(ga/TIMED);
+ n_cd->dlonn = abs(gb/TIMED);
+
+ n_cd->mlatn = abs(ilat/TIMEM);
+ n_cd->mlonn = abs(ilon/TIMEM);
+
+ n_cd->slatn = fmod(ilat,TIMEM);
+ n_cd->slonn = fmod(ilon,TIMEM);
+
+ n_cd->slatn = fabs(n_cd->slatn);
+ n_cd->slonn = fabs(n_cd->slonn);
+
+ if (n_cd->slatn == TIMEM)
+ {
+ n_cd->slatn = 0.0;
+ n_cd->mlatn += 1;
+ }
+
+ if (n_cd->slonn == TIMEM)
+ {
+ n_cd->slonn = 0.0;
+ n_cd->mlonn += 1;
+ }
+
+ if (n_cd->mlatn == 60)
+ {
+ n_cd->mlatn = 0;
+ n_cd->dlatn += 1;
+ }
+
+ if (n_cd->mlonn == 60)
+ {
+ n_cd->mlonn = 0;
+ n_cd->dlonn += 1;
+ }
+
+ if (n_lat < 0.0)
+ n_cd->dlatn = -n_cd->dlatn;
+ if (n_lon < 0.0)
+ n_cd->dlonn = -n_cd->dlonn;
+
+ return n_cd;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/testgrid.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/testgrid.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/canada/testgrid.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,49 @@
+/*
+ * NAD to NAD conversion test program.
+ *
+ * Tom Moore, March 1997
+ *
+ */
+
+#include <stdio.h>
+#include "nadconv.h"
+
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ double lat, lon, orig_slat, orig_slon;
+ int orig_dlat, orig_dlon, orig_mlat, orig_mlon;
+ NAD_DATA *nadPtr;
+ N_COORD *new_coord;
+
+ sscanf(argv[1],"%d",&orig_dlat);
+ sscanf(argv[2],"%d",&orig_mlat);
+ sscanf(argv[3],"%lf",&orig_slat);
+ sscanf(argv[4],"%d",&orig_dlon);
+ sscanf(argv[5],"%d",&orig_mlon);
+ sscanf(argv[6],"%lf",&orig_slon);
+
+ lat = orig_dlat*3600 + orig_mlat*60 + orig_slat;
+ lon = orig_dlon*3600 + orig_mlon*60 + orig_slon;
+
+ if ((nadPtr=NAD_Init("d:/ntv2/gridshft/ntv2_0.gsb", "NAD27", "NAD83")) == NULL) {
+ return 1;
+ }
+
+ if (NAD_Forward(nadPtr, &lat, &lon) != NAD_OK)
+ return 2;
+ printf("forward = %f %f\n", lat, lon);
+ new_coord = sdms(lat, lon);
+ printf("forward = %d %d %f %d %d %f\n", new_coord->dlatn,new_coord->mlatn,new_coord->slatn,new_coord->dlonn,new_coord->mlonn,new_coord->slonn);
+
+ if (NAD_Reverse(nadPtr, &lat, &lon) != NAD_OK)
+ return 2;
+ printf("reverse = %f %f\n", lat, lon);
+ new_coord = sdms(lat, lon);
+ printf("reverse = %d %d %f %d %d %f\n", new_coord->dlatn,new_coord->mlatn,new_coord->slatn,new_coord->dlonn,new_coord->mlonn,new_coord->slonn);
+
+
+ return 0;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 1997 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+include $(TOPDIR)/config/common.mak
+
+#
+# Sub-directories that need to be built
+#
+subdirs = canada usa
+
+#
+# Default target to build everything in all sub-directories
+#
+all: $(subdirs)
+
+#
+# Target to allow individual sub-directories to be built
+# (e.g. make canada)
+#
+.PHONY: $(subdirs)
+$(subdirs):
+ cd $@; $(MAKE)
+
+#
+# Pass specialized targets into the sub-directories
+#
+.PHONY: $(STANDARD_TARGETS)
+$(STANDARD_TARGETS):
+ @for i in $(subdirs); do \
+ $(MAKE) --directory $$i $@; \
+ done
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/dtusa.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/dtusa.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/dtusa.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,354 @@
+/*********************************************************************
+
+ CSOURCE_INFORMATION
+
+ NAME
+ dtusa.c
+
+ DESCRIPTION
+ Module used to convert geographics point from nad27 to nad83. Interface
+ between nadconv module and the c_interface.
+ END_DESCRIPTION
+
+ END_CSOURCE_INFORMATION
+
+ Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ ********************************************************************/
+
+#include "ecs.h"
+#include "projects.h"
+
+typedef struct {
+ struct CTABLE *dtptr;
+ int count;
+ char *tablename;
+} datuminfo;
+
+int tableqty = 7;
+datuminfo datumtable[] = {{NULL,0,"conus"},{NULL,0,"alaska"},{NULL,0,"hawaii"},{NULL,0,"prvi"},
+ {NULL,0,"stgeorge"},{NULL,0,"stlrnc"},{NULL,0,"stpaul"}};
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_nad_init
+
+ DESCRIPTION
+ Prepare the nad converter to convert points in a table of the USA.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ char *table: The table name
+ IN/OUT
+ void **privdata: Private data pointer
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : Contain the result of the operation. Success if TRUE,
+ failure if FALSE.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Search in datumtable the corresponding position of the datum table.
+ If it's not there, return FALSE. Set privdata to this position.
+
+ 2. Increment count in privdata
+
+ 3. If count in privdata is 1 and dtptr is NULL then
+ Begin
+ 3.1. Check the OGDIDATUM environment variable. If it's not there,
+ decrement count in privdata and return FALSE
+
+ 3.2. Get the OGDIDATUM and concatenate the table name to form a table
+ file directory.
+
+ 3.3. Call nad_init in the library with the file path found in 3.2.
+ Get the returned code.
+
+ 3.4. If the code is an error, decrement count in privdata and return FALSE.
+ End
+
+ 4. Return TRUE
+
+ ********************************************************************
+ */
+
+int dyn_nad_init(privdata, table)
+ void **privdata;
+ char *table;
+{
+ int i;
+ datuminfo *ptr;
+ char *pathfile;
+
+ ptr = NULL;
+ for (i=0;i<tableqty;i++) {
+ if (strcmp(table,datumtable[i].tablename) == 0) {
+ ptr = &(datumtable[i]);
+ break;
+ }
+ }
+ *privdata = (void *) ptr;
+ if (ptr == NULL)
+ return FALSE;
+ ptr->count++;
+
+ if (ptr->count == 1 && ptr->dtptr == NULL) {
+ if (getenv("OGDIDATUM") == NULL) {
+ ptr->count--;
+ return FALSE;
+ }
+
+ pathfile = malloc(strlen(getenv("OGDIDATUM"))+12);
+ if (pathfile == NULL) {
+ ptr->count--;
+ return FALSE;
+ }
+ strcpy(pathfile,getenv("OGDIDATUM"));
+ strcat(pathfile,"/");
+ strcat(pathfile,table);
+
+ ptr->dtptr = nad_init(pathfile);
+ if (ptr->dtptr == NULL) {
+ ptr->count--;
+ return FALSE;
+ }
+ free(pathfile);
+ }
+
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_nad_close
+
+ DESCRIPTION
+ Free the allocated structure dtptr
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ void *privdata: The private data of the driver
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : Contain the result of the operation. Success if TRUE,
+ failure if FALSE.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Decrement count in privdata
+
+ 2. If count is lower or equal to zero
+ Begin
+ 2.1. Close the pointer dtptr in privdata with NAD_Close and set it to NULL
+ End
+
+ 3. Return TRUE
+
+ ********************************************************************
+ */
+
+int dyn_nad_close(privdata)
+ void *privdata;
+{
+ datuminfo *ptr = (datuminfo *) privdata;
+
+ if (ptr == NULL) return TRUE;
+
+ ptr->count--;
+ if (ptr->count<=0) {
+ nad_free(ptr->dtptr);
+ ptr->dtptr = NULL;
+ }
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_nad_forward
+
+ DESCRIPTION
+ Convert a point in the NAD27 datum to NAD83. If an error occur,
+ don't make any convertion.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ void *privdata: The private data of the driver
+ IN/OUT
+ double *x: lattitude of the geographical coordinate
+ double *y: longitude of the geographical coordinate
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : Contain the result of the operation. Success if TRUE,
+ failure if FALSE. In this case, it's always success.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Copy the x and y coordinates in temp_x and temp_y
+
+ 2. Call nad_cvt with temp_x and temp_y and inverse to 0
+
+ 3. If the previous operation is a success, put in x and y
+ the contain of temp_x and temp_y.
+
+ 4. Return TRUE
+
+ ********************************************************************
+ */
+
+int dyn_nad_forward(privdata,x,y)
+ void *privdata;
+ double *x;
+ double *y;
+{
+ datuminfo *ptr = (datuminfo *) privdata;
+ projUV val,val1;
+
+ if (ptr == NULL) return TRUE;
+
+ if (ptr->dtptr == NULL)
+ return TRUE;
+
+ val.u = *x * DEG_TO_RAD;
+ val.v = *y * DEG_TO_RAD;
+
+ val1 = nad_cvt(val,0,ptr->dtptr);
+
+ if (val1.u != HUGE_VAL && val1.v != HUGE_VAL) {
+ *x = val1.u * RAD_TO_DEG;
+ *y = val1.v * RAD_TO_DEG;
+ }
+
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_nad_reverse
+
+ DESCRIPTION
+ Convert a point in the NAD83 datum to NAD27. If an error occur,
+ don't make any convertion.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ void *privdata: The private data of the driver
+ IN/OUT
+ double *x: lattitude of the geographical coordinate
+ double *y: longitude of the geographical coordinate
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : Contain the result of the operation. Success if TRUE,
+ failure if FALSE. In this case, it's always success.
+
+ END_FUNCTION_INFORMATION
+
+ PSEUDO_CODE
+
+ 1. Copy the x and y coordinates in temp_x and temp_y
+
+ 2. Call nad_cvt with temp_x and temp_y and inverse to 1
+
+ 3. If the previous operation is a success, put in x and y
+ the contain of temp_x and temp_y.
+
+ 4. Return TRUE
+
+ ********************************************************************
+ */
+
+int dyn_nad_reverse(privdata,x,y)
+ void *privdata;
+ double *x;
+ double *y;
+{
+ datuminfo *ptr = (datuminfo *) privdata;
+ projUV val,val1;
+
+ if (ptr == NULL) return TRUE;
+
+ if (ptr->dtptr == NULL)
+ return TRUE;
+
+ val.u = *x * DEG_TO_RAD;
+ val.v = *y * DEG_TO_RAD;
+
+ val1 = nad_cvt(val,1,ptr->dtptr);
+
+ if (val1.u != HUGE_VAL && val1.v != HUGE_VAL) {
+ *x = val1.u * RAD_TO_DEG;
+ *y = val1.v * RAD_TO_DEG;
+ }
+
+ return TRUE;
+}
+
+
+#ifdef _WINDOWS
+/*
+ * When the DLL is being unloaded, make sure to destroy all of
+ * the clients that remain open.
+ */
+BOOL WINAPI
+DllMain( HINSTANCE hinstDLL, // handle of DLL module
+ DWORD fdwReason, // reason for calling function
+ LPVOID lpvReserved)
+{
+ int i;
+
+ switch (fdwReason) {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ break;
+ case DLL_PROCESS_DETACH:
+ for (i=0;i<tableqty;i++) {
+ if (datumtable[i].dtptr != NULL) {
+ nad_free(datumtable[i].dtptr);
+ datumtable[i].dtptr=NULL;
+ datumtable[i].count=0;
+ }
+ }
+ break;
+ }
+ return TRUE;
+}
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/dtusa.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/dtusa.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/dtusa.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,13 @@
+LIBRARY dtusa
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_nad_init
+ dyn_nad_close
+ dyn_nad_forward
+ dyn_nad_reverse
+ DllMain
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/datum_driver/usa/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = dtusa
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = dtusa.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(PROJ_STATICLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,876 @@
+/******************************************************************************
+ *
+ * Component: OGDI ADRG Driver
+ * Purpose: External (dyn_*) entry points for ADRG driver.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: adrg.c,v $
+ * Revision 1.9 2007/02/12 16:09:06 cbalint
+ * * Add hook macros for all GNU systems, hook fread,fwrite,read,fgets.
+ * * Handle errors in those macro, if there are any.
+ * * Fix some includes for GNU systems.
+ * * Reduce remaining warnings, now we got zero warnings with GCC.
+ *
+ * Modified Files:
+ * config/unix.mak contrib/ogdi_import/dbfopen.c
+ * contrib/ogdi_import/shapefil.h contrib/ogdi_import/shpopen.c
+ * ogdi/c-api/ecs_xdr.c ogdi/c-api/ecsinfo.c ogdi/c-api/server.c
+ * ogdi/datum_driver/canada/nadconv.c ogdi/driver/adrg/adrg.c
+ * ogdi/driver/adrg/adrg.h ogdi/driver/adrg/object.c
+ * ogdi/driver/adrg/utils.c ogdi/driver/rpf/rpf.h
+ * ogdi/driver/rpf/utils.c ogdi/gltpd/asyncsvr.c
+ * ogdi/glutil/iofile.c vpflib/vpfprim.c vpflib/vpfspx.c
+ * vpflib/vpftable.c vpflib/vpftidx.c vpflib/xvt.h
+ *
+ * Revision 1.8 2003/08/27 04:50:01 warmerda
+ * Fixed _releaseAllLayers() to release the layers starting with the
+ * last till the first since it appears that ecs_FreeLayer() is unexpectedly
+ * reducing the layer count, and shuffling layers down in the ecs_Server
+ * layer list. Found while investigating leaking described in bug 795612.
+ *
+ * Revision 1.7 2001/06/25 19:46:10 warmerda
+ * Made cleanup safer if verifyLocation() fails.
+ *
+ * Revision 1.6 2001/06/23 14:06:31 warmerda
+ * added capabilities support, cache layer list when opening datastore
+ *
+ * Revision 1.5 2001/06/22 16:37:50 warmerda
+ * added Image support, upgraded headers
+ *
+ */
+
+#include "adrg.h"
+#include "datadict.h"
+#include <assert.h>
+
+ECS_CVSID("$Id: adrg.c,v 1.9 2007/02/12 16:09:06 cbalint Exp $");
+
+static void _releaseAllLayers _ANSI_ARGS_((ecs_Server *s));
+int colorintensity[6] = {0,63,105,147,189,255};
+
+/* layer oriented functions are keeped in data structure to simplify code */
+
+LayerMethod adrg_layerMethod[11] = {
+ /* 0 */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Area */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Line */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Point */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Matrix */ { NULL, NULL, _rewindRasterLayer, _getNextObjectRaster, _getObjectRaster, _getObjectIdRaster },
+ /* Image */ { NULL, NULL, _rewindImageLayer, _getNextObjectImage, _getObjectImage, _getObjectIdImage },
+ /* Text */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Edge */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Face */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Node */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Ring */ { NULL, NULL, NULL, NULL, NULL, NULL }
+};
+
+/* ----------------------------------------------------------------------
+ * _dyn_CreateServer:
+ *
+ * Creation of a new ADRG server
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_CreateServer(s,Request)
+ ecs_Server *s;
+ char *Request;
+{
+ register ServerPrivateData *spriv = s->priv =
+ (void *) calloc(sizeof(ServerPrivateData),1);
+ struct dirent *structure;
+ DIR *dirlist;
+ char *c;
+ char buffer[125];
+ char cc,sc[3];
+
+ if (spriv == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server private data");
+ return &(s->result);
+ }
+
+ spriv->imgdir = (char *) malloc(strlen(s->pathname)+1);
+ if (spriv->imgdir == NULL) {
+ free(s->priv);
+ ecs_SetError(&(s->result),1,"Not enough memory");
+ return &(s->result);
+ }
+
+ spriv->layer_count = 0;
+ spriv->layer_list = (char **) malloc(sizeof(char *) * 1);
+
+ if (s->pathname[2] == ':') {
+ strcpy(spriv->imgdir,s->pathname+1);
+ } else {
+ strcpy(spriv->imgdir,s->pathname);
+ }
+
+ /* Search for the .GEN file and set spriv->genfilename
+ with this value. */
+
+ dirlist = opendir(spriv->imgdir);
+ if (dirlist==NULL) {
+ free(spriv->imgdir);
+ free(s->priv);
+ ecs_SetError(&(s->result),1,"Unable to see the ADRG directory");
+ return &(s->result);
+ }
+
+ structure = (struct dirent *) readdir(dirlist);
+
+ while (structure != NULL) {
+ if (!((strcmp(structure->d_name,".") == 0) ||
+ (strcmp(structure->d_name,"..") == 0))) {
+ c = structure->d_name;
+ while((c[0]!='.') && (c[0]!='\0'))
+ c++;
+
+ if ((strcmp(".GEN",c) == 0) || (strcmp(".gen",c) == 0)) {
+ spriv->genfilename = (char *) malloc(strlen(spriv->imgdir)+
+ strlen(structure->d_name)+2);
+ if (spriv->genfilename==NULL) {
+ free(spriv->imgdir);
+ free(s->priv);
+ ecs_SetError(&(s->result),1,"Not enough memory");
+ return &(s->result);
+ }
+
+ strcpy(spriv->genfilename,spriv->imgdir);
+ strcat(spriv->genfilename,"/");
+ strcat(spriv->genfilename,structure->d_name);
+
+ } else if( (strcmp(".IMG",c) == 0) || (strcmp(".img",c) == 0)) {
+ spriv->layer_list = (char **)
+ realloc(spriv->layer_list,
+ sizeof(char *)*(spriv->layer_count+1));
+ if( spriv->layer_list == NULL )
+ {
+ ecs_SetError(&(s->result),1,"Not enough memory");
+ return &(s->result);
+ }
+
+ spriv->layer_list[spriv->layer_count++] =
+ strdup( structure->d_name );
+ }
+ }
+
+ structure = (struct dirent *) readdir(dirlist);
+ }
+
+ closedir(dirlist);
+
+
+ /* check the .GEN file and see if the location is valid */
+
+ if (!_verifyLocation(s)) {
+ if( spriv->imgdir )
+ free(spriv->imgdir);
+ if( spriv->genfilename )
+ free(spriv->genfilename);
+ free(s->priv);
+ return &(s->result);
+ }
+
+ /* initialize the driver globalRegion */
+
+ if (!_initRegionWithDefault(s)) {
+ free(spriv->imgdir);
+ free(spriv->genfilename);
+ free(s->priv);
+ return &(s->result);
+ }
+
+ /* Read overview and open the corresponding file */
+
+ if (!_read_overview(s)) {
+ free(spriv->imgdir);
+ free(spriv->genfilename);
+ free(s->priv);
+ return &(s->result);
+ }
+
+ /* Open the adrg IMG file */
+
+ strcpy(buffer,spriv->imgdir);
+ strcat(buffer,"/");
+ strcat(buffer,spriv->overview.imgfilename);
+
+ spriv->overview.imgfile = fopen(buffer,"rb");
+ if (spriv->overview.imgfile == NULL) {
+ strcpy(buffer,spriv->imgdir);
+ strcat(buffer,"/");
+ loc_strlwr(spriv->overview.imgfilename);
+ strcat(buffer,spriv->overview.imgfilename);
+ spriv->overview.imgfile = fopen(buffer,"rb");
+ if (spriv->overview.imgfile == NULL) {
+ strcpy(buffer,spriv->imgdir);
+ strcat(buffer,"/");
+ loc_strupr(spriv->overview.imgfilename);
+ strcat(buffer,spriv->overview.imgfilename);
+ spriv->overview.imgfile = fopen(buffer,"rb");
+ if (spriv->overview.imgfile == NULL) {
+ ecs_SetError(&(s->result),1,"Unable to open the adrg .IMG file ");
+ if (spriv->overview.tilelist != NULL) {
+ free(spriv->overview.tilelist);
+ }
+ free(spriv->imgdir);
+ free(spriv->genfilename);
+ free(s->priv);
+ return &(s->result);
+ }
+ }
+ }
+ spriv->overview.firstposition = 1;
+ cc = getc(spriv->overview.imgfile);
+ while(!feof(spriv->overview.imgfile)) {
+ if (cc==(char) 30) {
+ ogdi_fread(sc,3,1,spriv->overview.imgfile);
+ spriv->overview.firstposition+=3;
+ if (strncmp(sc,"IMG",3) == 0) {
+ spriv->overview.firstposition+=4;
+ fseek(spriv->overview.imgfile,3,SEEK_CUR);
+ cc = getc(spriv->overview.imgfile);
+ while(cc==' ') {
+ spriv->overview.firstposition++;
+ cc = getc(spriv->overview.imgfile);
+ }
+ spriv->overview.firstposition++;
+ break;
+ }
+ }
+
+ spriv->overview.firstposition++;
+ cc = getc(spriv->overview.imgfile);
+ }
+
+ /* initialize layer private data */
+
+ s->nblayer = 0;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * _dyn_DestroyServer:
+ *
+ * Destruction of this ADRG server
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_DestroyServer(s)
+ ecs_Server *s;
+{
+ register ServerPrivateData *spriv = s->priv;
+
+ /* Release all layer */
+
+ _releaseAllLayers(s);
+
+ if(spriv != NULL) {
+ int i;
+ if (spriv->imgdir != NULL) {
+ free(spriv->imgdir);
+ }
+ if (spriv->genfilename != NULL) {
+ free(spriv->genfilename);
+ }
+ if (spriv->overview.tilelist != NULL) {
+ free(spriv->overview.tilelist);
+ }
+ if (spriv->overview.imgfile != NULL) {
+ fclose(spriv->overview.imgfile);
+ }
+
+ for( i = 0; i < spriv->layer_count; i++ )
+ free( spriv->layer_list[i] );
+ if( spriv->layer_list != NULL )
+ free( spriv->layer_list );
+
+ free(spriv);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+
+}
+
+void _freelayerpriv(lpriv)
+ LayerPrivateData *lpriv;
+{
+ if (lpriv != NULL) {
+ if (lpriv->tilelist != NULL)
+ free(lpriv->tilelist);
+ if (lpriv->imgfile != NULL)
+ fclose(lpriv->imgfile);
+
+ free(lpriv);
+ }
+ lpriv = NULL;
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_SelectLayer:
+ *
+ * Select or reselect a layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SelectLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int layer;
+ register LayerPrivateData *lpriv;
+ register ServerPrivateData *spriv = s->priv;
+ char c,sc[3];
+ char buffer[128];
+
+ /* first, try to find an existing layer with same request and family */
+
+ if ((layer = ecs_GetLayer(s,sel)) != -1) {
+
+ /* if it already exists than assign currentLayer and set index to 0 to force rewind */
+
+ s->currentLayer = layer;
+ s->layer[layer].index = 0;
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+ ecs_SetGeoRegion(&(s->result),lpriv->region.north, lpriv->region.south,
+ lpriv->region.east, lpriv->region.west,
+ lpriv->region.ns_res, lpriv->region.ew_res);
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+ }
+
+ /* it did not exists so we are going to try to create it */
+
+ if ((layer = ecs_SetLayer(s,sel)) == -1) {
+ return &(s->result);
+ }
+
+ /* allocate memory to hold private info about this new layer */
+
+ if ((s->layer[layer].priv = (void *) malloc(sizeof(LayerPrivateData))) == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate layer private data");
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+ lpriv->tilelist = NULL;
+ lpriv->buffertile = NULL;
+
+ strcpy(lpriv->imgfilename,sel->Select);
+
+ /* Extract the layer information from the GEN file */
+
+ if (!_read_adrg(s,&(s->layer[layer]))) {
+ _freelayerpriv(lpriv);
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+
+ /* Open the adrg IMG file */
+
+ strcpy(buffer,spriv->imgdir);
+ strcat(buffer,"/");
+ strcat(buffer,lpriv->imgfilename);
+ lpriv->imgfile = fopen(buffer,"rb");
+
+ if (lpriv->imgfile == NULL) {
+
+ strcpy(buffer,spriv->imgdir);
+ strcat(buffer,"/");
+ loc_strlwr(lpriv->imgfilename);
+ strcat(buffer,lpriv->imgfilename);
+ lpriv->imgfile = fopen(buffer,"rb");
+
+ if (lpriv->imgfile == NULL) {
+ strcpy(buffer,spriv->imgdir);
+ strcat(buffer,"/");
+ loc_strupr(lpriv->imgfilename);
+ strcat(buffer,lpriv->imgfilename);
+ lpriv->imgfile = fopen(buffer,"rb");
+
+ if (lpriv->imgfile == NULL) {
+ _freelayerpriv(lpriv);
+ ecs_FreeLayer(s,layer);
+ ecs_SetError(&(s->result),1,"Unable to open the adrg .IMG file ");
+ return &(s->result);
+ }
+ }
+ }
+
+ lpriv->firstposition = 1;
+ c = getc(lpriv->imgfile);
+ while(!feof(lpriv->imgfile)) {
+ if (c==(char) 30) {
+ ogdi_fread(sc,3,1,lpriv->imgfile);
+ lpriv->firstposition+=3;
+ if (strncmp(sc,"IMG",3) == 0) {
+ lpriv->firstposition+=4;
+ fseek(lpriv->imgfile,3,SEEK_CUR);
+ c = getc(lpriv->imgfile);
+ while(c==' ') {
+ lpriv->firstposition++;
+ c = getc(lpriv->imgfile);
+ }
+ lpriv->firstposition++;
+ break;
+ }
+ }
+
+ lpriv->firstposition++;
+ c = getc(lpriv->imgfile);
+ }
+
+ s->currentLayer = layer;
+ s->layer[layer].nbfeature = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res);
+
+
+ ecs_SetGeoRegion(&(s->result),lpriv->region.north, lpriv->region.south,
+ lpriv->region.east, lpriv->region.west,
+ lpriv->region.ns_res, lpriv->region.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_ReleaseLayer:
+ *
+ * deselect a layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_ReleaseLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int layer;
+ char buffer[128];
+ register LayerPrivateData *lpriv;
+ /* first, try to find an existing layer with same request and family */
+
+ if ((layer = ecs_GetLayer(s,sel)) == -1) {
+ sprintf(buffer,"Invalid layer %s",sel->Select);
+ ecs_SetError(&(s->result),1,buffer);
+ return &(s->result);
+ }
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+
+ if (lpriv != NULL) {
+ _freelayerpriv(lpriv);
+ ecs_FreeLayer(s,layer);
+
+ if (s->currentLayer == layer) {
+ s->currentLayer = -1; /* just in case released layer was selected */
+ }
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* deselect all layer */
+
+static void
+_releaseAllLayers(s)
+ ecs_Server *s;
+{
+ int i;
+
+ for (i = s->nblayer-1; i >= 0; i-- )
+ dyn_ReleaseLayer(s,&(s->layer[i].sel));
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_SelectRegion:
+ *
+ * selection current geographic region.
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_SelectRegion(s,gr)
+ ecs_Server *s;
+ ecs_Region *gr;
+{
+
+ s->currentRegion.north = gr->north;
+ s->currentRegion.south = gr->south;
+ s->currentRegion.east = gr->east;
+ s->currentRegion.west = gr->west;
+ s->currentRegion.ns_res = gr->ns_res;
+ s->currentRegion.ew_res = gr->ew_res;
+
+ /* reset currentLayer index to 0 to force rewind */
+
+ if (s->currentLayer != -1) {
+ s->layer[s->currentLayer].index = 0;
+ s->layer[s->currentLayer].nbfeature = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetDictionary:
+ *
+ * return the itcl_class object
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetDictionary(s)
+ ecs_Server *s;
+{
+
+ ecs_SetText(&(s->result),datadict);
+ ecs_SetSuccess(&(s->result));
+
+ return &(s->result);
+
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetAttributesFormat:
+ *
+ * return the attribute format of the currently selected layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *
+dyn_GetAttributesFormat(s)
+ ecs_Server *s;
+{
+ ecs_SetObjAttributeFormat(&(s->result));
+
+ ecs_AddAttributeFormat(&(s->result),"category",Integer,5,0,0);
+ ecs_AddAttributeFormat(&(s->result),"label",Char,80,0,0);
+
+ ecs_SetSuccess(&(s->result));
+
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetNextObject:
+ *
+ * return the next object for the current layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetNextObject(s)
+ ecs_Server *s;
+{
+
+ if (s->layer[s->currentLayer].index == 0) {
+ (adrg_layerMethod[s->layer[s->currentLayer].sel.F].rewind)(s,&(s->layer[s->currentLayer]));
+ }
+
+ (adrg_layerMethod[s->layer[s->currentLayer].sel.F].getNextObject)(s,&(s->layer[s->currentLayer]));
+
+ return &(s->result);
+
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetRasterInfo:
+ *
+ * return raster layer meta information
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetRasterInfo(s)
+ ecs_Server *s;
+{
+ register unsigned int i,j,k;
+ char buffer[2];
+ register LayerPrivateData *lpriv;
+ int count;
+
+ strcpy(buffer,"");
+ lpriv = (LayerPrivateData *) s->layer[s->currentLayer].priv;
+
+ /* Put table contain in RasterInfo here */
+
+ if (s->layer[s->currentLayer].sel.F == Matrix) {
+ ecs_SetRasterInfo(&(s->result),lpriv->columns,lpriv->rows);
+ count = 1;
+ for(i=0;i<6;i++) {
+ for(j=0;j<6;j++) {
+ for(k=0;k<6;k++) {
+ ecs_AddRasterInfoCategory(&(s->result),count,
+ colorintensity[i],
+ colorintensity[j],
+ colorintensity[k],buffer,0);
+ count++;
+ }
+ }
+ }
+ } else {
+ ecs_SetRasterInfo(&(s->result),1,0);
+ ecs_AddRasterInfoCategory(&(s->result),1, 255, 255, 255,"No data",0);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * dyn_GetObject:
+ *
+ * return an object for the current layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObject(s,Id)
+ ecs_Server *s;
+ char *Id;
+{
+ if (adrg_layerMethod[s->layer[s->currentLayer].sel.F].getObject != NULL)
+ (adrg_layerMethod[s->layer[s->currentLayer].sel.F].getObject)(s,&(s->layer[s->currentLayer]),Id);
+ else {
+ ecs_SetError(&(s->result),1,"Can't get object for this type of layer");
+ }
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetObjectIdFromCoord:
+ *
+ * return the object id sitting at (or near) to a coordinate
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObjectIdFromCoord(s,coord)
+ ecs_Server *s;
+ ecs_Coordinate *coord;
+{
+ if (adrg_layerMethod[s->layer[s->currentLayer].sel.F].getObjectIdFromCoord != NULL)
+ (adrg_layerMethod[s->layer[s->currentLayer].sel.F].getObjectIdFromCoord)(s,&(s->layer[s->currentLayer]),coord);
+ else {
+ ecs_SetError(&(s->result),1,"Can't get objectid from coordinate for this type of layer");
+ }
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_UpdateDictionary:
+ *
+ * Return the content of this location data dictionary in a Tcl List
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_UpdateDictionary(s,info)
+ ecs_Server *s;
+ char *info;
+{
+ register ServerPrivateData *spriv = s->priv;
+ int i;
+
+/* -------------------------------------------------------------------- */
+/* Reduced capabilities without layers. */
+/* -------------------------------------------------------------------- */
+ if( strcmp(info,"ogdi_server_capabilities") == 0 )
+ {
+ ecs_AddText(&(s->result),
+ "<?xml version=\"1.0\" ?>\n"
+ "<OGDI_Capabilities version=\"3.1\">\n"
+ "</OGDI_Capabilities>\n" );
+ ecs_SetSuccess(&(s->result));
+ }
+
+/* -------------------------------------------------------------------- */
+/* Full capabilities. */
+/* -------------------------------------------------------------------- */
+ else if( strcmp(info,"ogdi_capabilities") == 0 )
+ {
+ char line[256];
+
+ ecs_AddText(&(s->result),
+ "<?xml version=\"1.0\" ?>\n"
+ "<OGDI_Capabilities version=\"3.1\">\n" );
+ ecs_AddText(&(s->result),
+ " <FeatureTypeList>\n"
+ " <Operations>\n"
+ " <Query/>\n"
+ " </Operations>\n" );
+
+ for (i=0; i < spriv->layer_count; i++ )
+ {
+ ecs_Layer dummy_layer;
+ LayerPrivateData *lpriv;
+
+ dummy_layer.priv = (void *) calloc(sizeof(LayerPrivateData),1);
+
+ lpriv = (LayerPrivateData *) dummy_layer.priv;
+ lpriv->tilelist = NULL;
+ lpriv->buffertile = NULL;
+
+ strcpy(lpriv->imgfilename,spriv->layer_list[i]);
+
+ /* Extract the layer information from the GEN file */
+
+ if (!_read_adrg(s,&dummy_layer))
+ {
+ _freelayerpriv(lpriv);
+ continue;
+ }
+
+ /* Format the XML info */
+
+ ecs_AddText(&(s->result),
+ " <FeatureType>\n" );
+ sprintf( line, " <Name>%s</Name>\n",
+ spriv->layer_list[i] );
+ ecs_AddText(&(s->result), line );
+
+ sprintf( line, " <SRS>PROJ4:%s</SRS>\n", PROJ_LONGLAT );
+ ecs_AddText(&(s->result),line);
+ sprintf(line,
+ " <LatLonBoundingBox minx=\"%.9f\" miny=\"%.9f\"\n"
+ " maxx=\"%.9f\" maxy=\"%.9f\" />\n",
+ lpriv->region.west,
+ lpriv->region.south,
+ lpriv->region.east,
+ lpriv->region.north );
+ ecs_AddText(&(s->result),line);
+
+ sprintf(line,
+ " <BoundingBox minx=\"%.9f\" miny=\"%.9f\"\n"
+ " maxx=\"%.9f\" maxy=\"%.9f\"\n"
+ " resx=\"%.9f\" resy=\"%.9f\" />\n",
+ lpriv->region.west,
+ lpriv->region.south,
+ lpriv->region.east,
+ lpriv->region.north,
+ lpriv->region.ew_res,
+ lpriv->region.ns_res );
+ ecs_AddText(&(s->result),line);
+
+ ecs_AddText(&(s->result),
+ " <Family>Matrix</Family>\n"
+ " <Family>Image</Family>\n"
+ " </FeatureType>\n" );
+
+ _freelayerpriv(lpriv);
+ }
+
+ ecs_AddText(&(s->result),
+ " </FeatureTypeList>\n"
+ "</OGDI_Capabilities>\n" );
+ ecs_SetSuccess(&(s->result));
+ }
+
+/* -------------------------------------------------------------------- */
+/* Old style return result. */
+/* -------------------------------------------------------------------- */
+ else
+ {
+ ecs_SetText(&(s->result)," ");
+ for( i = 0; i < spriv->layer_count; i++ )
+ {
+ ecs_AddText( &(s->result), spriv->layer_list[i] );
+ ecs_AddText( &(s->result), " " );
+ }
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_GetServerProjection:
+ *
+ * Return this server cartographic projection
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetServerProjection(s)
+ ecs_Server *s;
+{
+ ecs_SetText(&(s->result), PROJ_LONGLAT);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * _dyn_GetGlobalBound:
+ *
+ * Return this server global bounding region
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_GetGlobalBound(s)
+ ecs_Server *s;
+{
+ ecs_SetGeoRegion(&(s->result),s->globalRegion.north, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.west,
+ s->globalRegion.ns_res, s->globalRegion.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_SetServerLanguage:
+ *
+ * Set this server lnaguage for error message; not yet implemented
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetServerLanguage(s,language)
+ ecs_Server *s;
+ u_int language;
+{
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+
+
+char *loc_strlwr (string)
+ char *string;
+{
+ size_t i;
+
+ if (!string)
+ return string;
+
+ for (i=0; i<strlen (string); i++)
+ string[i] = (char)tolower (string[i]);
+ return string;
+}
+
+char *loc_strupr (string)
+ char *string;
+{
+ size_t i;
+
+ if (!string)
+ return string;
+
+ for (i=0; i<strlen (string); i++)
+ string[i] = (char)toupper (string[i]);
+ return string;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,23 @@
+LIBRARY ADRG
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_CreateServer
+ dyn_DestroyServer
+ dyn_SelectLayer
+ dyn_ReleaseLayer
+ dyn_SelectRegion
+ dyn_GetDictionary
+ dyn_GetNextObject
+ dyn_UpdateDictionary
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_GetRasterInfo
+ dyn_GetObject
+ dyn_GetObjectIdFromCoord
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_SetServerLanguage
+ dyn_GetAttributesFormat
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/adrg.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,153 @@
+/******************************************************************************
+ *
+ * Component: OGDI ADRG Driver
+ * Purpose: Data structure and prototype declarations for ADRG driver.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: adrg.h,v $
+ * Revision 1.8 2007/02/12 21:01:48 cbalint
+ * Fix win32 target. It build and works now. (tested with VC6)
+ *
+ * Revision 1.7 2007/02/12 16:09:06 cbalint
+ * * Add hook macros for all GNU systems, hook fread,fwrite,read,fgets.
+ * * Handle errors in those macro, if there are any.
+ * * Fix some includes for GNU systems.
+ * * Reduce remaining warnings, now we got zero warnings with GCC.
+ *
+ * Modified Files:
+ * config/unix.mak contrib/ogdi_import/dbfopen.c
+ * contrib/ogdi_import/shapefil.h contrib/ogdi_import/shpopen.c
+ * ogdi/c-api/ecs_xdr.c ogdi/c-api/ecsinfo.c ogdi/c-api/server.c
+ * ogdi/datum_driver/canada/nadconv.c ogdi/driver/adrg/adrg.c
+ * ogdi/driver/adrg/adrg.h ogdi/driver/adrg/object.c
+ * ogdi/driver/adrg/utils.c ogdi/driver/rpf/rpf.h
+ * ogdi/driver/rpf/utils.c ogdi/gltpd/asyncsvr.c
+ * ogdi/glutil/iofile.c vpflib/vpfprim.c vpflib/vpfspx.c
+ * vpflib/vpftable.c vpflib/vpftidx.c vpflib/xvt.h
+ *
+ * Revision 1.6 2001/06/23 14:06:31 warmerda
+ * added capabilities support, cache layer list when opening datastore
+ *
+ * Revision 1.5 2001/06/22 16:37:50 warmerda
+ * added Image support, upgraded headers
+ *
+ */
+
+#include "ecs.h"
+#include <sys/stat.h>
+#ifdef _WINDOWS
+#include <direct.h>
+#include "compat/dirent.h"
+#include <io.h>
+
+#else
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+
+#include <ogdi_macro.h>
+
+#define MAXADRGTILES 26
+
+#ifndef max
+#define max(x,y) ((x > y) ? x : y)
+#endif
+
+typedef struct {
+ int isActive;
+ unsigned char data[49152];
+} tile_mem;
+
+/* private data general to all Grass layer */
+
+typedef struct {
+ char imgname[10]; /* IMG name */
+ char imgfilename[14]; /* IMG file name */
+ int zonenumber; /* ARC zone number */
+ int rows; /* Number of rows */
+ int columns; /* Number of columns */
+ int rowtiles; /* Number of 128x128 tiles in a row */
+ int coltiles; /* Number of 128x128 tiles in a column */
+ ecs_Region region; /* Bounding rectangle of the matrix */
+ int *tilelist; /* Tile list of all the tiles positions.
+ This list is (rowtiles*coltiles) long. */
+ FILE *imgfile; /* IMG file itself */
+ int ARV,BRV;
+ double LSO,PSO;
+ int firstposition; /* First pixel position in file */
+ tile_mem *buffertile; /* buffer table */
+ int firsttile; /* Position of the first tile in the buffer table */
+} LayerPrivateData;
+
+typedef struct {
+ char *genfilename;
+ char *imgdir;
+ LayerPrivateData overview;
+
+ int layer_count;
+ char **layer_list;
+
+} ServerPrivateData;
+
+/* layer oriented method definition */
+
+void _openRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _closeRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _rewindRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _getNextObjectRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _getObjectRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, char *objectId));
+void _getObjectIdRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, ecs_Coordinate *coord));
+int _calcPosValue _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,int i,int j,int UseOverview));
+void _openImageLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _closeImageLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _rewindImageLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _getNextObjectImage _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _getObjectImage _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, char *objectId));
+void _getObjectIdImage _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, ecs_Coordinate *coord));
+int _calcImagePosValue _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,int i,int j,int UseOverview));
+void _LoadADRGTiles _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,int *UseOverview));
+
+/* layer oriented method are keeped into a single data structure to simplify the code */
+
+typedef void layerfunc();
+typedef void layerobfunc();
+typedef void layercoordfunc();
+
+
+typedef struct {
+ layerfunc *open;
+ layerfunc *close;
+ layerfunc *rewind;
+ layerfunc *getNextObject;
+ layerobfunc *getObject;
+ layercoordfunc *getObjectIdFromCoord;
+} LayerMethod;
+
+void _calPosWithCoord _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,double pos_x,double pos_y,int *i,int *j,int UseOverview));
+
+int _IsOutsideRegion _ANSI_ARGS_((double n, double s, double e,double w, ecs_Region *x));
+
+int _read_adrg _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l));
+int _read_overview _ANSI_ARGS_((ecs_Server *s));
+char *subfield _ANSI_ARGS_((char *buffer, int index, int length));
+double parse_coord_x _ANSI_ARGS_((char *buffer));
+double parse_coord_y _ANSI_ARGS_((char *buffer));
+int _verifyLocation _ANSI_ARGS_((ecs_Server *s));
+int _initRegionWithDefault _ANSI_ARGS_((ecs_Server *s));
+char *loc_strupr _ANSI_ARGS_((char *string));
+char *loc_strlwr _ANSI_ARGS_((char *string));
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/datadict.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/datadict.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/datadict.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,106 @@
+static char datadict[] = {'\n'
+,'i','t','c','l','_','c','l','a','s','s',' ','W','K','B','_','D','a','t','a','D','i','c','t','i','o','n','a','r','y',' ','{'
+,'\n'
+,'\t','i','n','h','e','r','i','t',' ','d','d'
+,'\n'
+
+,'\n'
+,'c','o','n','s','t','r','u','c','t','o','r',' ','{','w','p','a','t','h',' ','l','o','c','a','t','i','o','n','}',' ','{'
+,'\n'
+,'#','\t','d','d',':',':','c','o','n','s','t','r','u','c','t','o','r',' ','$','w','i','n','d','o','w','p','a','t','h',' ','$','l','o','c','a','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','d','d',' ','$','w','p','a','t','h',' ','$','l','o','c','a','t','i','o','n'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','l','a','y','o','u','t',' ','{','}',' ','{'
+,'\n'
+,' ',' ',' ',' ','f','r','a','m','e',' ','$','w','i','n','d','o','w','.','c','e','n','t','e','r'
+,'\n'
+,'\t','m','a','p','L','i','s','t','b','o','x'
+,'\n'
+,'\t','b','u','t','t','o','n','s'
+,'\n'
+,'\t','u','p','d','a','t','e','d','i','c','t'
+,'\n'
+,'\t',':',':','u','p','d','a','t','e',' ','i','d','l','e','t','a','s','k','s','\t'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','b','u','t','t','o','n','s',' ','{','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','L','i','s','t','E','n','t','r','y',' ','{','i','n','d','e','x','}',' ','{'
+,'\n'
+,'\t','r','e','g','s','u','b',' ','{','\\','(','[','A','-','Z',']','+','\\',')','$','}',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','g','e','t',' ','$','i','n','d','e','x',']',' ','{','}',' ','s','_','n','a','m','e',' '
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','s','_','n','a','m','e'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','u','p','d','a','t','e','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+
+,'\n'
+,' ',' ','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','d','e','l','e','t','e',' ','0',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','s','i','z','e',']'
+,'\n'
+,' ',' ','f','o','r','e','a','c','h',' ','s','_','i','t','e','m',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',']',' ','{'
+,'\n'
+,' ',' ','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','i','n','s','e','r','t',' ','e','n','d',' ','[','g','e','t','U','R','L','E','n','t','r','y',' ','$','s','_','i','t','e','m',']'
+,'\n'
+,' ',' ','}'
+,'\n'
+
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','U','R','L','E','n','t','r','y',' ','{','s','_','p','a','t','h','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','{','s','_','p','a','t','h','}'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',' ','{','a','r','g','s','}',' ','{'
+,'\n'
+,' ','\t','r','e','t','u','r','n',' ','R','a','s','t','e','r'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','P','a','t','h','n','a','m','e',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','s','e','l','e','c','t','i','o','n','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','s','e','l','e','c','t','i','o','n','\t'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'p','r','o','t','e','c','t','e','d',' ','a','_','r','a','m','d','i','s','k',' ',';','#',' ','w','h','e','t','h','e','r',' ','t','h','e',' ','c','o','v','e','r','a','g','e',' ','i','s',' ','t','o',' ','b','e',' ','l','o','a','d','e','d',' ','i','n','t','o',' ','r','a','m',' ','o','r',' ','d','i','s','k','.'
+,'\n'
+,'\t','\t','\t','\t','\t',';','#',' ','v','a','l','u','e','s',' ','a','r','e',' ','e','i','t','h','e','r',' ','\"','R','A','M','\"',' ','o','r',' ','\"','D','I','S','K','\"'
+,'\n'
+,'p','r','o','t','e','c','t','e','d',' ','s','_','d','i','s','k','D','e','f','a','u','l','t',' ','\"','D','I','S','K','\"'
+,'\n'
+
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'\0'};
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/ddadrg.tcl
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/ddadrg.tcl 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/ddadrg.tcl 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,51 @@
+itcl_class WKB_DataDictionary {
+ inherit dd
+
+constructor {wpath location} {
+# dd::constructor $windowpath $location
+ dd $wpath $location
+}
+
+method layout {} {
+ frame $window.center
+ mapListbox
+ buttons
+ updatedict
+ ::update idletasks
+}
+
+method buttons {} {
+ return
+}
+
+method getListEntry {index} {
+ regsub {\([A-Z]+\)$} [$mapList subwidget listbox get $index] {} s_name
+ return $s_name
+}
+
+method updatedict {} {
+
+ $mapList subwidget listbox delete 0 [$mapList subwidget listbox size]
+ foreach s_item [ecs_UpdateDictionary $url] {
+ $mapList subwidget listbox insert end [getURLEntry $s_item]
+ }
+
+}
+
+method getURLEntry {s_path} {
+ return ${s_path}
+}
+
+method getSelectedClass {args} {
+ return Raster
+}
+
+method getPathname {coverage class selection} {
+ return $selection
+}
+
+protected a_ramdisk ;# whether the coverage is to be loaded into ram or disk.
+ ;# values are either "RAM" or "DISK"
+protected s_diskDefault "DISK"
+
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,33 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = adrg
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = adrg.c utils.c object.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(GLUTIL_STATICLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR datadict.h
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+datadict.h: ddadrg.tcl
+ $(STRINGIFY) -file ddadrg.tcl datadict.h
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/object.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/object.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/object.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,692 @@
+/******************************************************************************
+ *
+ * Component: OGDI ADRG Driver
+ * Purpose: Implementation of ADRG getObject* functions.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: object.c,v $
+ * Revision 1.6 2007/02/12 16:09:06 cbalint
+ * * Add hook macros for all GNU systems, hook fread,fwrite,read,fgets.
+ * * Handle errors in those macro, if there are any.
+ * * Fix some includes for GNU systems.
+ * * Reduce remaining warnings, now we got zero warnings with GCC.
+ *
+ * Modified Files:
+ * config/unix.mak contrib/ogdi_import/dbfopen.c
+ * contrib/ogdi_import/shapefil.h contrib/ogdi_import/shpopen.c
+ * ogdi/c-api/ecs_xdr.c ogdi/c-api/ecsinfo.c ogdi/c-api/server.c
+ * ogdi/datum_driver/canada/nadconv.c ogdi/driver/adrg/adrg.c
+ * ogdi/driver/adrg/adrg.h ogdi/driver/adrg/object.c
+ * ogdi/driver/adrg/utils.c ogdi/driver/rpf/rpf.h
+ * ogdi/driver/rpf/utils.c ogdi/gltpd/asyncsvr.c
+ * ogdi/glutil/iofile.c vpflib/vpfprim.c vpflib/vpfspx.c
+ * vpflib/vpftable.c vpflib/vpftidx.c vpflib/xvt.h
+ *
+ * Revision 1.5 2001/06/22 16:37:50 warmerda
+ * added Image support, upgraded headers
+ *
+ */
+
+#include "ecs.h"
+#include "adrg.h"
+
+ECS_CVSID("$Id: object.c,v 1.6 2007/02/12 16:09:06 cbalint Exp $");
+
+/*
+ * --------------------------------------------------------------------------
+ * _LoadADRGTiles
+ *
+ * Load tiles in memory if it's not too big. The projection
+ * must be longlat. These tiles is a kind of buffer for a row
+ * of tiles.
+ * --------------------------------------------------------------------------
+ */
+
+void _LoadADRGTiles(s,l,UseOverview)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int *UseOverview;
+{
+ register ServerPrivateData *spriv = s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int i1,j1,i2,j2,prev_i,prev_j,i,count,tile,tile_physique;
+ double y,prev_y;
+
+ /* Found the first and the last request point in adrg matrix */
+
+ y = s->currentRegion.north - l->index*s->currentRegion.ns_res;
+ prev_y = s->currentRegion.north - (l->index-1)*s->currentRegion.ns_res;
+
+ _calPosWithCoord(s,l,s->currentRegion.west,y,&i1,&j1,FALSE);
+ _calPosWithCoord(s,l,s->currentRegion.east,y,&i2,&j2,FALSE);
+ _calPosWithCoord(s,l,s->currentRegion.east,prev_y,&prev_i,&prev_j,FALSE);
+
+ /* Found the first and last tile */
+
+ i1 = i1/128;
+ i2 = i2/128;
+ j1 = j1/128;
+ j2 = j2/128;
+ prev_j = prev_j/128;
+
+ /* Update the tile database */
+
+ count = 0;
+ if ((lpriv->buffertile == NULL) || (prev_j != j1) || (l->index == 0)) {
+
+ if ((i2-i1) > MAXADRGTILES) {
+ *UseOverview = TRUE;
+ _calPosWithCoord(s,l,s->currentRegion.west,y,&i1,&j1,TRUE);
+ _calPosWithCoord(s,l,s->currentRegion.east,y,&i2,&j2,TRUE);
+ _calPosWithCoord(s,l,s->currentRegion.east,prev_y,&prev_i,&prev_j,TRUE);
+
+ /* Found the first and last tile */
+
+ i1 = i1/128;
+ i2 = i2/128;
+ j1 = j1/128;
+ j2 = j2/128;
+ prev_j = prev_j/128;
+
+ if ((spriv->overview.buffertile == NULL) || (prev_j != j1) || (l->index == 0)) {
+
+ if (spriv->overview.buffertile != NULL) {
+ free(spriv->overview.buffertile);
+ spriv->overview.buffertile = NULL;
+ }
+
+ if ((i2-i1) > MAXADRGTILES) {
+ return;
+ }
+
+ if (s->rasterconversion.isProjEqual == FALSE) {
+ return;
+ }
+
+ spriv->overview.firsttile = i1;
+ spriv->overview.buffertile = malloc((i2-i1+1)*sizeof(tile_mem));
+
+ for(i=i1;i<=i2;i++) {
+ tile = (j1 * spriv->overview.coltiles) + i;
+ if ((tile < 0) ||
+ (tile > (spriv->overview.coltiles*spriv->overview.rowtiles)))
+ tile_physique = 0;
+ else
+ tile_physique = spriv->overview.tilelist[tile];
+
+ if (tile_physique != 0) {
+ fseek(spriv->overview.imgfile,(spriv->overview.firstposition + (tile_physique-1)*49152) - 1,SEEK_SET);
+ ogdi_fread(spriv->overview.buffertile[count].data,49152,1,spriv->overview.imgfile);
+ spriv->overview.buffertile[count].isActive = TRUE;
+ } else {
+ spriv->overview.buffertile[count].isActive = FALSE;
+ }
+
+ count++;
+ }
+
+ }
+ return;
+ }
+
+ if (lpriv->buffertile != NULL) {
+ free(lpriv->buffertile);
+ lpriv->buffertile = NULL;
+ }
+
+ *UseOverview = FALSE;
+
+ if (s->rasterconversion.isProjEqual == FALSE) {
+ if ((i2-i1) > MAXADRGTILES)
+ *UseOverview = TRUE;
+ return;
+ }
+
+ if ((lpriv->zonenumber == 9) ||
+ (lpriv->zonenumber == 18)) {
+ return;
+ }
+
+ lpriv->firsttile = i1;
+ lpriv->buffertile = malloc((i2-i1+1)*sizeof(tile_mem));
+
+ for(i=i1;i<=i2;i++) {
+ tile = (j1 * lpriv->coltiles) + i;
+ if ((tile < 0) || (tile > (lpriv->coltiles*lpriv->rowtiles)))
+ tile_physique = 0;
+ else
+ tile_physique = lpriv->tilelist[tile];
+
+ if (tile_physique != 0) {
+ fseek(lpriv->imgfile,(lpriv->firstposition + (tile_physique-1)*49152) - 1,SEEK_SET);
+ ogdi_fread(lpriv->buffertile[count].data,49152,1,lpriv->imgfile);
+ lpriv->buffertile[count].isActive = TRUE;
+ } else {
+ lpriv->buffertile[count].isActive = FALSE;
+ }
+
+ count++;
+ }
+ }
+}
+
+
+/*
+ * --------------------------------------------------------------------------
+ * _get*Object*Raster:
+ *
+ * a set of functions to acheive Line objects retrieval
+ * --------------------------------------------------------------------------
+ */
+
+void _getNextObjectRaster(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ int i,i2,j2;
+ char buffer[128];
+ static int UseOverview;
+
+ int totalcol,totalrow;
+ int value;
+ double pos;
+
+ if (l->index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ _LoadADRGTiles(s,l,&UseOverview);
+
+ totalcol = (int) ((s->currentRegion.east - s->currentRegion.west)/s->currentRegion.ew_res);
+ totalrow = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res);
+ ecs_SetGeomMatrix(&(s->result),totalcol);
+
+ if (s->rasterconversion.isProjEqual) {
+ for (i=0; i<totalcol; i++) {
+ value = _calcPosValue(s,l,i,l->index,UseOverview);
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),i,value);
+ }
+ } else {
+ for (i=0; i<totalcol; i++) {
+ i2 = ECSGETI(s,((double) l->index),((double)i));
+ j2 = ECSGETJ(s,((double) l->index),((double)i));
+ value = _calcPosValue(s,l,j2,i2,UseOverview);
+
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),i,value);
+ }
+ }
+
+
+ sprintf(buffer,"%d",l->index);
+ if (!ecs_SetObjectId(&(s->result),buffer)) {
+ return;
+ }
+
+ pos = s->currentRegion.north - l->index*s->currentRegion.ns_res;
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),s->currentRegion.west,
+ pos+s->currentRegion.ns_res,
+ s->currentRegion.east,pos)
+
+
+ l->index++;
+ ecs_SetSuccess(&(s->result));
+}
+
+void
+_getObjectRaster(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ int i,i2,j2;
+ char buffer[128];
+ int totalcol,totalrow;
+ int value;
+ int index;
+ double pos;
+
+ index = atoi(id);
+
+ if (index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"Bad index value");
+ return;
+ }
+
+ totalcol = (int) ((s->currentRegion.east - s->currentRegion.west)/s->currentRegion.ew_res);
+ totalrow = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res);
+ ecs_SetGeomMatrix(&(s->result),totalcol);
+
+ if (s->rasterconversion.isProjEqual) {
+ for (i=0; i<totalcol; i++) {
+ value = _calcPosValue(s,l,i,index,FALSE);
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),i,value);
+ }
+ } else {
+ for (i=0; i<totalcol; i++) {
+ i2 = ECSGETI(s,((double) index),((double)i));
+ j2 = ECSGETJ(s,((double) index),((double)i));
+ value = _calcPosValue(s,l,j2,i2,FALSE);
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),i,value);
+ }
+ }
+
+ sprintf(buffer,"%d",index);
+ if (!ecs_SetObjectId(&(s->result),buffer)) {
+ return;
+ }
+
+ pos = s->currentRegion.north - index*s->currentRegion.ns_res;
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),s->currentRegion.west,
+ pos+s->currentRegion.ns_res,
+ s->currentRegion.east,pos)
+
+ ecs_SetSuccess(&(s->result));
+}
+
+void
+_getObjectIdRaster(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+
+ ecs_SetSuccess(&(s->result));
+}
+
+void _rewindRasterLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+}
+
+
+int _calcPosValue(s,l,i,j,UseOverview)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int i;
+ int j;
+ int UseOverview;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ register LayerPrivateData *ptrlpriv;
+ register ServerPrivateData *spriv = s->priv;
+ double pos_x, pos_y;
+ int pix_c,pix_r;
+ register int value,tile,tile_physique,tile_x,tile_y;
+ register int tile_r,tile_c;
+ register unsigned int Red,Green,Blue,PosRed;
+
+ if (UseOverview == TRUE) {
+ ptrlpriv = &(spriv->overview);
+ } else {
+ ptrlpriv = lpriv;
+ }
+
+ pos_x = s->currentRegion.west + i*s->currentRegion.ew_res;
+ pos_y = s->currentRegion.north - j*s->currentRegion.ns_res;
+
+ _calPosWithCoord(s,l,pos_x,pos_y,&pix_c,&pix_r,UseOverview);
+
+ if ((pix_c>=0) && (pix_c<ptrlpriv->columns) &&
+ (pix_r>=0) && (pix_r<ptrlpriv->rows)) {
+
+ /* Trouver la tile correspondante a pix_c,pix_r */
+
+ tile_x = pix_c/128;
+ tile_y = pix_r/128;
+ tile = (tile_y * ptrlpriv->coltiles) + tile_x;
+
+ /* Trouver a quel numero de tile correspond cette tile */
+
+ if ((tile < 0) || (tile > (ptrlpriv->coltiles*ptrlpriv->rowtiles)))
+ tile_physique = 0;
+ else
+ tile_physique = ptrlpriv->tilelist[tile];
+
+ /* Si cette tile physique est 0, c'est une tile vide */
+
+ if (tile_physique == 0) {
+ value = 0;
+ } else {
+ tile_r = pix_r - tile_y * 128;
+ tile_c = pix_c - tile_x * 128;
+
+ if (ptrlpriv->buffertile != NULL) {
+ tile_physique = tile_x - ptrlpriv->firsttile;
+
+ if (ptrlpriv->buffertile[tile_physique].isActive == TRUE) {
+ PosRed = tile_r*128 + tile_c;
+ Red = (ptrlpriv->buffertile[tile_physique].data[PosRed]) / 43;
+ Green = (ptrlpriv->buffertile[tile_physique].data[PosRed+16384]) / 43;
+ Blue = (ptrlpriv->buffertile[tile_physique].data[PosRed+32768]) / 43;
+ } else {
+ value = 0;
+ return value;
+ }
+ } else {
+ if ((tile_physique--) < 0)
+ tile_physique = 0;
+
+ PosRed = ptrlpriv->firstposition + tile_physique*49152 + tile_r*128 + tile_c;
+ fseek(ptrlpriv->imgfile,PosRed-1,SEEK_SET);
+ Red = ((unsigned int) getc(ptrlpriv->imgfile)) / 43;
+ fseek(ptrlpriv->imgfile,16383,SEEK_CUR);
+ Green = ((unsigned int) getc(ptrlpriv->imgfile)) / 43;
+ fseek(ptrlpriv->imgfile,16383,SEEK_CUR);
+ Blue = ((unsigned int) getc(ptrlpriv->imgfile)) / 43;
+
+ }
+ value = Red*36 + Green*6 + Blue + 1;
+ }
+ } else {
+ value = 0;
+ }
+
+ return value;
+}
+
+/*
+ --------------------------------------------------------------------
+
+ Given an equilateral coordinate, calculate the position in the raster
+
+ --------------------------------------------------------------------
+ */
+
+void _calPosWithCoord(s,l,pos_x,pos_y,i,j,UseOverview)
+ ecs_Server *s;
+ ecs_Layer *l;
+ double pos_x;
+ double pos_y;
+ int *i;
+ int *j;
+ int UseOverview;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ register LayerPrivateData *ptrlpriv;
+ register ServerPrivateData *spriv = s->priv;
+ register long pix_c,pix_r;
+ double x,y,x0,y0;
+ double diff;
+
+ if (UseOverview == TRUE) {
+ ptrlpriv = &(spriv->overview);
+ } else {
+ ptrlpriv = lpriv;
+ }
+
+ /* The ARC zone is important in the x,y calculation. */
+
+ if (lpriv->zonenumber == 9) {
+ /* North pole case */
+
+ x0 = (((double) ptrlpriv->BRV)/360.0) * (90.0 - ptrlpriv->PSO) * sin(ptrlpriv->LSO * PI / 180.0);
+ y0 = (-1.0 * ((double) ptrlpriv->BRV)/360.0) * (90.0 - ptrlpriv->PSO) * cos(ptrlpriv->LSO * PI / 180.0);
+ x = (((double) ptrlpriv->BRV)/360.0) * (90.0 - pos_x) * sin(pos_y * PI / 180.0);
+ y = (-1.0 * ((double) ptrlpriv->BRV)/360.0) * (90.0 - pos_x) * cos(pos_y * PI / 180.0);
+
+ pix_r = (int) (y0 - y);
+ pix_c = (int) (x - x0);
+
+ } else if (lpriv->zonenumber == 18) {
+ /* South pole case */
+
+ x0 = (((double) ptrlpriv->BRV)/360.0) * (90.0 + ptrlpriv->PSO) * sin(ptrlpriv->LSO * PI / 180.0);
+ y0 = (((double) ptrlpriv->BRV)/360.0) * (90.0 + ptrlpriv->PSO) * cos(ptrlpriv->LSO * PI / 180.0);
+ x = (((double) ptrlpriv->BRV)/360.0) * (90.0 + pos_x) * sin(pos_y * PI / 180.0);
+ y = (((double) ptrlpriv->BRV)/360.0) * (90.0 + pos_x) * cos(pos_y * PI / 180.0);
+
+ pix_r = (int) (y0 - y);
+ pix_c = (int) (x - x0);
+
+ } else {
+ /* Non-polar zones */
+
+ diff = pos_x - ptrlpriv->LSO;
+
+ pix_r = (int) ((ptrlpriv->PSO - pos_y) * (ptrlpriv->BRV/360));
+ pix_c = (int) (diff * (ptrlpriv->ARV/360));
+ }
+
+ *i = pix_c;
+ *j = pix_r;
+
+ return;
+}
+
+
+
+/*
+ * --------------------------------------------------------------------------
+ * _get*Object*Image:
+ *
+ * a set of functions to acheive Line objects retrieval
+ * --------------------------------------------------------------------------
+ */
+
+void _getNextObjectImage(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ int i,i2,j2;
+ char buffer[128];
+ static int UseOverview;
+
+ int totalcol,totalrow;
+ int value;
+ double pos;
+
+ if (l->index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ _LoadADRGTiles(s,l,&UseOverview);
+
+ totalcol = (int) ((s->currentRegion.east - s->currentRegion.west)/s->currentRegion.ew_res);
+ totalrow = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res);
+ ecs_SetGeomImage(&(s->result),totalcol);
+
+ if (s->rasterconversion.isProjEqual) {
+ for (i=0; i<totalcol; i++) {
+ value = _calcImagePosValue(s,l,i,l->index,UseOverview);
+ ECS_SETGEOMIMAGEVALUE(&(s->result),i,value);
+ }
+ } else {
+ for (i=0; i<totalcol; i++) {
+ i2 = ECSGETI(s,((double) l->index),((double)i));
+ j2 = ECSGETJ(s,((double) l->index),((double)i));
+ value = _calcImagePosValue(s,l,j2,i2,UseOverview);
+
+ ECS_SETGEOMIMAGEVALUE((&(s->result)),i,value);
+ }
+ }
+
+
+ sprintf(buffer,"%d",l->index);
+ if (!ecs_SetObjectId(&(s->result),buffer)) {
+ return;
+ }
+
+ pos = s->currentRegion.north - l->index*s->currentRegion.ns_res;
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),s->currentRegion.west,
+ pos+s->currentRegion.ns_res,
+ s->currentRegion.east,pos)
+
+
+ l->index++;
+ ecs_SetSuccess(&(s->result));
+}
+
+void
+_getObjectImage(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ int i,i2,j2;
+ char buffer[128];
+ int totalcol,totalrow;
+ int value;
+ int index;
+ double pos;
+
+ index = atoi(id);
+
+ if (index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"Bad index value");
+ return;
+ }
+
+ totalcol = (int) ((s->currentRegion.east - s->currentRegion.west)/s->currentRegion.ew_res);
+ totalrow = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res);
+ ecs_SetGeomImage(&(s->result),totalcol);
+
+ if (s->rasterconversion.isProjEqual) {
+ for (i=0; i<totalcol; i++) {
+ value = _calcImagePosValue(s,l,i,index,FALSE);
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),i,value);
+ }
+ } else {
+ for (i=0; i<totalcol; i++) {
+ i2 = ECSGETI(s,((double) index),((double)i));
+ j2 = ECSGETJ(s,((double) index),((double)i));
+ value = _calcImagePosValue(s,l,j2,i2,FALSE);
+ ECS_SETGEOMIMAGEVALUE((&(s->result)),i,value);
+ }
+ }
+
+ sprintf(buffer,"%d",index);
+ if (!ecs_SetObjectId(&(s->result),buffer)) {
+ return;
+ }
+
+ pos = s->currentRegion.north - index*s->currentRegion.ns_res;
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),s->currentRegion.west,
+ pos+s->currentRegion.ns_res,
+ s->currentRegion.east,pos)
+
+ ecs_SetSuccess(&(s->result));
+}
+
+void
+_getObjectIdImage(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+
+ ecs_SetSuccess(&(s->result));
+}
+
+void _rewindImageLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+}
+
+
+int _calcImagePosValue(s,l,i,j,UseOverview)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int i;
+ int j;
+ int UseOverview;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ register LayerPrivateData *ptrlpriv;
+ register ServerPrivateData *spriv = s->priv;
+ double pos_x, pos_y;
+ int pix_c,pix_r;
+ register int value,tile,tile_physique,tile_x,tile_y;
+ register int tile_r,tile_c;
+ register unsigned int Red,Green,Blue,PosRed;
+
+ if (UseOverview == TRUE) {
+ ptrlpriv = &(spriv->overview);
+ } else {
+ ptrlpriv = lpriv;
+ }
+
+ pos_x = s->currentRegion.west + i*s->currentRegion.ew_res;
+ pos_y = s->currentRegion.north - j*s->currentRegion.ns_res;
+
+ _calPosWithCoord(s,l,pos_x,pos_y,&pix_c,&pix_r,UseOverview);
+
+ if ((pix_c>=0) && (pix_c<ptrlpriv->columns) &&
+ (pix_r>=0) && (pix_r<ptrlpriv->rows)) {
+
+ /* Trouver la tile correspondante a pix_c,pix_r */
+
+ tile_x = pix_c/128;
+ tile_y = pix_r/128;
+ tile = (tile_y * ptrlpriv->coltiles) + tile_x;
+
+ /* Trouver a quel numero de tile correspond cette tile */
+
+ if ((tile < 0) || (tile > (ptrlpriv->coltiles*ptrlpriv->rowtiles)))
+ tile_physique = 0;
+ else
+ tile_physique = ptrlpriv->tilelist[tile];
+
+ /* Si cette tile physique est 0, c'est une tile vide */
+
+ if (tile_physique == 0) {
+ value = ecs_GetPixelFromRGB(0,0,0,0);
+ } else {
+ tile_r = pix_r - tile_y * 128;
+ tile_c = pix_c - tile_x * 128;
+
+ if (ptrlpriv->buffertile != NULL) {
+ tile_physique = tile_x - ptrlpriv->firsttile;
+
+ if (ptrlpriv->buffertile[tile_physique].isActive == TRUE) {
+ PosRed = tile_r*128 + tile_c;
+ Red = (ptrlpriv->buffertile[tile_physique].data[PosRed]);
+ Green = (ptrlpriv->buffertile[tile_physique].data[PosRed+16384]);
+ Blue = (ptrlpriv->buffertile[tile_physique].data[PosRed+32768]);
+ } else {
+ value = ecs_GetPixelFromRGB(0,0,0,0);
+ return value;
+ }
+ } else {
+ if ((tile_physique--) < 0)
+ tile_physique = 0;
+
+ PosRed = ptrlpriv->firstposition + tile_physique*49152 + tile_r*128 + tile_c;
+ fseek(ptrlpriv->imgfile,PosRed-1,SEEK_SET);
+ Red = ((unsigned int) getc(ptrlpriv->imgfile));
+ fseek(ptrlpriv->imgfile,16383,SEEK_CUR);
+ Green = ((unsigned int) getc(ptrlpriv->imgfile));
+ fseek(ptrlpriv->imgfile,16383,SEEK_CUR);
+ Blue = ((unsigned int) getc(ptrlpriv->imgfile));
+
+ }
+ value = ecs_GetPixelFromRGB(1,Red,Green,Blue);
+ }
+ } else {
+ value = ecs_GetPixelFromRGB(0,0,0,0);
+ }
+
+ return value;
+}
+
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/utils.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/utils.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/adrg/utils.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,584 @@
+/******************************************************************************
+ *
+ * Component: OGDI ADRG Driver
+ * Purpose: Supporting ADRG functions.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: utils.c,v $
+ * Revision 1.7 2007/02/12 16:09:06 cbalint
+ * * Add hook macros for all GNU systems, hook fread,fwrite,read,fgets.
+ * * Handle errors in those macro, if there are any.
+ * * Fix some includes for GNU systems.
+ * * Reduce remaining warnings, now we got zero warnings with GCC.
+ *
+ * Modified Files:
+ * config/unix.mak contrib/ogdi_import/dbfopen.c
+ * contrib/ogdi_import/shapefil.h contrib/ogdi_import/shpopen.c
+ * ogdi/c-api/ecs_xdr.c ogdi/c-api/ecsinfo.c ogdi/c-api/server.c
+ * ogdi/datum_driver/canada/nadconv.c ogdi/driver/adrg/adrg.c
+ * ogdi/driver/adrg/adrg.h ogdi/driver/adrg/object.c
+ * ogdi/driver/adrg/utils.c ogdi/driver/rpf/rpf.h
+ * ogdi/driver/rpf/utils.c ogdi/gltpd/asyncsvr.c
+ * ogdi/glutil/iofile.c vpflib/vpfprim.c vpflib/vpfspx.c
+ * vpflib/vpftable.c vpflib/vpftidx.c vpflib/xvt.h
+ *
+ * Revision 1.6 2003/08/27 05:00:06 warmerda
+ * Fixed problems with _read_adrg(), _read_overview() and _initRegionWithDefault
+ * so that the files are actually closed after use. As per bug 795612.
+ *
+ * Revision 1.5 2001/06/22 16:37:50 warmerda
+ * added Image support, upgraded headers
+ *
+ */
+
+#include "adrg.h"
+
+ECS_CVSID("$Id: utils.c,v 1.7 2007/02/12 16:09:06 cbalint Exp $");
+
+/*
+ ----------------------------------------------------------
+
+ _read_adrg
+
+ extract the information from the .GEN file and put them
+ into lpriv.
+
+ ----------------------------------------------------------
+ */
+
+int _read_adrg(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ register ServerPrivateData *spriv = s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ FILE *fichier;
+ int first;
+ char c,sc[4];
+ char buffer[20];
+ double x,y;
+ int i,j,count;
+ int isTiled;
+
+ fichier = fopen(spriv->genfilename,"r");
+ if (fichier == NULL) {
+ ecs_SetError(&(s->result),1,"Unable to open the .GEN file");
+ return FALSE;
+ }
+
+ c = getc(fichier);
+
+ while(!feof(fichier)) {
+ if (c==(char) 30) {
+ ogdi_fread(sc,3,1,fichier);
+ if(strncmp("GIN",sc,3) == 0) {
+ first = TRUE;
+
+ /* Jump ^^ et PRT */
+
+ fseek(fichier,7,SEEK_CUR);
+
+ /* Read NAM */
+
+ ogdi_fread(buffer,8,1,fichier);
+ strncpy(lpriv->imgname,buffer,8);
+ lpriv->imgname[8] = '\0';
+
+
+ /* Jump ^^ STR LOD LAD UNIloa */
+
+ fseek(fichier,17,SEEK_CUR);
+
+ /* Read SWO SWA NWO NWA NEO NEA SEO SEA */
+
+ for(i=0;i<4;i++) {
+ ogdi_fread(buffer,11,1,fichier);
+ buffer[11] = '\0';
+ x = parse_coord_x(buffer);
+ ogdi_fread(buffer,10,1,fichier);
+ buffer[10] = '\0';
+ y = parse_coord_y(buffer);
+
+ if (first) {
+ lpriv->region.east = x;
+ lpriv->region.west = x;
+ lpriv->region.north = y;
+ lpriv->region.south = y;
+ first = FALSE;
+ } else {
+ if (x<(lpriv->region.west))
+ lpriv->region.west = x;
+ if (x>(lpriv->region.east))
+ lpriv->region.east = x;
+ if (y<(lpriv->region.south))
+ lpriv->region.south = y;
+ if (y>(lpriv->region.north))
+ lpriv->region.north = y;
+ }
+ }
+
+ /* Jump SCA */
+
+ fseek(fichier,9,SEEK_CUR);
+
+ /* Read ZNA */
+
+ ogdi_fread(buffer,2,1,fichier);
+ buffer[2] = '\0';
+ lpriv->zonenumber = atoi(buffer);
+
+ /* Jump PSP IMR */
+
+ fseek(fichier,6,SEEK_CUR);
+
+ /* Read ARV */
+
+ ogdi_fread(buffer,8,1,fichier);
+ buffer[8] = '\0';
+ lpriv->ARV = atoi(buffer);
+
+ /* Read BRV */
+
+ ogdi_fread(buffer,8,1,fichier);
+ buffer[8] = '\0';
+ lpriv->BRV = atoi(buffer);
+
+ /* Read LSO PSO */
+
+ ogdi_fread(buffer,11,1,fichier);
+ buffer[11] = '\0';
+ lpriv->LSO = parse_coord_x(buffer);
+
+ ogdi_fread(buffer,10,1,fichier);
+ buffer[10] = '\0';
+ lpriv->PSO = parse_coord_y(buffer);
+
+ /* Jump TXT ^^ NUL NUS NLL NLS */
+
+ fseek(fichier,89,SEEK_CUR);
+
+ /* Read NFL */
+
+ ogdi_fread(buffer,3,1,fichier);
+ buffer[3] = '\0';
+ lpriv->rowtiles = atoi(buffer);
+ lpriv->rows = lpriv->rowtiles * 128;
+ lpriv->region.ns_res = (lpriv->region.north - lpriv->region.south) / (double) lpriv->rows;
+
+ /* Read NFC */
+
+ ogdi_fread(buffer,3,1,fichier);
+ buffer[3] = '\0';
+ lpriv->coltiles = atoi(buffer);
+ lpriv->columns = lpriv->coltiles * 128;
+ lpriv->region.ew_res = (lpriv->region.east - lpriv->region.west) / (double) lpriv->columns;
+
+ /* Jump PNC PNL COD ROD POR PCB PVB */
+
+ fseek(fichier,17,SEEK_CUR);
+
+ /* Read BAD and check if it valid. If not, search another GIN */
+
+ ogdi_fread(buffer,12,1,fichier);
+#ifdef _WINDOWS
+ if (strnicmp(buffer,lpriv->imgfilename,12) != 0) {
+#else
+ if (strncasecmp(buffer,lpriv->imgfilename,12) != 0) {
+#endif
+ c = getc(fichier);
+ continue;
+ }
+ lpriv->imgfilename[12] = '\0';
+
+ /* Read the TIF */
+
+ ogdi_fread(buffer,1,1,fichier);
+ if (buffer[0] == 'N')
+ isTiled = FALSE;
+ else
+ isTiled = TRUE;
+
+
+ /* If is tiled, get the TSI. */
+
+ if (isTiled) {
+ /* Jump ^^ BID WS1 WS2 ^^ */
+ fseek(fichier,47,SEEK_CUR);
+ }
+
+ lpriv->tilelist = (int *) malloc(sizeof(int)*lpriv->rowtiles*lpriv->coltiles);
+ if (lpriv->tilelist == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory");
+ fclose( fichier );
+ return FALSE;
+ }
+
+ count = 0;
+ for(i=0;i<lpriv->rowtiles;i++) {
+ for(j=0;j<lpriv->coltiles;j++) {
+ if (isTiled) {
+ ogdi_fread(buffer,5,1,fichier);
+ buffer[5] = '\0';
+ lpriv->tilelist[count] = atoi(buffer);
+ } else {
+ lpriv->tilelist[count] = count+1;
+ }
+ count++;
+ }
+ }
+
+ fclose( fichier );
+ return TRUE;
+ }
+ }
+
+ c = getc(fichier);
+ }
+
+ ecs_SetError(&(s->result),1,"ADRG image not found");
+ fclose( fichier );
+ return FALSE;
+}
+
+
+/*
+ ----------------------------------------------------------
+
+ _read_overview
+
+ extract the information from the .GEN file and put them
+ into the overview attribute of spriv.
+
+ ----------------------------------------------------------
+ */
+
+int _read_overview(s)
+ ecs_Server *s;
+{
+ register ServerPrivateData *spriv = s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) &(spriv->overview);
+ FILE *fichier;
+ int first;
+ char c,sc[4];
+ char buffer[20];
+ int i,j,count;
+ int isTiled;
+
+ lpriv->tilelist = NULL;
+ lpriv->buffertile = NULL;
+
+ fichier = fopen(spriv->genfilename,"r");
+ if (fichier == NULL) {
+ ecs_SetError(&(s->result),1,"Unable to open the .GEN file");
+ return FALSE;
+ }
+
+ c = getc(fichier);
+
+ while(!feof(fichier)) {
+ if (c==(char) 30) {
+ ogdi_fread(sc,3,1,fichier);
+ if(strncmp("OVV",sc,3) == 0) {
+ first = TRUE;
+
+ /* Jump ^^ et PRT */
+
+ fseek(fichier,7,SEEK_CUR);
+
+ /* Read NAM */
+
+ ogdi_fread(buffer,8,1,fichier);
+ strncpy(lpriv->imgname,buffer,8);
+ lpriv->imgname[8] = '\0';
+
+ /* Jump STR */
+
+ fseek(fichier,2,SEEK_CUR);
+
+ /* Read ARV */
+
+ ogdi_fread(buffer,8,1,fichier);
+ buffer[8] = '\0';
+ lpriv->ARV = atoi(buffer);
+
+ /* Read BRV */
+
+ ogdi_fread(buffer,8,1,fichier);
+ buffer[8] = '\0';
+ lpriv->BRV = atoi(buffer);
+
+ /* Read LSO PSO */
+
+ ogdi_fread(buffer,11,1,fichier);
+ buffer[11] = '\0';
+ lpriv->LSO = parse_coord_x(buffer);
+ ogdi_fread(buffer,10,1,fichier);
+ buffer[10] = '\0';
+ lpriv->PSO = parse_coord_y(buffer);
+
+ /* Jump ^^ NUL NUS NLL NLS */
+
+ fseek(fichier,25,SEEK_CUR);
+
+ /* Read NFL */
+
+ ogdi_fread(buffer,3,1,fichier);
+ buffer[3] = '\0';
+ lpriv->rowtiles = atoi(buffer);
+ lpriv->rows = lpriv->rowtiles * 128;
+
+ /* Read NFC */
+
+ ogdi_fread(buffer,3,1,fichier);
+ buffer[3] = '\0';
+ lpriv->coltiles = atoi(buffer);
+ lpriv->columns = lpriv->coltiles * 128;
+
+ /* Jump PNC PNL COD ROD POR PCB PVB */
+
+ fseek(fichier,17,SEEK_CUR);
+
+ /* Read BAD and check if it valid. If not, search another GIN */
+
+ ogdi_fread(buffer,12,1,fichier);
+ strncpy(lpriv->imgfilename,buffer,12);
+ lpriv->imgfilename[12] = '\0';
+
+ /* Read the TIF */
+
+ ogdi_fread(buffer,1,1,fichier);
+ if (buffer[0] == 'N')
+ isTiled = FALSE;
+ else
+ isTiled = TRUE;
+
+
+ /* If is tiled, get the TSI. */
+
+ if (isTiled) {
+ /* Jump ^^ BID WS1 WS2 ^^ */
+ fseek(fichier,47,SEEK_CUR);
+ }
+
+ lpriv->tilelist = (int *) malloc(sizeof(int)*lpriv->rowtiles*lpriv->coltiles);
+ if (lpriv->tilelist == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory");
+ fclose( fichier );
+ return FALSE;
+ }
+
+ count = 0;
+ for(i=0;i<lpriv->rowtiles;i++) {
+ for(j=0;j<lpriv->coltiles;j++) {
+ if (isTiled) {
+ ogdi_fread(buffer,5,1,fichier);
+ buffer[5] = '\0';
+ lpriv->tilelist[count] = atoi(buffer);
+ } else {
+ lpriv->tilelist[count] = count+1;
+ }
+ count++;
+ }
+ }
+
+ /* Set the bounding rectangle of the matrix with the global region
+ (no region set for the overview, only data convertion). */
+
+ fclose( fichier );
+ return TRUE;
+ }
+ }
+
+ c = getc(fichier);
+ }
+
+ ecs_SetError(&(s->result),1,"ADRG overview not found");
+ fclose( fichier );
+
+ return FALSE;
+}
+
+char *subfield(buffer,index,length)
+ char *buffer;
+ int index;
+ int length;
+{
+ static char sub[20];
+ int k;
+ for (k=0;k<length;++k)
+ sub[k] = buffer[index+k];
+ sub[k]=0;
+ return sub;
+}
+
+double parse_coord_x(buffer)
+ char *buffer;
+{
+ double deg, min, sec;
+ double degrees;
+
+ deg = atof(subfield(buffer,1,3));
+ min = atof(subfield(buffer,4,2));
+ sec = atof(subfield(buffer,6,5));
+ degrees = deg + min/60.0 + sec/3600.0;
+ if (buffer[0] == '-')
+ degrees = -degrees;
+ return degrees;
+}
+
+double parse_coord_y(buffer)
+ char *buffer;
+{
+ double deg, min, sec;
+ double degrees;
+
+ deg = atof(subfield(buffer,1,2));
+ min = atof(subfield(buffer,3,2));
+ sec = atof(subfield(buffer,5,5));
+ degrees = deg + min/60.0 + sec/3600.0;
+ if (buffer[0] == '-')
+ degrees = -degrees;
+ return degrees;
+}
+
+
+/*
+ ----------------------------------------------------------
+ _VerifyLocation:
+
+ check if the .GEN file is valid.
+
+ ----------------------------------------------------------
+ */
+
+int
+_verifyLocation(s)
+ ecs_Server *s;
+{
+ int returnvalue;
+ FILE *test;
+ register ServerPrivateData *spriv = s->priv;
+
+ returnvalue = FALSE;
+
+ test = fopen(spriv->genfilename,"r");
+ if (test != NULL) {
+ fclose(test);
+ returnvalue = TRUE;
+ }
+
+ if (!returnvalue)
+ ecs_SetError(&(s->result),1,"Invalid ADRG URL. The .GEN file is invalid");
+ return returnvalue;
+}
+
+/*
+ -------------------------------------------------------------------------
+ _initRegionWithDefault:
+
+ Prepare the global region of this driver
+
+ Extracting the global bounding box imply a search of all
+ images MBR in the .GEN file. Each image start with ^^GIN and
+ the first coordinate of this image is kept 32 spaces after.
+ At this location, we got two coordinate for each corner of the
+ MBR.
+
+ SWO 11 char South-West corner longitude
+ SWA 10 char South-West corner latitude
+ NWO 11 char North-West corner longitude
+ NWA 10 char North-West corner latitude
+ NEO 11 char North-East corner longitude
+ NEA 10 char North-East corner latitude
+ SEO 11 char South-East corner longitude
+ SEA 10 char South-East corner latitude
+
+ --------------------------------------------------------------------------
+ */
+
+int _initRegionWithDefault(s)
+ ecs_Server *s;
+{
+ register ServerPrivateData *spriv = s->priv;
+ int first = TRUE;
+ FILE *fichier;
+ char c,sc[4];
+ char buffer[12];
+ double x,y;
+ int i;
+
+ fichier = fopen(spriv->genfilename,"r");
+ if (fichier == NULL) {
+ ecs_SetError(&(s->result),1,"Unable to open the .GEN file");
+ return FALSE;
+ }
+
+ c = getc(fichier);
+
+ while(!feof(fichier)) {
+ if (c==(char) 30) {
+ ogdi_fread(sc,3,1,fichier);
+ if(strncmp("GIN",sc,3) == 0) {
+ fseek(fichier,32,SEEK_CUR);
+ for(i=0;i<4;i++) {
+ ogdi_fread(buffer,11,1,fichier);
+ x = parse_coord_x(buffer);
+ ogdi_fread(buffer,10,1,fichier);
+ y = parse_coord_y(buffer);
+
+ if (first) {
+ s->globalRegion.east = x;
+ s->globalRegion.west = x;
+ s->globalRegion.north = y;
+ s->globalRegion.south = y;
+ first = FALSE;
+ } else {
+ if (x<(s->globalRegion.west))
+ s->globalRegion.west = x;
+ if (x>(s->globalRegion.east))
+ s->globalRegion.east = x;
+ if (y<(s->globalRegion.south))
+ s->globalRegion.south = y;
+ if (y>(s->globalRegion.north))
+ s->globalRegion.north = y;
+ }
+ }
+ }
+ }
+
+ c = getc(fichier);
+ }
+
+ s->globalRegion.ns_res = (s->globalRegion.north - s->globalRegion.south)/1000.0;
+ s->globalRegion.ew_res = (s->globalRegion.east - s->globalRegion.west)/1000.0;
+
+ fclose( fichier );
+ return 1;
+}
+
+
+int _IsOutsideRegion(n,s,e,w,region)
+ double n,s,e,w;
+ ecs_Region *region;
+{
+ if ((n < region->south) ||
+ (s > region->north) ||
+ (e < region->west) ||
+ (w > region->east)) {
+ return 1;
+ }
+ return 0;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/datadict.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/datadict.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/datadict.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,164 @@
+static char datadict[] = {'\n'
+,'i','t','c','l','_','c','l','a','s','s',' ','W','K','B','_','D','a','t','a','D','i','c','t','i','o','n','a','r','y',' ','{'
+,'\n'
+,'\t','i','n','h','e','r','i','t',' ','d','d'
+,'\n'
+
+,'\n'
+,'c','o','n','s','t','r','u','c','t','o','r',' ','{','w','p','a','t','h',' ','l','o','c','a','t','i','o','n','}',' ','{'
+,'\n'
+,' ',' ',' ',' ','#','d','d',':',':','c','o','n','s','t','r','u','c','t','o','r',' ','$','w','i','n','d','o','w','p','a','t','h',' ','$','l','o','c','a','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','d','d',' ','$','w','p','a','t','h',' ','$','l','o','c','a','t','i','o','n'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','l','a','y','o','u','t',' ','{','}',' ','{'
+,'\n'
+,' ',' ',' ',' ','f','r','a','m','e',' ','$','w','i','n','d','o','w','.','c','e','n','t','e','r'
+,'\n'
+,'\t','m','a','p','L','i','s','t','b','o','x'
+,'\n'
+,'\t','b','u','t','t','o','n','s'
+,'\n'
+,'\t','u','p','d','a','t','e','d','i','c','t'
+,'\n'
+,'\t',':',':','u','p','d','a','t','e',' ','i','d','l','e','t','a','s','k','s','\t'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','b','u','t','t','o','n','s',' ','{','}',' ','{'
+,'\n'
+,'\t','f','r','a','m','e',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1'
+,'\n'
+,'\t','p','a','c','k',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1',' ','-','s','i','d','e',' ','t','o','p',' ','-','f','i','l','l',' ','x',' ','-','p','a','d','y',' ','2',' ','-','e','x','p','a','n','d',' ','f','a','l','s','e'
+,'\n'
+
+,'\n'
+,'\t','s','e','t',' ','w','(','b','u','t','t','o','n',')',' ','[','b','u','t','t','o','n',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1','.','r','a','m','d','i','s','k',' ','\\'
+,'\n'
+,'\t','\t','-','t','e','x','t',' ','\"','R','a','m','/','D','i','s','k','\"',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','_','t','o','g','g','l','e','S','t','a','t','e','\"',']'
+,'\n'
+,'\t','p','a','c','k',' ','$','w','(','b','u','t','t','o','n',')',' ','-','s','i','d','e',' ','l','e','f','t',' ','-','p','a','d','x',' ','1',' ','-','e','x','p','a','n','d',' ','1'
+,'\n'
+,'\t','$','o','b','j','_','l','i','b','r','a','r','i','a','n',' ','R','e','g','i','s','t','e','r','S','t','a','t','u','s','I','n','f','o',' ','$','w','(','b','u','t','t','o','n',')',' ','[','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','G','e','t','S','t','r','i','n','g',' ','S','T','A','T','U','S','-','D','T','E','D','-','R','A','M',']'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','_','t','o','g','g','l','e','S','t','a','t','e',' ','{','}',' ','{'
+,'\n'
+
+,'\n'
+,'\t','s','e','t',' ','s','_','s','e','l','e','c','t','i','o','n',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','c','u','r','s','e','l','e','c','t','i','o','n',']'
+,'\n'
+,'\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','s','_','s','e','l','e','c','t','i','o','n',' ','\"','\"',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','e','r','r','o','r','M','s','g',' ','\"','T','h','e','r','e',' ','m','u','s','t',' ','b','e',' ','a',' ','c','o','v','e','r','a','g','e',' ','s','e','l','e','c','t','e','d','\"'
+,'\n'
+,'\t','\t','r','e','t','u','r','n'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','s','e','t',' ','s','_','n','a','m','e',' ','[','g','e','t','L','i','s','t','E','n','t','r','y',' ','$','s','_','s','e','l','e','c','t','i','o','n',']'
+,'\n'
+,'\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','a','_','r','a','m','d','i','s','k','(','$','s','_','n','a','m','e',')',' ','R','A','M',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','a','_','r','a','m','d','i','s','k','(','$','s','_','n','a','m','e',')',' ','D','I','S','K'
+,'\n'
+,'\t','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','a','_','r','a','m','d','i','s','k','(','$','s','_','n','a','m','e',')',' ','R','A','M'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','d','e','l','e','t','e',' ','$','s','_','s','e','l','e','c','t','i','o','n'
+,'\n'
+,'\t','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','i','n','s','e','r','t',' ','$','s','_','s','e','l','e','c','t','i','o','n',' ','[','g','e','t','U','R','L','E','n','t','r','y',' ','$','s','_','n','a','m','e',']'
+,'\n'
+,'\t','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','s','e','l','e','c','t','i','o','n',' ','s','e','t',' ','$','s','_','s','e','l','e','c','t','i','o','n',' ','$','s','_','s','e','l','e','c','t','i','o','n'
+,'\n'
+
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','L','i','s','t','E','n','t','r','y',' ','{','i','n','d','e','x','}',' ','{'
+,'\n'
+,'\t','r','e','g','s','u','b',' ','{','\\','(','[','A','-','Z',']','+','\\',')','$','}',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','g','e','t',' ','$','i','n','d','e','x',']',' ','{','}',' ','s','_','n','a','m','e',' '
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','s','_','n','a','m','e'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','u','p','d','a','t','e','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+
+,'\n'
+,' ',' ','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','d','e','l','e','t','e',' ','0',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','s','i','z','e',']'
+,'\n'
+,' ',' ','f','o','r','e','a','c','h',' ','s','_','i','t','e','m',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',']',' ','{'
+,'\n'
+,' ',' ','\t','i','f',' ','{','[','i','n','f','o',' ','e','x','i','s','t','s',' ','a','_','r','a','m','d','i','s','k','(','$','s','_','i','t','e','m',')',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','a','_','r','a','m','d','i','s','k','(','$','s','_','i','t','e','m',')',' ','$','s','_','d','i','s','k','D','e','f','a','u','l','t'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','i','n','s','e','r','t',' ','e','n','d',' ','[','g','e','t','U','R','L','E','n','t','r','y',' ','$','s','_','i','t','e','m',']'
+,'\n'
+,' ',' ','}'
+,'\n'
+
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','U','R','L','E','n','t','r','y',' ','{','s','_','p','a','t','h','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','{','s','_','p','a','t','h','}','\\','(','$','a','_','r','a','m','d','i','s','k','(','$','s','_','p','a','t','h',')','\\',')'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',' ','{','a','r','g','s','}',' ','{'
+,'\n'
+,' ','\t','r','e','t','u','r','n',' ','R','a','s','t','e','r'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','P','a','t','h','n','a','m','e',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','s','e','l','e','c','t','i','o','n','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','s','e','l','e','c','t','i','o','n','\t'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'p','r','o','t','e','c','t','e','d',' ','a','_','r','a','m','d','i','s','k',' ',';','#',' ','w','h','e','t','h','e','r',' ','t','h','e',' ','c','o','v','e','r','a','g','e',' ','i','s',' ','t','o',' ','b','e',' ','l','o','a','d','e','d',' ','i','n','t','o',' ','r','a','m',' ','o','r',' ','d','i','s','k','.'
+,'\n'
+,'\t','\t','\t','\t','\t',';','#',' ','v','a','l','u','e','s',' ','a','r','e',' ','e','i','t','h','e','r',' ','\"','R','A','M','\"',' ','o','r',' ','\"','D','I','S','K','\"'
+,'\n'
+,'p','r','o','t','e','c','t','e','d',' ','s','_','d','i','s','k','D','e','f','a','u','l','t',' ','\"','D','I','S','K','\"'
+,'\n'
+
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'\0'};
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,714 @@
+/******************************************************************************
+ *
+ * Component: OGDI DTED Driver
+ * Purpose: External (dyn_*) entry points for DTED driver.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: dted.c,v $
+ * Revision 1.10 2001/06/13 17:17:40 warmerda
+ * fixed capabilities to match 6.2 spec
+ *
+ * Revision 1.9 2001/04/19 05:04:12 warmerda
+ * fixed roundoff issues with computing nbfeature
+ *
+ * Revision 1.8 2001/04/10 16:18:28 warmerda
+ * added ogdi_server_capabilities, and ogdi_capabilities support
+ *
+ * Revision 1.7 2001/04/10 14:29:43 warmerda
+ * Upgraded with changes from DND (hand applied to avoid losing bug fixes).
+ * Patch also includes change to exclude zero elevations when computing
+ * mincat/maxcat.
+ * New style headers also applied.
+ *
+ */
+
+#include "dted.h"
+#include "datadict.h"
+
+ECS_CVSID("$Id: dted.c,v 1.10 2001/06/13 17:17:40 warmerda Exp $");
+
+/* layer oriented functions are keeped in data structure to simplify code */
+
+LayerMethod dted_layerMethod[11] = {
+ /* 0 */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Area */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Line */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Point */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Matrix */ { NULL, NULL, _rewindRasterLayer, _getNextObjectRaster, _getObjectRaster, _getObjectIdRaster },
+ /* Image */ { NULL, NULL, _rewindRasterLayer, _getNextObjectRaster, _getObjectRaster, _getObjectIdRaster },
+ /* Text */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Edge */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Face */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Node */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Ring */ { NULL, NULL, NULL, NULL, NULL, NULL }
+};
+
+/* ----------------------------------------------------------------------
+ * _dyn_CreateServer:
+ *
+ * Creation of a new S server
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_CreateServer(s,Request)
+ ecs_Server *s;
+ char *Request;
+{
+ ServerPrivateData *spriv = s->priv =
+ (void *) calloc(1,sizeof(ServerPrivateData));
+
+ (void) Request;
+
+ if (spriv == NULL) {
+ ecs_SetError(&(s->result),1,
+ "Not enough memory to allocate server private data");
+ return &(s->result);
+ }
+
+ spriv->pathname = (char *) malloc(strlen(s->pathname)+1);
+ if (spriv->pathname == NULL) {
+ free(s->priv);
+ ecs_SetError(&(s->result),1,"Not enough memory");
+ return &(s->result);
+ }
+
+ if (s->pathname[2] == ':') {
+ strcpy(spriv->pathname,s->pathname+1);
+ } else {
+ strcpy(spriv->pathname,s->pathname);
+ }
+
+ /* check the path and see if the location is valid */
+
+ if (!_verifyLocation(s)) {
+ free(spriv->pathname);
+ free(s->priv);
+ return &(s->result);
+ }
+
+ /* initialize the driver globalRegion */
+ /*
+ if (!_initRegionWithDefault(s)) {
+ free(spriv->pathname);
+ free(s->priv);
+ return &(s->result);
+ }
+ */
+ /* initialize with the info from the database */
+
+ /* set the last-opened tile to "none" */
+ spriv->lastTile.x=spriv->lastTile.y=-1;
+ spriv->lastTile.none=0;
+
+ if (!_readValuesFromDirList(s)) {
+ free(spriv->pathname);
+ free(s->priv);
+ return &(s->result);
+ }
+
+ if (! _readDMED(s)) {
+ ecs_SetError(&(s->result), 1, "Unable to reconstruct missing DMED file.");
+ free(spriv->pathname);
+ free(s->priv);
+ return &(s->result);
+ }
+
+ /* 1,1 are placeholders; the width is calculated from _getResolution */
+ if (!ecs_TileInitialize( s, &(spriv->t), &(s->globalRegion), spriv->xtiles,
+ spriv->ytiles, 1, 1, _calcPosValue, _getTileDim)) {
+ ecs_SetError(&(s->result), 1, "Unable to retrieve tile structure.");
+ free(spriv->pathname);
+ free(s->priv);
+ return &(s->result);
+ }
+
+ if (! _sample_tiles(s,&(spriv->t))) {
+ ecs_SetError(&(s->result), 1, "Unable to sample data to set colour table.");
+ free(spriv->pathname);
+ free(s->priv);
+ return &(s->result);
+ }
+
+ s->nblayer = 0;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_DestroyServer:
+ *
+ * Destruction of this GRASS server
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_DestroyServer(s)
+ ecs_Server *s;
+{
+ ServerPrivateData *spriv = s->priv;
+ int i;
+
+ /* Release all layer */
+
+ _releaseAllLayers(s);
+
+ if(spriv != NULL) {
+ ecs_TileClearBuffer(&(spriv->t));
+ if (spriv->pathname != NULL) {
+ free(spriv->pathname);
+ }
+ for( i=0; i < spriv->xtiles; i++ )
+ {
+ if( spriv->ewdir != NULL && spriv->ewdir[i].nsfile != NULL )
+ free( spriv->ewdir[i].nsfile );
+ }
+ if( spriv->ewdir != NULL )
+ free( spriv->ewdir );
+
+ free(spriv);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+
+}
+
+void _freelayerpriv(lpriv)
+ LayerPrivateData *lpriv;
+{
+ if (lpriv != NULL) {
+ if (lpriv->ewdir != NULL)
+ free(lpriv->ewdir);
+
+ if (lpriv->matrixbuffer != NULL)
+ free(lpriv->matrixbuffer);
+ free(lpriv);
+ }
+ lpriv = NULL;
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_SelectLayer:
+ *
+ * Select or reselect a layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SelectLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int layer;
+ /* char *ewdir,*nsfile; */
+ LayerPrivateData *lpriv;
+ /* char *dtedfilename; */
+ ServerPrivateData *spriv = s->priv;
+
+ if (sel->F != Matrix && sel->F != Image) {
+ ecs_SetError(&(s->result),1,"Invalid layer type");
+ return &(s->result);
+ }
+
+ /* first, try to find an existing layer with same request and family */
+ if (spriv->lastTile.none) {
+ fclose(spriv->ewdir[spriv->lastTile.x].nsfile[spriv->lastTile.y].filehandle);
+ spriv->lastTile.x=spriv->lastTile.y=-1;
+ spriv->lastTile.none=0;
+ }
+
+ if ((layer = ecs_GetLayer(s,sel)) != -1) {
+
+ /* if it already exists than assign currentLayer and set index to 0 to force rewind */
+
+ s->currentLayer = layer;
+ _rewindRasterLayer(s,&(s->layer[layer]));
+ ecs_SetGeoRegion(&(s->result),s->globalRegion.north, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.west, s->globalRegion.ns_res,
+ s->globalRegion.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+ }
+
+ /* it did not exists so we are going to try to create it */
+
+ if ((layer = ecs_SetLayer(s,sel)) == -1) {
+ return &(s->result);
+ }
+
+ /* allocate memory to hold private info about this new layer */
+
+ if ((s->layer[layer].priv = (void *) malloc(sizeof(LayerPrivateData))) == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate layer private data");
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+ lpriv->ewdir = NULL;
+ lpriv->nsfile = NULL;
+ lpriv->matrixbuffer = NULL;
+ lpriv->family = sel->F;
+
+ if (!_parse_request(s,sel->Select,&(lpriv->isInRam))) {
+ _freelayerpriv(layer);
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+
+ s->currentLayer = layer;
+ s->layer[layer].nbfeature = (int)
+ ((s->currentRegion.north - s->currentRegion.south)
+ /s->currentRegion.ns_res + 0.5);
+
+ ecs_SetGeoRegion(&(s->result),s->globalRegion.north, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.west,
+ s->globalRegion.ns_res, s->globalRegion.ew_res);
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * dyn_GetAttributesFormat:
+ *
+ * return the attribute format of the currently selected layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *
+dyn_GetAttributesFormat(s)
+ ecs_Server *s;
+{
+ ecs_SetObjAttributeFormat(&(s->result));
+
+ ecs_AddAttributeFormat(&(s->result),"category",Integer,5,0,0);
+ ecs_AddAttributeFormat(&(s->result),"label",Char,80,0,0);
+
+ ecs_SetSuccess(&(s->result));
+
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_ReleaseLayer:
+ *
+ * deselect a layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_ReleaseLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int layer;
+ char buffer[128];
+ ServerPrivateData *spriv=s->priv;
+ LayerPrivateData *lpriv;
+
+ /* first, try to find an existing layer with same request and family */
+
+ if ((layer = ecs_GetLayer(s,sel)) == -1) {
+ sprintf(buffer,"Invalid layer %s",sel->Select);
+ ecs_SetError(&(s->result),1,buffer);
+ return &(s->result);
+ }
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+
+ if (lpriv != NULL) {
+ _freelayerpriv(lpriv);
+ ecs_FreeLayer(s,layer);
+
+ if (s->currentLayer == layer) {
+ s->currentLayer = -1; /* just in case released layer was selected */
+ }
+ }
+ if (spriv->lastTile.none) {
+ fclose(spriv->ewdir[spriv->lastTile.x].nsfile[spriv->lastTile.y].filehandle);
+ spriv->lastTile.x=spriv->lastTile.y=-1;
+ spriv->lastTile.none=0;
+
+ }
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* deselect all layer */
+
+void
+_releaseAllLayers(s)
+ ecs_Server *s;
+{
+ int i;
+
+ for (i = 0; i < s->nblayer; ++i)
+ dyn_ReleaseLayer(s,&(s->layer[i].sel));
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_SelectRegion:
+ *
+ * selection current geographic region.
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_SelectRegion(s,gr)
+ ecs_Server *s;
+ ecs_Region *gr;
+{
+
+ s->currentRegion.north = gr->north;
+ s->currentRegion.south = gr->south;
+ s->currentRegion.east = gr->east;
+ s->currentRegion.west = gr->west;
+ s->currentRegion.ns_res = gr->ns_res;
+ s->currentRegion.ew_res = gr->ew_res;
+
+ /* reset currentLayer index to 0 to force rewind */
+
+ if (s->currentLayer != -1) {
+ _rewindRasterLayer(s,&(s->layer[s->currentLayer]));
+ s->layer[s->currentLayer].nbfeature = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res + 0.5);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetDictionary:
+ *
+ * return the itcl_class object
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetDictionary(s)
+ ecs_Server *s;
+{
+ if (ecs_SetText(&(s->result),datadict)) {
+ ecs_SetSuccess(&(s->result));
+ }
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * dyn_GetNextObject:
+ *
+ * return the next object for the current layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetNextObject(s)
+ ecs_Server *s;
+{
+
+ if (s->layer[s->currentLayer].index == 0) {
+ (dted_layerMethod[s->layer[s->currentLayer].sel.F].rewind)(s,&(s->layer[s->currentLayer]));
+ }
+
+ (dted_layerMethod[s->layer[s->currentLayer].sel.F].getNextObject)(s,&(s->layer[s->currentLayer]));
+
+ return &(s->result);
+
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetRasterInfo:
+ *
+ * return raster layer meta information
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetRasterInfo(s)
+ ecs_Server *s;
+{
+ int k;
+ int intensity;
+ char buffer[256];
+ LayerPrivateData *lpriv;
+ int limit1,limit2;
+ int max, min, range;
+ double m,b;
+
+ ServerPrivateData *spriv = s->priv;
+ lpriv = (LayerPrivateData *) s->layer[s->currentLayer].priv;
+
+ if (lpriv->family == Matrix) {
+ /* rules for re-categorization:
+ 1) if there are more than 216 categories, rescale to 1-216.
+ 2) else recategorize to 1 to (maxcat-mincat) + 1.
+ */
+
+ range=spriv->maxcat-spriv->mincat;
+ min=1;
+ if (range<216) {
+ max=range+1;
+ } else {
+ max=216;
+ }
+ limit1 = (int) (((max - min) / 3.0) + min);
+ limit2 = (int) ((2*(max - min) / 3.0) + min);
+
+ /* Put table contain in RasterInfo here */
+
+ ecs_SetRasterInfo(&(s->result),100, 100);
+ for (k=min;k<=max;k++) {
+ if (spriv->maxcat-spriv->mincat<216) {
+ sprintf(buffer, "%d", k+spriv->mincat);
+ } else {
+ sprintf(buffer,"%d",(k-1)*(spriv->maxcat-spriv->mincat)/215 + spriv->mincat);
+ }
+ m = 242.0 / (limit1 - min);
+
+ if (k < limit1) {
+ b = 255-m*limit1;
+ intensity = (int) (m*((double) k)+b);
+ if (intensity >= 255)
+ intensity = 255;
+ if (intensity <= 13)
+ intensity = 13;
+ ecs_AddRasterInfoCategory(&(s->result),k,0,0,intensity,buffer,0);
+ } else {
+ if (k > limit2) {
+ b = 255-m*max;
+ intensity = (int) (m*((double) k)+b);
+ if (intensity >= 255)
+ intensity = 255;
+ if (intensity <= 13)
+ intensity = 13;
+ ecs_AddRasterInfoCategory(&(s->result),k,intensity,0,0,buffer,0);
+ } else {
+ b = 255-m*limit2;
+ intensity = (int) (m*((double) k)+b);
+ if (intensity >= 255)
+ intensity = 255;
+ if (intensity <= 13)
+ intensity = 13;
+ ecs_AddRasterInfoCategory(&(s->result),k,0,intensity,0,buffer,0);
+ }
+ }
+ }
+ } else {
+ ecs_SetRasterInfo(&(s->result),5,0);
+ ecs_AddRasterInfoCategory(&(s->result),1, 255, 255, 255,"No data",0);
+ s->result.res.ecs_ResultUnion_u.ri.mincat = spriv->mincat;
+ s->result.res.ecs_ResultUnion_u.ri.maxcat = spriv->maxcat;
+ }
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * dyn_GetObject:
+ *
+ * return an object for the current layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObject(s,Id)
+ ecs_Server *s;
+ char *Id;
+{
+ if (dted_layerMethod[s->layer[s->currentLayer].sel.F].getObject != NULL)
+ (dted_layerMethod[s->layer[s->currentLayer].sel.F].getObject)(s,&(s->layer[s->currentLayer]),Id);
+ else {
+ ecs_SetError(&(s->result),1,"Can't get object for this type of layer");
+ }
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetObjectIdFromCoord:
+ *
+ * return the object id sitting at (or near) to a coordinate
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObjectIdFromCoord(s,coord)
+ ecs_Server *s;
+ ecs_Coordinate *coord;
+{
+ if (dted_layerMethod[s->layer[s->currentLayer].sel.F].getObjectIdFromCoord != NULL)
+ (dted_layerMethod[s->layer[s->currentLayer].sel.F].getObjectIdFromCoord)(s,&(s->layer[s->currentLayer]),coord);
+ else {
+ ecs_SetError(&(s->result),1,"Can't get objectid from coordinate for this type of layer");
+ }
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_UpdateDictionary:
+ *
+ * Return the content of this location data dictionary in a Tcl List
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_UpdateDictionary(s,info)
+ ecs_Server *s;
+ char *info;
+{
+ ServerPrivateData *spriv = s->priv;
+
+ if( strcmp(info,"ogdi_server_capabilities") == 0 )
+ {
+ ecs_AddText(&(s->result),
+ "<?xml version=\"1.0\" ?>\n"
+ "<OGDI_Capabilities version=\"3.1\">\n"
+ "</OGDI_Capabilities>\n" );
+ ecs_SetSuccess(&(s->result));
+ }
+
+ else if( strcmp(info,"ogdi_capabilities") == 0 )
+ {
+ char line[256];
+
+ ecs_AddText(&(s->result),
+ "<?xml version=\"1.0\" ?>\n"
+ "<OGDI_Capabilities version=\"3.1\">\n" );
+ ecs_AddText(&(s->result),
+ " <FeatureTypeList>\n"
+ " <Operations>\n"
+ " <Query/>\n"
+ " </Operations>\n"
+ " <FeatureType>\n" );
+
+ sprintf( line, " <Name>%s(RAM)</Name>\n", spriv->layername);
+ ecs_AddText(&(s->result),line);
+
+ sprintf( line, " <SRS>PROJ4:%s</SRS>\n", PROJ_LONGLAT );
+ ecs_AddText(&(s->result),line);
+
+ sprintf(line,
+ " <LatLonBoundingBox minx=\"%.9f\" miny=\"%.9f\"\n"
+ " maxx=\"%.9f\" maxy=\"%.9f\" />\n",
+ s->globalRegion.west, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.north );
+
+ ecs_AddText(&(s->result),line);
+
+ sprintf(line,
+ " <BoundingBox minx=\"%.9f\" miny=\"%.9f\"\n"
+ " maxx=\"%.9f\" maxy=\"%.9f\"\n"
+ " resx=\"%.9f\" resy=\"%.9f\" />\n",
+ s->globalRegion.west, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.north,
+ s->globalRegion.ew_res, s->globalRegion.ns_res );
+ ecs_AddText(&(s->result),line);
+
+ ecs_AddText(&(s->result),
+ " <Family>Matrix</Family>\n" );
+ ecs_AddText(&(s->result),
+ " <Family>Image</Family>\n" );
+ ecs_AddText(&(s->result),
+ " </FeatureType>\n"
+ " </FeatureTypeList>\n"
+ "</OGDI_Capabilities>\n" );
+ ecs_SetSuccess(&(s->result));
+ }
+
+ else if( strcmp(info,"") == 0 )
+ {
+ char buffer[64];
+
+ strcpy(buffer,spriv->layername);
+ ecs_AddText(&(s->result),buffer);
+ ecs_SetSuccess(&(s->result));
+ }
+ else
+ {
+ char emsg[129];
+
+ sprintf( emsg, "DTED driver UpdateDictionary(%s) unsupported.", info );
+
+ ecs_SetError(&(s->result), 1, emsg );
+ }
+
+ return (&(s->result));
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_GetServerProjection:
+ *
+ * Return this server cartographic projection
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetServerProjection(s)
+ ecs_Server *s;
+{
+ ecs_SetText(&(s->result), PROJ_LONGLAT);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * _dyn_GetGlobalBound:
+ *
+ * Return this server global bounding region
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_GetGlobalBound(s)
+ ecs_Server *s;
+{
+ ecs_SetGeoRegion(&(s->result),s->globalRegion.north, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.west, s->globalRegion.ns_res,
+ s->globalRegion.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_SetServerLanguage:
+ *
+ * Set this server lnaguage for error message; not yet implemented
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetServerLanguage(s,language)
+ ecs_Server *s;
+ u_int language;
+{
+ (void) language;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * _dyn_SetCompression:
+ *
+ * No compression used in local databases.
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetCompression(s,compression)
+ ecs_Server *s;
+ ecs_Compression *compression;
+{
+ (void) compression;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,23 @@
+LIBRARY DTED
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_CreateServer
+ dyn_DestroyServer
+ dyn_SelectLayer
+ dyn_ReleaseLayer
+ dyn_SelectRegion
+ dyn_GetDictionary
+ dyn_GetNextObject
+ dyn_UpdateDictionary
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_GetRasterInfo
+ dyn_GetObject
+ dyn_GetObjectIdFromCoord
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_SetServerLanguage
+ dyn_GetAttributesFormat
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/dted.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,169 @@
+/******************************************************************************
+ *
+ * Component: OGDI DTED Driver
+ * Purpose: Structure and function declarations for DTED Driver.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: dted.h,v $
+ * Revision 1.4 2001/04/10 14:29:43 warmerda
+ * Upgraded with changes from DND (hand applied to avoid losing bug fixes).
+ * Patch also includes change to exclude zero elevations when computing
+ * mincat/maxcat.
+ * New style headers also applied.
+ *
+ */
+
+#include "ecs.h"
+#include <sys/stat.h>
+#ifdef _WINDOWS
+#include <direct.h>
+#include "compat/dirent.h"
+#else
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+
+#ifdef _WINDOWS
+#define strcasecmp(a,b) stricmp(a,b)
+#define strncasecmp(a,b,c) strnicmp(a,b,c)
+#endif
+
+#ifndef max
+#define max(x,y) ((x > y) ? x : y)
+#endif
+
+#define HDR_LENGTH 80
+#define UHL_LENGTH 80
+#define DSI_LENGTH 648
+#define ACC_LENGTH 2700
+
+/* Categories table */
+
+typedef struct {
+ unsigned int elevation;
+ int count;
+} CatTable;
+
+/* private data general to all Grass layer */
+
+typedef struct {
+ char *ewdir; /* Directory for east-west coord */
+ char *nsfile; /* DTED tile file in ewdir */
+
+#if 0
+ int rows; /* Number of rows */
+ int columns; /* Number of columns */
+#endif
+
+ unsigned char *matrixbuffer; /* dted matrix itself */
+ int isInRam;
+ ecs_Family family;
+
+} LayerPrivateData;
+
+typedef struct NSFile {
+ char name[20];
+ short used; /* 1 if used 0 if unused (i.e. no data for this tile) */
+ ecs_Region region;
+ int rows;
+ int columns;
+
+ int coord; /* the longlat coordinate value : not guaranteed to be there */
+ FILE *filehandle;
+} NSFile;
+
+typedef struct EWDir {
+ char name[20]; /* the name of the directory */
+ NSFile *nsfile; /* array of filenames */
+ unsigned short nb_files; /* number of files in this dir*/
+ int coord; /* the longlat coordinate value : not guaranteed to be there */
+} EWDir;
+
+typedef struct {
+ int mincat; /* Minimum and maximum category */
+ int maxcat;
+ char layername[16]; /* the layername from DMED */
+ char *pathname;
+ EWDir *ewdir; /* 1D array of directory names */
+
+ ecs_TileStructure t;
+ int xtiles; /* the number of horiz tiles */
+ int ytiles; /* the number of vertical tiles */
+ ecs_TileID lastTile;
+ int level; /* 0,1,2 depending on the "level" of the DTED file */
+ int cat_increment; /* the width of one colour band */
+ int firstcoordfilepos;
+
+} ServerPrivateData;
+
+/* private functions prototype */
+
+int _parse_request _ANSI_ARGS_((ecs_Server *s,char *sel,int *isInRam));
+int _read_dted _ANSI_ARGS_((ecs_Server *s,int xtile, int ytile));
+int _verifyLocation _ANSI_ARGS_((ecs_Server *s));
+int _createDynamicMapset _ANSI_ARGS_((ecs_Server *s));
+int _initRegionWithDefault _ANSI_ARGS_((ecs_Server *s));
+char *subfield _ANSI_ARGS_((char *buffer,int index,int length));
+double parse_coord _ANSI_ARGS_((char *buffer));
+int _initCatTable _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+int _readDMED _ANSI_ARGS_((ecs_Server *s));
+int _readValuesFromDirList _ANSI_ARGS_((ecs_Server *s));
+
+/* layer oriented method definition */
+
+void _openRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _closeRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _rewindRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _getNextObjectRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _getObjectRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, char *objectId));
+void _getObjectIdRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, ecs_Coordinate *coord));
+int _calcPosValue _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, int xtile,
+ int ytile, int xpixel, int ypixel, int *cat));
+int _getTileDim _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, double x, double y, int *width, int *height));
+
+int _get_level _ANSI_ARGS_((ecs_Server *s, int xtile, int ytile, int *level));
+int _sample_tiles _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t));
+int _getRawValue _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, int xtile,
+ int ytile, int xpixel, int ypixel, int *cat));
+int _sample_getRawValue _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, int xtile,
+ int ytile, int xpixel, int ypixel, int *cat));
+/* int _sample_read_dted _ANSI_ARGS_((ecs_Server *s, int xtile, int ytile, int32 *firstcoordfilepos)); */
+int _sample_read_dted(ecs_Server *s, int xtile, int ytile, int32 *firstcoordfilepos, FILE *fileptr);
+
+
+/* layer oriented method are keeped into a single data structure to simplify the code */
+
+
+typedef void layerfunc();
+typedef void layerobfunc();
+typedef void layercoordfunc();
+
+
+typedef struct {
+ layerfunc *open;
+ layerfunc *close;
+ layerfunc *rewind;
+ layerfunc *getNextObject;
+ layerobfunc *getObject;
+ layercoordfunc *getObjectIdFromCoord;
+} LayerMethod;
+
+int _IsOutsideRegion _ANSI_ARGS_((double n, double s, double e,double w, ecs_Region *x));
+void _releaseAllLayers _ANSI_ARGS_((ecs_Server *s));
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = dted
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = dted.c utils.c object.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(GLUTIL_STATICLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR datadict.h
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/object.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/object.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/object.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,425 @@
+/******************************************************************************
+ *
+ * Component: OGDI DTED Driver
+ * Purpose: Implementation of DTED Server getObject* functions
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: object.c,v $
+ * Revision 1.7 2007/02/12 15:52:57 cbalint
+ *
+ * Preliminary cleanup.
+ * Get rif of unitialized variables, and unused ones.
+ *
+ * Revision 1.6 2001/04/19 05:04:59 warmerda
+ * move pos_y to middle of row, add errors for unsupported funcs
+ *
+ * Revision 1.5 2001/04/10 14:29:43 warmerda
+ * Upgraded with changes from DND (hand applied to avoid losing bug fixes).
+ * Patch also includes change to exclude zero elevations when computing
+ * mincat/maxcat.
+ * New style headers also applied.
+ *
+ */
+
+#include "ecs.h"
+#include "dted.h"
+
+ECS_CVSID("$Id: object.c,v 1.7 2007/02/12 15:52:57 cbalint Exp $");
+
+/*
+ * --------------------------------------------------------------------------
+ * _get*Object*Raster:
+ *
+ * a set of functions to acheive Line objects retrieval
+ * --------------------------------------------------------------------------
+ */
+
+
+void _getNextObjectRaster(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ ServerPrivateData *spriv = s->priv;
+ ecs_Coordinate start, end;
+ double pos_y;
+ double record_y;
+
+ if (l->index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /* get geographic position of current region's matrix point l->index */
+ pos_y = s->currentRegion.north - (l->index+0.5) * s->currentRegion.ns_res;
+
+ /* get the corresponding point from the global region's matrix */
+ record_y = (int) ((s->globalRegion.north-pos_y) / s->globalRegion.ns_res);
+
+ start.x=s->currentRegion.west;
+ end.x=s->currentRegion.east;
+ start.y=pos_y;
+ end.y=pos_y;
+
+ if (!ecs_TileGetLine(s, &(spriv->t), &start, &end)) {
+ ecs_SetError(&(s->result),1,"Unable to retrieve a line.");
+ return;
+ }
+ if (l->sel.F == Image) {
+ s->result.res.ecs_ResultUnion_u.dob.geom.family = Image;
+ }
+
+ l->index++;
+ ecs_SetSuccess(&(s->result));
+
+}
+
+void
+_getObjectRaster(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ (void) l;
+ (void) id;
+ ecs_SetError(&(s->result),1,
+ "GetObject(id) not supported for DTED.");
+}
+
+void
+_getObjectIdRaster(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ (void) l;
+ (void) coord;
+
+ ecs_SetError(&(s->result),1,
+ "GetObjectIdFromCoord() not supported for DTED.");
+}
+
+void _rewindRasterLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ ServerPrivateData *spriv = s->priv;
+ ecs_TileClearBuffer(&(spriv->t));
+ l->index=0;
+}
+
+
+/* returns a raw category value. */
+int _getRawValue(ecs_Server *s, ecs_TileStructure *t, int xtile,
+ int ytile, int xpixel, int ypixel, int *cat) {
+
+ char dtedfilename[512];
+ unsigned char number[2];
+ int32 filepos;
+ unsigned char pos1;
+ unsigned char pos2;
+ int x,y;
+ LayerPrivateData *lpriv = (LayerPrivateData *) s->layer[s->currentLayer].priv;
+ ServerPrivateData *spriv= (ServerPrivateData *) s->priv;
+
+ x=xpixel;
+ y=spriv->ewdir[xtile].nsfile[ytile].rows-ypixel;
+
+ /* check if we're off the map */
+ if (x < 0 || y < 0 || y >= spriv->ewdir[xtile].nsfile[ytile].rows || x >= spriv->ewdir[xtile].nsfile[ytile].columns) {
+ *cat=t->offValue;
+ return TRUE;
+ }
+
+ /* check if tile appears in database */
+
+ if (! spriv->ewdir[xtile].nsfile[ytile].used) {
+ *cat = t->offValue;
+ return TRUE;
+ }
+
+ /* open file if necessary, close old file */
+ if ((spriv->lastTile.none==0) || spriv->lastTile.x != xtile
+ || spriv->lastTile.y != ytile) {
+ if (spriv->lastTile.none) {
+ fclose(spriv->ewdir[spriv->lastTile.x].nsfile[spriv->lastTile.y].filehandle);
+ }
+ /*( if (spriv->ewdir[xtile].nsfile[ytile].filehandle == -1) */
+
+ strcpy(dtedfilename,spriv->pathname);
+ strcat(dtedfilename,"/");
+ strcat(dtedfilename,spriv->ewdir[xtile].name);
+ strcat(dtedfilename,"/");
+ strcat(dtedfilename,spriv->ewdir[xtile].nsfile[ytile].name);
+
+#ifdef _WINDOWS
+ spriv->ewdir[xtile].nsfile[ytile].filehandle = fopen(dtedfilename, "rb");
+#else
+ spriv->ewdir[xtile].nsfile[ytile].filehandle = fopen(dtedfilename, "r");
+#endif
+
+ if (!spriv->ewdir[xtile].nsfile[ytile].filehandle) {
+ return FALSE;
+ }
+
+ if (!_read_dted(s,xtile,ytile))
+ return FALSE;
+
+ spriv->lastTile.none=1;
+ spriv->lastTile.x=xtile;
+ spriv->lastTile.y=ytile;
+
+ } /* end open file */
+
+ if (lpriv->isInRam) {
+ /* filepos = (x)*(12+lpriv->rows*2);*/
+ filepos = (x)*(12+spriv->ewdir[xtile].nsfile[ytile].rows*2);
+ if (filepos < 0)
+ filepos = 0;
+ filepos += 8 + y*2;
+
+ pos1 = lpriv->matrixbuffer[filepos];
+ pos2 = lpriv->matrixbuffer[filepos+1];
+ if(pos1 & 128) {
+ /*
+ pos1 &= 127;
+ *cat = -((pos1<<8) + pos2);
+ */
+ *cat = 0;
+ } else {
+ *cat = (pos1<<8) + pos2;
+ }
+ } else {
+ /* ZZZ */
+ /* filepos = (x)*(12+lpriv->rows*2);*/
+
+ filepos = (x)*(12+spriv->ewdir[xtile].nsfile[ytile].rows*2);
+ if (filepos < 0)
+ filepos = 0;
+ filepos += 8 + y*2 + spriv->firstcoordfilepos;
+
+ fseek(spriv->ewdir[xtile].nsfile[ytile].filehandle, filepos, SEEK_SET);
+
+ if (fread(&number,1,2,spriv->ewdir[xtile].nsfile[ytile].filehandle) < 2) {
+ return FALSE;
+ }
+
+ if(number[0] & 128) {
+ /*
+ number[0] &= 127;
+ *cat = (256*number[0] + number[1]);
+ */
+ *cat = 0;
+ } else {
+ *cat = 256*number[0] + number[1];
+ }
+ }
+ return TRUE;
+}
+
+/* returns TRUE/FALSE, puts category in "cat" */
+/* scales category to be between 1-216 */
+/* pre: expects t->height to be set to the tileheight */
+/* if no tile, sets to "0" */
+
+int _calcPosValue(ecs_Server *s, ecs_TileStructure *t, int xtile,
+ int ytile, int xpixel, int ypixel, int *cat ) {
+ ServerPrivateData *spriv=s->priv;
+ LayerPrivateData *lpriv = (LayerPrivateData *)s->layer[s->currentLayer].priv;
+ ecs_Region tile;
+ double tile_width;
+ double tile_height;
+
+ if (xtile < 0 || xtile >= spriv->xtiles ||
+ ytile < 0 || ytile >= spriv->ytiles) {
+ *cat = t->offValue;
+ return TRUE;
+ }
+
+ if (! spriv->ewdir[xtile].nsfile[ytile].used) {
+ *cat = t->offValue;
+ return TRUE;
+ }
+ tile_width=(s->globalRegion.east-s->globalRegion.west) / spriv->xtiles;
+ tile_height=(s->globalRegion.north-s->globalRegion.south) / spriv->ytiles;
+
+ /* the boundaries of the logical tile (as the tiling library sees it) */
+ tile.east=s->globalRegion.west+tile_width * (xtile+1);
+ tile.west=s->globalRegion.west+tile_width * xtile;
+
+ tile.north=s->globalRegion.north-tile_height * (ytile);
+ tile.south=s->globalRegion.north-tile_height * (ytile + 1);
+
+ /* transform if the data Region is different than the tile region. */
+ xpixel= (int) (xpixel-(spriv->ewdir[xtile].nsfile[ytile].region.west-tile.west)/
+ spriv->ewdir[xtile].nsfile[ytile].region.ew_res);
+ ypixel= (int) (ypixel-(tile.north -spriv->ewdir[xtile].nsfile[ytile].region.north)/
+ spriv->ewdir[xtile].nsfile[ytile].region.ns_res);
+
+ _getRawValue(s,t,xtile,ytile,xpixel,ypixel,cat);
+
+ if (lpriv->family == Matrix) {
+ /* catch stragglers */
+ if (*cat < spriv->mincat) {
+ *cat = spriv->mincat;
+ }
+ if (*cat > spriv->maxcat) {
+ *cat=spriv->maxcat;
+ }
+ *cat = *cat - spriv->mincat; /* ensure non-negative */
+
+ if (spriv->maxcat-spriv->mincat > 215) {
+ *cat = *cat * 215/(spriv->maxcat-spriv->mincat) +1;
+ }
+ if (*cat > 216) {
+ *cat = 216;
+ }
+ }
+ return TRUE;
+}
+
+/* figures out what the "global" resolution is for this coordinate */
+/* x, y : point in the tile */
+
+int _getTileDim(ecs_Server *s, ecs_TileStructure *t, double x, double y,
+ int *width, int *height) {
+ int ns_int, ew_int=0; /* interval value in seconds*/
+ ServerPrivateData *spriv= s->priv;
+
+ (void) t;
+ (void) x;
+
+ if (y < 0)
+ y=-y;
+ if (y <= 50.0) {
+ ew_int=1;
+ } else if ((50.0 < y) && (y <= 70.0)) {
+ ew_int=2;
+ } else if ((70.0 < y) && (y <= 75.0)) {
+ ew_int=3;
+ } else if ((75.0 < y) && (y <= 80.0)) {
+ ew_int=4;
+ } else if (y > 80.0) {
+ ew_int=6;
+ }
+
+ switch (spriv->level) {
+ case 0:
+ ns_int= 30;
+ ew_int= ew_int * 30;
+ break;
+ case 1:
+ ns_int= 3;
+ ew_int*= 3;
+ break;
+ case 2:
+ /* ns_int=1 */
+ ns_int= 1;
+ ew_int*= 1;
+ break;
+ default:
+ return FALSE;
+ break;
+ }
+ *width=3600/ew_int+1;
+ *height=3600/ns_int+1;
+ return TRUE;
+}
+
+/* ==========================================
+ Test procedures to be used without an lpriv value
+ */
+
+int _sample_getRawValue(ecs_Server *s, ecs_TileStructure *t, int xtile,
+ int ytile, int xpixel, int ypixel, int *cat) {
+ char *dtedfilename;
+ unsigned char number[2];
+ int32 filepos;
+
+ int x,y;
+ ServerPrivateData *spriv= (ServerPrivateData *) s->priv;
+ static int32 firstcoordfilepos;
+
+ x=xpixel;
+ y=t->height-ypixel;
+
+ /* check if tile appears in database */
+
+ if (! spriv->ewdir[xtile].nsfile[ytile].used) {
+ *cat = t->offValue;
+ return TRUE;
+ }
+
+ /* open file if necessary, close old file */
+ if ((spriv->lastTile.none==0) || spriv->lastTile.x != xtile
+ || spriv->lastTile.y != ytile) {
+ if (spriv->lastTile.none) {
+ fclose(spriv->ewdir[spriv->lastTile.x].nsfile[spriv->lastTile.y].filehandle);
+ }
+ /*( if (spriv->ewdir[xtile].nsfile[ytile].filehandle == -1) */
+
+ dtedfilename = (char *) malloc(strlen(spriv->pathname)+strlen(spriv->ewdir[xtile].name)+strlen(spriv->ewdir[xtile].nsfile[ytile].name)+3);
+ if (dtedfilename == NULL) {
+ return FALSE;
+ }
+ strcpy(dtedfilename,spriv->pathname);
+ strcat(dtedfilename,"/");
+ strcat(dtedfilename,spriv->ewdir[xtile].name);
+ strcat(dtedfilename,"/");
+ strcat(dtedfilename,spriv->ewdir[xtile].nsfile[ytile].name);
+
+#ifdef _WINDOWS
+ spriv->ewdir[xtile].nsfile[ytile].filehandle = fopen(dtedfilename, "rb");
+#else
+ spriv->ewdir[xtile].nsfile[ytile].filehandle = fopen(dtedfilename, "r");
+#endif
+ free(dtedfilename);
+ if (!spriv->ewdir[xtile].nsfile[ytile].filehandle) {
+ return FALSE;
+ }
+
+ if (!_sample_read_dted(s,xtile,ytile, &firstcoordfilepos, spriv->ewdir[xtile].nsfile[ytile].filehandle))
+ return FALSE;
+
+ spriv->lastTile.none=1;
+ spriv->lastTile.x=xtile;
+ spriv->lastTile.y=ytile;
+
+ } /* end open file */
+
+ /* filepos = (x)*(12+lpriv->rows*2);*/
+ filepos = (x)*(12+spriv->ewdir[xtile].nsfile[ytile].rows*2);
+
+ if (filepos < 0)
+ filepos = 0;
+ filepos += 8 + y*2 + firstcoordfilepos;
+
+ fseek(spriv->ewdir[xtile].nsfile[ytile].filehandle, filepos, SEEK_SET);
+
+ if (fread(&number, 1,2,spriv->ewdir[xtile].nsfile[ytile].filehandle) < 2) {
+ fclose(spriv->ewdir[xtile].nsfile[ytile].filehandle);
+ return FALSE;
+ }
+
+ if(number[0] & 128) {
+ *cat = 0;
+ } else {
+ *cat = 256*number[0] + number[1];
+ }
+
+
+ return TRUE;
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/utils.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/utils.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/dted/utils.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,972 @@
+/******************************************************************************
+ *
+ * Component: OGDI DTED Driver
+ * Purpose: Various DTED support functions.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: utils.c,v $
+ * Revision 1.7 2007/02/12 15:52:57 cbalint
+ *
+ * Preliminary cleanup.
+ * Get rif of unitialized variables, and unused ones.
+ *
+ * Revision 1.6 2001/04/10 14:29:43 warmerda
+ * Upgraded with changes from DND (hand applied to avoid losing bug fixes).
+ * Patch also includes change to exclude zero elevations when computing
+ * mincat/maxcat.
+ * New style headers also applied.
+ *
+ */
+
+#include "dted.h"
+
+ECS_CVSID("$Id: utils.c,v 1.7 2007/02/12 15:52:57 cbalint Exp $");
+
+/*
+ ----------------------------------------------------------
+
+ _parse_request
+
+ extract esdir and nsfile from request, store in private data structure
+
+ ----------------------------------------------------------
+ */
+
+#define SYNTAXERRORMESSAGE "Badly formed request: %s, must be LayerName(loadtype)"
+
+int _parse_request(s,sel,isInRam)
+ ecs_Server *s;
+ char *sel;
+ int *isInRam;
+{
+ static int compiled = 0;
+ static ecs_regexp *reg;
+ char buffer[512];
+ static char *atom1 = NULL;
+
+ if (atom1 != NULL) {
+ free(atom1);
+ atom1 = NULL;
+ }
+
+ if (!compiled) {
+ reg = EcsRegComp(".*\\((.*)\\)$");
+ compiled = 1;
+ }
+
+ if (!EcsRegExec(reg,sel,NULL)) {
+ sprintf(buffer,SYNTAXERRORMESSAGE,sel);
+ ecs_SetError(&(s->result),1,buffer);
+ return 0;
+ }
+
+ if (!ecs_GetRegex(reg,1,&atom1)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ return 0;
+ }
+
+ if (strlen(atom1) == 0) {
+ sprintf(buffer,SYNTAXERRORMESSAGE,atom1);
+ ecs_SetError(&(s->result),1,buffer);
+ return 0;
+ }
+
+ *isInRam = TRUE;
+
+ return 1;
+}
+
+/*
+ ----------------------------------------------------------
+
+ _read_dted
+
+ extract the information from a dted file and put them
+ into lpriv.
+
+ ----------------------------------------------------------
+ */
+
+int _read_dted(ecs_Server *s, int xtile, int ytile) {
+ char buffer[UHL_LENGTH], temp[3];
+ char *chtmp;
+ double origin_lon, origin_lat;
+ double interval_lon, interval_lat;
+ double lat_spacing, lon_spacing;
+ LayerPrivateData *lpriv=s->layer[s->currentLayer].priv;
+ ServerPrivateData *spriv =s->priv;
+ int columns, rows;
+ int size;
+
+ fseek(spriv->ewdir[xtile].nsfile[ytile].filehandle, 0, SEEK_SET);
+
+ spriv->firstcoordfilepos = 0;
+
+ if (fread(buffer,1,UHL_LENGTH,spriv->ewdir[xtile].nsfile[ytile].filehandle) < UHL_LENGTH)
+ return FALSE;
+ spriv->firstcoordfilepos += UHL_LENGTH;
+
+ if (buffer[0] == 'H') {
+ if (fread (buffer,1,UHL_LENGTH,spriv->ewdir[xtile].nsfile[ytile].filehandle) < UHL_LENGTH)
+ return FALSE;
+ spriv->firstcoordfilepos += UHL_LENGTH;
+ }
+
+ origin_lon = parse_coord(buffer+4);
+ origin_lat = parse_coord(buffer+12);
+ interval_lon = atoi(subfield(buffer,20,4))/10.0;
+ interval_lat = atoi(subfield(buffer,24,4))/10.0;
+
+ columns = atoi(subfield(buffer,47,4));
+ rows = atoi(subfield(buffer,51,4));
+
+ lat_spacing = interval_lat / 3600.0;
+ lon_spacing = interval_lon / 3600.0;
+ spriv->ewdir[xtile].nsfile[ytile].region.north = origin_lat+lat_spacing/2+lat_spacing*rows;
+ spriv->ewdir[xtile].nsfile[ytile].region.south = origin_lat-lat_spacing/2;
+ spriv->ewdir[xtile].nsfile[ytile].region.west = origin_lon-lon_spacing/2;
+ spriv->ewdir[xtile].nsfile[ytile].region.east = origin_lon+lon_spacing/2+lon_spacing*columns;
+ spriv->ewdir[xtile].nsfile[ytile].region.ns_res = (spriv->ewdir[xtile].nsfile[ytile].region.north - spriv->ewdir[xtile].nsfile[ytile].region.south) / rows;
+ spriv->ewdir[xtile].nsfile[ytile].region.ew_res = (spriv->ewdir[xtile].nsfile[ytile].region.east - spriv->ewdir[xtile].nsfile[ytile].region.west) / columns;
+
+ spriv->ewdir[xtile].nsfile[ytile].columns=columns;
+ spriv->ewdir[xtile].nsfile[ytile].rows=rows;
+
+ /* find the DTED type */
+
+ fseek(spriv->ewdir[xtile].nsfile[ytile].filehandle, spriv->firstcoordfilepos, SEEK_SET);
+ if (fread(buffer,1,UHL_LENGTH,spriv->ewdir[xtile].nsfile[ytile].filehandle) < UHL_LENGTH)
+ return FALSE;
+
+ strncpy(temp,&buffer[63],1);
+ temp[1]='\0';
+ spriv->level=(int) strtol(temp,&chtmp, 10);
+
+ spriv->firstcoordfilepos += DSI_LENGTH + ACC_LENGTH ;
+
+ /* Read the data info if isInRam is true */
+
+ if (lpriv->isInRam) {
+ fseek(spriv->ewdir[xtile].nsfile[ytile].filehandle, spriv->firstcoordfilepos, SEEK_SET);
+ if (lpriv->matrixbuffer != NULL) {
+ free(lpriv->matrixbuffer);
+ lpriv->matrixbuffer = NULL;
+ }
+ size = columns*(rows*2+8+4);
+ lpriv->matrixbuffer = (unsigned char *) malloc(size);
+ if (lpriv->matrixbuffer == NULL) {
+ ecs_SetError(&(s->result),1,"not enough memory to load dted matrix in ram");
+ return FALSE;
+ }
+ if (fread(lpriv->matrixbuffer,1,size,spriv->ewdir[xtile].nsfile[ytile].filehandle) < (unsigned int) size) {
+ ecs_SetError(&(s->result),1,"read too much info in file");
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/* set spriv->maxcat and spriv->mincat */
+
+int _sample_tiles(ecs_Server *s, ecs_TileStructure *t) {
+ double ns_min, ns_max, ew_min, ew_max;
+ double ns_inc, ew_inc;
+ int x, y;
+ int i,j, cat;
+ int firsttime=1;
+ int tileWidth, tileHeight, xpixel, ypixel;
+ ServerPrivateData *spriv=s->priv;
+ int range;
+
+ int nb_xsamp=5;
+ int nb_ysamp=5;
+
+ ns_inc=(s->globalRegion.north-s->globalRegion.south)/spriv->ytiles;
+ ew_inc=(s->globalRegion.east-s->globalRegion.west)/spriv->xtiles;
+
+ s->globalRegion.ns_res = 1.0;
+ s->globalRegion.ew_res = 1.0;
+
+ for (x=0; x<spriv->xtiles; x++) {
+ for (y=0; y<spriv->ytiles; y++) {
+ if (spriv->ewdir[x].nsfile[y].used) {
+ /* found one in use: sample it */
+ /* find the coordinates at selected intervals */
+ ns_min=s->globalRegion.south+ns_inc*y;
+ ns_max=s->globalRegion.south+ns_inc*(y+1);
+ ew_min=s->globalRegion.west+ew_inc*x;
+ ew_max=s->globalRegion.west+ew_inc*(x+1);
+ _getTileDim(s,t,ew_min+1,ns_min+1, &tileWidth, &tileHeight);
+
+ if (s->globalRegion.ns_res > ((ns_max - ns_min) / (double) tileHeight)) {
+ s->globalRegion.ns_res = ((ns_max - ns_min) / (double) tileHeight);
+ }
+ if (s->globalRegion.ew_res > ((ew_max - ew_min) / (double) tileWidth)) {
+ s->globalRegion.ew_res = ((ew_max - ew_min) / (double) tileWidth);
+ }
+
+ t->height=tileHeight;
+ for (i=0; i< nb_xsamp; i++) {
+ for (j=0; j< nb_ysamp; j++) {
+
+ /* figure out the pixel position in the tile */
+ xpixel=(int) i*tileWidth/nb_xsamp;
+ ypixel=(int) j*tileHeight/nb_ysamp;;
+
+ /* call the callback */
+ _sample_getRawValue(s,t,x,y,xpixel,ypixel,&cat);
+ if ( cat != 0 ) {
+ if (firsttime) {
+ spriv->mincat=cat;
+ spriv->maxcat=cat;
+ firsttime=0;
+ } else {
+ if (cat < spriv->mincat)
+ spriv->mincat=cat;
+ if (cat >spriv->maxcat)
+ spriv->maxcat=cat;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* adjust the sampled result:
+ 1) adjust maxcat outwards by 10%.
+ 2) if mincat < 0, adjust it down by 10 %.
+ */
+
+ range=spriv->maxcat-spriv->mincat;
+ if (spriv->mincat>50 || spriv->mincat < 0) {
+ spriv->mincat-=(int)(range* 0.10);
+ }
+ spriv->maxcat+=(int)(range*0.20);
+
+ if (spriv->lastTile.none) {
+ fclose(spriv->ewdir[spriv->lastTile.x].nsfile[spriv->lastTile.y].filehandle);
+ spriv->lastTile.none=0;
+ spriv->lastTile.x=-1;
+ spriv->lastTile.y=-1;
+ }
+
+
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------
+
+ _sample_read_dted
+
+ extract the information from a dted file. Doesn't require
+ lpriv.
+
+ ----------------------------------------------------------
+ */
+int _sample_read_dted(ecs_Server *s, int xtile, int ytile, int32 *firstcoordfilepos, FILE *fileptr) {
+ char buffer[UHL_LENGTH], temp[3];
+ char *chtmp;
+ double origin_lon, origin_lat;
+ double interval_lon, interval_lat;
+ double lat_spacing, lon_spacing;
+ ServerPrivateData *spriv =s->priv;
+ int columns, rows;
+
+ fseek(fileptr, 0, SEEK_SET);
+
+ *firstcoordfilepos = 0;
+
+ if (fread(buffer,1,UHL_LENGTH,fileptr) < UHL_LENGTH)
+ return FALSE;
+ *firstcoordfilepos += UHL_LENGTH;
+
+ if (buffer[0] == 'H') {
+ if (fread(buffer,1,UHL_LENGTH,fileptr) < UHL_LENGTH)
+ return FALSE;
+ *firstcoordfilepos += UHL_LENGTH;
+ }
+
+ origin_lon = parse_coord(buffer+4);
+ origin_lat = parse_coord(buffer+12);
+ interval_lon = atoi(subfield(buffer,20,4))/10.0;
+ interval_lat = atoi(subfield(buffer,24,4))/10.0;
+
+ columns = atoi(subfield(buffer,47,4));
+ rows = atoi(subfield(buffer,51,4));
+
+ lat_spacing = interval_lat / 3600.0;
+ lon_spacing = interval_lon / 3600.0;
+ spriv->ewdir[xtile].nsfile[ytile].region.north = origin_lat+lat_spacing/2+lat_spacing*rows;
+ spriv->ewdir[xtile].nsfile[ytile].region.south = origin_lat-lat_spacing/2;
+ spriv->ewdir[xtile].nsfile[ytile].region.west = origin_lon-lon_spacing/2;
+ spriv->ewdir[xtile].nsfile[ytile].region.east = origin_lon+lon_spacing/2+lon_spacing*columns;
+ spriv->ewdir[xtile].nsfile[ytile].region.ns_res = (spriv->ewdir[xtile].nsfile[ytile].region.north
+ -spriv->ewdir[xtile].nsfile[ytile].region.south) / rows;
+ spriv->ewdir[xtile].nsfile[ytile].region.ew_res = (spriv->ewdir[xtile].nsfile[ytile].region.east
+ -spriv->ewdir[xtile].nsfile[ytile].region.west) / columns;
+ spriv->ewdir[xtile].nsfile[ytile].columns=columns;
+ spriv->ewdir[xtile].nsfile[ytile].rows=rows;
+
+ /* find the DTED type */
+
+ fseek(fileptr, *firstcoordfilepos, SEEK_SET);
+ if (fread(buffer,1,UHL_LENGTH,fileptr) < UHL_LENGTH)
+ return FALSE;
+
+ strncpy(temp,&buffer[63],1);
+ temp[1]='\0';
+ spriv->level=(int) strtol(temp,&chtmp, 10);
+
+ *firstcoordfilepos += DSI_LENGTH + ACC_LENGTH ;
+
+ return TRUE;
+}
+
+
+/* retrieve nothing but the level from a tile */
+int _get_level(ecs_Server *s, int xtile, int ytile, int *level) {
+ char buffer[UHL_LENGTH], temp[3], dtedfilename[256];
+ char *chtmp;
+ ServerPrivateData *spriv =s->priv;
+
+ strcpy(dtedfilename,spriv->pathname);
+ strcat(dtedfilename,"/");
+ strcat(dtedfilename,spriv->ewdir[xtile].name);
+ strcat(dtedfilename,"/");
+ strcat(dtedfilename,spriv->ewdir[xtile].nsfile[ytile].name);
+
+#ifdef _WINDOWS
+ spriv->ewdir[xtile].nsfile[ytile].filehandle = fopen(dtedfilename, "rb");
+#else
+ spriv->ewdir[xtile].nsfile[ytile].filehandle = fopen(dtedfilename, "r");
+#endif
+
+ if (!spriv->ewdir[xtile].nsfile[ytile].filehandle) {
+ return FALSE;
+ }
+
+ fseek(spriv->ewdir[xtile].nsfile[ytile].filehandle, UHL_LENGTH, SEEK_SET);
+ if (fread(buffer,1,UHL_LENGTH,spriv->ewdir[xtile].nsfile[ytile].filehandle) < UHL_LENGTH)
+ return FALSE;
+
+ if (buffer[0] == 'H') {
+ if (fread(buffer,1,UHL_LENGTH,spriv->ewdir[xtile].nsfile[ytile].filehandle) < UHL_LENGTH)
+ return FALSE;
+ }
+
+ fclose(spriv->ewdir[xtile].nsfile[ytile].filehandle);
+ spriv->ewdir[xtile].nsfile[ytile].filehandle=NULL;
+ strncpy(temp,&buffer[63],1);
+ temp[1]='\0';
+ *level=(int) strtol(temp,&chtmp, 10);
+#if 0
+ printf("level is %d\n", *level);
+#endif
+ return TRUE;
+}
+
+
+
+
+
+
+char *subfield(buffer,index,length)
+ char *buffer;
+ int index;
+ int length;
+{
+ static char sub[20];
+ int k;
+ for (k=0;k<length;++k)
+ sub[k] = buffer[index+k];
+ sub[k]=0;
+ return sub;
+}
+
+double parse_coord(buffer)
+ char *buffer;
+{
+ int deg, min, sec;
+ double degrees;
+ char hem;
+
+ deg = atoi(subfield(buffer,0,3));
+ min = atoi(subfield(buffer,3,2));
+ sec = atoi(subfield(buffer,5,2));
+ degrees = deg + min/60.0 + sec/3600.0;
+ hem = buffer[7];
+ if (hem == 's' || hem == 'S' || hem == 'w' || hem == 'W')
+ degrees = -degrees;
+ return degrees;
+}
+
+/*
+ ----------------------------------------------------------
+ _VerifyLocation:
+
+ check if the path is valid. Check if the directory exist
+ and check if the parent path contain a dmed file.
+
+ ----------------------------------------------------------
+ */
+
+int
+_verifyLocation(s)
+ ecs_Server *s;
+{
+ int returnvalue;
+ int lenght;
+ DIR *dirlist;
+ FILE *test;
+ ServerPrivateData *spriv = s->priv;
+ char *ptr,*ptr1,*ptr2;
+
+ returnvalue = FALSE;
+ lenght = strlen(spriv->pathname);
+ /* Check if the path is valid */
+ dirlist = opendir(spriv->pathname);
+ if (dirlist != NULL) {
+ closedir(dirlist);
+ /* Check the parent directory */
+ ptr = ptr1 = spriv->pathname;
+ while(ptr[0]!='\0') {
+ if ((ptr[0]=='/') && (ptr[1]!='\0')) {
+ ptr1 = ptr;
+ }
+ ptr++;
+ }
+ ptr1++;
+ ptr2 = malloc(ptr1-(spriv->pathname)+6);
+ if (ptr2 != NULL) {
+ strncpy(ptr2,spriv->pathname,ptr1-(spriv->pathname));
+ ptr2[ptr1-(spriv->pathname)] = '\0';
+ strcat(ptr2,"dmed");
+ test = fopen(ptr2,"r");
+ if (test != NULL) {
+ fclose(test);
+ returnvalue = TRUE;
+ } else {
+ strncpy(ptr2,spriv->pathname,ptr1-(spriv->pathname));
+ strcat(ptr2,"DMED");
+ test = fopen(ptr2,"r");
+ if (test != NULL) {
+ fclose(test);
+ returnvalue = TRUE;
+ }
+ }
+ free( ptr2 );
+ }
+ }
+ if (!returnvalue)
+ ecs_SetError(&(s->result),1,"Invalid URL. The dted directory is invalid");
+ return returnvalue;
+}
+
+/*
+ -------------------------------------------------------------------------
+ _initRegionWithDefault:
+
+ preparation de la fenetre globale pour le server
+ --------------------------------------------------------------------------
+ */
+
+int _initRegionWithDefault(s)
+ ecs_Server *s;
+{
+ char buffer[256];
+ struct dirent *structure1;
+ DIR *dirlist1;
+ struct dirent *structure2;
+ DIR *dirlist2=NULL;
+ static int compiled = 0;
+ static ecs_regexp *reglet;
+ static ecs_regexp *regnum;
+ int x,y;
+ char *letter;
+ char *number;
+ int first = TRUE;
+ ServerPrivateData *spriv = s->priv;
+ double increment_x = 1.0;
+ double increment_y = 1.0;
+
+ if (!compiled) {
+ reglet = EcsRegComp("([A-Za-z])");
+ regnum = EcsRegComp("([0-9]+)");
+ compiled = 1;
+ }
+
+ dirlist1 = opendir(spriv->pathname);
+ structure1 = (struct dirent *) readdir(dirlist1);
+ ecs_SetText(&(s->result)," "); /* make sure an empty list is returned in all case */
+
+ while (structure1 != NULL) {
+ if (!((strcmp(structure1->d_name,".") == 0) ||
+ (strcmp(structure1->d_name,"..") == 0)||
+ (strcmp(structure1->d_name,"CVS") == 0))) {
+
+ /* Extraction des donnees du repertoire structure1->d_name */
+
+ if (!EcsRegExec(regnum,structure1->d_name,NULL)) {
+ sprintf(buffer,"Badly formed dted directory name: %s. The number is incorrect",structure1->d_name);
+ ecs_SetError(&(s->result),1,buffer);
+ closedir(dirlist1);
+ closedir(dirlist2);
+ return 0;
+ }
+ if (!EcsRegExec(reglet,structure1->d_name,NULL)) {
+ sprintf(buffer,"Badly formed dted directory name: %s. No letters",structure1->d_name);
+ ecs_SetError(&(s->result),1,buffer);
+ closedir(dirlist1);
+ closedir(dirlist2);
+ return 0;
+ }
+
+ if (!ecs_GetRegex(regnum,0,&number)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ closedir(dirlist1);
+ closedir(dirlist2);
+ return 0;
+ }
+ if (!ecs_GetRegex(reglet,0,&letter)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ free(number);
+ closedir(dirlist1);
+ closedir(dirlist2);
+ return 0;
+ }
+ x = atoi(number);
+ if ((letter[0] == 'w') || (letter[0] == 'W'))
+ x = -x;
+ if (first) {
+ s->globalRegion.west = (double) x;
+ s->globalRegion.east = (double) x;
+ } else {
+ if ((double) x > s->globalRegion.east) {
+ if ((x - s->globalRegion.east) > increment_x)
+ increment_x = x - s->globalRegion.east;
+ s->globalRegion.east = (double) x;
+ }
+ if ((double) x < s->globalRegion.west) {
+ if ((s->globalRegion.west - x) > increment_x)
+ increment_x = s->globalRegion.west - x;
+ s->globalRegion.west = (double) x;
+ }
+ }
+
+ free(number);
+ free(letter);
+
+ sprintf(buffer,"%s/%s",spriv->pathname,structure1->d_name);
+
+ dirlist2 = opendir(buffer);
+ structure2 = (struct dirent *) readdir(dirlist2);
+
+ while (structure2 != NULL) {
+ if (!((strcmp(structure2->d_name,".") == 0) ||
+ (strcmp(structure2->d_name,"..") == 0)||
+ (strcmp(structure2->d_name,"CVS") == 0))) {
+ if (!EcsRegExec(regnum,structure2->d_name,NULL)) {
+ sprintf(buffer,"Badly formed dted file name: %s. The number is incorrect",structure2->d_name);
+ ecs_SetError(&(s->result),1,buffer);
+ closedir(dirlist1);
+ closedir(dirlist2);
+ return 0;
+ }
+ if (!EcsRegExec(reglet,structure2->d_name,NULL)) {
+ sprintf(buffer,"Badly formed dted file name: %s. No letters",structure2->d_name);
+ ecs_SetError(&(s->result),1,buffer);
+ closedir(dirlist1);
+ closedir(dirlist2);
+ return 0;
+ }
+
+ if (!ecs_GetRegex(regnum,0,&number)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ closedir(dirlist1);
+ closedir(dirlist2);
+ return 0;
+ }
+ if (!ecs_GetRegex(reglet,0,&letter)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ free(number);
+ closedir(dirlist1);
+ closedir(dirlist2);
+ return 0;
+ }
+ y = atoi(number);
+ if ((letter[0] == 's') || (letter[0] == 'S'))
+ y = -y;
+ free(number);
+ free(letter);
+ if (first) {
+ s->globalRegion.north = (double) y;
+ s->globalRegion.south = (double) y;
+ first = FALSE;
+ } else {
+ if ((double) y > s->globalRegion.north) {
+ if ((y - s->globalRegion.north) > increment_y)
+ increment_y = y - s->globalRegion.north;
+ s->globalRegion.north = (double) y;
+ }
+ if ((double) y < s->globalRegion.south) {
+ if ((s->globalRegion.south - y) > increment_y)
+ increment_y = s->globalRegion.south - y;
+ s->globalRegion.south = (double) y;
+ }
+ }
+ }
+ structure2 = (struct dirent *) readdir(dirlist2);
+ }
+
+ closedir(dirlist2);
+ }
+
+ structure1 = (struct dirent *) readdir(dirlist1);
+ }
+
+ closedir(dirlist1);
+
+ s->globalRegion.east += increment_x;
+ s->globalRegion.north += increment_y;
+
+ s->globalRegion.ns_res = (s->globalRegion.north - s->globalRegion.south)/2000.0;
+ s->globalRegion.ew_res = (s->globalRegion.east - s->globalRegion.west)/2000.0;
+
+ return 1;
+}
+
+int _IsOutsideRegion(n,s,e,w,region)
+ double n,s,e,w;
+ ecs_Region *region;
+{
+ if ((n < region->south) ||
+ (s > region->north) ||
+ (e < region->west) ||
+ (w > region->east)) {
+ return 1;
+ }
+ return 0;
+}
+
+/* postconditions: spriv->mincat, spriv->maxcat, spriv->level set */
+
+int _readDMED (ecs_Server *s) {
+ ServerPrivateData *spriv = s->priv;
+ int x,y;
+ int found=0;
+ /* spriv->mincat=1; */
+ /* spriv->maxcat=2000; */
+
+ for (x=0; x<spriv->xtiles; x++) {
+ for (y=0; y<spriv->ytiles; y++)
+ if (spriv->ewdir[x].nsfile[y].used) {
+ if (! _get_level(s, x, y, &(spriv->level))) {
+ return FALSE;
+ } else {
+ found=1;
+ break;
+ }
+ }
+ if (found) {
+ break;
+ }
+ }
+ if (!found) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+int _readValuesFromDirList(ecs_Server *s) {
+ char buffer[256];
+ struct dirent *structure1;
+ DIR *dirlist1;
+ struct dirent *structure2;
+ DIR *dirlist2 = NULL;
+ static int compiled = 0;
+ static ecs_regexp *reglet;
+ static ecs_regexp *regnum;
+ int x,y, i,j, tile_x, tile_y;
+ char *letter;
+ char *number;
+ int first = TRUE;
+ ServerPrivateData *spriv = s->priv;
+ double increment_x = 1.0;
+ double increment_y = 1.0;
+
+ EWDir ** dirlist = NULL;
+ int nb_ewdir=0;
+
+ if (!compiled) {
+ reglet = EcsRegComp("([A-Za-z])");
+ regnum = EcsRegComp("([0-9]+)");
+ compiled = 1;
+ }
+
+ dirlist1 = opendir(spriv->pathname);
+ structure1 = (struct dirent *) readdir(dirlist1);
+ ecs_SetText(&(s->result)," "); /* make sure an empty list is returned in all case */
+
+ while (structure1 != NULL) {
+ if (!((strcmp(structure1->d_name,".") == 0) ||
+ (strcmp(structure1->d_name,"..") == 0)||
+ (strcmp(structure1->d_name,"CVS") == 0))) {
+
+ /* Extraction des donnees du repertoire structure1->d_name */
+
+ if (!EcsRegExec(regnum,structure1->d_name,NULL)) {
+ sprintf(buffer,"Badly formed dted directory name: %s. The number is incorrect",structure1->d_name);
+ ecs_SetError(&(s->result),1,buffer);
+ closedir(dirlist1);
+ if( dirlist2 != NULL )
+ closedir(dirlist2);
+ return 0;
+ }
+ if (!EcsRegExec(reglet,structure1->d_name,NULL)) {
+ sprintf(buffer,"Badly formed dted directory name: %s. No letters",structure1->d_name);
+ ecs_SetError(&(s->result),1,buffer);
+ closedir(dirlist1);
+ if( dirlist2 != NULL )
+ closedir(dirlist2);
+ return 0;
+ }
+
+ if (!ecs_GetRegex(regnum,0,&number)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ closedir(dirlist1);
+ if( dirlist2 != NULL )
+ closedir(dirlist2);
+ return 0;
+ }
+ if (!ecs_GetRegex(reglet,0,&letter)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ free(number);
+ closedir(dirlist1);
+ if( dirlist2 != NULL )
+ closedir(dirlist2);
+ return 0;
+ }
+
+ x = atoi(number);
+ if (x > 1000) {
+ x = x / 10000;
+ }
+ if ((letter[0] == 'w') || (letter[0] == 'W'))
+ x = -x;
+ if (first) {
+ s->globalRegion.west = (double) x;
+ s->globalRegion.east = (double) x;
+ } else {
+ if ((double) x > s->globalRegion.east) {
+ if ((x - s->globalRegion.east) > increment_x)
+ increment_x = x - s->globalRegion.east;
+ s->globalRegion.east = (double) x;
+ }
+ if ((double) x < s->globalRegion.west) {
+ if ((s->globalRegion.west - x) > increment_x)
+ increment_x = s->globalRegion.west - x;
+ s->globalRegion.west = (double) x;
+ }
+ }
+
+ free(number);
+ free(letter);
+
+
+ /* record the ewdirs */
+#if 0
+ printf("ewdir= %s\n", structure1->d_name);
+#endif
+ nb_ewdir++;
+ dirlist = (EWDir **) realloc (dirlist, sizeof(EWDir *)* nb_ewdir);
+ if (!dirlist) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ return FALSE;
+ }
+ dirlist[nb_ewdir-1]= (EWDir *) malloc (sizeof(EWDir));
+
+ if (! dirlist[nb_ewdir-1]) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ return FALSE;
+ }
+ strcpy(dirlist[nb_ewdir-1]->name,structure1->d_name);
+ dirlist[nb_ewdir-1]->nb_files=0;
+ dirlist[nb_ewdir-1]->nsfile=NULL;
+
+ sprintf(buffer,"%s/%s",spriv->pathname,structure1->d_name);
+
+ /* parse the subdirectory */
+ dirlist2 = opendir(buffer);
+ structure2 = (struct dirent *) readdir(dirlist2);
+
+ while (structure2 != NULL) {
+
+ if (!((strcmp(structure2->d_name,".") == 0) ||
+ (strcmp(structure2->d_name,"..") == 0)||
+ (strcmp(structure2->d_name,"CVS") == 0)))
+ if ((strlen(structure2->d_name) > 4) && (strncasecmp("dt", &(structure2->d_name[strlen(structure2->d_name)-3]),2)) == 0) {
+ if (!EcsRegExec(regnum,structure2->d_name,NULL)) {
+ sprintf(buffer,"Badly formed dted file name: %s. The number is incorrect",structure2->d_name);
+ ecs_SetError(&(s->result),1,buffer);
+ closedir(dirlist1);
+ if( dirlist2 != NULL )
+ closedir(dirlist2);
+ return 0;
+ }
+ if (!EcsRegExec(reglet,structure2->d_name,NULL)) {
+ sprintf(buffer,"Badly formed dted file name: %s. No letters",structure2->d_name);
+ ecs_SetError(&(s->result),1,buffer);
+ closedir(dirlist1);
+ if( dirlist2 != NULL )
+ closedir(dirlist2);
+ return 0;
+ }
+#if 0
+ printf("nsdir= %s\n", structure2->d_name);
+#endif
+ dirlist[nb_ewdir-1]->nsfile=(NSFile *) realloc (dirlist[nb_ewdir-1]->nsfile, (sizeof(NSFile) * (++dirlist[nb_ewdir-1]->nb_files)));
+ if (!dirlist[nb_ewdir-1]->nsfile) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ return FALSE;
+ }
+ strcpy(dirlist[nb_ewdir-1]->nsfile[dirlist[nb_ewdir-1]->nb_files-1].name,structure2->d_name);
+
+ if (!ecs_GetRegex(regnum,0,&number)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ closedir(dirlist1);
+ if( dirlist2 != NULL )
+ closedir(dirlist2);
+ return 0;
+ }
+ if (!ecs_GetRegex(reglet,0,&letter)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ free(number);
+ closedir(dirlist1);
+ if( dirlist2 != NULL )
+ closedir(dirlist2);
+ return 0;
+ }
+ y = atoi(number);
+ if (y > 1000) {
+ y = y / 10000;
+ }
+ if ((letter[0] == 's') || (letter[0] == 'S'))
+ y = -y;
+
+ dirlist[nb_ewdir-1]->nsfile[dirlist[nb_ewdir-1]->nb_files-1].coord=y;
+ dirlist[nb_ewdir-1]->coord=x;
+
+
+ free(number);
+ free(letter);
+ if (first) {
+ s->globalRegion.north = (double) y;
+ s->globalRegion.south = (double) y;
+ first = FALSE;
+ } else {
+ if ((double) y > s->globalRegion.north) {
+ if ((y - s->globalRegion.north) > increment_y)
+ increment_y = y - s->globalRegion.north;
+ s->globalRegion.north = (double) y;
+ }
+ if ((double) y < s->globalRegion.south) {
+ if ((s->globalRegion.south - y) > increment_y)
+ increment_y = s->globalRegion.south - y;
+ s->globalRegion.south = (double) y;
+ }
+ }
+ }
+ structure2 = (struct dirent *) readdir(dirlist2);
+ }
+
+ closedir(dirlist2);
+ }
+
+ structure1 = (struct dirent *) readdir(dirlist1);
+ }
+
+ closedir(dirlist1);
+
+ s->globalRegion.east += increment_x;
+ s->globalRegion.north += increment_y;
+
+ /* these values are not used for anything, since the res is not constant */
+ s->globalRegion.ns_res = (s->globalRegion.north - s->globalRegion.south)/2000.0;
+ s->globalRegion.ew_res = (s->globalRegion.east - s->globalRegion.west)/2000.0;
+
+ /* allocate the directory structure in spriv*/
+
+ spriv->xtiles=(int) (s->globalRegion.east- s->globalRegion.west);
+ spriv->ytiles=(int) (s->globalRegion.north- s->globalRegion.south);
+#if 0
+ printf("xtiles=%d, ytiles=%d", spriv->xtiles, spriv->ytiles);
+#endif
+ spriv->ewdir=(EWDir *) (malloc (sizeof(EWDir) * spriv->xtiles));
+ if (spriv->ewdir == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ return FALSE;
+ }
+
+ for (i=0; i<(int) spriv->xtiles; i++) {
+ spriv->ewdir[i].nsfile=(NSFile *) malloc (sizeof(NSFile) * spriv->ytiles);
+ if (spriv->ewdir[i].nsfile == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ return FALSE;
+ }
+ for (j=0; j< (int) spriv->ytiles; j++) {
+ spriv->ewdir[i].nsfile[j].used=0;
+ spriv->ewdir[i].nsfile[j].filehandle=NULL;
+ }
+ }
+
+
+
+ /* sort the list of files we got into the 2d array of files */
+ for (x=0; x < nb_ewdir; x++) {
+ tile_x=(int) (dirlist[x]->coord - s->globalRegion.west);
+ for (y=0; y < dirlist[x]->nb_files; y++) {
+ /* there is a -1 because it is compared with the SW corner */
+
+ tile_y=(int) (s->globalRegion.north - dirlist[x]->nsfile[y].coord -1 );
+ strcpy(spriv->ewdir[tile_x].nsfile[tile_y].name,dirlist[x]->nsfile[y].name);
+ spriv->ewdir[tile_x].nsfile[tile_y].used=1;
+
+ }
+ strcpy(spriv->ewdir[tile_x].name,dirlist[x]->name);
+ }
+
+ /* free the memory */
+
+ for (y=0; y < nb_ewdir; y++) {
+ if ( dirlist[y]->nsfile)
+ free(dirlist[y]->nsfile);
+ free(dirlist[y]);
+ }
+
+ if (dirlist)
+ free(dirlist);
+
+ /* set the layer name based on the region */
+
+ sprintf(buffer, "%s","DTED");
+ strcpy(spriv->layername, buffer);
+
+ return 1;
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,53 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+# MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+# Description: Addition of skeleton in the build subdirs list.
+
+include $(TOPDIR)/config/common.mak
+
+#
+# Sub-directories that need to be built
+#
+# MOD START
+subdirs = adrg dted network rpf vrf skeleton
+# MOD END
+
+#
+# Default target to build everything in all sub-directories
+#
+all: $(subdirs)
+
+#
+# Target to allow individual sub-directories to be built
+# (e.g. make cgmmod)
+#
+.PHONY: $(subdirs)
+$(subdirs):
+ cd $@; $(MAKE)
+
+#
+# Pass specialized targets into the sub-directories
+#
+.PHONY: $(STANDARD_TARGETS)
+$(STANDARD_TARGETS):
+ @for i in $(subdirs); do \
+ $(MAKE) --directory $$i $@; \
+ done
+
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/ecs_clnt.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/ecs_clnt.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/ecs_clnt.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,295 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include <memory.h> /* for memset */
+#include "ecs.h"
+
+/* Default timeout can be changed using clnt_control() */
+static struct timeval TIMEOUT = { 25, 0 };
+
+ecs_Result *
+createserver_1(char **argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, CREATESERVER,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+destroyserver_1(void *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, DESTROYSERVER,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+selectlayer_1(ecs_LayerSelection *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SELECTLAYER,
+ (xdrproc_t) xdr_ecs_LayerSelection, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+releaselayer_1(ecs_LayerSelection *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, RELEASELAYER,
+ (xdrproc_t) xdr_ecs_LayerSelection, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+selectregion_1(ecs_Region *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SELECTREGION,
+ (xdrproc_t) xdr_ecs_Region, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getdictionnary_1(void *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETDICTIONNARY,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getattributeformat_1(void *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETATTRIBUTEFORMAT,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getnextobject_1(void *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETNEXTOBJECT,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getrasterinfo_1(void *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETRASTERINFO,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getobject_1(char **argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETOBJECT,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getobjectidfromcoord_1(ecs_Coordinate *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETOBJECTIDFROMCOORD,
+ (xdrproc_t) xdr_ecs_Coordinate, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+updatedictionary_1(char **argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, UPDATEDICTIONARY,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getserverprojection_1(void *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETSERVERPROJECTION,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getglobalbound_1(void *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETGLOBALBOUND,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setserverlanguage_1(u_int *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETSERVERLANGUAGE,
+ (xdrproc_t) xdr_u_int, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setserverprojection_1(char **argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETSERVERPROJECTION,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setrasterconversion_1(ecs_RasterConversion *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETRASTERCONVERSION,
+ (xdrproc_t) xdr_ecs_RasterConversion, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+createproxyserver_1(ecs_ProxyCreateServer *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, CREATEPROXYSERVER,
+ (xdrproc_t) xdr_ecs_ProxyCreateServer, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setcompression_1(ecs_Compression *argp, CLIENT *clnt)
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETCOMPRESSION,
+ (xdrproc_t) xdr_ecs_Compression, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = remote
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = remote.c ecs_clnt.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) $(GRASS_INCLUDE) $(PROJ_INCLUDE)
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(RPC_LINKLIB) $(WIN_LINKLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/remote.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/remote.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/remote.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,806 @@
+#include "ecs.h"
+
+#ifdef _SCO
+#include <rpc/rpc.h>
+#include <sys/fs/nfs/time.h>
+#endif
+
+#ifndef _WINDOWS
+# include <unistd.h>
+#endif
+
+struct ecs_Remote {
+ CLIENT *handle;
+ ecs_Result *result;
+};
+typedef struct ecs_Remote ecs_Remote;
+
+#define CONTIMEOUT 60
+#define DEFTIMEOUT 900
+#define MAXCONRETRY 1
+
+#define DISPATCHER 1
+
+#ifdef _WINDOWS
+int rpc_IsInit = 0;
+#endif
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+static struct timeval DISPATCH_TIMEOUT = { 20, 0 };
+
+
+u_long dispatch_1(clnt)
+ CLIENT *clnt;
+{
+ static u_long clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, DISPATCHER,
+ (xdrproc_t) xdr_void, (caddr_t) NULL,
+ (xdrproc_t) xdr_u_long, (caddr_t) &clnt_res,
+ DISPATCH_TIMEOUT) != RPC_SUCCESS) {
+ clnt_res = 0;
+ }
+ return clnt_res;
+}
+
+
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_CreateServer(s,Request)
+ ecs_Server *s;
+ char *Request;
+{
+ ecs_Remote *rc;
+ u_long csid;
+ struct timeval timeOut;
+ int counter;
+ ecs_ProxyCreateServer proxy_req;
+ char *proxyhost = getenv("GLTPPROXYHOST");
+
+#ifdef _WINDOWS
+ if (!rpc_IsInit) {
+ rpc_nt_init();
+ rpc_IsInit = 1;
+ }
+#endif
+
+ /*
+ Initialisation of ecs_Remote in s->priv
+ */
+
+ s->priv = (void *) malloc(sizeof(ecs_Remote));
+ if (s->priv == NULL) {
+ ecs_SetError(&(s->result),1,"No enough memory");
+ return &(s->result);
+ }
+
+ rc = (ecs_Remote *) s->priv;
+ rc->handle = NULL;
+ rc->result = NULL;
+
+ /*
+ Ask to dispatcher what is the number of the new server
+ */
+
+ /* Try to open the dispatcher */
+
+ for(counter = 0; counter < MAXCONRETRY; counter++) {
+ rc->handle = clnt_create(proxyhost ? proxyhost : s->hostname,
+ proxyhost ? ECSPROXYPROG : ECSPROG,
+ ECSVERS, "tcp");
+ if (rc->handle != 0) {
+ break;
+ }
+ }
+
+ if (rc->handle == 0) {
+ ecs_SetError(&(s->result),1,"Unable to connect to dispatcher gltpd");
+ return &(s->result);
+ }
+
+#ifdef _WINDOWS
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+
+ /* Request to dispatcher */
+
+ csid = dispatch_1(rc->handle);
+
+ if (csid == 0) {
+ ecs_SetError(&(s->result),1,"Not answer from the dispatcher");
+ return &(s->result);
+ }
+
+ clnt_destroy(rc->handle);
+
+#ifdef _WINDOWS
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+
+ /* Try to connect to server with the number returned by dispatch_1 */
+
+ for(counter = 0; counter < MAXCONRETRY; counter++) {
+ rc->handle = clnt_create(proxyhost ? proxyhost : s->hostname,
+ csid, ECSVERS, "tcp");
+ if (rc->handle != 0) {
+ break;
+ }
+ }
+
+#ifdef _WINDOWS
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+
+ if (rc->handle == 0) {
+ ecs_SetError(&(s->result),1,"Unable to connect to server number given by dispatcher");
+ return &(s->result);
+ }
+
+ /* Initialize the timeout of the create client */
+
+ timeOut.tv_sec = CONTIMEOUT;
+ timeOut.tv_usec = 0;
+ clnt_control(rc->handle, CLSET_TIMEOUT, (char *) &timeOut);
+
+ /* Call the server creation method */
+
+ if (proxyhost) {
+ proxy_req.server_name = s->hostname;
+ proxy_req.server_url = Request;
+ rc->result = (ecs_Result *) (createproxyserver_1(&proxy_req,rc->handle));
+ } else {
+ rc->result = (ecs_Result *) (createserver_1(&Request,rc->handle));
+ }
+
+ /* Initialize default timeout */
+
+ timeOut.tv_sec = DEFTIMEOUT;
+ timeOut.tv_usec = 0;
+ clnt_control(rc->handle, CLSET_TIMEOUT, (char *) &timeOut);
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),1,"No answer from server when CreateServer is called");
+ return &(s->result);
+ } else {
+ return rc->result;
+ }
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_DestroyServer(s)
+ ecs_Server *s;
+{
+ ecs_Remote *rc;
+ struct timeval timeOut;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ /* Initialize the timeout of the create client */
+
+ timeOut.tv_sec = CONTIMEOUT;
+ timeOut.tv_usec = 0;
+ clnt_control(rc->handle, CLSET_TIMEOUT, (char *) &timeOut);
+
+ rc->result = (ecs_Result *) (destroyserver_1(NULL,rc->handle));
+ clnt_destroy(rc->handle);
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when DestroyServer is called. The server is possibly orphan.");
+ } else {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ ecs_SetSuccess(&(s->result));
+ }
+ free(rc);
+ rc = NULL;
+
+
+ return &(s->result);
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SelectLayer(s,ls)
+ ecs_Server *s;
+ ecs_LayerSelection *ls;
+{
+ ecs_Remote *rc;
+ int layer;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ if ((layer = ecs_GetLayer(s,ls)) == -1) {
+ /* it did not exists so we are going to try to create it */
+ if ((layer = ecs_SetLayer(s,ls)) == -1) {
+ return &(s->result);
+ }
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (selectlayer_1(ls,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when selectlayer is called.");
+ return &(s->result);
+ }
+
+ s->currentLayer = layer;
+ s->layer[layer].index = 0;
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_ReleaseLayer(s,ls)
+ ecs_Server *s;
+ ecs_LayerSelection *ls;
+{
+ ecs_Remote *rc;
+ int layer;
+ char buffer[128];
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ if ((layer = ecs_GetLayer(s,ls)) == -1) {
+ sprintf(buffer,"Invalid layer %s",ls->Select);
+ ecs_SetError(&(s->result),1,buffer);
+ return &(s->result);
+ }
+ ecs_FreeLayer(s,layer);
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (releaselayer_1(ls,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when releaselayer is called.");
+ return &(s->result);
+ }
+
+ if (s->currentLayer == layer) {
+ s->currentLayer = -1;
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SelectRegion(s,gr)
+ ecs_Server *s;
+ ecs_Region *gr;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ s->currentRegion.north = gr->north;
+ s->currentRegion.south = gr->south;
+ s->currentRegion.east = gr->east;
+ s->currentRegion.west = gr->west;
+ s->currentRegion.ns_res = gr->ns_res;
+ s->currentRegion.ew_res = gr->ew_res;
+
+ rc->result = (ecs_Result *) (selectregion_1(gr,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when selectregion is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetDictionary(s)
+ ecs_Server *s;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (getdictionnary_1(NULL,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when getdictionary is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetNextObject(s)
+ ecs_Server *s;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (getnextobject_1(NULL,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when getnextobject is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObject(s,Id)
+ ecs_Server *s;
+ char *Id;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (getobject_1(&Id,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when getobject is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_UpdateDictionary(s,info)
+ ecs_Server *s;
+ char *info;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (updatedictionary_1(&info,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when updatedictionary is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetServerProjection(s)
+ ecs_Server *s;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (getserverprojection_1(NULL,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when getserverprojection is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetServerLanguage(s,language)
+ ecs_Server *s;
+ u_int language;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (setserverlanguage_1(&language,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when setserverlanguage is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetServerProjection(s,projection)
+ ecs_Server *s;
+ char *projection;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (setserverprojection_1(&projection,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when setserverprojection is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObjectIdFromCoord(s,c)
+ ecs_Server *s;
+ ecs_Coordinate *c;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (getobjectidfromcoord_1(c,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when GetObjectIdFromCoord is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetAttributesFormat(s)
+ ecs_Server *s;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (getattributeformat_1(NULL,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when GetAttributesFormat is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetRasterInfo(s)
+ ecs_Server *s;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (getrasterinfo_1(NULL,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when getrasterinfo is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetGlobalBound(s)
+ ecs_Server *s;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (getglobalbound_1(NULL,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when getglobalbound is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+
+}
+
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetRasterConversion(s,rasterconversion)
+ ecs_Server *s;
+ ecs_RasterConversion *rasterconversion;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (setrasterconversion_1(rasterconversion,
+ rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when setrasterconvertion is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+
+}
+
+/*
+ ------------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetCompression(s,compression)
+ ecs_Server *s;
+ ecs_Compression *compression;
+{
+ ecs_Remote *rc;
+
+ rc = (ecs_Remote *) s->priv;
+ if (rc == NULL) {
+ ecs_SetError(&(s->result),1,"Server not initialized");
+ return &(s->result);
+ }
+
+ /* Free old rc->result */
+
+ if (rc->result != NULL) {
+ xdr_free((xdrproc_t) xdr_ecs_Result,(char *) rc->result);
+ rc->result = NULL;
+ }
+
+ rc->result = (ecs_Result *) (setcompression_1(compression,rc->handle));
+
+ if (rc->result == NULL) {
+ ecs_SetError(&(s->result),
+ 1,"No answer from server when setcompression is called.");
+ return &(s->result);
+ }
+
+ return rc->result;
+}
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/remote.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/remote.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/remote.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,24 @@
+LIBRARY REMOTE
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_CreateServer
+ dyn_DestroyServer
+ dyn_SelectLayer
+ dyn_SelectRegion
+ dyn_GetDictionary
+ dyn_GetNextObject
+ dyn_UpdateDictionary
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_ReleaseLayer
+ dyn_GetAttributesFormat
+ dyn_GetRasterInfo
+ dyn_GetObject
+ dyn_GetObjectIdFromCoord
+ dyn_SetServerLanguage
+ dyn_SetServerProjection
+ dyn_SetRasterConversion
+ dyn_SetCompression
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/sun/ecs_clnt.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/sun/ecs_clnt.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/network/sun/ecs_clnt.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,298 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "ecs.h"
+
+/* Default timeout can be changed using clnt_control() */
+static struct timeval TIMEOUT = { 25, 0 };
+
+ecs_Result *
+createserver_1(argp, clnt)
+ char **argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, CREATESERVER,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+destroyserver_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, DESTROYSERVER,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+selectlayer_1(argp, clnt)
+ ecs_LayerSelection *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SELECTLAYER,
+ (xdrproc_t) xdr_ecs_LayerSelection, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+releaselayer_1(argp, clnt)
+ ecs_LayerSelection *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, RELEASELAYER,
+ (xdrproc_t) xdr_ecs_LayerSelection, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+selectregion_1(argp, clnt)
+ ecs_Region *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SELECTREGION,
+ (xdrproc_t) xdr_ecs_Region, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getdictionnary_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETDICTIONNARY,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getattributeformat_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETATTRIBUTEFORMAT,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getnextobject_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETNEXTOBJECT,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getrasterinfo_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETRASTERINFO,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getobject_1(argp, clnt)
+ char **argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETOBJECT,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getobjectidfromcoord_1(argp, clnt)
+ ecs_Coordinate *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETOBJECTIDFROMCOORD,
+ (xdrproc_t) xdr_ecs_Coordinate, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+updatedictionary_1(argp, clnt)
+ char **argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, UPDATEDICTIONARY,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getserverprojection_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETSERVERPROJECTION,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getglobalbound_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETGLOBALBOUND,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setserverlanguage_1(argp, clnt)
+ u_int *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETSERVERLANGUAGE,
+ (xdrproc_t) xdr_u_int, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setserverprojection_1(argp, clnt)
+ char **argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETSERVERPROJECTION,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setrasterconversion_1(argp, clnt)
+ ecs_RasterConversion *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETRASTERCONVERSION,
+ (xdrproc_t) xdr_ecs_RasterConversion, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/datadict.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/datadict.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/datadict.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,106 @@
+static char datadict[] = {'\n'
+,'i','t','c','l','_','c','l','a','s','s',' ','W','K','B','_','D','a','t','a','D','i','c','t','i','o','n','a','r','y',' ','{'
+,'\n'
+,'\t','i','n','h','e','r','i','t',' ','d','d'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','c','o','n','s','t','r','u','c','t','o','r',' ','{','w','p','a','t','h',' ','l','o','c','a','t','i','o','n','}',' ','{'
+,'\n'
+,'\t','#','d','d',':',':','c','o','n','s','t','r','u','c','t','o','r',' ','$','w','i','n','d','o','w','p','a','t','h',' ','$','l','o','c','a','t','i','o','n'
+,'\n'
+,'\t','d','d',' ','$','w','p','a','t','h',' ','$','l','o','c','a','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','l','a','y','o','u','t',' ','{','}',' ','{'
+,'\n'
+,'\t','f','r','a','m','e',' ','$','w','i','n','d','o','w','.','c','e','n','t','e','r'
+,'\n'
+,'\t','m','a','p','L','i','s','t','b','o','x'
+,'\n'
+,'\t','u','p','d','a','t','e','d','i','c','t'
+,'\n'
+,'\t',':',':','u','p','d','a','t','e',' ','i','d','l','e','t','a','s','k','s','\t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','L','i','s','t','E','n','t','r','y',' ','{','i','n','d','e','x','}',' ','{'
+,'\n'
+,'\t','r','e','g','s','u','b',' ','{','\\','(','[','A','-','Z',']','+','\\',')','$','}',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','g','e','t',' ','$','i','n','d','e','x',']',' ','{','}',' ','s','_','n','a','m','e',' '
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','s','_','n','a','m','e'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','u','p','d','a','t','e','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+,'\t'
+,'\n'
+,'\t','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','d','e','l','e','t','e',' ','0',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','s','i','z','e',']'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','s','_','i','t','e','m',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','[','i','n','f','o',' ','e','x','i','s','t','s',' ','a','_','r','a','m','d','i','s','k','(','$','s','_','i','t','e','m',')',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','a','_','r','a','m','d','i','s','k','(','$','s','_','i','t','e','m',')',' ','$','s','_','d','i','s','k','D','e','f','a','u','l','t'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t',' ',' ',' ',' ','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','i','n','s','e','r','t',' ','e','n','d',' ','[','g','e','t','U','R','L','E','n','t','r','y',' ','$','s','_','i','t','e','m',']'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','U','R','L','E','n','t','r','y',' ','{','s','_','p','a','t','h','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','{','s','_','p','a','t','h','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',' ','{','a','r','g','s','}',' ','{'
+,'\n'
+,' ','\t','r','e','t','u','r','n',' ','R','a','s','t','e','r'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','P','a','t','h','n','a','m','e',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','s','e','l','e','c','t','i','o','n','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','s','e','l','e','c','t','i','o','n','\t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','p','r','o','t','e','c','t','e','d',' ','a','_','r','a','m','d','i','s','k',' ',';','#',' ','w','h','e','t','h','e','r',' ','t','h','e',' ','c','o','v','e','r','a','g','e',' ','i','s',' ','t','o',' ','b','e',' ','l','o','a','d','e','d',' ','i','n','t','o',' ','r','a','m',' ','o','r',' ','d','i','s','k','.'
+,'\n'
+,' ',' ',' ',' ',';','#',' ','v','a','l','u','e','s',' ','a','r','e',' ','e','i','t','h','e','r',' ','\"','R','A','M','\"',' ','o','r',' ','\"','D','I','S','K','\"'
+,'\n'
+,' ',' ',' ',' ','p','r','o','t','e','c','t','e','d',' ','s','_','d','i','s','k','D','e','f','a','u','l','t',' ','\"','D','I','S','K','\"'
+,'\n'
+
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'\0'};
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = rpf
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = rpf.c utils.c object.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) \
+ $(GRASS_INCLUDE) $(PROJ_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(VPF_STATICLIB) $(GLUTIL_STATICLIB) $(WIN_LINKLIB) $(MATH_LINKLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR datadict.h
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/object.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/object.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/object.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,783 @@
+/******************************************************************************
+ *
+ * Component: OGDI RPF Driver
+ * Purpose: Implementation of RPF getObject functions.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: object.c,v $
+ * Revision 1.3 2001/04/12 19:22:46 warmerda
+ * applied DND support Image type support
+ *
+ */
+
+#include "ecs.h"
+#include "rpf.h"
+
+ECS_CVSID("$Id: object.c,v 1.3 2001/04/12 19:22:46 warmerda Exp $");
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ _getNextObjectRaster
+
+DESCRIPTION
+
+ Pick a line in the line buffer and return it to the OGDI.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ A dyn_SelectLayer must have been call previously succesfully.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ l->index is incremented of 1.
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+
+ ecs_Server *s: The driver information
+ ecs_Layer *l: The current layer
+
+END_PARAMETERS
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ If the line index l->index is bigger than the number of lines (l->nbfeature)
+ Begin
+
+ Return the error code 2 end of selection
+
+ End
+
+ Calculate the extremities of the lines in the current projection:
+
+ Point1:
+ x: s->currentRegion.west
+ y: s->currentRegion.north - l->index * s->currentRegion.ns_res
+
+ Point2:
+ x: s->currentRegion.east
+ y: s->currentRegion.north - l->index * s->currentRegion.ns_res
+
+ Call ecs_GetTileLine with these two points. If an error occur,
+ return the error "Unable to retreive the line".
+
+ Increment l->index
+
+ Set a success message
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+void dyn_getNextObjectRaster(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ LayerPrivateData *lpriv = l->priv;
+ ecs_Coordinate start, end;
+ double pos_y;
+
+ if (l->index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /* get geographic position of current region's matrix point l->index */
+ pos_y = s->currentRegion.north - l->index * s->currentRegion.ns_res;
+
+ start.x=s->currentRegion.west;
+ end.x=s->currentRegion.east;
+ start.y=pos_y;
+ end.y=pos_y;
+
+ if (!ecs_TileGetLine(s, &(lpriv->tilestruct), &start, &end)) {
+ ecs_SetError(&(s->result),1,"Unable to retrieve a line.");
+ return;
+ }
+
+ l->index++;
+ ecs_SetSuccess(&(s->result));
+}
+
+void
+dyn_getObjectRaster(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ (void) l;
+ (void) id;
+ ecs_SetError(&(s->result),1,"The GetObject function is not implemented for this adapter");
+}
+
+void
+dyn_getObjectIdRaster(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ (void) l;
+ (void) coord;
+ ecs_SetError(&(s->result),1,"The GetObjectIdFromCoord function is not implemented for this adapter");
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ _rewindRasterLayer
+
+DESCRIPTION
+
+ Prepare a new selection.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ A dyn_SelectLayer must have been call previously succesfully.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ The layer is reinitialized and ready to be used
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+
+ ecs_Server *s: The driver information
+ ecs_Layer *l: The current layer
+
+END_PARAMETERS
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Call ecs_TileClearBuffer
+
+ Set l->index to 0.
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+void dyn_rewindRasterLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ LayerPrivateData *lpriv = l->priv;
+
+ (void) s;
+
+ ecs_TileClearBuffer(&(lpriv->tilestruct));
+ l->index=0;
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ _PointCallBack
+
+DESCRIPTION
+
+ This callback function will return the value of a given point
+ in a given tile.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ A dyn_SelectLayer must have been call previously succesfully.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ The tile may have change if the tile requested was not the
+ same than the previous one.
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+
+ ecs_Server *s: The driver information
+ ecs_TileStructure *t: The tile structure
+ int xtile: The tile column in the tile grid
+ int ytile: The tile line in the tile grid
+ int xpixel: The x position of the point inside the current tile
+ int ypixel: The y position of the point inside the current tile
+
+ OUTPUT
+
+ int *cat: The return value.
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ int: Indicate a success or an error message.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Call _rpf_readtile for the tile xtile,ytile.
+
+ If lpriv->isActive is FALSE, return 0 for cat.
+
+ Calculate the pixel position: (xpixel,lpriv->columns-ypixel)
+
+ If the point position is inside the region of the raster,
+ Greater to 0 but smaller than the number of columns or lines
+ Begin
+
+ Calculate the subtile position in the current tile
+ tile x = pixel position x / 256
+ tile y = pixel position y / 256
+ physical tile position = tile y * 6 + tile x
+
+ Calculate the rows and column position of the pixel in this tile
+ tile row = pixel position x - tile x * 256
+ tile column = pixel position y - tile y* 256
+
+ Get the value of the current point in this tile
+ Value = (lpriv->buffertile[physical tile position].data[tile row * 256 + tile column]+13
+
+ The return value cat receive the equivalent value of Value
+ cat = lpriv->equi_cat[Value]
+
+ End
+
+ Else return a 0 value for cat.
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+int dyn_PointCallBack(s,t,xtile,ytile,xpixel,ypixel,cat)
+
+ ecs_Server *s;
+ ecs_TileStructure *t;
+ int xtile;
+ int ytile;
+ int xpixel;
+ int ypixel;
+ int *cat;
+
+{
+ ecs_Layer *l = (ecs_Layer *) &(s->layer[s->currentLayer]);
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int pix_c,pix_r;
+ register int tile,tile_x,tile_y;
+ register int tile_r,tile_c;
+ register unsigned int Val,PosVal;
+ register double rapport;
+
+ (void) t;
+
+ rapport = s->currentRegion.ns_res/lpriv->entry->vert_interval;
+ if (rapport > 10.0) {
+ if (lpriv->entry->frames[ytile][xtile].exists == FALSE)
+ *cat = 0;
+ else {
+ if (xpixel < 100 || xpixel > 1436 ||
+ ypixel < 100 || ypixel > 1436)
+ *cat = ((lpriv->entry->boundary_id+1)*4)%216;
+ else
+ *cat = 0;
+ }
+ return TRUE;
+ }
+
+ if (!dyn_read_rpftile(s,l,xtile,ytile)) {
+ *cat = 0;
+ return TRUE;
+ }
+
+ if (lpriv->isActive == FALSE) {
+ *cat = 0;
+ return TRUE;
+ }
+
+ pix_c = xpixel;
+ pix_r = ypixel;
+
+ if ((pix_c>=0) && (pix_c<lpriv->columns) &&
+ (pix_r>=0) && (pix_r<lpriv->rows))
+ {
+
+ /* Compute subframe numbers for pix_c,pix_r */
+
+ tile_x = pix_c/256;
+ tile_y = pix_r/256;
+ tile = tile_y*6+tile_x;
+
+ /* Si cette tile physique est 0, c'est une tile vide */
+
+ tile_r = pix_r - tile_y * 256;
+ tile_c = pix_c - tile_x * 256;
+
+ PosVal = tile_r*256 + tile_c;
+
+ Val = (lpriv->buffertile[tile].data[PosVal]);
+ *cat = lpriv->equi_cat[Val];
+ }
+ else
+ *cat = 0;
+
+return TRUE;
+}
+
+/*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ _DimCallBack
+
+DESCRIPTION
+
+ This callback function will return the resolution of the tile
+ for the geographic point in it.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ A dyn_SelectLayer must have been call previously succesfully.
+
+END_PRECONDITIONS
+
+PARAMETERS
+
+ INPUT
+
+ ecs_Server *s: The driver information
+ ecs_TileStructure *t: The tile structure
+ double x: The x of the geographic position
+ double y: The y of the geographic position
+
+ OUTPUT
+
+ int *width: Width of the tile at the position x
+ int *height: Height of the tile at the position y
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ int: Indicate a success or an error message.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Set 1536 to *width and *height
+
+ return TRUE
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+int dyn_DimCallBack(s,t,x,y,width,height)
+ ecs_Server *s;
+ ecs_TileStructure *t;
+ double x;
+ double y;
+ int *width;
+ int *height;
+{
+ (void) s;
+ (void) t;
+ (void) x;
+ (void) y;
+
+ *width = 1536;
+ *height = 1536;
+ return TRUE;
+}
+
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ _getNextObjectImage
+
+DESCRIPTION
+
+ Pick a line in the line buffer and return it to the OGDI.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ A dyn_SelectLayer must have been call previously succesfully.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ l->index is incremented of 1.
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+
+ ecs_Server *s: The driver information
+ ecs_Layer *l: The current layer
+
+END_PARAMETERS
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ If the line index l->index is bigger than the number of lines (l->nbfeature)
+ Begin
+
+ Return the error code 2 end of selection
+
+ End
+
+ Calculate the extremities of the lines in the current projection:
+
+ Point1:
+ x: s->currentRegion.west
+ y: s->currentRegion.north - l->index * s->currentRegion.ns_res
+
+ Point2:
+ x: s->currentRegion.east
+ y: s->currentRegion.north - l->index * s->currentRegion.ns_res
+
+ Call ecs_GetTileLine with these two points. If an error occur,
+ return the error "Unable to retreive the line".
+
+ Increment l->index
+
+ Set a success message
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+void dyn_getNextObjectImage(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ LayerPrivateData *lpriv = l->priv;
+ ecs_Coordinate start, end;
+ double pos_y;
+
+ if (l->index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /* get geographic position of current region's matrix point l->index */
+ pos_y = s->currentRegion.north - l->index * s->currentRegion.ns_res;
+
+ start.x=s->currentRegion.west;
+ end.x=s->currentRegion.east;
+ start.y=pos_y;
+ end.y=pos_y;
+
+ if (!ecs_TileGetLine(s, &(lpriv->tilestruct), &start, &end)) {
+ ecs_SetError(&(s->result),1,"Unable to retrieve a line.");
+ return;
+ }
+
+ s->result.res.ecs_ResultUnion_u.dob.geom.family = Image;
+
+ l->index++;
+ ecs_SetSuccess(&(s->result));
+}
+
+void
+dyn_getObjectImage(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ ecs_SetError(&(s->result),1,"The GetObject function is not implemented for this adapter");
+}
+
+void
+dyn_getObjectIdImage(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ ecs_SetError(&(s->result),1,"The GetObjectIdFromCoord function is not implemented for this adapter");
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ _rewindImageLayer
+
+DESCRIPTION
+
+ Prepare a new selection.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ A dyn_SelectLayer must have been call previously succesfully.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ The layer is reinitialized and ready to be used
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+
+ ecs_Server *s: The driver information
+ ecs_Layer *l: The current layer
+
+END_PARAMETERS
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Call ecs_TileClearBuffer
+
+ Set l->index to 0.
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+void dyn_rewindImageLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ LayerPrivateData *lpriv = l->priv;
+ ecs_TileClearBuffer(&(lpriv->tilestruct));
+ l->index=0;
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ _PointCallBack
+
+DESCRIPTION
+
+ This callback function will return the value of a given point
+ in a given tile.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ A dyn_SelectLayer must have been call previously succesfully.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ The tile may have change if the tile requested was not the
+ same than the previous one.
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+
+ ecs_Server *s: The driver information
+ ecs_TileStructure *t: The tile structure
+ int xtile: The tile column in the tile grid
+ int ytile: The tile line in the tile grid
+ int xpixel: The x position of the point inside the current tile
+ int ypixel: The y position of the point inside the current tile
+
+ OUTPUT
+
+ int *cat: The return value.
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ int: Indicate a success or an error message.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Call _rpf_readtile for the tile xtile,ytile.
+
+ If lpriv->isActive is FALSE, return 0 for cat.
+
+ Calculate the pixel position: (xpixel,lpriv->columns-ypixel)
+
+ If the point position is inside the region of the Image,
+ Greater to 0 but smaller than the number of columns or lines
+ Begin
+
+ Calculate the subtile position in the current tile
+ tile x = pixel position x / 256
+ tile y = pixel position y / 256
+ physical tile position = tile y * 6 + tile x
+
+ Calculate the rows and column position of the pixel in this tile
+ tile row = pixel position x - tile x * 256
+ tile column = pixel position y - tile y* 256
+
+ Get the value of the current point in this tile
+ Value = (lpriv->buffertile[physical tile position].data[tile row * 256 + tile column]+13
+
+ The return value cat receive the equivalent value of Value
+ cat = lpriv->equi_cat[Value]
+
+ End
+
+ Else return a 0 value for cat.
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+int dyn_ImagePointCallBack(s,t,xtile,ytile,xpixel,ypixel,cat)
+
+ ecs_Server *s;
+ ecs_TileStructure *t;
+ int xtile;
+ int ytile;
+ int xpixel;
+ int ypixel;
+ int *cat;
+
+{
+ ecs_Layer *l = (ecs_Layer *) &(s->layer[s->currentLayer]);
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int pix_c,pix_r;
+ register int tile,tile_x,tile_y;
+ register int tile_r,tile_c;
+ register unsigned int Val,PosVal;
+ register double rapport;
+
+ rapport = s->currentRegion.ns_res/lpriv->entry->vert_interval;
+ if (rapport > 10.0) {
+ if (lpriv->entry->frames[ytile][xtile].exists == FALSE) {
+ *cat = ecs_GetPixelFromRGB(0,0,0,0);
+ } else {
+ if (xpixel < 100 || xpixel > 1436 ||
+ ypixel < 100 || ypixel > 1436) {
+ *cat = ecs_GetPixelFromRGB(1,0,255,0);
+ } else {
+ *cat = ecs_GetPixelFromRGB(0,0,0,0);
+ }
+ return TRUE;
+ }
+ }
+
+ if (!dyn_read_rpftile(s,l,xtile,ytile)) {
+ *cat = ecs_GetPixelFromRGB(0,0,0,0);
+ return TRUE;
+ }
+
+ if (lpriv->isActive == FALSE) {
+ *cat = ecs_GetPixelFromRGB(0,0,0,0);
+ return TRUE;
+ }
+
+ pix_c = xpixel;
+ pix_r = ypixel;
+
+ if ((pix_c>=0) && (pix_c<lpriv->columns) &&
+ (pix_r>=0) && (pix_r<lpriv->rows)) {
+
+ /* Compute subframe numbers for pix_c,pix_r */
+
+ tile_x = pix_c/256;
+ tile_y = pix_r/256;
+ tile = tile_y*6+tile_x;
+
+ /* Si cette tile physique est 0, c'est une tile vide */
+
+ tile_r = pix_r - tile_y * 256;
+ tile_c = pix_c - tile_x * 256;
+
+ PosVal = tile_r*256 + tile_c;
+
+ Val = (lpriv->buffertile[tile].data[PosVal]);
+ *cat = ecs_GetPixelFromRGB(1,lpriv->rgb_pal[Val].r,
+ lpriv->rgb_pal[Val].g,
+ lpriv->rgb_pal[Val].b);
+ } else {
+ *cat = ecs_GetPixelFromRGB(0,0,0,0);
+ }
+ return TRUE;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1063 @@
+/******************************************************************************
+ *
+ * Component: OGDI RPF Driver
+ * Purpose: Implementation of dyn_* api for RPF driver.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: rpf.c,v $
+ * Revision 1.13 2007/02/24 16:58:17 cbalint
+ * Clear olso tilestruct while freeing memory in dyn_freelayerpriv()
+ * glibc mtrace() reports zero malloc problems now.
+ * Thanks to djdejohn for the report !
+ * Modified Files:
+ * ChangeLog ogdi/driver/rpf/rpf.c
+ *
+ * Revision 1.12 2004/03/26 22:33:41 warmerda
+ * Fixed computation of nbfeature in dyn_SelectRegion() to avoid rounding
+ * error issues. As per Bug 924250.
+ *
+ * Revision 1.11 2001/08/27 14:56:29 warmerda
+ * RPF rasterinfo width fixed
+ *
+ * Revision 1.10 2001/08/16 13:06:52 warmerda
+ * ensure that only Matrix and Image are allowed by RPF SelectLayer
+ *
+ * Revision 1.9 2001/06/13 17:17:40 warmerda
+ * fixed capabilities to match 6.2 spec
+ *
+ * Revision 1.8 2001/05/30 19:02:51 warmerda
+ * return real per-layer bounds in capabilities
+ *
+ * Revision 1.7 2001/04/16 21:32:05 warmerda
+ * added capabilities support
+ *
+ * Revision 1.6 2001/04/12 19:22:46 warmerda
+ * applied DND support Image type support
+ *
+ */
+
+#include "rpf.h"
+#include "datadict.h"
+
+ECS_CVSID("$Id: rpf.c,v 1.13 2007/02/24 16:58:17 cbalint Exp $");
+
+int colorintensity[6] = {0,63,105,147,189,255};
+
+
+/* layer oriented functions are keeped in data structure to simplify code */
+
+LayerMethod rpf_layerMethod[11] = {
+ /* 0 */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Area */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Line */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Point */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Matrix */ { NULL, NULL, dyn_rewindRasterLayer, dyn_getNextObjectRaster, dyn_getObjectRaster, dyn_getObjectIdRaster },
+ /* Image */ { NULL, NULL, dyn_rewindImageLayer, dyn_getNextObjectImage, dyn_getObjectImage, dyn_getObjectIdImage },
+ /* Text */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Edge */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Face */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Node */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Ring */ { NULL, NULL, NULL, NULL, NULL, NULL }
+};
+
+/* ----------------------------------------------------------------------
+ * _dyn_CreateServer:
+ *
+ * Creation of a new RPF server
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_CreateServer(s,Request)
+ ecs_Server *s;
+ char *Request;
+{
+ register ServerPrivateData *spriv = s->priv = (void *) malloc(sizeof(ServerPrivateData));
+
+ (void) Request;
+
+ if (spriv == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server private data");
+ return &(s->result);
+ }
+
+ spriv->pathname = (char *) malloc(strlen(s->pathname)+1);
+ if (spriv->pathname == NULL) {
+ free(s->priv);
+ ecs_SetError(&(s->result),1,"Not enough memory");
+ return &(s->result);
+ }
+
+ if (s->pathname[2] == ':') {
+ strcpy(spriv->pathname,s->pathname+1);
+ } else {
+ strcpy(spriv->pathname,s->pathname);
+ }
+
+ tprintf("dyn_CreateServer 1\n");
+
+ /* check the path and see if the location is valid */
+
+ if (!(dyn_verifyLocation(s))) {
+ free(spriv->pathname);
+ free(s->priv);
+ return &(s->result);
+ }
+
+ tprintf("dyn_CreateServer 2\n");
+
+ /* initialize the driver globalRegion */
+
+ if (!(dyn_initRegionWithDefault(s))) {
+ free(spriv->pathname);
+ free(s->priv);
+ return &(s->result);
+ }
+
+
+ tprintf("dyn_CreateServer 3\n");
+
+ /* initialize layer private data */
+
+ s->nblayer = 0;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_DestroyServer:
+ *
+ * Destruction of this RPF server
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_DestroyServer(s)
+ ecs_Server *s;
+{
+ register ServerPrivateData *spriv = s->priv;
+
+ /* Release all layer */
+
+ dyn_releaseAllLayers(s);
+
+ if(spriv != NULL) {
+ if (spriv->pathname != NULL) {
+ free(spriv->pathname);
+ }
+ if (spriv->toc != (Toc_file *)NULL) {
+ free_toc(spriv->toc);
+ }
+
+ free(spriv);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+
+}
+
+void dyn_freelayerpriv(lpriv)
+ LayerPrivateData *lpriv;
+{
+ if (lpriv != NULL) {
+ lpriv->entry = NULL;
+ if (lpriv->buffertile != NULL) {
+ free(lpriv->buffertile);
+ lpriv->buffertile = NULL;
+ }
+
+ /* empty tilestruct */
+ ecs_TileDeleteAllLines (&(lpriv->tilestruct));
+
+ if (lpriv->ff != NULL)
+ free(lpriv->ff);
+ if (lpriv->rgb_pal != NULL)
+ free(lpriv->rgb_pal);
+ if (lpriv->rpf_table != NULL)
+ free(lpriv->rpf_table);
+ free(lpriv);
+ }
+ lpriv = NULL;
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ dyn_SelectLayer
+
+DESCRIPTION
+
+ Select a layer and prepare it to be read in the rpf database.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ dyn_CreateServer must have been previously called.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ The layer is selected and ready to be read with the commands
+ dyn_GetNextObject, dyn_GetRasterInfo and dyn_GetObject.
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+ ecs_Server *s: The driver information
+ ecs_LayerSelection *sel: The layer selection information
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ ecs_Result *: The result structure common to all OGDI calls.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Check if a layer exist with ecs_GetLayer. If a layer exist
+ Begin
+
+ The current layer is now the layer returned by ecs_GetLayer
+ The index of this layer is set to 0
+ Return a success message
+
+ End
+
+ Set a new layer in the layer structure with ecs_SetLayer.
+
+ Allocate the mamory needed to hold private info about this new layer.
+
+ Prepare the new allocated structure with default values.
+
+ Prepare the layer for selection with _prepare_rpflayer. If an error
+ occur, free the memory of this layer, call ecs_FreeLayer and return
+ an error message.
+
+ Set the current layer to the new layer
+
+ Set the index of this layer to 0
+
+ Return a success message
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+ecs_Result *dyn_SelectLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int layer;
+ register LayerPrivateData *lpriv;
+ ecs_Region region;
+
+ /* Disallow any families but Image and Matrix */
+ if( sel->F != Matrix && sel->F != Image )
+ {
+ ecs_SetError(&(s->result),1,
+ "RPF driver only supports Matrix and Image in SelectLayer.");
+ return &(s->result);
+ }
+
+ /* first, try to find an existing layer with same request and family */
+
+ if ((layer = ecs_GetLayer(s,sel)) != -1) {
+
+ /* if it already exists than assign currentLayer and set index to 0 to force rewind */
+
+ s->currentLayer = layer;
+ s->layer[layer].index = 0;
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+ region.north = lpriv->entry->nw_lat;
+ region.south = lpriv->entry->sw_lat;
+ region.east = lpriv->entry->ne_long;
+ region.west = lpriv->entry->nw_long;
+ region.ns_res = (region.north - region.south) / (1536*lpriv->entry->vert_frames);
+ region.ew_res = (region.east - region.west) / (1536*lpriv->entry->horiz_frames);
+
+ ecs_SetGeoRegion(&(s->result),region.north, region.south,
+ region.east, region.west, region.ns_res,
+ region.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+ }
+
+ /* it did not exists so we are going to try to create it */
+
+ if ((layer = ecs_SetLayer(s,sel)) == -1) {
+ return &(s->result);
+ }
+
+ /* allocate memory to hold private info about this new layer */
+
+ if ((s->layer[layer].priv = (void *) malloc(sizeof(LayerPrivateData))) == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate layer private data");
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+ lpriv->entry = NULL;
+ lpriv->buffertile = NULL;
+ lpriv->ff = NULL;
+ lpriv->rgb_pal = NULL;
+ lpriv->rpf_table = NULL;
+ lpriv->cct = NULL;
+ lpriv->tile_row = -1;
+ lpriv->tile_col = -1;
+ lpriv->isActive = FALSE;
+ lpriv->isColor = TRUE;
+
+ /*
+ Prepare the layer for selection with _prepare_rpflayer. If an error
+ occur, free the memory of this layer, call ecs_FreeLayer and return
+ an error message.
+ */
+
+ if (!(dyn_prepare_rpflayer(s,&(s->layer[layer])))) {
+ dyn_freelayerpriv(lpriv);
+ ecs_FreeLayer(s,layer);
+ /* The error message is already set */
+ return &(s->result);
+ }
+
+ s->currentLayer = layer;
+ s->layer[layer].nbfeature = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res);
+ s->layer[layer].index = 0;
+
+ region.north = lpriv->entry->nw_lat;
+ region.south = lpriv->entry->sw_lat;
+ region.east = lpriv->entry->ne_long;
+ region.west = lpriv->entry->nw_long;
+ region.ns_res = (region.north - region.south) / (1536*lpriv->entry->vert_frames);
+ region.ew_res = (region.east - region.west) / (1536*lpriv->entry->horiz_frames);
+
+ ecs_SetGeoRegion(&(s->result),region.north, region.south,
+ region.east, region.west, region.ns_res,
+ region.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ dyn_ReleaseLayer
+
+DESCRIPTION
+
+ Release a given layer
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ dyn_CreateServer must have been previously called.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ If a layer with the selection information sel exist. It will
+ be remove from the memory and from the layer list.
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+ ecs_Server *s: The driver information
+ ecs_LayerSelection *sel: The layer selection information
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ ecs_Result *: The result structure common to all OGDI calls.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Check if a layer exist with ecs_GetLayer. If the layer don't exist
+ Begin
+
+ Return an error message to indicate the layer don't exist.
+
+ End
+
+ Free the layer private data in the layer previously selected.
+
+ Call ecs_FreeLayer to free the layer from the layer list.
+
+ If the currentlayer was this layer, set the currentlayer to -1.
+
+ Return a success message
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+ecs_Result *dyn_ReleaseLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int layer;
+ char buffer[128];
+ register LayerPrivateData *lpriv;
+
+ /* first, try to find an existing layer with same request and family */
+
+ if ((layer = ecs_GetLayer(s,sel)) == -1) {
+ sprintf(buffer,"Invalid layer %s",sel->Select);
+ ecs_SetError(&(s->result),1,buffer);
+ return &(s->result);
+ }
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+
+ if (lpriv != NULL) {
+ dyn_freelayerpriv(lpriv);
+ ecs_FreeLayer(s,layer);
+
+ if (s->currentLayer == layer) {
+ s->currentLayer = -1; /* just in case released layer was selected */
+ }
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* deselect all layer */
+
+void
+dyn_releaseAllLayers(s)
+ ecs_Server *s;
+{
+ int i;
+
+ for (i = 0; i < s->nblayer; ++i)
+ dyn_ReleaseLayer(s,&(s->layer[i].sel));
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_SelectRegion:
+ *
+ * selection current geographic region.
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_SelectRegion(s,gr)
+ ecs_Server *s;
+ ecs_Region *gr;
+{
+
+ s->currentRegion.north = gr->north;
+ s->currentRegion.south = gr->south;
+ s->currentRegion.east = gr->east;
+ s->currentRegion.west = gr->west;
+ s->currentRegion.ns_res = gr->ns_res;
+ s->currentRegion.ew_res = gr->ew_res;
+
+ /* reset currentLayer index to 0 to force rewind */
+
+ if (s->currentLayer != -1) {
+ s->layer[s->currentLayer].index = 0;
+ s->layer[s->currentLayer].nbfeature =
+ (int) ((s->currentRegion.north - s->currentRegion.south)
+ / s->currentRegion.ns_res + 0.5);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetAttributesFormat:
+ *
+ * return the attribute format of the currently selected layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *
+dyn_GetAttributesFormat(s)
+ ecs_Server *s;
+{
+ ecs_SetObjAttributeFormat(&(s->result));
+
+ ecs_AddAttributeFormat(&(s->result),"category",Integer,5,0,0);
+ ecs_AddAttributeFormat(&(s->result),"label",Char,80,0,0);
+
+ ecs_SetSuccess(&(s->result));
+
+ return &(s->result);
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ dyn_GetDictionary
+
+DESCRIPTION
+
+ Get a itcl applet to Grassland able to read
+ dyn_UpdateDictionary results.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ dyn_CreateServer must have been previously called.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ No post conditions
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+ ecs_Server *s: The driver information
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ ecs_Result *: The result structure common to all OGDI calls.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Return the contain of the struct in datadict.h with SetText.
+
+ Return a success message
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+ecs_Result *dyn_GetDictionary(s)
+ ecs_Server *s;
+{
+ ecs_SetText(&(s->result),datadict);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * dyn_GetNextObject:
+ *
+ * return the next object for the current layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetNextObject(s)
+ ecs_Server *s;
+{
+
+ if (s->layer[s->currentLayer].index == 0) {
+ (rpf_layerMethod[s->layer[s->currentLayer].sel.F].rewind)(s,&(s->layer[s->currentLayer]));
+ }
+
+ (rpf_layerMethod[s->layer[s->currentLayer].sel.F].getNextObject)(s,&(s->layer[s->currentLayer]));
+
+ return &(s->result);
+
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ dyn_GetRasterInfo
+
+DESCRIPTION
+
+ Return the raster information for the current layer and set a
+ category table for a 6x6x6 color cube for matrix informations and
+ a default category table for images.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ dyn_CreateServer must have been previously called. A SelectLayer
+ must have been called successfully previously.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ No post conditions
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+ ecs_Server *s: The driver information
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ ecs_Result *: The result structure common to all OGDI calls.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Get the current private layer information
+
+ If the layer is matricial
+ Begin
+
+ Call ecs_SetRasterInfo with the width and the height of the
+ layer. To calculate that, multiply the number of tiles
+ horizontally and vertically by 1536.
+
+ For each value i between 0 and 5
+ Begin
+
+ For each value j between 0 and 5
+ Begin
+
+ For each value k between 0 and 5
+ Begin
+
+ Add a category with ecs_AddRasterInfoCategory
+ with a color r=i*43, g=j*43 and b=k*43. The
+ buffer is a empty string.
+
+ End
+
+ End
+
+ End
+
+ End
+
+ Else if the layer is an image
+ Begin
+
+ Call ecs_SetRasterInfo. Set the width with 1 (RGB image) and
+ height to 0.
+
+ Add a category with ecs_AddRasterInfoCategory with a white
+ color. The buffer is a string "No data".
+
+ End
+
+ Return a success message
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+ecs_Result *dyn_GetRasterInfo(s)
+ ecs_Server *s;
+{
+ register unsigned int i,j,k;
+ char buffer[2];
+ register LayerPrivateData *lpriv;
+ int count, rows, columns;
+ ecs_Region region = s->currentRegion;
+
+ strcpy(buffer,"");
+ lpriv = (LayerPrivateData *) s->layer[s->currentLayer].priv;
+
+ /* Put table contain in RasterInfo here */
+
+ rows = (int) floor((region.north-region.south)/region.ns_res + 0.5);
+ columns = (int) floor((region.east-region.west)/region.ew_res + 0.5);
+
+ if (s->layer[s->currentLayer].sel.F == Matrix) {
+ ecs_SetRasterInfo(&(s->result),columns,rows);
+ count = 1;
+ if (lpriv->isColor == TRUE) {
+ for(i=0;i<6;i++) {
+ for(j=0;j<6;j++) {
+ for(k=0;k<6;k++) {
+ ecs_AddRasterInfoCategory(&(s->result),count,
+ colorintensity[i],
+ colorintensity[j],
+ colorintensity[k],buffer,0);
+ count++;
+ }
+ }
+ }
+ } else {
+ for(i=1;i<255;i++) {
+ ecs_AddRasterInfoCategory(&(s->result),i,i,i,i,buffer,0);
+ }
+ }
+ } else {
+ ecs_SetRasterInfo(&(s->result),1,0);
+ ecs_AddRasterInfoCategory(&(s->result),1, 255, 255, 255,"No data",0);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ _initCatTable
+
+ Inititalize category informations
+
+ ----------------------------------------------------------------------
+ */
+
+int dyn_initCatTable(s,layer)
+ ecs_Server *s;
+ ecs_Layer *layer;
+{
+ register LayerPrivateData *lpriv;
+
+ (void) s;
+
+ lpriv = (LayerPrivateData *) layer->priv;
+
+ lpriv->mincat = 0+13;
+ lpriv->maxcat = lpriv->n_pal_cols-1+13;
+
+ return TRUE;
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetObject:
+ *
+ * return an object for the current layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObject(s,Id)
+ ecs_Server *s;
+ char *Id;
+{
+ if (rpf_layerMethod[s->layer[s->currentLayer].sel.F].getObject != NULL)
+ (rpf_layerMethod[s->layer[s->currentLayer].sel.F].getObject)(s,&(s->layer[s->currentLayer]),Id);
+ else {
+ ecs_SetError(&(s->result),1,"Can't get object for this type of layer");
+ }
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetObjectIdFromCoord:
+ *
+ * return the object id sitting at (or near) to a coordinate
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObjectIdFromCoord(s,coord)
+ ecs_Server *s;
+ ecs_Coordinate *coord;
+{
+ if (rpf_layerMethod[s->layer[s->currentLayer].sel.F].getObjectIdFromCoord != NULL)
+ (rpf_layerMethod[s->layer[s->currentLayer].sel.F].getObjectIdFromCoord)(s,&(s->layer[s->currentLayer]),coord);
+ else {
+ ecs_SetError(&(s->result),1,"Can't get objectid from coordinate for this type of layer");
+ }
+ return &(s->result);
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ dyn_UpdateDictionary
+
+DESCRIPTION
+
+ Return a list of entries in the format of the SelectLayer request.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ dyn_CreateServer must have been previously called.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ No post conditions
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+ ecs_Server *s: The driver information
+ char *info: The info structure. Not used in this structure
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ ecs_Result *: The result structure common to all OGDI calls.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Set an empty string with ecs_Settext
+
+ For each valid entry (invalid_geographics to false) in spriv->toc
+ Begin
+
+ Construct with the strings scale, zone, type and producer in
+ Toc_entry a selection string in the format scale at zone@type at producer.
+ Take care to remove all the empty zones. Keep a space in the end.
+
+ Add this string in ecs_Result with ecs_AddText.
+
+ End
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+ecs_Result *dyn_UpdateDictionary(s,info)
+ ecs_Server *s;
+ char *info;
+{
+ char buffer[50],result[50];
+ register ServerPrivateData *spriv = s->priv;
+ int i,j,k;
+ Toc_file *toc;
+
+ toc = spriv->toc;
+
+ if( strcmp(info,"ogdi_server_capabilities") == 0 )
+ {
+ ecs_AddText(&(s->result),
+ "<?xml version=\"1.0\" ?>\n"
+ "<OGDI_Capabilities version=\"3.1\">\n"
+ "</OGDI_Capabilities>\n" );
+ ecs_SetSuccess(&(s->result));
+ }
+
+ else if( strcmp(info,"ogdi_capabilities") == 0 )
+ {
+ char line[256];
+
+ ecs_AddText(&(s->result),
+ "<?xml version=\"1.0\" ?>\n"
+ "<OGDI_Capabilities version=\"3.1\">\n" );
+ ecs_AddText(&(s->result),
+ " <FeatureTypeList>\n"
+ " <Operations>\n"
+ " <Query/>\n"
+ " </Operations>\n" );
+
+ for (i=0; i<(int)toc->num_boundaries; i++)
+ {
+ Toc_entry *entry = toc->entries + i;
+
+ if (entry->invalid_geographics == 1L)
+ continue;
+
+ sprintf(buffer,"%s@%s@%s@%s@%d",
+ entry->scale,
+ entry->zone, entry->type,
+ entry->producer,
+ entry->boundary_id);
+
+ /* Remove the spaces */
+ k = 0;
+ for(j=0;j<(int) strlen(buffer);j++) {
+ if (buffer[j] != ' ') {
+ result[k] = buffer[j];
+ k++;
+ }
+ }
+ result[k] = '\0';
+
+ ecs_AddText(&(s->result),
+ " <FeatureType>\n" );
+ sprintf( line, " <Name>%s</Name>\n", result );
+ ecs_AddText(&(s->result), line );
+
+
+
+ sprintf( line, " <SRS>PROJ4:%s</SRS>\n", PROJ_LONGLAT );
+ ecs_AddText(&(s->result),line);
+
+ sprintf(line,
+ " <LatLonBoundingBox minx=\"%.9f\" miny=\"%.9f\"\n"
+ " maxx=\"%.9f\" maxy=\"%.9f\" />\n",
+ entry->nw_long, entry->se_lat,
+ entry->se_long, entry->nw_lat );
+
+ ecs_AddText(&(s->result),line);
+
+ sprintf(line,
+ " <BoundingBox minx=\"%.9f\" miny=\"%.9f\"\n"
+ " maxx=\"%.9f\" maxy=\"%.9f\"\n"
+ " resx=\"%.9f\" resy=\"%.9f\" />\n",
+ entry->nw_long, entry->se_lat,
+ entry->se_long, entry->nw_lat,
+ entry->horiz_interval, entry->vert_interval );
+ ecs_AddText(&(s->result),line);
+
+ ecs_AddText(&(s->result),
+ " <Family>Matrix</Family>\n"
+ " <Family>Image</Family>\n"
+ " </FeatureType>\n" );
+ }
+
+ ecs_AddText(&(s->result),
+ " </FeatureTypeList>\n"
+ "</OGDI_Capabilities>\n" );
+ ecs_SetSuccess(&(s->result));
+ }
+ else if( strcmp(info,"") == 0 )
+ {
+ ecs_SetText(&(s->result)," ");
+
+ for (i=0; i<(int)toc->num_boundaries; i++)
+ {
+ if (toc->entries[i].invalid_geographics == 1L)
+ continue;
+
+ sprintf(buffer,"%s@%s@%s@%s@%d",toc->entries[i].scale,
+ toc->entries[i].zone,toc->entries[i].type,
+ toc->entries[i].producer,toc->entries[i].boundary_id);
+
+ /* Remove the spaces */
+ k = 0;
+ for(j=0;j<(int) strlen(buffer);j++) {
+ if (buffer[j] != ' ') {
+ result[k] = buffer[j];
+ k++;
+ }
+ }
+ result[k] = '\0';
+
+ if (!(ecs_AddText(&(s->result),result))) {
+ return &(s->result);
+ }
+
+ if (!(ecs_AddText(&(s->result)," "))) {
+ return &(s->result);
+ }
+ }
+
+ ecs_SetSuccess(&(s->result));
+ }
+ else
+ {
+ char emsg[129];
+
+ sprintf( emsg, "RPF driver UpdateDictionary(%s) unsupported.", info );
+
+ ecs_SetError(&(s->result), 1, emsg );
+ }
+
+ return &(s->result);
+
+}
+
+
+
+/* ----------------------------------------------------------------------
+ * _dyn_GetServerProjection:
+ *
+ * Return this server cartographic projection
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetServerProjection(s)
+ ecs_Server *s;
+{
+ ecs_SetText(&(s->result), PROJ_LONGLAT);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * _dyn_GetGlobalBound:
+ *
+ * Return this server global bounding region
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_GetGlobalBound(s)
+ ecs_Server *s;
+{
+ ecs_SetGeoRegion(&(s->result),s->globalRegion.north, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.west, s->globalRegion.ns_res,
+ s->globalRegion.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_SetServerLanguage:
+ *
+ * Set this server lnaguage for error message; not yet implemented
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetServerLanguage(s,language)
+ ecs_Server *s;
+ u_int language;
+{
+ (void) language;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,24 @@
+LIBRARY RPF
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_CreateServer
+ dyn_DestroyServer
+ dyn_SelectLayer
+ dyn_ReleaseLayer
+ dyn_SelectRegion
+ dyn_GetDictionary
+ dyn_GetNextObject
+ dyn_UpdateDictionary
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_GetRasterInfo
+ dyn_GetObject
+ dyn_GetObjectIdFromCoord
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_SetServerLanguage
+ dyn_GetAttributesFormat
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/rpf.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,586 @@
+/******************************************************************************
+ *
+ * Component: OGDI RPF Driver
+ * Purpose: Declarations of RPF driver structures and functions.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: rpf.h,v $
+ * Revision 1.7 2007/02/12 21:01:48 cbalint
+ * Fix win32 target. It build and works now. (tested with VC6)
+ *
+ * Revision 1.6 2007/02/12 16:09:06 cbalint
+ * * Add hook macros for all GNU systems, hook fread,fwrite,read,fgets.
+ * * Handle errors in those macro, if there are any.
+ * * Fix some includes for GNU systems.
+ * * Reduce remaining warnings, now we got zero warnings with GCC.
+ *
+ * Modified Files:
+ * config/unix.mak contrib/ogdi_import/dbfopen.c
+ * contrib/ogdi_import/shapefil.h contrib/ogdi_import/shpopen.c
+ * ogdi/c-api/ecs_xdr.c ogdi/c-api/ecsinfo.c ogdi/c-api/server.c
+ * ogdi/datum_driver/canada/nadconv.c ogdi/driver/adrg/adrg.c
+ * ogdi/driver/adrg/adrg.h ogdi/driver/adrg/object.c
+ * ogdi/driver/adrg/utils.c ogdi/driver/rpf/rpf.h
+ * ogdi/driver/rpf/utils.c ogdi/gltpd/asyncsvr.c
+ * ogdi/glutil/iofile.c vpflib/vpfprim.c vpflib/vpfspx.c
+ * vpflib/vpftable.c vpflib/vpftidx.c vpflib/xvt.h
+ *
+ * Revision 1.5 2001/04/12 19:22:46 warmerda
+ * applied DND support Image type support
+ *
+ */
+
+#ifndef RPF_H
+#define RPF_H 1
+
+#include "ecs.h"
+#include <sys/stat.h>
+#ifdef _WINDOWS
+#include <direct.h>
+#include "compat/dirent.h"
+#else
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
+#endif
+#ifdef _WINDOWS
+#include <io.h>
+#endif
+#include <fcntl.h>
+#include <string.h>
+
+#include <ogdi_macro.h>
+
+
+#ifndef max
+#define max(x,y) ((x > y) ? x : y)
+#endif
+
+#define ushort unsigned short
+#define uint unsigned int
+/* typedef's conflict with /usr/include/sys/types.h
+typedef unsigned short ushort;
+typedef unsigned long uint;
+*/
+typedef unsigned char bool;
+typedef unsigned char uchar;
+typedef unsigned char* ucharp;
+typedef char ascii;
+typedef float real4;
+typedef double real8;
+
+#ifndef BOOLEAN
+#define BOOLEAN short
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+#define BOOL_TRUE 0xFF
+#define BOOL_FALSE 0
+
+#define LOC_BOUNDARIES 3
+#define LOC_FRAMES 4
+
+#define LOC_COVERAGE 6
+#define LOC_COMPRESSION 8
+#define LOC_CLUT 9
+#define LOC_IMAGE 10
+
+#define LOC_HEADER_SECTION 128
+#define LOC_LOCATION_SECTION 129
+#define LOC_COVERAGE_SECTION 130
+#define LOC_COMPRESSION_SECTION 131
+#define LOC_COMPRESSION_LOOKUP_SUBSECTION 132
+#define LOC_COMPRESSION_PARAMETER_SUBSECTION 133
+#define LOC_COLORGRAY_SECTION_SUBHEADER 134
+#define LOC_COLORMAP_SUBSECTION 135
+#define LOC_IMAGE_DESCR_SUBHEADER 136
+#define LOC_IMAGE_DISPLAY_PARAM_SUBHEADER 137
+#define LOC_MASK_SUBSECTION 138
+#define LOC_COLOR_CONVERTOR_SUBSECTION 139
+#define LOC_SPATIAL_DATA_SUBSECTION 140
+#define LOC_ATTRIBUTE_SECTION_SUBHEADER 141
+#define LOC_ATTRIBUTE_SUBSECTION 142
+#define LOC_EXPLICIT_AREAL_TABLE 143
+#define LOC_RELATED_IMAGE_SECTION_SUBHEADER 144
+#define LOC_RELATED_IMAGE_SUBSECTION 145
+#define LOC_REPLACE_UPDATE_SECTION_SUBHEADER 146
+#define LOC_REPLACE_UPDATE_TABLE 147
+#define LOC_BOUNDARY_SECTION_SUBHEADER 148
+#define LOC_BOUNDARY_RECTANGLE_TABLE 149
+#define LOC_FRAME_FILE_INDEX_SUBHEADER 150
+#define LOC_FRAME_FILE_INDEX_SUBSECTION 151
+#define LOC_COLOR_TABLE_SECTION_SUBHEADER 152
+#define LOC_COLOR_TABLE_INDEX_RECORD 153
+
+typedef enum _rpf_type
+{
+ RPF_CADRG,
+ RPF_CIB,
+ RPF_CDTED
+} Rpf_type;
+
+typedef struct header
+{
+ bool endian;
+ ushort hdr_sec_len; /* header section length */
+ ascii filename[12];
+ uchar new;
+ ascii standard_num[15];
+ ascii standard_date[8];
+ ascii classification;
+ ascii country[2];
+ ascii release[2];
+ uint loc_sec_phys_loc; /* location section physical location */
+ uint loc_sec_log_loc; /* location section logical location */
+ uint cadrg_or_cib;
+ Rpf_type rpf_type;
+ int NITF_hdr_len;
+} Header;
+
+
+typedef struct location
+{
+ ushort id;
+ uint length; /* section/component length */
+ uint phys_index; /* section/component physical location */
+ uint log_index; /* section/component logical location */
+} Location;
+
+#define CADRG_COLORS 216
+
+typedef struct rgb
+{
+ unsigned char r, g, b, alpha;
+} Rgb;
+
+#define RGPF_TOC "a.toc"
+
+typedef struct boundary
+{
+ ascii type[8];
+ ascii compression[6];
+ ascii scale[18];
+ ascii zone[2];
+ ascii producer[6];
+ real8 nw_lat, nw_long;
+ real8 sw_lat, sw_long;
+ real8 ne_lat, ne_long;
+ real8 se_lat, se_long;
+ real8 vert_interval, horiz_interval;
+ real8 vert_resolution, horiz_resolution;
+ uint vert_frames, horiz_frames;
+} Boundary;
+
+
+typedef struct frame_index
+{
+ ushort boundary_id;
+ ushort frame_row, frame_col;
+ ascii dir_number[3];
+ ascii filename[12];
+ ascii location[6];
+} Frame_index;
+
+typedef struct frame_entry
+{
+ int exists;
+ ushort frame_row;
+ ushort frame_col;
+ char *directory;
+ char filename[16];
+ char georef[7];
+} Frame_entry;
+
+
+typedef struct toc_entry
+{
+ real8 nw_lat, nw_long;
+ real8 sw_lat, sw_long;
+ real8 ne_lat, ne_long;
+ real8 se_lat, se_long;
+ real8 vert_interval, horiz_interval;
+ real8 vert_resolution, horiz_resolution;
+ int horiz_frames, vert_frames;
+ Frame_entry **frames;
+ ushort boundary_id;
+ ascii type[8];
+ ascii compression[6];
+ ascii scale[18];
+ ascii zone[2];
+ ascii producer[6];
+ ascii *title;
+ int invalid_geographics;
+} Toc_entry;
+
+typedef struct toc_file
+{
+ Header head;
+ Toc_entry *entries;
+ uint num_boundaries;
+} Toc_file;
+
+typedef struct coverage
+{
+ real8 nw_lat, nw_long;
+ real8 sw_lat, sw_long;
+ real8 ne_lat, ne_long;
+ real8 se_lat, se_long;
+ real8 vert_resolution, horiz_resolution;
+ real8 vert_interval, horiz_interval;
+} Coverage;
+
+
+typedef struct compression
+{
+ ushort algorithm;
+ ushort noff_recs;
+ ushort nparm_off_recs;
+ ushort tables;
+ ushort table_length;
+ ushort parameters;
+ ushort para_length;
+} Compression;
+
+
+typedef struct lookup_table
+{
+ ushort id;
+ uint records;
+ ushort values;
+ ushort bit_length;
+ uint phys_offset;
+} Lookup_table;
+
+typedef struct comp_param
+{
+ ushort id;
+ uint rec_off;
+} Comp_parm;
+
+
+typedef struct color_table
+{
+ uchar colormaps;
+ ushort color_length;
+ uint table_index;
+ ascii filename[12];
+} Color_table;
+
+
+typedef struct color_offset
+{
+ ushort color_id;
+ uint records;
+ uchar length;
+ ushort hist_length;
+ uint offset_color_index;
+ uint offset_histogram_index;
+} Color_offset;
+
+
+typedef struct rpf_image
+{
+ ushort spectral_groups;
+ ushort subframe_tables;
+ ushort spectral_tables;
+ ushort spectral_lines;
+ ushort horiz_subframes, vert_subframes;
+ uint output_cols, output_rows;
+} RPF_image;
+
+
+typedef struct attribute
+{
+ ascii curr_date[8];
+ ascii prod_date[8];
+ ascii sig_date[8];
+ ascii series_code[2];
+ ascii map_code[8];
+ ascii old_datum_code[4];
+ ascii edition_id[8];
+ ascii proj_code[2];
+ real4 parameters[4];
+ ushort vert_datum_code;
+ ushort horiz_datum_code;
+ uint vert_abs_acc;
+ ushort vert_abs_units;
+ uint horiz_abs_acc;
+ ushort horiz_abs_units;
+ uint vert_rel_acc;
+ ushort vert_rel_units;
+ uint horiz_rel_acc;
+ ushort horiz_rel_units;
+ ushort ellips_code;
+ ascii sound_datum_code;
+ ushort nav_code;
+ short grid_code;
+ real4 east_mag_chg;
+ ushort east_mag_units;
+ real4 west_mag_chg;
+ ushort west_mag_units;
+ real4 grid_north;
+ ushort grid_north_units;
+ short max_elev;
+ ushort max_elev_units;
+ real8 max_elev_lat;
+ real8 max_elev_lon;
+} Attribute;
+
+
+typedef struct replace
+{
+ ascii new_filename[12];
+ ascii old_filename[12];
+ ascii repupd_status;
+} Replace;
+
+
+typedef struct display1
+{
+ bool all_subframes;
+ bool no_transparent;
+ ushort subframe_seq_length;
+ ushort transparent_seq_length;
+ uint image_rows;
+ uint image_codes;
+ uchar code_length;
+ uint transparent_value;
+} Display1;
+
+typedef struct frame_file
+{
+ Frame_entry entry;
+ Header head;
+ Coverage cover;
+ Compression compr;
+ uint loc_lut_shdr;
+ Lookup_table lut[4];
+ uint comp_parm_shdr;
+ Comp_parm *comp;
+ uint indices[6][6];
+ uint loc_data;
+ RPF_image img;
+ Attribute att;
+ Replace repupd;
+ bool all_subframes;
+ int NITF_hdr_len;
+} Frame_file;
+
+extern void check_swap _ANSI_ARGS_((unsigned char little_endian));
+extern void swap _ANSI_ARGS_((unsigned char *ptr, size_t count));
+
+extern Toc_entry *parse_toc _ANSI_ARGS_((ecs_Server *s, char *, Header *, uint *));
+extern int parse_locations _ANSI_ARGS_((ecs_Server *s, FILE *, Location *, int));
+extern int parse_clut _ANSI_ARGS_((ecs_Server *s, Frame_file *, char *, Rgb *,int,uint *, int, uint *, uchar *));
+extern int parse_frame _ANSI_ARGS_((ecs_Server *s, Frame_file *, char *));
+
+extern BOOLEAN get_comp_lut _ANSI_ARGS_((ecs_Server *s, Frame_file *file, char *, uchar *table, uint *cct, int ReducedColorTable));
+extern BOOLEAN get_rpf_image_tile _ANSI_ARGS_((ecs_Server *s, Frame_file *, char *, int tno, unsigned char *table, uchar *tile, int decompress, uchar blackpixel));
+extern void free_toc _ANSI_ARGS_((Toc_file *toc));
+
+/* Categories table */
+
+typedef struct {
+ unsigned int r, g, b;
+ int count;
+} CatTable;
+
+typedef struct {
+ int isActive;
+ unsigned char data[65536]; /* 256*256 Sub frames */
+} tile_mem;
+
+/*
+********************************************************************
+
+STRUCTURE_INFORMATION
+
+NAME
+
+ LayerPrivateData
+
+DESCRIPTION
+
+ structure for storing informations need by a OGDI layer in RPF
+
+END_DESCRIPTION
+
+ATTRIBUTES
+
+ Toc_entry *entry: Pointer to the table of content for this layer
+ int tile_row: Current tile row in the tile table of this layer
+ int tile_col: Current tile col in the tile table of this layer
+ int isActive: Indicate if the layer information contain a tile or not.
+ int rows: Number of rows of the current tile
+ int columns: Number of columns of the current tile
+ unsigned int mincat: Minimum number of categories of the current tile
+ unsigned int maxcat: Maximum number of categories of the current tile
+ int firstcoordfilepos: First position in the file of the current tile
+ Frame_file *ff: Header file information for the current tile
+ Rgb *rgb_pal: Table of colors
+ int equi_cat[255]: Table of correspondance between each value in the rgb_pal and the 6x6x6 color table.
+ uint n_pal_cols: Number of colors in the rgb_pal table
+ uchar *rpf_table: The rpf table
+ uchar blackpixel: The blackpixel value
+ uint *cct: The cct
+ int boundary_num: Boundary number
+ int firsttile: Number of the first tile
+ tile_mem *buffertile: Buffer tile list (each tile contain a 6x6 subtiles)
+ ecs_TileStructure tilestruct: The tile structure used by the tile handler library
+ unsigned int isColor: Indicate if the table is in color or not
+END_ATTRIBUTES
+
+END_STRUCTURE_INFORMATION
+
+********************************************************************
+*/
+
+typedef struct {
+
+ Toc_entry *entry;
+ int tile_row;
+ int tile_col;
+ int isActive;
+ int rows;
+ int columns;
+ unsigned int mincat;
+ unsigned int maxcat;
+ int firstcoordfilepos;
+ Frame_file *ff;
+ Rgb *rgb_pal;
+ int equi_cat[255];
+ uint n_pal_cols;
+ uchar *rpf_table;
+ uchar blackpixel;
+ uint *cct;
+ int boundary_num;
+ int firsttile;
+ tile_mem *buffertile;
+ ecs_TileStructure tilestruct;
+ unsigned int isColor;
+
+} LayerPrivateData;
+
+/*
+********************************************************************
+
+STRUCTURE_INFORMATION
+
+NAME
+
+ ServerPrivateData
+
+DESCRIPTION
+
+ structure for storing global informations for the driver rpf
+
+END_DESCRIPTION
+
+ATTRIBUTES
+
+ char *pathname: The directory path where the database is located in the hard-disk.
+ Toc_file *toc: The table of content of the rpf database.
+
+END_ATTRIBUTES
+
+END_STRUCTURE_INFORMATION
+
+********************************************************************
+*/
+
+typedef struct {
+
+ char *pathname;
+ Toc_file *toc;
+
+} ServerPrivateData;
+
+/* private functions prototype */
+
+int dyn_prepare_rpflayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l));
+int dyn_read_rpftile _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,int tile_row,int tile_col));
+int dyn_verifyLocation _ANSI_ARGS_((ecs_Server *s));
+int dyn_initRegionWithDefault _ANSI_ARGS_((ecs_Server *s));
+void check_swap _ANSI_ARGS_((unsigned char little_endian));
+void swap _ANSI_ARGS_((unsigned char *ptr, size_t count));
+Toc_entry *parse_toc _ANSI_ARGS_((ecs_Server *s, char *dir, Header *head, uint *num_boundaries));
+int parse_locations _ANSI_ARGS_((ecs_Server *s, FILE *fin, Location *locs, int count));
+int parse_clut _ANSI_ARGS_((ecs_Server *s,Frame_file *frame,char *filename,
+ Rgb *rgb,int ReducedColorTable,uint *cct,int Nitf_hdr_len,
+ uint *n_cols,uchar *blackpixel));
+int parse_frame _ANSI_ARGS_((ecs_Server *s,Frame_file *file,char *filename));
+BOOLEAN get_comp_lut _ANSI_ARGS_((ecs_Server *s,Frame_file *file,char *filename,
+ uchar *table, uint *cct,int ReducedColorTable));
+BOOLEAN get_rpf_image_tile _ANSI_ARGS_((ecs_Server *s,Frame_file *file,char *filename,int tno,
+ uchar *table,uchar *tile,int decompress,uchar blackpixel));
+void free_toc _ANSI_ARGS_((Toc_file *toc));
+
+/* objects functions */
+
+void dyn_getNextObjectRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l));
+void dyn_rewindRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l));
+int dyn_PointCallBack _ANSI_ARGS_((ecs_Server *s,ecs_TileStructure *t,int xtile,int ytile,
+ int xpixel,int ypixel,int *cat));
+int dyn_ImagePointCallBack _ANSI_ARGS_((ecs_Server *s,ecs_TileStructure *t,int xtile,int ytile,
+ int xpixel,int ypixel,int *cat));
+int dyn_DimCallBack _ANSI_ARGS_((ecs_Server *s,ecs_TileStructure *t,
+ double x,double y,int *width,int *height));
+
+/* layer oriented method definition */
+void dyn_openRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void dyn_closeRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void dyn_rewindRasterLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void dyn_getNextObjectRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void dyn_getObjectRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, char *objectId));
+void dyn_getObjectIdRaster _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, ecs_Coordinate *coord));
+int _calcPosValue _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,int i,int j));
+void dyn_openImageLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void dyn_closeImageLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void dyn_rewindImageLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void dyn_getNextObjectImage _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void dyn_getObjectImage _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, char *objectId));
+void dyn_getObjectIdImage _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, ecs_Coordinate *coord));
+int _calcImagePosValue _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,int i,int j));
+
+/* layer oriented method are keeped into a single data structure to simplify the code */
+
+typedef void layerfunc();
+typedef void layerobfunc();
+typedef void layercoordfunc();
+
+
+typedef struct {
+ layerfunc *open;
+ layerfunc *close;
+ layerfunc *rewind;
+ layerfunc *getNextObject;
+ layerobfunc *getObject;
+ layercoordfunc *getObjectIdFromCoord;
+} LayerMethod;
+
+void dyn_calPosWithCoord _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,double pos_x,double pos_y,int *i,int *j));
+int dyn_IsOutsideRegion _ANSI_ARGS_((double n, double s, double e,double w, ecs_Region *x));
+void dyn_releaseAllLayers _ANSI_ARGS_((ecs_Server *s));
+
+/*
+#define tprintf(A) printf(A)
+*/
+
+#define tprintf(A)
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/utils.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/utils.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/rpf/utils.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,2218 @@
+/******************************************************************************
+ *
+ * Component: OGDI RPF Driver
+ * Purpose: Implementation of various RPF support functions.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: utils.c,v $
+ * Revision 1.9 2007/02/12 16:09:06 cbalint
+ * * Add hook macros for all GNU systems, hook fread,fwrite,read,fgets.
+ * * Handle errors in those macro, if there are any.
+ * * Fix some includes for GNU systems.
+ * * Reduce remaining warnings, now we got zero warnings with GCC.
+ *
+ * Modified Files:
+ * config/unix.mak contrib/ogdi_import/dbfopen.c
+ * contrib/ogdi_import/shapefil.h contrib/ogdi_import/shpopen.c
+ * ogdi/c-api/ecs_xdr.c ogdi/c-api/ecsinfo.c ogdi/c-api/server.c
+ * ogdi/datum_driver/canada/nadconv.c ogdi/driver/adrg/adrg.c
+ * ogdi/driver/adrg/adrg.h ogdi/driver/adrg/object.c
+ * ogdi/driver/adrg/utils.c ogdi/driver/rpf/rpf.h
+ * ogdi/driver/rpf/utils.c ogdi/gltpd/asyncsvr.c
+ * ogdi/glutil/iofile.c vpflib/vpfprim.c vpflib/vpfspx.c
+ * vpflib/vpftable.c vpflib/vpftidx.c vpflib/xvt.h
+ *
+ * Revision 1.8 2004/03/29 05:18:05 warmerda
+ * Added check for FSDEVG field when reading TOC file (in parse_toc).
+ * Apparently needed for CIB1 data, as per bug 917678.
+ *
+ * Revision 1.7 2001/06/26 18:14:55 warmerda
+ * implement rpf_fopen_ci() to case insenstive file access
+ *
+ * Revision 1.6 2001/04/12 19:22:46 warmerda
+ * applied DND support Image type support
+ *
+ */
+
+#include "rpf.h"
+
+ECS_CVSID("$Id: utils.c,v 1.9 2007/02/12 16:09:06 cbalint Exp $");
+
+void dyn_string_tolower(char *);
+
+#ifdef _WINDOWS
+#define DIR_CHAR '\\'
+#else
+#define DIR_CHAR '/'
+#endif
+
+/*
+** rpf_fopen_ci()
+**
+** Cover for fopen() that can open a file with either upper
+** case or lower case. Allows grabbing of a.toc or A.TOC on
+** Unix regardless of how the data came off CD.
+*/
+
+static FILE *rpf_fopen_ci( const char *dir, const char *file,
+ const char *access )
+{
+ char *filename = malloc(strlen(dir)+strlen(file)+3);
+ FILE *fp;
+ int i;
+
+ if( filename == NULL )
+ return NULL;
+
+ if( dir[strlen(dir)-1] == '/' || dir[strlen(dir)-1] == '\\' )
+ sprintf( filename, "%s%s", dir, file );
+ else
+ sprintf( filename, "%s%c%s", dir, DIR_CHAR, file );
+
+ /* try natural */
+ fp = fopen( filename, access );
+
+ /* try upper case */
+ if( fp == NULL )
+ {
+ for( i = strlen(dir); filename[i] != '\0'; i++ )
+ {
+ if( filename[i] >= 'a' && filename[i] <= 'z' )
+ filename[i] = filename[i] - 'a' + 'A';
+ }
+ fp = fopen( filename, access );
+ }
+
+ /* try lower case */
+ if( fp == NULL )
+ {
+ for( i = strlen(dir); filename[i] != '\0'; i++ )
+ {
+ if( filename[i] >= 'A' && filename[i] <= 'Z' )
+ filename[i] = filename[i] - 'A' + 'a';
+ }
+ fp = fopen( filename, access );
+ }
+
+/* printf( "fp=%p, filename=%s\n", fp, filename ); */
+
+ free( filename );
+
+ return fp;
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ _prepare_rpflayer
+
+DESCRIPTION
+
+ Initialize the current layer private structure with the layer resquest
+ information.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ l->priv must be set in memory and with default values.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ The layer structure is initialized.
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+
+ ecs_Server *s: The driver information
+ ecs_Layer *l: The current layer
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ int: Indicate if it's a success or a error situation.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ Parse the selection request and try to link the information
+ in it with the table of content. If the link is not found,
+ return an error message. If it's found, set the entry pointer
+ to this request.
+
+ Initialize tile structure with ecs_TileInitialize. The different
+ arguments are already in the table of content. If a problem occur,
+ return an error message.
+
+ Return a success message
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+int dyn_prepare_rpflayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ char *scale;
+ char *zone;
+ char *type;
+ char *producer;
+ char *boundid;
+ char *buffer;
+ int i,count,stringlen,val;
+ ecs_Region region;
+
+ /*
+ Parse the selection request and try to link the information
+ in it with the table of content. Simply scan the selection
+ string and put a pointer to the beginning of each substring.
+ */
+ scale = NULL;
+ zone = NULL;
+ type = NULL;
+ producer = NULL;
+ boundid = NULL;
+
+ buffer = malloc(strlen(l->sel.Select)+1);
+ if (buffer == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory");
+ return FALSE;
+ }
+ strcpy(buffer,l->sel.Select);
+ count = 0 ;
+ scale = buffer;
+ stringlen = strlen(buffer);
+ for (i=0;i<stringlen;i++) {
+ if (buffer[i] == '@') {
+ buffer[i] = '\0';
+ count++;
+
+ switch(count) {
+ case 1:
+ zone = &buffer[i+1];
+ break;
+ case 2:
+ type = &buffer[i+1];
+ break;
+ case 3:
+ producer = &buffer[i+1];
+ break;
+ case 4:
+ boundid = &buffer[i+1];
+ buffer[stringlen] = '\0';
+ break;
+ default:
+ ecs_SetError(&(s->result),1,"Bad request format. Expect scale at zone@rpf_type at producer@boundary_id");
+ free(buffer);
+ return FALSE;
+ }
+ }
+ }
+
+ if (boundid == NULL) {
+ ecs_SetError(&(s->result),1,"Bad request format. Expect scale at zone@rpf_type at producer@boundary_id");
+ free(buffer);
+ return FALSE;
+ }
+
+ val = atoi(boundid);
+
+ /* Found an entry in the toc with these four informations. If it's not there, return an error. */
+
+ for(i=0; i<(int) spriv->toc->num_boundaries; i++) {
+#if 0
+ printf("scale:%s\n",spriv->toc->entries[i].scale);
+ printf("zone:%s\n",spriv->toc->entries[i].zone);
+ printf("type:%s\n",spriv->toc->entries[i].type);
+ printf("producer:%s\n",spriv->toc->entries[i].producer);
+ printf("boundary:%d\n",spriv->toc->entries[i].boundary_id);
+ printf("---------------------\n");
+#endif
+ if (strstr(spriv->toc->entries[i].scale,scale) != NULL) {
+ if (strstr(spriv->toc->entries[i].zone,zone) != NULL) {
+ if (strstr(spriv->toc->entries[i].type,type) != NULL) {
+ if (strstr(spriv->toc->entries[i].producer,producer) != NULL) {
+ if (val == spriv->toc->entries[i].boundary_id) {
+ lpriv->entry = &(spriv->toc->entries[i]);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (lpriv->entry == NULL) {
+ ecs_SetError(&(s->result),1,"This request don't exist in the table of content of RPF");
+ free(buffer);
+ return FALSE;
+ }
+
+ free(buffer);
+
+ /*
+ Initialize tile structure with ecs_TileInitialize. The differents
+ arguments are already in the table of content.
+ */
+
+ region.north = lpriv->entry->nw_lat;
+ region.south = lpriv->entry->sw_lat;
+ region.east = lpriv->entry->ne_long;
+ region.west = lpriv->entry->nw_long;
+ region.ns_res = (region.north - region.south) / (1536*lpriv->entry->vert_frames);
+ region.ew_res = (region.east - region.west) / (1536*lpriv->entry->horiz_frames);
+
+ if (l->sel.F == Matrix) {
+ if (!ecs_TileInitialize( s, &(lpriv->tilestruct), &(region),
+ lpriv->entry->horiz_frames, lpriv->entry->vert_frames,
+ 1536, 1536, dyn_PointCallBack, NULL)) {
+ ecs_SetError(&(s->result), 1, "Unable to retrieve tile structure.");
+ return FALSE;
+ }
+ } else {
+ if (!ecs_TileInitialize( s, &(lpriv->tilestruct), &(region),
+ lpriv->entry->horiz_frames, lpriv->entry->vert_frames,
+ 1536, 1536, dyn_ImagePointCallBack, NULL)) {
+ ecs_SetError(&(s->result), 1, "Unable to retrieve tile structure.");
+ return FALSE;
+ }
+ }
+
+ /* Check if it's a black and white image */
+
+ lpriv->isColor = TRUE;
+ if (strstr(spriv->toc->entries[i].type,"CIB") != NULL) {
+ lpriv->isColor = FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ _read_rpftile
+
+DESCRIPTION
+
+ Initialize the current layer private structure with the layer resquest
+ information.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ A dyn_SelectLayer must have been call previously succesfully.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ The layer structure contain a complete tile for the position
+ tile_row and tile_col in the tile grid.
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+
+ ecs_Server *s: The driver information
+ ecs_Layer *l: The current layer
+ int tile_row: The requested tile row
+ int tile_col: The requested tile column.
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ int: Indicate if it's a success or a error situation.
+
+END_FUNCTION_INFORMATION
+
+PSEUDOCODE
+
+ If tile_row and tile_col is the same than the one in lpriv,
+ return a success.
+
+ Free the previous tile in the layer. If isActive is true, erase
+ all the substructures related to this layer (except entry and
+ tilestruct).
+
+ Allocate lpriv->ff. If a problem occur, set isActive to false
+ and return an error message.
+
+ Parse the frame with parse_frame. The framefile name is in the TOC.
+ If a problem occur, set isActive to false and return an error message.
+
+ With the header of ff, calculate the region of the current tile and
+ the attributes lpriv->columns and lpriv->rows.
+
+ origin_lat = lpriv->ff->cover.nw_lat - 1536.E0*lpriv->ff->cover.vert_interval;
+ origin_lon = lpriv->ff->cover.nw_long + 1536.E0*lpriv->ff->cover.horiz_interval;
+ lon_spacing = lpriv->ff->cover.horiz_interval;
+ lat_spacing = lpriv->ff->cover.vert_interval;
+ lpriv->columns = 1536L;
+ lpriv->rows = 1536L;
+ lpriv->region.north = origin_lat+1+lat_spacing/2;
+ lpriv->region.south = origin_lat-lat_spacing/2;
+ lpriv->region.west = origin_lon-lon_spacing/2;
+ lpriv->region.east = origin_lon+1+lon_spacing/2;
+ lpriv->region.ns_res = (lpriv->region.north - lpriv->region.south) / lpriv->rows;
+ lpriv->region.ew_res = (lpriv->region.east - lpriv->region.west) / lpriv->columns;
+
+ Allocate lpriv->rgb_pal, the color palette. If a problem occur,
+ set isActive to false and return an error message.
+
+ Allocate lpriv->cct. If a problem occur, set isActive to false
+ and return an error message.
+
+ Allocate lpriv->rpf_table. If a problem occur,
+ set isActive to false and return an error message.
+
+ Call parse_clut.
+
+ Call get_comp_lut.
+
+ Allocate the tile buffer. If a problem occur,
+ set isActive to false and return an error message.
+
+ For each value i between 0 and 6
+ Begin
+
+ For each value j between 0 and 6
+ Begin
+
+ Call get_rpf_image_tile for the tile i*6+j.
+ Set lpriv->buffertile[i*6+j].isActive to true.
+
+ End
+
+ End
+
+ Set equi_cat with the color category equivalence
+
+ Return a success message.
+
+END_PSEUDOCODE
+
+*******************************************************************
+*/
+
+int dyn_read_rpftile(s, l, tile_row, tile_col)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int tile_row;
+ int tile_col;
+{
+ double origin_lon, origin_lat;
+ double lat_spacing, lon_spacing;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int i,j,k;
+ char *framefile;
+ const char *dir;
+
+ /*
+ Check if tile_row and tile_col is the same than the one in lpriv.
+ */
+
+ if ((tile_row == lpriv->tile_row) &&
+ (tile_col == lpriv->tile_col)) {
+ return TRUE;
+ }
+
+ /* Free the previous tile in the layer */
+
+ if (lpriv->ff != NULL)
+ free(lpriv->ff);
+ if (lpriv->rgb_pal != NULL)
+ free(lpriv->rgb_pal);
+ if (lpriv->rpf_table != NULL)
+ free(lpriv->rpf_table);
+ if (lpriv->cct != NULL)
+ free(lpriv->cct);
+ if (lpriv->buffertile != NULL)
+ free(lpriv->buffertile);
+ lpriv->tile_row = tile_row;
+ lpriv->tile_col = tile_col;
+ lpriv->mincat = 0;
+ lpriv->maxcat = 0;
+ lpriv->firstcoordfilepos = 0;
+ lpriv->ff = NULL;
+ lpriv->rgb_pal = NULL;
+ lpriv->n_pal_cols = 0;
+ lpriv->rpf_table = NULL;
+ lpriv->blackpixel = 0;
+ lpriv->cct = NULL;
+ lpriv->boundary_num = 0;
+ lpriv->firsttile = 0;
+ lpriv->buffertile = NULL;
+ lpriv->isActive = lpriv->entry->frames[tile_col][tile_row].exists;
+ lpriv->rows = lpriv->entry->frames[tile_col][tile_row].frame_row;
+ lpriv->columns = lpriv->entry->frames[tile_col][tile_row].frame_col;
+
+ if (lpriv->isActive == FALSE)
+ return TRUE;
+
+ lpriv->ff = (Frame_file *)malloc(sizeof(Frame_file));
+ if (lpriv->ff == NULL) {
+ ecs_SetError(&(s->result),1,"not enough memory");
+ return FALSE;
+ }
+
+ /* Create the framefile string */
+
+ framefile = malloc(strlen(lpriv->entry->frames[tile_col][tile_row].directory)+
+ strlen(lpriv->entry->frames[tile_col][tile_row].filename)+3);
+ if (framefile == NULL) {
+ lpriv->isActive = FALSE;
+ ecs_SetError(&(s->result),1,"Cannot parse frame file");
+ free(lpriv->ff);
+ lpriv->ff = NULL;
+ return FALSE;
+ }
+
+ dir = lpriv->entry->frames[tile_col][tile_row].directory;
+
+ if( dir[strlen(dir)-1] == '\\' || dir[strlen(dir)-1] == '/' )
+ sprintf( framefile, "%s%s", dir,
+ lpriv->entry->frames[tile_col][tile_row].filename);
+ else
+ sprintf( framefile, "%s%c%s", dir, DIR_CHAR,
+ lpriv->entry->frames[tile_col][tile_row].filename);
+
+ /* Parse the frame */
+
+ if (!parse_frame(s, lpriv->ff, framefile)) {
+ lpriv->isActive = FALSE;
+ free(framefile);
+ ecs_SetError(&(s->result),1,"Cannot parse frame file");
+ free(lpriv->ff);
+ lpriv->ff = NULL;
+ return FALSE;
+ }
+
+ origin_lat = lpriv->ff->cover.nw_lat - 1536.E0*lpriv->ff->cover.vert_interval;
+ origin_lon = lpriv->ff->cover.nw_long + 1536.E0*lpriv->ff->cover.horiz_interval;
+ lon_spacing = lpriv->ff->cover.horiz_interval;
+ lat_spacing = lpriv->ff->cover.vert_interval;
+
+ lpriv->columns = 1536L;
+ lpriv->rows = 1536L;
+
+ lpriv->rgb_pal = (Rgb *) malloc(217L*sizeof(Rgb));
+ if (lpriv->rgb_pal == NULL)
+ {
+ lpriv->isActive = FALSE;
+ free(framefile);
+ ecs_SetError(&(s->result),1,"not enough memory to load rpf matrix in ram");
+ return FALSE;
+ }
+
+ lpriv->cct = (uint *)malloc(256L*sizeof(uint));
+ if (lpriv->cct == NULL)
+ {
+ lpriv->isActive = FALSE;
+ free(framefile);
+ ecs_SetError(&(s->result),1,"not enough memory to load rpf cct in ram");
+ return FALSE;
+ }
+ lpriv->rpf_table = (uchar *)malloc(4096L*4L*4L);
+ if (lpriv->rpf_table == NULL)
+ {
+ lpriv->isActive = FALSE;
+ free(framefile);
+ ecs_SetError(&(s->result),1,"not enough memory to load rpf table in ram");
+ return FALSE;
+ }
+
+ parse_clut(s, lpriv->ff, framefile, lpriv->rgb_pal, 0L, lpriv->cct, lpriv->ff->NITF_hdr_len, &lpriv->n_pal_cols, &lpriv->blackpixel);
+
+ get_comp_lut(s, lpriv->ff, framefile, lpriv->rpf_table, lpriv->cct, 0L);
+
+ /* Read the data info if isInRam is true */
+
+ lpriv->buffertile = malloc(36*sizeof(tile_mem));
+ for (i=0; i<6L; i++)
+ for (j=0; j<6L; j++)
+ {
+ k = i*6+j;
+ get_rpf_image_tile(s, lpriv->ff, framefile, (int)lpriv->ff->indices[i][j], lpriv->rpf_table, lpriv->buffertile[k].data, 1L, lpriv->blackpixel);
+ lpriv->buffertile[k].isActive = TRUE;
+ }
+
+ for(i=0;i<(int) lpriv->n_pal_cols;i++) {
+ if (lpriv->isColor == TRUE)
+ lpriv->equi_cat[i] =
+ (lpriv->rgb_pal[i].r/43)*36 +
+ (lpriv->rgb_pal[i].g/43)*6 +
+ lpriv->rgb_pal[i].b/43 + 1;
+ else
+ lpriv->equi_cat[i] = ((lpriv->rgb_pal[i].r + lpriv->rgb_pal[i].g + lpriv->rgb_pal[i].b)/3) + 1;
+ }
+
+ free(framefile);
+ return TRUE;
+}
+
+/*
+ ----------------------------------------------------------
+ _VerifyLocation:
+
+ check if the path is valid. Check if the directory exist
+ and check if the parent path contain a a.toc file.
+
+ ----------------------------------------------------------
+ */
+
+int
+dyn_verifyLocation(s)
+ ecs_Server *s;
+{
+ int returnvalue;
+ int lenght;
+ DIR *dirlist;
+ FILE *test;
+ register ServerPrivateData *spriv = s->priv;
+ char *ptr,*ptr1;
+
+ returnvalue = FALSE;
+
+ lenght = strlen(spriv->pathname);
+ /* Check if the path is valid */
+ dirlist = opendir(spriv->pathname);
+ if (dirlist != NULL) {
+ closedir(dirlist);
+ /* Check the parent directory */
+ ptr = ptr1 = spriv->pathname;
+ while(ptr[0]!='\0') {
+ if ((ptr[0]=='/') && (ptr[1]!='\0')) {
+ ptr1 = ptr;
+ }
+ ptr++;
+ }
+ ptr1++;
+ test = rpf_fopen_ci( spriv->pathname, RGPF_TOC, "r" );
+ if (test != NULL) {
+ fclose(test);
+ returnvalue = TRUE;
+ }
+ }
+
+ if (!returnvalue)
+ {
+ ecs_SetError(&(s->result),1,"Invalid URL. The rpf directory is invalid");
+ }
+ return returnvalue;
+}
+
+/*
+ -------------------------------------------------------------------------
+ _initRegionWithDefault:
+
+ preparation de la fenetre globale pour le server
+ --------------------------------------------------------------------------
+ */
+
+int dyn_initRegionWithDefault(s)
+ ecs_Server *s;
+{
+ int i;
+ register ServerPrivateData *spriv = s->priv;
+ Toc_file *toc;
+ Toc_entry *entry;
+ double lat_min, lat_max, lon_min, lon_max;
+
+ spriv->toc = (Toc_file *)malloc(sizeof(Toc_file));
+
+ spriv->toc->entries = parse_toc(s, spriv->pathname, &spriv->toc->head, &spriv->toc->num_boundaries);
+ if (spriv->toc->entries == (Toc_entry *)NULL)
+ {
+ return 0;
+ }
+ toc = spriv->toc;
+
+ lat_min = lon_min = 300.E0;
+ lat_max = lon_max = -300.E0;
+ for (i=0; i<(int)toc->num_boundaries; i++)
+ {
+ if (toc->entries[i].invalid_geographics == 1L)
+ continue;
+ entry = &toc->entries[i];
+ if (entry->nw_lat > lat_max) lat_max = entry->nw_lat;
+ if (entry->se_lat < lat_min) lat_min = entry->se_lat;
+ if (entry->se_long > lon_max) lon_max = entry->se_long;
+ if (entry->nw_long < lon_min) lon_min = entry->nw_long;
+ }
+
+ s->globalRegion.north = lat_max;
+ s->globalRegion.south = lat_min;
+ s->globalRegion.east = lon_max;
+ s->globalRegion.west = lon_min;
+
+ s->globalRegion.ns_res = (s->globalRegion.north - s->globalRegion.south)/2000.0;
+ s->globalRegion.ew_res = (s->globalRegion.east - s->globalRegion.west)/2000.0;
+
+ return 1;
+}
+
+
+int dyn_IsOutsideRegion(n,s,e,w,region)
+ double n,s,e,w;
+ ecs_Region *region;
+{
+ if ((n < region->south) ||
+ (s > region->north) ||
+ (e < region->west) ||
+ (w > region->east)) {
+ return 1;
+ }
+ return 0;
+}
+
+
+/***********************************************************************\
+*
+* Function: check_swap, swap
+*
+* Description:
+*
+* Handle endian-ness properly for this machine.
+*
+\***********************************************************************/
+
+static int do_swap;
+
+
+/*****
+ check_swap
+
+ Verify whether we need to perform byte swapping.
+*****/
+void check_swap(unsigned char little_endian)
+{
+ unsigned char *c_ptr;
+ unsigned short s;
+
+ s = 1;
+ c_ptr = (unsigned char *) &s;
+
+ do_swap = 0L;
+ if (*c_ptr == 0 && little_endian)
+ do_swap = 1L;
+ else if (*c_ptr == 1 && !little_endian)
+ do_swap = 1L;
+}
+
+
+/*****
+ swap
+
+ Swap the bytes if necessary.
+*****/
+void swap(unsigned char *ptr, size_t count)
+{
+ if (do_swap)
+ {
+ unsigned char *end, temp;
+
+ end = &ptr[count - 1];
+ while (end > ptr)
+ {
+ temp = *end;
+ *end = *ptr;
+ *ptr = temp;
+
+ ptr++, end--;
+ }
+ }
+}
+/***********************************************************************\
+*
+* Function: parse_toc
+*
+* Description:
+*
+* Read and parse the table of contents file.
+*
+\***********************************************************************/
+
+#ifdef _WINDOWS
+#define FILE_SEP '\\'
+#else
+#define FILE_SEP '/'
+#endif
+
+Toc_entry *parse_toc(ecs_Server *s, char *dir, Header *head, uint *num_boundaries)
+{
+ Toc_entry *entries, *entry;
+ Frame_entry *frame;
+
+ Location locations[4]; /* from 2 to 4 */
+ FILE *toc;
+ ushort n, path_length;
+ int i, j, k;
+ char *directory;
+ ushort boundary_id, frame_row, frame_col;
+ int new_boundary_ids=0L;
+ uint N_index_recs; /* # frame file index records */
+
+ uint path_off; /* offset of frame file pathname */
+ ushort Bound_rec_len; /* Boundary record length */
+ ushort N_pathname_recs; /* # frame file pathname records */
+ ushort Index_rec_len; /* frame file index record length */
+ uint bnd_rec_tbl_off; /* Bound. rect. table offset */
+ uint frm_index_tbl_off; /* Frame file index table offset */
+ char NITF[5];
+ char string[256];
+
+ /* Open input "A.TOC" */
+
+ toc = rpf_fopen_ci( dir, RGPF_TOC, "rb" );
+
+ if( toc == NULL )
+ {
+ sprintf(string, "parsetoc: Can't open %s",RGPF_TOC);
+ ecs_SetError(&(s->result),1,string);
+ return((Toc_entry *)NULL);
+ }
+
+ tprintf ("parsetoc: here 1\n");
+
+ /* Check for NITF header */
+
+ fseek(toc, 0, SEEK_SET);
+ ogdi_fread(NITF, 4L, 1, toc) ;
+ NITF[4] = '\0';
+ if (strcmp(NITF, "NITF") == 0) /* Match: skip NITF hdr */
+ {
+ char FSDWNG[6];
+
+ head->NITF_hdr_len = 410L;
+
+ /* Determine if conditional FSDEVG field exists */
+ /* by examining FSDWNG field */
+ /* Adjust hdr length by 40 characters if needed */
+ /* note: rpf/cib1 products need this */
+ fseek(toc, 280, SEEK_SET);
+ ogdi_fread(FSDWNG, 6L, 1, toc);
+ if( memcmp(FSDWNG, "999998", 6) == 0 )
+ head->NITF_hdr_len += 40L;
+ }
+ else /* not in NITF format */
+ {
+ head->NITF_hdr_len = 0L;
+ } /* else */
+
+ /* Skip over NITF header, if it is there. */
+
+ fseek(toc, head->NITF_hdr_len, SEEK_SET);
+
+ /* Read header */
+
+ ogdi_fread(&head->endian, sizeof(head->endian), 1, toc) ; /* 1 byte */
+ check_swap(head->endian);
+
+ ogdi_fread(&head->hdr_sec_len, sizeof(head->hdr_sec_len), 1, toc); /* 2 bytes */
+ swap((ucharp)&head->hdr_sec_len, sizeof(head->hdr_sec_len)) ;
+ ogdi_fread(head->filename, sizeof(head->filename), 1, toc); /* 12 bytes */
+
+ /* Read rest of header so we can write it later */
+
+ ogdi_fread(&head->new, sizeof(head->new), 1, toc) ;
+ ogdi_fread(head->standard_num, sizeof(head->standard_num), 1, toc) ;
+ ogdi_fread(head->standard_date, sizeof(head->standard_date), 1, toc);
+ ogdi_fread(&head->classification, sizeof(head->classification), 1, toc);
+ ogdi_fread(head->country, sizeof(head->country), 1, toc);
+ ogdi_fread(head->release, sizeof(head->release), 1, toc);
+ ogdi_fread(&head->loc_sec_phys_loc, sizeof(head->loc_sec_phys_loc), 1, toc) ;
+ swap((ucharp)&head->loc_sec_phys_loc,sizeof(head->loc_sec_phys_loc));
+
+ /* Fseek to start of location section */
+
+ fseek(toc, head->loc_sec_phys_loc, SEEK_SET);
+
+ /* Locate the correct sections */
+
+ locations[0].id = LOC_BOUNDARY_SECTION_SUBHEADER; /* 148 */
+ locations[1].id = LOC_BOUNDARY_RECTANGLE_TABLE; /* 149 */
+ locations[2].id = LOC_FRAME_FILE_INDEX_SUBHEADER; /* 150 */
+ locations[3].id = LOC_FRAME_FILE_INDEX_SUBSECTION; /* 151 */
+ parse_locations(s, toc, locations, 4L);
+
+ for (i = 0; i < 4; i++)
+ if ((int) locations[i].phys_index == ~0)
+ {
+ sprintf(string, "Can't locate section %d in table of contents",locations[i].id);
+ ecs_SetError(&(s->result),1,string);
+ return((Toc_entry *)NULL);
+ }
+ tprintf ("parsetoc: here 2\n");
+
+ /* Read boundary rectangles */
+ /* Number of Boundary records */
+
+ fseek(toc, locations[0].phys_index, SEEK_SET);
+ ogdi_fread(&bnd_rec_tbl_off, sizeof(bnd_rec_tbl_off), 1, toc);
+ swap((ucharp)&bnd_rec_tbl_off, sizeof(bnd_rec_tbl_off));
+ ogdi_fread(&n, sizeof(n), 1, toc);
+ swap((ucharp)&n, sizeof(n));
+
+ *num_boundaries = (int)n;
+ sprintf(string,"parse_toc: n = %d\n",n);
+ tprintf(string);
+
+ /* Boundary record length */
+
+ ogdi_fread(&Bound_rec_len, sizeof(Bound_rec_len), 1, toc) ;
+ swap((ucharp)&Bound_rec_len, sizeof(Bound_rec_len));
+
+ fseek(toc, locations[1].phys_index, SEEK_SET);
+
+ /* Read Boundary rectangle records */
+
+ entries = (Toc_entry *) malloc((size_t)n * sizeof(Toc_entry));
+ if (entries == (Toc_entry *)NULL)
+ {
+ ecs_SetError(&(s->result),1,"Error on malloc of entries");
+ return((Toc_entry *)NULL);
+ }
+ for (i = 0; i < (int)n; i++)
+ {
+ ogdi_fread(&entries[i].type, 1, 5, toc); /* e.g. "CADRG" */
+ entries[i].type[5] = '\0';
+ if (i == 0L)
+ {
+ if (strncmp(entries[i].type,"CADRG",5) == 0)
+ head->rpf_type = RPF_CADRG;
+ else if (strncmp(entries[i].type,"CIB",3) == 0)
+ head->rpf_type = RPF_CIB;
+ else if (strncmp(entries[i].type,"CDTED",5) == 0)
+ head->rpf_type = RPF_CDTED;
+ }
+ ogdi_fread(&entries[i].compression, 1, 5, toc);
+ ogdi_fread(&entries[i].scale, 1, 12, toc);
+ ogdi_fread(&entries[i].zone, 1, 1, toc);
+ ogdi_fread(&entries[i].producer, 1, 5, toc);
+
+ ogdi_fread(&entries[i].nw_lat, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].nw_long, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].sw_lat, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].sw_long, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].ne_lat, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].ne_long, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].se_lat, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].se_long, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].vert_resolution, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].horiz_resolution, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].vert_interval, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].horiz_interval, sizeof(real8), 1, toc);
+ ogdi_fread(&entries[i].vert_frames, sizeof(uint), 1, toc);
+ ogdi_fread(&entries[i].horiz_frames, sizeof(uint), 1, toc);
+
+ swap((ucharp)&entries[i].nw_lat, sizeof(real8));
+ swap((ucharp)&entries[i].nw_long, sizeof(real8));
+ swap((ucharp)&entries[i].sw_lat, sizeof(real8));
+ swap((ucharp)&entries[i].sw_long, sizeof(real8));
+ swap((ucharp)&entries[i].ne_lat, sizeof(real8));
+ swap((ucharp)&entries[i].ne_long, sizeof(real8));
+ swap((ucharp)&entries[i].se_lat, sizeof(real8));
+ swap((ucharp)&entries[i].se_long, sizeof(real8));
+ swap((ucharp)&entries[i].vert_resolution, sizeof(real8));
+ swap((ucharp)&entries[i].horiz_resolution, sizeof(real8));
+ swap((ucharp)&entries[i].vert_interval, sizeof(real8));
+ swap((ucharp)&entries[i].horiz_interval, sizeof(real8));
+ swap((ucharp)&entries[i].vert_frames, sizeof(uint));
+ swap((ucharp)&entries[i].horiz_frames, sizeof(uint));
+
+ entries[i].type[5] = '\0';
+ entries[i].compression[5] = '\0';
+ entries[i].scale[12] = '\0';
+ entries[i].zone[1] = '\0';
+ entries[i].producer[5] = '\0';
+ if(entries[i].nw_lat <= 150.E0 && entries[i].nw_lat >= -150.E0 &&
+ entries[i].se_lat <= 150.E0 && entries[i].se_lat >= -150.E0 &&
+ entries[i].nw_long <= 400.E0 && entries[i].nw_long >= -400.E0 &&
+ entries[i].se_long <= 400.E0 && entries[i].se_long >= -400.E0)
+ entries[i].invalid_geographics = 0L;
+ else
+ {
+ entries[i].invalid_geographics = 1L;
+ entries[i].nw_lat = 1536.E0;
+ entries[i].nw_long = 0.E0;
+ entries[i].sw_lat = 0.E0;
+ entries[i].sw_long = 0.E0;
+ entries[i].ne_lat = 1536.E0;
+ entries[i].ne_long = 1536.E0;
+ entries[i].se_lat = 0.E0;
+ entries[i].se_long = 1536.E0;
+ entries[i].vert_resolution = 1.E0;
+ entries[i].horiz_resolution = 1.E0;
+ entries[i].vert_interval = 1.E0;
+ entries[i].horiz_interval = 1.E0;
+ }
+ entries[i].frames = (Frame_entry **)
+ malloc((size_t)entries[i].vert_frames * sizeof(Frame_entry *));
+ if (entries[i].frames == (Frame_entry **)NULL)
+ {
+ sprintf(string,"Error on malloc of entries[%d].frames",i);
+ ecs_SetError(&(s->result),1,string);
+ return((Toc_entry *)NULL);
+ }
+
+ for (j = 0; j < entries[i].vert_frames; j++)
+ {
+ entries[i].frames[j] = (Frame_entry *)
+ malloc((size_t)entries[i].horiz_frames * sizeof(Frame_entry));
+ if (entries[i].frames[j] == (Frame_entry *)NULL)
+ {
+ sprintf(string, "Error on malloc of entries[%d].frames[%d]",i,j);
+ ecs_SetError(&(s->result),1,string);
+ return((Toc_entry *)NULL);
+ }
+ for (k = 0; k < entries[i].horiz_frames; k++) {
+ entries[i].frames[j][k].exists = 0L;
+ entries[i].frames[j][k].directory= (char *) NULL;
+ }
+ }
+
+ } /* for i < n_bound_recs */
+
+ /* Read # of frame file index records */
+ /* Skip 1 byte security classification */
+ /* locations[2] is loc of frame file index section subheader */
+
+ fseek(toc, locations[2].phys_index + 1, SEEK_SET);
+ ogdi_fread(&frm_index_tbl_off, sizeof(frm_index_tbl_off), 1, toc);
+ swap((ucharp)&frm_index_tbl_off, sizeof(frm_index_tbl_off));
+ ogdi_fread(&N_index_recs, sizeof(N_index_recs), 1, toc);
+ swap((ucharp)&N_index_recs, sizeof(N_index_recs));
+
+ ogdi_fread(&N_pathname_recs, sizeof(N_pathname_recs), 1, toc);
+ swap((ucharp)&N_pathname_recs, sizeof(N_pathname_recs));
+
+ ogdi_fread(&Index_rec_len, sizeof(Index_rec_len), 1, toc);
+ swap((ucharp)&Index_rec_len, sizeof(Index_rec_len));
+
+ /* Read frame file index records */
+
+ for (i = 0; i < (int)N_index_recs; i++)
+ {
+
+ /* locations[3] is frame file index table subsection */
+
+ fseek(toc, locations[3].phys_index + Index_rec_len*i, SEEK_SET);
+
+ ogdi_fread(&boundary_id, sizeof(boundary_id), 1, toc);
+ swap((ucharp)&boundary_id, sizeof(boundary_id));
+ if (i == 0 && boundary_id == 0)
+ new_boundary_ids = 1L;
+ if (new_boundary_ids == 0L)
+ boundary_id--;
+
+ if (boundary_id > (ushort)(*num_boundaries-1L))
+ {
+ sprintf(string,"Bad boundary id in FF index record %d", i);
+ ecs_SetError(&(s->result),1,string);
+ return((Toc_entry *)NULL);
+ }
+
+ entry = &entries[boundary_id];
+ entry->boundary_id = boundary_id;
+
+ ogdi_fread(&frame_row, sizeof(frame_row), 1, toc);
+ ogdi_fread(&frame_col, sizeof(frame_col), 1, toc);
+ swap((ucharp)&frame_row, sizeof(frame_row));
+ swap((ucharp)&frame_col, sizeof(frame_col));
+ if (new_boundary_ids == 0L)
+ {
+ frame_row--;
+ frame_col--;
+ }
+ else
+ {
+ /* Trick so that frames are numbered north to south */
+ frame_row = (entry->vert_frames-1L) - frame_row;
+ }
+
+ if ((int)frame_row > entry->vert_frames-1L)
+ {
+ sprintf(string,"Bad row num:%d, in FF index record %d",frame_row,i);
+ ecs_SetError(&(s->result),1,string);
+ return((Toc_entry *)NULL);
+ }
+
+ if ((int)frame_col > entry->horiz_frames-1L)
+ {
+ sprintf(string,"Bad col number in FF index record %d", i);
+ ecs_SetError(&(s->result),1,string);
+ return((Toc_entry *)NULL);
+ }
+
+ frame = &entry->frames[frame_row][frame_col];
+
+ frame->frame_row = frame_row;
+ frame->frame_col = frame_col;
+
+ if (frame->exists)
+ {
+ sprintf(string,"FF %d is a duplicate", i);
+ ecs_SetError(&(s->result),1,string);
+ return((Toc_entry *)NULL);
+ }
+
+ /* Pathname offset */
+
+ ogdi_fread(&path_off, sizeof(path_off), 1, toc);
+ swap((ucharp)&path_off, sizeof(path_off));
+
+ /* Get filename tail */
+
+ ogdi_fread(frame->filename, 1, 12, toc);
+ frame->filename[12] = '\0';
+#ifndef _WINDOWS
+ dyn_string_tolower((char *) frame->filename);
+#endif
+
+ /* Check if the filename is an overview */
+
+ for (j=0;j<12;j++) {
+ if (strcmp(&(frame->filename[j]),".OVR") == 0 ||
+ strcmp(&(frame->filename[j]),".ovr") == 0) {
+ entry->invalid_geographics = 1L;
+ break;
+ }
+ }
+
+ /* Get file geo reference */
+
+ ogdi_fread(frame->georef, 1, 6, toc);
+ frame->georef[6] = '\0';
+
+ /* Go to start of pathname record */
+ /* New path_off offset from start of frame file index section of TOC?? */
+ /* Add pathoffset wrt frame file index table subsection (loc[3]) */
+
+ fseek(toc, locations[3].phys_index + path_off, SEEK_SET);
+
+ ogdi_fread(&path_length, sizeof(path_length), 1, toc);
+ swap((ucharp)&path_length, sizeof(path_length));
+
+ frame->directory = (char *) malloc((size_t)path_length + (size_t)4L +
+ strlen(dir));
+ if (frame->directory == (char *)NULL)
+ {
+ ecs_SetError(&(s->result),1,"Error on malloc of frame->directory");
+ return((Toc_entry *)NULL);
+ }
+ frame->directory[0] = '\0';
+
+ directory = (char *) malloc((size_t)(path_length + 1));
+ if (directory == (char *)NULL)
+ {
+ ecs_SetError(&(s->result),1,"Error on malloc of directory");
+ return((Toc_entry *)NULL);
+ }
+
+ /* Read directory name from toc. */
+
+ ogdi_fread(directory, 1, path_length, toc);
+ directory[path_length] = '\0';
+
+ /* Skip 1st 2 chars: "./": */
+
+ if (directory[2] != '\0')
+ strcat(frame->directory,&directory[2]);
+#ifndef _WINDOWS
+ dyn_string_tolower((char *) frame->directory);
+#endif
+
+ free(directory);
+
+ frame->exists = 1L;
+
+ } /* for i = N_index_recs */
+
+ fclose(toc);
+ tprintf ("parsetoc: here end\n");
+ sprintf(string,"parse_toc: *num_boundaries = %d\n",*num_boundaries);
+ tprintf(string);
+
+ return(entries);
+}
+
+/***********************************************************************\
+*
+* Function: parse_locations
+*
+* Description:
+*
+* Locate sections in file.
+*
+\***********************************************************************/
+
+int parse_locations(ecs_Server *s, FILE *fin, Location *locs, int count)
+{
+ int i, j;
+ ushort n;
+ ushort id;
+ uint phys_index;
+ ushort us;
+ uint ui;
+ (void) s;
+
+ /* Initialize indices so we can later tell if they weren't found */
+
+ for (j = 0; j < count; j++)
+ locs[j].phys_index = (uint)(~0);
+
+ /* Skip location section length */
+
+ ogdi_fread(&us, sizeof(us), 1, fin);
+
+ /* Skip component location table offset */
+
+ ogdi_fread(&ui, sizeof(ui), 1, fin);
+
+ /* How many sections: # of section location records */
+
+ ogdi_fread(&n, sizeof(n), 1, fin);
+ swap((ucharp)&n, sizeof(n));
+
+ /* Skip location record length */
+
+ ogdi_fread(&us, sizeof(us), 1, fin);
+
+ /* Skip component aggregate length */
+
+ ogdi_fread(&ui, sizeof(ui), 1, fin);
+
+ /* Now go find the ones we want */
+
+ for (i = 0; i < (int)n; i++)
+ {
+ ogdi_fread(&id, sizeof(id), 1, fin);
+
+ /* Skip section length */
+
+ ogdi_fread(&ui, sizeof(ui), 1, fin);
+
+ ogdi_fread(&phys_index, sizeof(phys_index), 1, fin);
+
+ swap((ucharp)&id, sizeof(id));
+ swap((ucharp)&phys_index, sizeof(phys_index));
+
+ for (j = 0; j < count; j++)
+ if (locs[j].id == id)
+ locs[j].phys_index = phys_index;
+
+ } /* for i */
+
+ return(1L);
+
+} /* parse_locations */
+
+/***********************************************************************\
+*
+* Function: parse_clut
+*
+* Description:
+*
+* Read and parse just the colortable information in a frame file.
+*
+\***********************************************************************/
+
+#define MAXOFFSETRECS 10 /* Max # of color/gray offset records: usually 5 */
+#define MAXCCRECS 5 /* Max # of color converter records: usually 2 */
+
+int
+parse_clut(s, frame, filename, rgb, ReducedColorTable, cct, Nitf_hdr_len, n_cols, blackpixel)
+ecs_Server *s;
+Frame_file *frame;
+char *filename;
+Rgb *rgb;
+int ReducedColorTable;
+uint *cct;
+int Nitf_hdr_len;
+uint *n_cols;
+uchar *blackpixel;
+{
+ FILE *fin;
+ Location loc[3];
+ int i,j;
+ uint loc_sec_phys_loc; /* location section physical location */
+ uchar N_offset_recs; /* # of offset records */
+ uchar N_cc_offset_recs; /* # of color converter offset records */
+ ushort Offset_rec_len = 17; /* offset record length */
+ Color_offset *col_off; /* color offset: array of records. */
+ ushort table_id[MAXOFFSETRECS]; /* Color/gray offset record fields*/
+ uint n_col_recs[MAXOFFSETRECS]; /* # color records */
+ uchar col_elem_len[MAXOFFSETRECS]; /* color element length */
+ ushort hist_rec_len[MAXOFFSETRECS]; /* histogram record length */
+ uint color_tbl_offset[MAXOFFSETRECS]; /* color table offset */
+ uint hist_tbl_offset[MAXOFFSETRECS]; /* histogram table offset */
+ uint clrmap_off_tbl_off; /* colormap offset table offset */
+ /* color converter subsection hdr */
+ uint cct_off_tbl_off; /* color convertion offset table offset */
+ ushort cct_off_recl; /* cc offset recl */
+ ushort cct_recl; /* cc recl */
+ /* color converter offset record fields */
+ ushort cct_id[MAXCCRECS]; /* color conversion table ID */
+ uint cct_nrec[MAXCCRECS]; /* # cc recs */
+ uint cct_tbl_off[MAXCCRECS]; /* cc table offset */
+ uint cct_src[MAXCCRECS]; /* cc src color/gray offset table offset */
+ uint cct_tgt[MAXCCRECS]; /* cc tgt color/gray offset table offset */
+ double mindistblackp; /* minimum distance for black pixel */
+ double dist; /* distance for black pixel */
+ double r,g,b;
+ char string[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+
+ (void) frame;
+
+ fin = rpf_fopen_ci( spriv->pathname, filename, "rb" );
+ if (fin == NULL )
+ {
+ sprintf(string,"Can't open %s",filename);
+ ecs_SetError(&(s->result),1,string);
+ return(0L);
+ }
+
+ /* Skip NITF header if there */
+
+ fseek(fin, Nitf_hdr_len, SEEK_SET);
+
+ /* Skip header up to location of location section: 48-4=44 */
+
+ fseek(fin, 48-4, SEEK_CUR);
+
+ ogdi_fread(&loc_sec_phys_loc, sizeof(loc_sec_phys_loc), 1, fin);
+ swap((ucharp)&loc_sec_phys_loc, sizeof(loc_sec_phys_loc));
+
+ /* Go to location section */
+
+ fseek(fin, loc_sec_phys_loc, SEEK_SET);
+
+ /* Locate the proper section */
+
+ loc[0].id = LOC_COLORGRAY_SECTION_SUBHEADER; /* 134 */
+ loc[1].id = LOC_COLORMAP_SUBSECTION; /* 135 */
+ loc[2].id = LOC_COLOR_CONVERTOR_SUBSECTION; /* 139 */
+ parse_locations(s, fin, loc, 3L);
+
+ if ((int) loc[0].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find color/gray section subheader (ID=134) location");
+ return(0L);
+ }
+
+ /* Go find the color table: loc[0].id=LOC_CLUT */
+
+ fseek(fin, loc[0].phys_index, SEEK_SET);
+
+ /* Read section subheader */
+ /* Number of offset records:1-5 */
+
+ ogdi_fread(&N_offset_recs, sizeof(N_offset_recs), 1, fin);
+
+ /* Number of color converter offset records */
+
+ ogdi_fread(&N_cc_offset_recs, sizeof(N_cc_offset_recs), 1, fin);
+
+ /* Read colormap offset table */
+
+ col_off = (Color_offset *) malloc (sizeof(Color_offset)*
+ (size_t)N_offset_recs);
+ if (col_off == (Color_offset *)NULL)
+ {
+ ecs_SetError(&(s->result),1,"Parse_clut malloc error on col_off");
+ return(0L) ;
+ }
+
+ /* Check for colormap subsection: id = 135 */
+ /* ?? can't find this section */
+
+ if ((int) loc[1].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find colormap subsection location ID=135");
+ free((char *)col_off);
+ return(0L);
+ }
+
+ /* Read color/gray offset records (colormap subsection) */
+
+ fseek(fin, loc[1].phys_index, SEEK_SET);
+
+ /* colormap offset table offset length:4 */
+
+ ogdi_fread(&clrmap_off_tbl_off, sizeof(clrmap_off_tbl_off), 1, fin);
+ swap((ucharp)&clrmap_off_tbl_off, sizeof(clrmap_off_tbl_off));
+
+ /* offset record length:17 */
+
+ ogdi_fread(&Offset_rec_len, sizeof(Offset_rec_len), 1, fin);
+ swap((ucharp)&Offset_rec_len, sizeof(Offset_rec_len));
+
+ /* Read colormap offset table */
+
+ for (i=0; i<N_offset_recs; i++)
+ {
+
+ /* id: 3:grayscale 4:rgbm216, 5:rgbm32, 6:rgbm16 */
+
+ ogdi_fread(&table_id[i], sizeof(table_id[i]), 1, fin);
+ swap((ucharp)&table_id[i], sizeof(table_id[i]));
+
+ ogdi_fread(&n_col_recs[i], sizeof(n_col_recs[i]), 1, fin);
+ swap((ucharp)&n_col_recs[i], sizeof(n_col_recs[i]));
+
+ ogdi_fread(&col_elem_len[i], sizeof(col_elem_len[i]), 1, fin);
+
+ /* Moved down to here */
+
+ ogdi_fread(&hist_rec_len[i], sizeof(hist_rec_len[i]), 1, fin);
+ swap((ucharp)&hist_rec_len[i], sizeof(hist_rec_len[i]));
+
+ /* Color table offset */
+
+ ogdi_fread(&color_tbl_offset[i], sizeof(color_tbl_offset[i]), 1, fin);
+ swap((ucharp)&color_tbl_offset[i], sizeof(color_tbl_offset[i]));
+
+ /* Hist. table offset */
+
+ ogdi_fread(&hist_tbl_offset[i], sizeof(hist_tbl_offset[i]), 1, fin);
+ swap((ucharp)&hist_tbl_offset[i], sizeof(hist_tbl_offset[i]));
+
+ } /* for i = N_offset_recs */
+
+ /* Go to proper file position wrt colormap subsection (loc[1]) */
+
+ for (i=0; i<N_offset_recs; i++)
+ {
+
+ fseek(fin, loc[1].phys_index + color_tbl_offset[i], SEEK_SET) ;
+
+ if (table_id[i] == 3 || /* read, use grayscale */
+ (ReducedColorTable == 0L && /* read, use colortable */
+ i == 0L))
+ {
+ *n_cols = n_col_recs[i];
+ *blackpixel = 0;
+ mindistblackp = 1.E20;
+ for (j = 0; j < (int)n_col_recs[i]; j++) /* 216, 32, or 16 */
+ {
+ if (table_id[i] == 3L)
+ {
+ ogdi_fread(&rgb[j].r, 1, 1, fin); /* rgb is mono */
+ rgb[j].g = rgb[j].b = rgb[j].r;
+ }
+ else
+ ogdi_fread(&rgb[j], sizeof(rgb[j]), 1, fin); /* rgb is rgba, size=4 */
+ r = (double)(unsigned char)(rgb[j].r);
+ g = (double)(unsigned char)(rgb[j].g);
+ b = (double)(unsigned char)(rgb[j].b);
+ dist = sqrt(r*r+g*g+b*b);
+ if (dist < mindistblackp)
+ {
+ mindistblackp = dist;
+ *blackpixel = (uchar)j;
+ }
+ } /* for j */
+
+ } /* if table_id */
+
+ } /* for i = N_offset_recs */
+
+ if (ReducedColorTable != 0)
+ {
+ /* Read cct records */
+
+ fseek(fin, loc[2].phys_index, SEEK_SET);
+
+ ogdi_fread(&cct_off_tbl_off, sizeof(cct_off_tbl_off), 1, fin);
+ swap ((ucharp)&cct_off_tbl_off, sizeof(cct_off_tbl_off)) ;
+
+ ogdi_fread(&cct_off_recl, sizeof(cct_off_recl), 1, fin);
+ swap ((ucharp)&cct_off_recl, sizeof(cct_off_recl)) ;
+
+ ogdi_fread(&cct_recl, sizeof(cct_recl), 1, fin);
+ swap ((ucharp)&cct_recl, sizeof(cct_recl)) ;
+
+ /* Read colormap conversion table */
+
+ for (i=0; i<N_cc_offset_recs; i++)
+ {
+
+ /* id: 128:cct/rgbm/32, 129:cct/rgbm/16 */
+
+ ogdi_fread(&cct_id[i], sizeof(cct_id[i]), 1, fin);
+ swap((ucharp)&cct_id[i], sizeof(cct_id[i]));
+
+ ogdi_fread(&cct_nrec[i], sizeof(cct_nrec[i]), 1, fin);
+ swap((ucharp)&cct_nrec[i], sizeof(cct_nrec[i]));
+
+ ogdi_fread(&cct_tbl_off[i], sizeof(cct_tbl_off[i]), 1, fin);
+ swap((ucharp)&cct_tbl_off[i], sizeof(cct_tbl_off[i]));
+
+ ogdi_fread(&cct_src[i], sizeof(cct_src[i]), 1, fin);
+ swap((ucharp)&cct_src[i], sizeof(cct_src[i]));
+
+ ogdi_fread(&cct_tgt[i], sizeof(cct_tgt[i]), 1, fin);
+ swap((ucharp)&cct_tgt[i], sizeof(cct_tgt[i]));
+
+ } /* for i = N_cc_offset_recs */
+
+ for (i=0; i<N_cc_offset_recs; i++)
+ {
+ /* Go to proper file position wrt color map subsection (loc[1]) */
+
+ fseek(fin, loc[1].phys_index + cct_tgt[i], SEEK_SET) ;
+
+ /* id: 3:grayscale 4:rgbm216, 5:rgbm32, 6:rgbm16 */
+
+ ogdi_fread(&table_id[i], sizeof(table_id[i]), 1, fin);
+ swap((ucharp)&table_id[i], sizeof(table_id[i]));
+
+ ogdi_fread(&n_col_recs[i], sizeof(n_col_recs[i]), 1, fin);
+ swap((ucharp)&n_col_recs[i], sizeof(n_col_recs[i]));
+
+ ogdi_fread(&col_elem_len[i], sizeof(col_elem_len[i]), 1, fin);
+
+ /* Moved down to here */
+
+ ogdi_fread(&hist_rec_len[i], sizeof(hist_rec_len[i]), 1, fin);
+ swap((ucharp)&hist_rec_len[i], sizeof(hist_rec_len[i]));
+
+ /* Color table offset */
+
+ ogdi_fread(&color_tbl_offset[i], sizeof(color_tbl_offset[i]), 1, fin);
+ swap((ucharp)&color_tbl_offset[i], sizeof(color_tbl_offset[i]));
+
+ /* Hist. table offset */
+
+ ogdi_fread(&hist_tbl_offset[i], sizeof(hist_tbl_offset[i]), 1, fin);
+ swap((ucharp)&hist_tbl_offset[i], sizeof(hist_tbl_offset[i]));
+
+ /* Go to proper file position wrt colormap subsection (loc[1]) */
+
+ fseek(fin, loc[1].phys_index + color_tbl_offset[i], SEEK_SET) ;
+
+ if ((i+1L) == ReducedColorTable)
+ {
+ *blackpixel = 0;
+ mindistblackp = 1.E20;
+ for (j = 0; j < (int)n_col_recs[i]; j++) /* 32 or 16 */
+ {
+ ogdi_fread(&rgb[j], sizeof(rgb[j]), 1, fin); /* rgb is rgba, size=4 */
+ r = (double)(unsigned char)(rgb[j].r);
+ g = (double)(unsigned char)(rgb[j].g);
+ b = (double)(unsigned char)(rgb[j].b);
+ dist = sqrt(r*r+g*g+b*b);
+ if (dist < mindistblackp)
+ {
+ mindistblackp = dist;
+ *blackpixel = (uchar)j;
+ }
+ }
+ }
+
+ } /* for i = N_cc_offset_recs */
+
+ for (i=0; i<N_cc_offset_recs; i++)
+ {
+ /* Go to proper file position wrt color conversion subsection (loc[2]) */
+
+ fseek(fin, loc[2].phys_index + cct_tbl_off[i], SEEK_SET) ;
+
+ if ((i+1L) == ReducedColorTable)
+ {
+ ogdi_fread(cct, sizeof(uint), 216, fin);
+ } /* if table_id */
+
+ } /* for i = N_cc_offset_recs */
+ }
+
+ if (ReducedColorTable==0) /* 216 colors chosen */
+ for (j=0; j<CADRG_COLORS; j++)
+ cct[j] = (uint)j ;
+
+ fclose(fin);
+ free((char *)col_off);
+
+ return 0;
+} /* parse_clut */
+
+/***********************************************************************\
+*
+* Function: parse_frame
+*
+* Description:
+*
+* Parse the frame file format.
+*
+*
+\***********************************************************************/
+
+int
+parse_frame(s, file, filename)
+ecs_Server *s;
+Frame_file *file;
+char *filename;
+{
+ Location loc[11];
+ FILE *fin;
+ int i, j;
+ char NITF[5];
+ ascii date[8];
+ uint lkup_off_tbl_off; /* 2lookup offset table offset */
+ ushort lkup_tbl_off_recl; /* lookup table offset record length */
+ uint subfr_mask_tbl_off; /* subframe mask table offset */
+ int nsubfr=0; /* the number of subframes */
+ char string[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+
+ fin = rpf_fopen_ci( spriv->pathname, filename, "rb" );
+ if (fin == NULL)
+ {
+ sprintf(string,"Can't open frame file %s",filename);
+ ecs_SetError(&(s->result),1,string);
+ return(0L);
+ }
+
+ /* Check for NITF header */
+
+ fseek(fin, 0, SEEK_SET);
+ ogdi_fread(NITF, 4L, 1, fin) ;
+ NITF[4] = '\0';
+ if (strcmp(NITF, "NITF") == 0) /* Match: skip NITF hdr */
+ {
+ fseek(fin,413, SEEK_SET) ;
+ fseek(fin, 31, SEEK_CUR) ; /* Key off date, pos 32 in RPF header */
+ ogdi_fread( date, sizeof(date), 1, fin);
+ if (strncmp(date,"199",3) == 0) /* Check for short 413 hdr */
+ file->NITF_hdr_len = 413L;
+ else /* Else long 426 hdr */
+ file->NITF_hdr_len = 426L;
+ }
+ else /* not in NITF format */
+ {
+ file->NITF_hdr_len = 0L;
+ } /* else */
+
+ /* Skip Nitf header */
+
+ fseek(fin, file->NITF_hdr_len, SEEK_SET);
+
+ /* Read header */
+
+ ogdi_fread(&file->head.endian, sizeof(file->head.endian), 1, fin) ;
+ check_swap(file->head.endian);
+ ogdi_fread(&file->head.hdr_sec_len, sizeof(file->head.hdr_sec_len), 1, fin);
+ ogdi_fread( file->head.filename, sizeof(file->head.filename), 1, fin);
+ ogdi_fread(&file->head.new, sizeof(file->head.new), 1, fin) ;
+ ogdi_fread( file->head.standard_num, sizeof(file->head.standard_num), 1, fin) ;
+ if (strncmp(&file->head.standard_num[9],"41",2) == 0)
+ file->head.rpf_type = RPF_CIB;
+ else if (strncmp(&file->head.standard_num[9],"38",2) == 0)
+ file->head.rpf_type = RPF_CADRG;
+ else if (strncmp(&file->head.standard_num[9],"44",2) == 0)
+ file->head.rpf_type = RPF_CDTED;
+ ogdi_fread( file->head.standard_date, sizeof(file->head.standard_date), 1, fin);
+ ogdi_fread(&file->head.classification, sizeof(file->head.classification), 1,fin);
+ ogdi_fread( file->head.country, sizeof(file->head.country), 1, fin);
+ ogdi_fread( file->head.release, sizeof(file->head.release), 1, fin);
+ ogdi_fread(&file->head.loc_sec_phys_loc, sizeof(file->head.loc_sec_phys_loc), 1, fin) ;
+
+ swap((ucharp)&file->head.hdr_sec_len, sizeof(file->head.hdr_sec_len)) ;
+ swap((ucharp)&file->head.loc_sec_phys_loc, sizeof(file->head.loc_sec_phys_loc));
+
+ /* Position to start of location section: 2 choices: */
+
+ fseek(fin, file->head.loc_sec_phys_loc, SEEK_SET) ;
+
+ /* Locate the sections we need */
+
+ loc[0].id = LOC_COMPRESSION_SECTION; /* 131 */
+ loc[1].id = LOC_IMAGE_DESCR_SUBHEADER; /* 136 */
+ if (file->head.rpf_type == RPF_CDTED)
+ loc[2].id = LOC_COMPRESSION_PARAMETER_SUBSECTION; /* 133 */
+ else
+ loc[2].id = LOC_COMPRESSION_LOOKUP_SUBSECTION; /* 132 */
+ loc[3].id = LOC_SPATIAL_DATA_SUBSECTION; /* 140 */
+ loc[4].id = LOC_IMAGE_DISPLAY_PARAM_SUBHEADER; /* 137 */
+ loc[5].id = LOC_MASK_SUBSECTION; /* 138 */
+ loc[6].id = LOC_COVERAGE_SECTION; /* 130 */
+ loc[7].id = LOC_REPLACE_UPDATE_SECTION_SUBHEADER; /* 146 */
+ loc[8].id = LOC_REPLACE_UPDATE_TABLE; /* 147 */
+ loc[9].id = LOC_ATTRIBUTE_SECTION_SUBHEADER; /* 141 */
+ loc[10].id = LOC_ATTRIBUTE_SUBSECTION; /* 142 */
+
+ parse_locations(s, fin, loc, 11L);
+
+ if ((int) loc[0].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find LOC_COMPRESSION section in FF");
+ }
+ if ((int) loc[1].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find LOC_IMAGE section in FF");
+ return(0L);
+ }
+
+ /* Read the coverage section */
+
+ if ((int) loc[6].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find LOC_COVERAGE_SECTION in FF");
+ return(0L);
+ }
+
+ ogdi_fread(&file->cover.nw_lat, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.nw_long, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.sw_lat, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.sw_long, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.ne_lat, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.ne_long, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.se_lat, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.se_long, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.vert_resolution, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.horiz_resolution, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.vert_interval, sizeof(real8), 1, fin);
+ ogdi_fread(&file->cover.horiz_interval, sizeof(real8), 1, fin);
+
+ swap((ucharp)&file->cover.nw_lat, sizeof(real8));
+ swap((ucharp)&file->cover.nw_long, sizeof(real8));
+ swap((ucharp)&file->cover.sw_lat, sizeof(real8));
+ swap((ucharp)&file->cover.sw_long, sizeof(real8));
+ swap((ucharp)&file->cover.ne_lat, sizeof(real8));
+ swap((ucharp)&file->cover.ne_long, sizeof(real8));
+ swap((ucharp)&file->cover.se_lat, sizeof(real8));
+ swap((ucharp)&file->cover.se_long, sizeof(real8));
+ swap((ucharp)&file->cover.vert_resolution, sizeof(real8));
+ swap((ucharp)&file->cover.horiz_resolution, sizeof(real8));
+ swap((ucharp)&file->cover.vert_interval, sizeof(real8));
+ swap((ucharp)&file->cover.horiz_interval, sizeof(real8));
+
+ /* Read the compression tables */
+
+ if ((int) loc[0].phys_index != ~0)
+ {
+ fseek(fin, loc[0].phys_index, SEEK_SET);
+ ogdi_fread(&file->compr.algorithm , sizeof(file->compr.algorithm ), 1, fin);
+ ogdi_fread(&file->compr.noff_recs ,sizeof(file->compr.noff_recs ), 1,fin);
+ ogdi_fread(&file->compr.nparm_off_recs,sizeof(file->compr.nparm_off_recs), 1,fin);
+
+ swap((ucharp)&file->compr.algorithm ,sizeof(file->compr.algorithm ));
+ swap((ucharp)&file->compr.noff_recs ,sizeof(file->compr.noff_recs ));
+ swap((ucharp)&file->compr.nparm_off_recs,sizeof(file->compr.noff_recs ));
+ }
+
+/* If not CDTED read lookup table section */
+
+ if (file->head.rpf_type != RPF_CDTED)
+ {
+ file->loc_lut_shdr = loc[2].phys_index;
+ if ((int) loc[2].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Warning: Can't find compr. lookup subsection in FrameFile: Using alternate computation");
+
+ /* length of compr. sect. subhdr = 10 */
+
+ fseek(fin, loc[0].phys_index + 10, SEEK_SET);
+ }
+ else
+ {
+ fseek(fin, loc[2].phys_index, SEEK_SET);
+ } /* else */
+
+ /* Read Header fields for CIB */
+
+ ogdi_fread(&lkup_off_tbl_off, sizeof(lkup_off_tbl_off), 1, fin);
+ ogdi_fread(&lkup_tbl_off_recl, sizeof(lkup_tbl_off_recl), 1, fin);
+ swap ((ucharp)&lkup_off_tbl_off, sizeof(lkup_off_tbl_off)) ;
+ swap ((ucharp)&lkup_tbl_off_recl, sizeof(lkup_tbl_off_recl)) ;
+
+ for (i=0; i<4; i++)
+ {
+ ogdi_fread(&file->lut[i].id , sizeof(file->lut[i].id ), 1,fin);
+ ogdi_fread(&file->lut[i].records , sizeof(file->lut[i].records ), 1, fin);
+ ogdi_fread(&file->lut[i].values , sizeof(file->lut[i].values ), 1, fin);
+ ogdi_fread(&file->lut[i].bit_length , sizeof(file->lut[i].bit_length ), 1, fin);
+ ogdi_fread(&file->lut[i].phys_offset, sizeof(file->lut[i].phys_offset), 1, fin);
+ swap((ucharp)&file->lut[i].id , sizeof(file->lut[i].id ));
+ swap((ucharp)&file->lut[i].records , sizeof(file->lut[i].records ));
+ swap((ucharp)&file->lut[i].values , sizeof(file->lut[i].values ));
+ swap((ucharp)&file->lut[i].bit_length , sizeof(file->lut[i].bit_length ));
+ swap((ucharp)&file->lut[i].phys_offset, sizeof(file->lut[i].phys_offset));
+
+ if (file->lut[i].records != 4096 ||
+ file->lut[i].values != 4 ||
+ file->lut[i].bit_length != 8)
+ {
+ ecs_SetError(&(s->result),1,"Bad VQ info in compression record");
+ return(0L);
+ }
+
+ }
+
+ /* For each compression table */
+ for (i = 0; i < 4; i++)
+ {
+
+ /* Position from compression lookup subsection: loc[2] */
+
+ fseek(fin, loc[2].phys_index + file->lut[i].phys_offset, SEEK_SET);
+
+ /* Skip tables */
+
+ fseek(fin, 4096*4, SEEK_CUR);
+
+ } /* for i=1 to 4 (# compression tables, 1 for each pixel row) */
+ }
+
+/* If CDTED read compression parameter section */
+
+ else if (file->head.rpf_type == RPF_CDTED)
+ {
+ uint comp_off_tbl_off;
+ ushort comp_off_recl;
+ int bits_off;
+ int bitshuff_off;
+ uchar bits[16];
+ int hufflen=0;
+
+ file->comp_parm_shdr = loc[2].phys_index;
+ if ((int) loc[2].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Warning: Can't find compr. parameter subsection in FrameFile");
+ return(0L);
+
+ }
+ else
+ {
+ fseek(fin, loc[2].phys_index, SEEK_SET);
+ } /* else */
+
+ /* Read Header fields for CDTED */
+
+ ogdi_fread(&comp_off_tbl_off, sizeof(comp_off_tbl_off), 1, fin);
+ ogdi_fread(&comp_off_recl, sizeof(comp_off_recl), 1, fin);
+ swap ((ucharp)&comp_off_tbl_off, sizeof(comp_off_tbl_off)) ;
+ swap ((ucharp)&comp_off_recl, sizeof(comp_off_recl)) ;
+
+ file->comp = (Comp_parm *)malloc(sizeof(Comp_parm)*
+ file->compr.nparm_off_recs);
+ bitshuff_off = ~0;
+ for (i=0; i<file->compr.nparm_off_recs; i++)
+ {
+ ogdi_fread(&file->comp[i].id , sizeof(file->comp[i].id ), 1,fin);
+ ogdi_fread(&file->comp[i].rec_off, sizeof(file->comp[i].rec_off), 1, fin);
+ swap((ucharp)&file->comp[i].id , sizeof(file->comp[i].id ));
+ swap((ucharp)&file->comp[i].rec_off, sizeof(file->comp[i].rec_off));
+
+ if (file->comp[i].id == 1)
+ bitshuff_off = file->comp[i].rec_off;
+
+ } /* for i */
+
+ if (bitshuff_off == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Compression param ID 1 not found");
+ return(0L);
+ }
+
+ bits_off = bitshuff_off + 7 ; /* skip 4 vars in tbl: 2+2+2+1 */
+
+ /* Skip Huffman bits */
+
+ file->comp_parm_shdr = loc[2].phys_index + bits_off;
+ fseek(fin, loc[2].phys_index + bits_off, SEEK_SET);
+ ogdi_fread(bits, 16, 1, fin) ; /* bits array */
+ for (i=0; i<16; i++)
+ hufflen += bits[i]; /* len of huffval table */
+ fseek(fin, hufflen, SEEK_CUR);
+
+ }
+
+ /* Read the image data */
+
+ fseek(fin, loc[1].phys_index, SEEK_SET);
+ ogdi_fread(&file->img.spectral_groups, sizeof(file->img.spectral_groups), 1, fin);
+ ogdi_fread(&file->img.subframe_tables, sizeof(file->img.subframe_tables), 1, fin);
+ ogdi_fread(&file->img.spectral_tables, sizeof(file->img.spectral_tables), 1, fin);
+ ogdi_fread(&file->img.spectral_lines, sizeof(file->img.spectral_lines ), 1, fin);
+ ogdi_fread(&file->img.horiz_subframes, sizeof(file->img.horiz_subframes), 1, fin);
+ ogdi_fread(&file->img.vert_subframes, sizeof(file->img.vert_subframes ), 1, fin);
+ ogdi_fread(&file->img.output_cols, sizeof(file->img.output_cols ), 1, fin);
+ ogdi_fread(&file->img.output_rows, sizeof(file->img.output_rows ), 1, fin);
+
+ swap((ucharp)&file->img.spectral_groups, sizeof(file->img.spectral_groups));
+ swap((ucharp)&file->img.subframe_tables, sizeof(file->img.subframe_tables));
+ swap((ucharp)&file->img.spectral_tables, sizeof(file->img.spectral_tables));
+ swap((ucharp)&file->img.spectral_lines, sizeof(file->img.spectral_lines));
+ swap((ucharp)&file->img.horiz_subframes, sizeof(file->img.horiz_subframes));
+ swap((ucharp)&file->img.vert_subframes, sizeof(file->img.vert_subframes));
+ swap((ucharp)&file->img.output_cols, sizeof(file->img.output_cols));
+ swap((ucharp)&file->img.output_rows, sizeof(file->img.output_rows));
+ ogdi_fread(&subfr_mask_tbl_off, sizeof(subfr_mask_tbl_off), 1, fin) ;
+ swap((ucharp)&subfr_mask_tbl_off,sizeof(subfr_mask_tbl_off));
+ if (subfr_mask_tbl_off == 0xFFFFFFFFL)
+ file->all_subframes = 1; /* TRUE */
+ else
+ file->all_subframes = 0 ; /* FALSE */
+
+ /* Fseek to LOC_IMAGE_DISPLAY_PARAM_SUBHEADER, ID=137 */
+
+ if ((int) loc[4].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find IMAGE_DISPLAY_PARAM_SUBHEADER section in Frame file");
+ return(0L);
+ }
+
+ /* Image Display Parameters Subheader */
+
+ fseek(fin, loc[4].phys_index, SEEK_SET);
+
+ if (file->head.rpf_type == RPF_CDTED)
+ nsubfr = 1;
+ else if (file->head.rpf_type == RPF_CADRG || file->head.rpf_type == RPF_CIB)
+ nsubfr = 6;
+ if (file->img.vert_subframes != nsubfr ||
+ file->img.horiz_subframes != nsubfr)
+ {
+ ecs_SetError(&(s->result),1,"Bad number of subframes per frame");
+ return(0L);
+ }
+
+ /* Fseek to LOC_SPATIAL_DATA_SUBSECTION, ID=140 */
+
+ file->loc_data = loc[3].phys_index;
+ if ((int) loc[3].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find SPATIAL_DATA_SUBSECTION section in Frame file");
+ return(0L);
+ }
+
+ /* Read the mask data */
+
+ if (!file->all_subframes)
+ {
+
+ /* Fseek to LOC_MASK_SUBSECTION, ID=138 */
+
+ if ((int) loc[5].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find MASK_SUBSECTION section in Frame file");
+ return(0L);
+ }
+ fseek(fin, loc[5].phys_index, SEEK_SET);
+ fseek(fin, subfr_mask_tbl_off, SEEK_CUR); /* go to offset: skip hdr */
+ for (i=0; i<nsubfr; i++)
+ for (j=0; j<nsubfr; j++)
+ {
+ ogdi_fread(&file->indices[i][j], sizeof(uint), 1, fin);
+ swap((ucharp)&file->indices[i][j], sizeof(uint));
+ }
+ }
+ else
+ {
+ for (i=0; i<nsubfr; i++)
+ for (j=0; j<nsubfr; j++)
+ file->indices[i][j] = (uint)((i*6L+j)*6144L);
+ }
+
+ /* Fseek to LOC_ATTRIBUTE_SECTION_SUBHEADER, ID=141 */
+
+#ifdef LATER
+ if (loc[9].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find LOC_ATTRIBUTE_SUBHEADER section in Frame file");
+ return(0L);
+ }
+ fseek(fin, loc[10].phys_index, SEEK_SET);
+ if (loc[10].phys_index == ~0)
+ {
+ ecs_SetError(&(s->result),1,"Can't find LOC_ATTRIBUTE_SECTION_SUBHEADER section in Frame file");
+ return(0L);
+ }
+ fseek(fin, loc[10].phys_index, SEEK_SET);
+ ogdi_fread(&num_att_rec, sizeof(num_att_rec), 1, fin) ;
+ swap((ucharp)&num_att_rec, sizeof(num_att_rec));
+#endif
+
+ fclose(fin);
+
+ return(1L);
+} /* parse_frame */
+
+/***********************************************************************\
+*
+* Function: get_comp_luts
+*
+* Description:
+*
+* Get the compression lookup tables
+*
+\***********************************************************************/
+
+BOOLEAN
+get_comp_lut(s, file, filename, table, cct, ReducedColorTable)
+ecs_Server *s;
+Frame_file *file;
+char *filename;
+uchar *table;
+uint *cct;
+int ReducedColorTable;
+{
+ FILE *fin;
+ uint offset;
+ int index;
+ int tindex;
+ int i,j,k;
+ char string[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+
+ /* Open the file */
+
+ fin = rpf_fopen_ci( spriv->pathname, filename, "rb" );
+ if (fin == NULL)
+ {
+ sprintf(string,"Can't open frame file %s",filename);
+ ecs_SetError(&(s->result),1,string);
+ return FALSE;
+ }
+
+ /* Loop thru the compression tables */
+
+ for (i=0; i<4; i++)
+ {
+
+ /* Seek to the table postion */
+
+ offset = file->loc_lut_shdr + file->lut[i].phys_offset;
+ fseek(fin, offset, SEEK_SET);
+
+ /* Read the table */
+
+ ogdi_fread(&table[i*4096L*4L], (size_t)1, (size_t)(4096*4), fin);
+
+ /* Transform the table if reduced color table */
+
+ if (ReducedColorTable) /* 1 or 2 */
+ {
+ for (j=0; j<4096; j++)
+ for (k=0; k<4; k++)
+ {
+ index = i*4096L*4L + j*4L + k;
+ tindex = (unsigned char)table[index];
+ table[index] = (unsigned char)cct[tindex];
+ }
+ }
+ }
+
+ fclose(fin);
+
+ return TRUE;
+
+}
+
+/***********************************************************************\
+*
+* Function: get_rpf_image_tile
+*
+* Description:
+*
+* Get a decompressed RPF image tile
+*
+\***********************************************************************/
+
+BOOLEAN
+get_rpf_image_tile(s, file, filename, tno, table, tile, decompress, blackpixel)
+ecs_Server *s;
+Frame_file *file;
+char *filename;
+int tno;
+uchar *table;
+uchar *tile;
+int decompress;
+uchar blackpixel;
+{
+ FILE *fin;
+ uchar *ptr;
+ uchar *subframe;
+ int i, j, t, e;
+ uint val;
+ int index;
+ int offset;
+ int cc;
+ char string[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+
+ /* If blank subframe zero out tile */
+
+ if (tno == -1L && tno == ~0)
+ {
+ memset((uchar *)tile, (int)(uchar)blackpixel, (size_t)(256*256));
+ return TRUE;
+ }
+
+ /* Open the file */
+
+ fin = rpf_fopen_ci( spriv->pathname, filename, "rb" );
+ if (fin == NULL)
+ {
+ sprintf(string,"Can't open frame file %s",filename);
+ ecs_SetError(&(s->result),1,string);
+ return(0L);
+ }
+
+ /* Loop thru the compression tables */
+
+
+ /* Alloc the space for the subframe */
+
+ if ((subframe = (uchar *)malloc((size_t)6144L)) == (uchar *)NULL)
+ {
+ ecs_SetError(&(s->result),1,"Can't alloc space for subframe");
+ return FALSE;
+ }
+
+ /* Seek to start of subframe */
+
+ offset = file->loc_data + tno;
+ cc = fseek(fin, offset, SEEK_SET);
+
+ /* Read the subframe */
+
+ cc = fread(subframe, 1, 6144, fin);
+ fclose(fin);
+
+ /* This should never occur since all subframes should be present */
+
+ if ((ptr = subframe) == NULL)
+ return FALSE;
+
+ /* Decompress the tile */
+
+ if (decompress)
+ {
+ for (i = 0; i < 256; i += 4)
+ for (j = 0; j < 256; j += 8, ptr += 3)
+ {
+
+ /* Get first 12-bit value as index into VQ table */
+
+ val = (uint)((ptr[0] << 4) | (ptr[1] >> 4));
+ for (t = 0; t < 4; t++)
+ for (e = 0; e < 4; e++)
+ {
+ index = t*4096L*4L + val*4L + e;
+ tile[(i+t)*256L+(j+e )] = (unsigned char)table[index];
+#if 0
+ if ( tile[(i+t)*256L+(j+e )] > 31)
+ printf ("i,t,j,e %ld %ld %ld %ld %ld %ld %ld %ld\n",i,t,j,e,
+ tile[(i+t)*256L+(j+e )],index,val,table[index]);
+#endif
+ }
+
+ /* Get second 12-bit value as index into VQ table */
+
+ val = (uint)(((ptr[1] & 0x0F) << 8) | ptr[2]);
+ for (t = 0; t < 4; t++)
+ for (e = 0; e < 4; e++)
+ {
+ index = t*4096L*4L + val*4L + e;
+ tile[(i+t)*256L+(j+e+4L)] = (unsigned char)table[index];
+#if 0
+ if ( tile[(i+t)*256L+(j+e+4L)] > 31)
+ printf ("i,t,j,e+4L %ld %ld %ld %ld %ld\n",i,t,j,e+4L,
+ tile[(i+t)*256L+(j+e+4L)]);
+#endif
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < 6144; i++)
+ tile[i] = subframe[i];
+ }
+
+ free((char *)subframe);
+
+ return TRUE;
+}
+
+#ifndef _WINDOWS
+void dyn_string_tolower(chaine)
+ char *chaine;
+{
+ int i;
+
+ for( i=0; i< (int) strlen(chaine); i++) {
+ if (chaine[i] >= 'A' && chaine[i] <= 'Z')
+ chaine[i] += 32;
+ }
+}
+#endif
+
+void free_toc(Toc_file *toc)
+{
+ int i,j,k;
+
+ /* Loop thru the boundaries and free the arrays */
+
+ for (i=0; i<(int)toc->num_boundaries; i++)
+ {
+ if(toc->entries[i].frames != (Frame_entry **)NULL)
+ {
+ for (j=0; j<toc->entries[i].vert_frames; j++)
+ {
+ if(toc->entries[i].frames[j] != (Frame_entry *)NULL)
+ {
+ for (k=0; k<toc->entries[i].horiz_frames; k++)
+
+ if(toc->entries[i].frames[j][k].directory != (char *)NULL)
+ free(toc->entries[i].frames[j][k].directory);
+ free((char *)toc->entries[i].frames[j]);
+ }
+ }
+ free((char *)toc->entries[i].frames);
+ }
+ }
+ if(toc->entries != (Toc_entry *)NULL)
+ free((char *)toc->entries);
+
+}
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/datadict.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/datadict.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/datadict.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,244 @@
+static char datadict[] = {'\n'
+,'i','t','c','l','_','c','l','a','s','s',' ','s','k','e','l','e','t','o','n','_','D','a','t','a','D','i','c','t','i','o','n','a','r','y',' ','{'
+,'\n'
+,' ',' ','i','n','h','e','r','i','t',' ','d','d'
+,'\n'
+
+,'\n'
+,'c','o','n','s','t','r','u','c','t','o','r',' ','{','w','i','n','d','o','w','p','a','t','h',' ','l','o','c','a','t','i','o','n','}',' ','{'
+,'\n'
+,' ',' ','d','d',':',':','c','o','n','s','t','r','u','c','t','o','r',' ','$','w','i','n','d','o','w','p','a','t','h',' ','$','l','o','c','a','t','i','o','n'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','l','a','y','o','u','t',' ','{','}',' ','{'
+,'\n'
+,' ',' ','p','r','e','v','i','o','u','s',' ','l','a','y','o','u','t'
+,'\n'
+,'}'
+,'\n'
+,' '
+,'\n'
+,'m','e','t','h','o','d',' ','b','u','t','t','o','n','s',' ','{','}',' ','{'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','n','e','w','B','i','n','d','i','n','g',' ','{','w','i','d','g','e','t',' ','y','}',' ','{'
+,'\n'
+,'\t','p','r','e','v','i','o','u','s',' ','n','e','w','B','i','n','d','i','n','g',' ','$','w','i','d','g','e','t',' ','$','y'
+,'\n'
+,'\t','s','e','t',' ','s','_','n','e','a','r','e','s','t',' ','[','$','w','i','d','g','e','t',' ','n','e','a','r','e','s','t',' ','$','y',']'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'#',' ','c','h','a','n','g','e',' ','t','h','e',' ','t','i','t','l','e',' ','o','f',' ','t','h','e',' ','l','i','s','t','b','o','x'
+,'\n'
+,'m','e','t','h','o','d',' ','m','a','p','L','i','s','t','b','o','x',' ','{','}',' ','{'
+,'\n'
+,'\t','p','r','e','v','i','o','u','s',' ','m','a','p','L','i','s','t','b','o','x'
+,'\n'
+,'\t','$','w','i','n','d','o','w','.','c','e','n','t','e','r','.','r','i','g','h','t','.','l','a','y','e','r','s',' ','c','o','n','f','i','g','u','r','e',' ','-','l','a','b','e','l',' ','\"','F','e','a','t','u','r','e','s','\"'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','m','e','n','u','s',' ','{','}',' ','{'
+,'\n'
+,' ',' ','p','r','e','v','i','o','u','s',' ','m','e','n','u','s'
+,'\n'
+
+,'\n'
+,' ',' ','t','i','x','L','a','b','e','l','F','r','a','m','e',' ','$','w','i','n','d','o','w','.','m','e','n','u','.','f','r','a','m','e',' ','\\'
+,'\n'
+,' ',' ',' ',' ','-','l','a','b','e','l',' ','\"','O','p','t','i','o','n','s','\"',' ','\\'
+,'\n'
+,' ',' ',' ',' ','-','l','a','b','e','l','s','i','d','e',' ','a','c','r','o','s','s','t','o','p'
+,'\n'
+
+,'\n'
+,' ',' ','s','e','t',' ','p','a','t','h',' ','[','$','w','i','n','d','o','w','.','m','e','n','u','.','f','r','a','m','e',' ','s','u','b','w','i','d','g','e','t',' ','f','r','a','m','e',']'
+,'\n'
+
+,'\n'
+,' ',' ','s','e','t',' ','c','l','a','s','s','O','p','t','i','o','n','s',' ','$','p','a','t','h','.','c','l','a','s','s'
+,'\n'
+,' ',' ','t','i','x','O','p','t','i','o','n','M','e','n','u',' ','$','p','a','t','h','.','c','l','a','s','s',' ','-','l','a','b','e','l',' ','\"','F','e','a','t','u','r','e',' ','C','l','a','s','s',':',' ','\"',' ','\\'
+,'\n'
+,' ',' ',' ',' ','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','u','p','d','a','t','e','L','i','s','t','B','o','x','\"',' ','\\'
+,'\n'
+,' ',' ',' ',' ','-','o','p','t','i','o','n','s',' ','{'
+,'\n'
+,' ',' ',' ',' ',' ',' ','l','a','b','e','l',' ','w','i','d','t','h',' ','1','0'
+,'\n'
+,' ',' ',' ',' ',' ',' ','l','a','b','e','l',' ','a','n','c','h','o','r',' ','w'
+,'\n'
+,' ',' ',' ',' ',' ',' ','m','e','n','u','b','u','t','t','o','n','.','w','i','d','t','h',' ','1','2'
+,'\n'
+,' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ','p','a','c','k',' ','a','p','p','e','n','d',' ','$','p','a','t','h',' ','\\'
+,'\n'
+,' ',' ',' ',' ','$','p','a','t','h','.','c','l','a','s','s',' ','{',' ','l','e','f','t',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ','p','a','c','k',' ','a','p','p','e','n','d',' ','$','w','i','n','d','o','w','.','m','e','n','u',' ','\\'
+,'\n'
+,' ',' ',' ',' ','$','w','i','n','d','o','w','.','m','e','n','u','.','f','r','a','m','e',' ','{','t','o','p',' ','e','x','p','a','n','d',' ','f','i','l','l','x','}'
+,'\n'
+,' ',' ','}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','u','p','d','a','t','e','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+
+,'\n'
+,' ',' ',' ','s','e','t',' ','c','o','v','e','r','a','g','e','D','a','t','a',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',']'
+,'\n'
+,' ',' ',' ','f','o','r','e','a','c','h',' ','c','l','a','s','s',' ','$','c','o','v','e','r','a','g','e','O','r','d','e','r',' ','{'
+,'\n'
+,' ',' ',' ',' ',' ',' ','c','a','t','c','h',' ','{',' ','$','c','l','a','s','s','O','p','t','i','o','n','s',' ','a','d','d',' ','c','o','m','m','a','n','d',' ','$','c','l','a','s','s',' ','-','l','a','b','e','l',' ','$','c','l','a','s','s',' ','}'
+,'\n'
+,' ',' ',' ','}'
+,'\n'
+,' ',' ',' ','$','c','l','a','s','s','O','p','t','i','o','n','s',' ','c','o','n','f','i','g',' ','-','d','i','s','a','b','l','e','c','a','l','l','b','a','c','k',' ','0'
+,'\n'
+,' ',' ',' ','u','p','d','a','t','e','C','o','v','e','r','a','g','e','S','e','l','e','c','t','i','o','n',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','u','p','d','a','t','e','C','o','v','e','r','a','g','e','S','e','l','e','c','t','i','o','n',' ','{','a','r','g','s','}',' ','{'
+,'\n'
+,' ',' ','u','p','d','a','t','e','L','i','s','t','B','o','x',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',']'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,'#',' ','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e'
+,'\n'
+,'#',' ',' '
+,'\n'
+,'#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',' ','{','}',' ','{','}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',' ','{','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','[','$','c','l','a','s','s','O','p','t','i','o','n','s',' ','c','g','e','t',' ','-','v','a','l','u','e',']'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,'#',' ','u','p','d','a','t','e','L','i','s','t','b','o','x'
+,'\n'
+,'#'
+,'\n'
+,'#',' ','u','p','d','a','t','e','s',' ','t','h','e',' ','l','i','s','t','b','o','x',' ','w','i','t','h',' ','t','h','e',' ','s','e','l','e','c','t','e','d',' ','c','o','v','e','r','a','g','e',' ','a','n','d',' ','c','l','a','s','s','.'
+,'\n'
+,'#',' ','p','r','e',':',' ','p','r','o','t','e','c','t','e','d',' ','v','a','r','i','a','b','l','e',' ','c','o','v','e','r','a','g','e','D','a','t','a',' ','h','a','s',' ','b','e','e','n',' ','s','e','t',' ','w','i','t','h',' ','l','i','s','t'
+,'\n'
+,'#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','u','p','d','a','t','e','L','i','s','t','B','o','x',' ','{','s','e','l','e','c','t','e','d','C','l','a','s','s','}',' ','{'
+,'\n'
+,'\t','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','d','e','l','e','t','e',' ','0',' ','e','n','d'
+,'\n'
+,'\t','s','e','t',' ','m','a','p','s',' ','[','l','i','n','d','e','x',' ','$','c','o','v','e','r','a','g','e','D','a','t','a',' ','[','l','s','e','a','r','c','h',' ','$','c','o','v','e','r','a','g','e','O','r','d','e','r',' ','$','s','e','l','e','c','t','e','d','C','l','a','s','s',']',']'
+,'\n'
+,' ',' ','\t','f','o','r','e','a','c','h',' ','s','_','m','a','p',' ','$','m','a','p','s',' ','{'
+,'\n'
+,'\t','\t','a','p','p','e','n','d','M','a','p','I','t','e','m',' ','$','s','_','m','a','p'
+,'\n'
+,' ',' ','\t','}'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,'#',' ','a','p','p','e','n','d','M','a','p','I','t','e','m'
+,'\n'
+,'#',' ',' ',' ',' ','a','p','p','e','n','d',' ','s','o','m','e','t','h','i','n','g',' ','t','o',' ','t','h','e',' ','l','i','s','t',' ','o','f',' ','m','a','p',' ','i','t','e','m','s','.'
+,'\n'
+,'#'
+,'\n'
+,'#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','a','p','p','e','n','d','M','a','p','I','t','e','m',' ','{','i','t','e','m','}',' ','{'
+,'\n'
+,'\t','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','i','n','s','e','r','t',' ','e','n','d',' ','$','i','t','e','m'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+
+,'\n'
+,'#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,'#',' ','g','e','t','P','a','t','h','n','a','m','e'
+,'\n'
+,'#'
+,'\n'
+,'#',' ','c','o','n','s','t','r','u','c','t',' ','a',' ','p','a','t','h','n','a','m','e','.',' ',' ','I','f',' ','t','h','e','r','e',' ','i','s',' ','n','o',' ','e','x','p','r','e','s','s','i','o','n',',',' ','(','*',')',' ','i','s',' '
+,'\n'
+,'#',' ','a','p','p','e','n','d','e','d',' ','a','s',' ','a',' ','q','u','e','r','y','.'
+,'\n'
+,'#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','g','e','t','P','a','t','h','n','a','m','e',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','n','a','m','e','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','n','a','m','e'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'m','e','t','h','o','d',' ','s','e','t','P','r','i','v','a','t','e','D','a','t','a',' ','{','l','_','l','i','s','t','}',' ','{'
+,'\n'
+
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+,'p','r','o','t','e','c','t','e','d',' ','c','o','v','e','r','a','g','e','O','r','d','e','r',' ','{','R','a','s','t','e','r',' ','A','r','e','a',' ','L','i','n','e',' ','P','o','i','n','t',' ','T','e','x','t','}'
+,'\n'
+,'\t'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+
+,'\n'
+,'\0'};
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/datainfo.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/datainfo.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/datainfo.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,12 @@
+
+/*
+ This header contain the "database" itself. It's a list of values
+ for each available data type available in the skeleton driver.
+ */
+
+#ifndef DATAINFO_H
+#define DATAINFO_H
+
+
+#endif
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = skeleton
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = skeleton.c open.c object.c utils.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) $(GLUTIL_INCLUDE) $(PROJ_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(MACHINE) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(GLUTIL_STATICLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR datadict.h
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/object.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/object.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/object.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1602 @@
+/*********************************************************************
+
+ CSOURCE_INFORMATION
+
+ NAME
+ object.c
+
+ DESCRIPTION&
+ Implementation of skeleton driver getObject* functions
+ END_DESCRIPTION
+
+ END_CSOURCE_INFORMATION
+
+ Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ ********************************************************************/
+
+#include "skeleton.h"
+
+/*
+ Database of area.
+ */
+
+int dbareaqty = 2;
+dbareatype dbarea[2] = {{1,
+ 9,
+ {{598924.242,4921629.735},{594678.030,4920190.341},{594138.258,4917851.326},{595937.500,4915224.432},{599140.152,4915692.235},{601119.318,4916987.689},{601227.273,4920082.386},{600543.561,4920946.023},{598924.242,4921629.735}},
+ 6,
+ {{597736.742,4919434.659},{596369.318,4918535.038},{596441.288,4917491.477},{597772.727,4917203.598},{599140.152,4919038.826},{597736.742,4919434.659}},
+ 4921629.735,
+ 4915224.432,
+ 601227.273,
+ 594138.258},
+ {2,
+ 7,
+ {{605653.409,4920586.174},{602918.561,4919074.811},{602486.742,4916771.780},{604142.045,4915548.295},{606517.045,4916591.856},{607956.439,4919722.538},{605653.409,4920586.174}},
+ 5,
+ {{605185.606,4918499.053},{603314.394,4917635.417},{603494.318,4916843.750},{605149.621,4917023.674},{605185.606,4918499.053}},
+ 4920586.174,
+ 4915548.295,
+ 605185.606,
+ 603314.394}
+};
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getNextObjectArea
+
+ DESCRIPTION
+ This function retrieves the Area data objects in a sequential
+ access.
+
+ In this example, areas of the spearfish database are used and
+ each area contains two polygons, the main polygon and other as
+ an island. In the current layer, the geographical objects are
+ related to an index. If the current position in the index is
+ greater than the number of objects in it, then the function will
+ indicate that the selection is completed. The attributes will be
+ dummy values set in the format defined in GetAttributesFormat.
+
+ The objects are filtered in a way that prevents them to be
+ returned if the object is outside the current region. A filter
+ could also be applied in the drivers with a filter expression
+ like VRF.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void _getNextObjectArea(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ int i;
+ char buffer[3];
+
+ /*
+ Go to the next valid index position.
+ */
+
+ while (dbarea[l->index].north < s->currentRegion.south ||
+ dbarea[l->index].south > s->currentRegion.north ||
+ dbarea[l->index].east < s->currentRegion.west ||
+ dbarea[l->index].west > s->currentRegion.east) {
+ l->index++;
+ if (l->index >= l->nbfeature) {
+ break;
+ }
+ }
+
+ /*
+ If the index is superior to the number of geographical objects in
+ the database, the function returns an error message with an error
+ code of "2" that will simply indicate the end of the selection.
+ Code 1 is for a real error message.
+ */
+
+ if (l->index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /*
+ Extract the area at the position l->index. It's a valid polygon.
+ */
+
+ /*
+ ecs_SetGeomArea define a area in the OGDI. It indicate in the
+ ecs_Result structure the quantity of rings presents in the
+ area. In this case, the number of rings is 2, the main ring and
+ the island.
+ */
+
+ ecs_SetGeomArea(&(s->result),2);
+
+ /*
+ Define the first ring (ring number 0). When a ring is define, the
+ number of points and the centroid must be known. In that case, the
+ centroid is undefined (0,0). Once the ecs_SetGeomAreaRing is
+ called, the points are added one by one in the ring with
+ ECS_SETGEOMAREACOORD.
+ */
+
+ ecs_SetGeomAreaRing(&(s->result),0,
+ dbarea[l->index].arealistlength,0.0,0.0);
+
+ for(i=0;i<dbarea[l->index].arealistlength;i++) {
+ ECS_SETGEOMAREACOORD((&(s->result)), 0, i,
+ dbarea[l->index].arealist[i].x,
+ dbarea[l->index].arealist[i].y);
+ }
+
+ /*
+ Define the second ring (ring number 1). Work like the ring 0.
+ */
+
+ ecs_SetGeomAreaRing(&(s->result),1,
+ dbarea[l->index].islandlistlength,0.0,0.0);
+
+ for(i=0;i<dbarea[l->index].islandlistlength;i++) {
+ ECS_SETGEOMAREACOORD((&(s->result)), 1, i,
+ dbarea[l->index].islandlist[i].x,
+ dbarea[l->index].islandlist[i].y);
+ }
+
+ /*
+ Define the id of the object. Could be any value define for the
+ object in the database but it must be unique. The dyn_GetObject
+ and dyn_GetObjectIdFromCoord use this identifier to handle the
+ objects.
+ */
+
+ sprintf(buffer,"%d",l->index);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ /*
+ Define the bounding box of the object.
+ */
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ dbarea[l->index].west,
+ dbarea[l->index].south,
+ dbarea[l->index].east,
+ dbarea[l->index].north);
+
+ /*
+ Set the attribute list. It's a string list with a format describe
+ by dyn_GetAttributesFormat.
+ */
+
+ ecs_SetObjectAttr(&(s->result),"{test d'attributs} 1 10.0");
+
+ l->index++;
+
+ ecs_SetSuccess((&(s->result)));
+ return;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectArea
+
+ DESCRIPTION
+ This function retrieves an Area data object with a dynamic
+ access.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ char *id: A string with the object id number
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getObjectArea(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ int index;
+ int i;
+ char buffer[3];
+
+ index = atoi(id);
+
+ if (index < 0 || index >= l->nbfeature) {
+ ecs_SetError(&(s->result),1,"Invalid area id");
+ return;
+ }
+
+ /*
+ Extract the area at the position l->index. It's a valid polygon.
+ */
+
+ /*
+ ecs_SetGeomArea define a area in the OGDI. It indicate in the
+ ecs_Result structure the quantity of rings presents in the
+ area. In this case, the number of rings is 2, the main ring and
+ the island.
+ */
+
+ ecs_SetGeomArea(&(s->result),2);
+
+ /*
+ Define the first ring (ring number 0). When a ring is define, the
+ number of points and the centroid must be known. In that case, the
+ centroid is undefined (0,0). Once the ecs_SetGeomAreaRing is
+ called, the points are added one by one in the ring with
+ ECS_SETGEOMAREACOORD.
+ */
+
+ ecs_SetGeomAreaRing(&(s->result),0,
+ dbarea[index].arealistlength,0.0,0.0);
+
+ for(i=0;i<dbarea[index].arealistlength;i++) {
+ ECS_SETGEOMAREACOORD((&(s->result)), 0, i,
+ dbarea[index].arealist[i].x,
+ dbarea[index].arealist[i].y);
+ }
+
+ /*
+ Define the second ring (ring number 1). Work like the ring 0.
+ */
+
+ ecs_SetGeomAreaRing(&(s->result),1,
+ dbarea[index].islandlistlength,0.0,0.0);
+
+ for(i=0;i<dbarea[index].islandlistlength;i++) {
+ ECS_SETGEOMAREACOORD((&(s->result)), 1, i,
+ dbarea[index].islandlist[i].x,
+ dbarea[index].islandlist[i].y);
+ }
+
+ /*
+ Define the id of the object. Could be any value define for the
+ object in the database but it must be unique. The dyn_GetObject
+ and dyn_GetObjectIdFromCoord use this identifier to handle the
+ objects.
+ */
+
+ sprintf(buffer,"%d",index);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ /*
+ Define the bounding box of the object.
+ */
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ dbarea[index].west,
+ dbarea[index].south,
+ dbarea[index].east,
+ dbarea[index].north);
+
+
+ /*
+ Set the attribute list. It's a string list with a format describe
+ by dyn_GetAttributesFormat.
+ */
+
+ ecs_SetObjectAttr(&(s->result),"{test d'attributs} 1 10.0");
+
+ ecs_SetSuccess((&(s->result)));
+ return;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectIdArea
+
+ DESCRIPTION
+ This function retrieves the object id of the nearest area from a
+ set of coordinates. Usually, these coordinates are defined by
+ the user of the OGDI in order to extract with it a geographical
+ object.
+
+ The way the algorithm works in this example is simply by
+ checking which point of the area are the nearest from a set of
+ coordinates. The identifier of the polygon where the point
+ belong is returned.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information.
+ ecs_Coordinate *coord: Object coordinates.
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void _getObjectIdArea(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ double distance=0,calcdistance=0,pointdistance;
+ int firstobj;
+ int index,position;
+ char buffer[60];
+ int i;
+
+ firstobj = TRUE;
+ index = 0;
+
+ position = -1;
+
+ while (index <= l->nbfeature) {
+
+ /*
+ Calculate the shortest distance between the selected set of
+ coordinates and the area at the "index" position.
+ */
+
+ for(i=0;i<dbarea[index].arealistlength;i++) {
+ pointdistance = ((dbarea[index].arealist[i].x - coord->x)*(dbarea[index].arealist[i].x - coord->x)+
+ (dbarea[index].arealist[i].y - coord->y)*(dbarea[index].arealist[i].y - coord->y));
+ if (i==0)
+ calcdistance = pointdistance;
+ else
+ if (calcdistance > pointdistance)
+ calcdistance = pointdistance;
+ }
+
+ if (firstobj) {
+ distance = calcdistance;
+ position = index;
+ firstobj = FALSE;
+ } else {
+ if (calcdistance < distance) {
+ distance = calcdistance;
+ position = index;
+ }
+ }
+ index++;
+ }
+
+ if (position < 0) {
+ ecs_SetError(&(s->result),2,"No polygons found");
+ } else {
+ sprintf(buffer,"%d",position);
+ if(ecs_SetText(&(s->result),buffer)) {
+ ecs_SetSuccess(&(s->result));
+ }
+ }
+}
+
+
+/*
+ Database of lines
+ */
+
+int dblineqty = 4;
+dblinetype dbline[4] = {{1,
+ 9,
+ {{598924.242,4921629.735},{594678.030,4920190.341},{594138.258,4917851.326},{595937.500,4915224.432},{599140.152,4915692.235},{601119.318,4916987.689},{601227.273,4920082.386},{600543.561,4920946.023},{598924.242,4921629.735}},
+ 4921629.735,
+ 4915224.432,
+ 601227.273,
+ 594138.258},
+ {2,
+ 6,
+ {{597736.742,4919434.659},{596369.318,4918535.038},{596441.288,4917491.477},{597772.727,4917203.598},{599140.152,4919038.826},{597736.742,4919434.659}},
+ 4919434.659,
+ 4917203.598,
+ 599140.152,
+ 596369.318},
+ {3,
+ 7,
+ {{605653.409,4920586.174},{602918.561,4919074.811},{602486.742,4916771.780},{604142.045,4915548.295},{606517.045,4916591.856},{607956.439,4919722.538},{605653.409,4920586.174}},
+ 4920586.174,
+ 4915548.295,
+ 605185.606,
+ 603314.394},
+ {4,
+ 5,
+ {{605185.606,4918499.053},{603314.394,4917635.417},{603494.318,4916843.750},{605149.621,4917023.674},{605185.606,4918499.053}},
+ 4920586.174,
+ 4915548.295,
+ 605185.606,
+ 603314.394}};
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getNextObjectLine
+
+ DESCRIPTION
+ This function retrieves the Line data objects in a sequential
+ access.
+
+ In the current layer, the geographical objects are related to an
+ index. If the current position in the index is greater than the
+ number of objects in it, then the function will indicate that
+ the selection is completed. The attributes will be dummy values
+ set in the format defined in GetAttributesFormat.
+
+ The objects are filtered in a way that prevents them to be
+ returned if the object is outside the current region. A filter
+ could also be applied in the drivers with a filter expression
+ like VRF.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection informations.
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void _getNextObjectLine(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ int i;
+ char buffer[3];
+
+ /*
+ Go to the next valid index position.
+ */
+
+ while (dbline[l->index].north < s->currentRegion.south ||
+ dbline[l->index].south > s->currentRegion.north ||
+ dbline[l->index].east < s->currentRegion.west ||
+ dbline[l->index].west > s->currentRegion.east) {
+ l->index++;
+ if (l->index >= l->nbfeature) {
+ break;
+ }
+ }
+
+ /*
+ If the index is superior to the number of geographical objects in
+ the database, the function returns an error message with an error
+ code of "2" that will simply indicate the end of the selection.
+ Code 1 is for a real error message.
+ */
+
+ if (l->index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /*
+ Extract the line at the position l->index. It's
+ a valid polygon.
+ */
+
+ ecs_SetGeomLine(&(s->result),dbline[l->index].linelistlength);
+
+ for(i=0;i<dbline[l->index].linelistlength;i++) {
+ ECS_SETGEOMLINECOORD((&(s->result)), i,
+ dbline[l->index].linelist[i].x,
+ dbline[l->index].linelist[i].y);
+ }
+
+ /*
+ Define the id of the object. Could be any value define for the
+ object in the database but it must be unique and the dyn_GetObject
+ and dyn_GetObjectIdFromCoord use this identifier to handle the
+ objects.
+ */
+
+ sprintf(buffer,"%d",l->index);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ /*
+ Define the bounding box of the object.
+ */
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ dbline[l->index].west,
+ dbline[l->index].south,
+ dbline[l->index].east,
+ dbline[l->index].north);
+
+ /*
+ Set the attribute list. It's a string list with a format describe
+ by dyn_GetAttributesFormat.
+ */
+
+ ecs_SetObjectAttr(&(s->result),"{test d'attributs} 1 10.0");
+
+ l->index++;
+
+ ecs_SetSuccess((&(s->result)));
+ return;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectLine
+
+ DESCRIPTION
+ This function retrieves the Line data objects with a dynamic
+ access.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection informations.
+ char *id: A string with the object id number
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getObjectLine(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ int index;
+ int i;
+ char buffer[3];
+
+ index = atoi(id);
+
+ if (index < 0 || index >= l->nbfeature) {
+ ecs_SetError(&(s->result),1,"Invalid line id");
+ return;
+ }
+
+ /*
+ Extract the line at the position index. It's a valid polygon.
+ */
+
+ ecs_SetGeomLine(&(s->result),dbline[index].linelistlength);
+
+ for(i=0;i<dbline[index].linelistlength;i++) {
+ ECS_SETGEOMLINECOORD((&(s->result)), i,
+ dbline[index].linelist[i].x,
+ dbline[index].linelist[i].y);
+ }
+
+ sprintf(buffer,"%d",index);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ dbline[index].west,
+ dbline[index].south,
+ dbline[index].east,
+ dbline[index].north);
+
+ ecs_SetObjectAttr(&(s->result),"{test d'attributs} 1 10.0");
+
+ index++;
+
+ ecs_SetSuccess((&(s->result)));
+ return;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectIdLine
+
+ DESCRIPTION
+ This function retrieves the object id of the nearest polyline of
+ a set of coordinates.
+
+ The way the algorithm works in this example is simply by
+ checking which points of the polyline are the nearest from of
+ set of coordinates. The identifier of the polyline where the
+ point belong is returned,
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ ecs_Coordinate *coord: Object coordinate
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getObjectIdLine(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ double distance=0,calcdistance=0,pointdistance;
+ int firstobj;
+ int index,position;
+ char buffer[60];
+ int i;
+
+ firstobj = TRUE;
+ index = 0;
+
+ position = -1;
+
+ while (index <= l->nbfeature) {
+
+ /* Calculate the shortest distance between the set of coordinates and
+ the area at the "index" position */
+
+ for(i=0;i<dbline[index].linelistlength;i++) {
+ pointdistance = ((dbline[index].linelist[i].x - coord->x)*(dbline[index].linelist[i].x - coord->x)+
+ (dbline[index].linelist[i].y - coord->y)*(dbline[index].linelist[i].y - coord->y));
+ if (i==0)
+ calcdistance = pointdistance;
+ else
+ if (calcdistance > pointdistance)
+ calcdistance = pointdistance;
+ }
+
+ if (firstobj) {
+ distance = calcdistance;
+ position = index;
+ firstobj = FALSE;
+ } else {
+ if (calcdistance < distance) {
+ distance = calcdistance;
+ position = index;
+ }
+ }
+ index++;
+ }
+
+ if (position < 0) {
+ ecs_SetError(&(s->result),2,"No line found");
+ } else {
+ sprintf(buffer,"%d",position);
+ if(ecs_SetText(&(s->result),buffer)) {
+ ecs_SetSuccess(&(s->result));
+ }
+ }
+}
+
+/*
+ Database of points
+ */
+
+int dbpointqty = 9;
+dbpointtype dbpoint[9] = {{1,
+ {598924.242,4921629.735}},
+ {2,
+ {594678.030,4920190.341}},
+ {3,
+ {594138.258,4917851.326}},
+ {4,
+ {595937.500,4915224.432}},
+ {5,
+ {599140.152,4915692.235}},
+ {6,
+ {601119.318,4916987.689}},
+ {7,
+ {601227.273,4920082.386}},
+ {8,
+ {600543.561,4920946.023}},
+ {9,
+ {598924.242,4921629.735}}};
+
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getNextObjectPoint
+
+ DESCRIPTION
+ This function retrieves the Point data objects in a sequential
+ access.
+
+ In the current layer, the geographical objects are related to an
+ index. If the current position in the index is greater than the
+ number of objects in it, then the function will indicate that
+ the selection is completed. The attributes will be dummy values
+ set in the format defined in GetAttributesFormat.
+
+ An object is filtered in a way that prevents them to be returned
+ if the object is outside the current region. A filter could also
+ be apply in the drivers with a filter expression like VRF.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by OGDI API
+ ecs_Layer *l: Layer selection infos
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getNextObjectPoint(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ char buffer[3];
+
+ /*
+ Go to the next valid index position.
+ */
+
+ while (dbpoint[l->index].geopoint.y < s->currentRegion.south ||
+ dbpoint[l->index].geopoint.y > s->currentRegion.north ||
+ dbpoint[l->index].geopoint.x < s->currentRegion.west ||
+ dbpoint[l->index].geopoint.x > s->currentRegion.east) {
+ l->index++;
+ if (l->index >= l->nbfeature) {
+ break;
+ }
+ }
+
+ /*
+ If the index is superior to the number of geographical objects in
+ the database, the function returns an error message with an error
+ code of "2" that will simply indicate the end of the selection.
+ Code 1 is for a real error message.
+ */
+
+ if (l->index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /*
+ Extract the line at the position l->index. It's
+ a valid polygon.
+ */
+
+ ecs_SetGeomPoint(&(s->result),dbpoint[l->index].geopoint.x,dbpoint[l->index].geopoint.y);
+
+ sprintf(buffer,"%d",l->index);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ dbpoint[l->index].geopoint.x,
+ dbpoint[l->index].geopoint.y,
+ dbpoint[l->index].geopoint.x,
+ dbpoint[l->index].geopoint.y);
+
+ ecs_SetObjectAttr(&(s->result),"{test d'attributs} 1 10.0");
+
+ l->index++;
+
+ ecs_SetSuccess((&(s->result)));
+ return;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectPoint
+
+ DESCRIPTION
+ This function retrieves the Point data objects with a dynamic
+ access.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by OGDI API
+ ecs_Layer *l: Layer selection infos
+ char *id: A string with the object id number
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+
+void
+_getObjectPoint(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ int index;
+ char buffer[3];
+
+ index = atoi(id);
+
+ if (index < 0 || index >= l->nbfeature) {
+ ecs_SetError(&(s->result),1,"Invalid point id");
+ return;
+ }
+
+ ecs_SetGeomPoint(&(s->result),dbpoint[index].geopoint.x,dbpoint[index].geopoint.y);
+
+ sprintf(buffer,"%d",index);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ dbpoint[index].geopoint.x,
+ dbpoint[index].geopoint.y,
+ dbpoint[index].geopoint.x,
+ dbpoint[index].geopoint.y);
+
+ ecs_SetObjectAttr(&(s->result),"{test d'attributs} 1 10.0");
+
+ ecs_SetSuccess((&(s->result)));
+ return;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectIdPoint
+
+ DESCRIPTION
+ This function retrieves the object id of the nearest point
+ object from a set of coordinates
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by OGDI API
+ ecs_Layer *l: Layer selection infos
+ ecs_Coordinate *coord: Object coordinate
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getObjectIdPoint(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ double distance,calcdistance;
+ int firstobj;
+ int index,position;
+ char buffer[60];
+
+ firstobj = TRUE;
+ index = 0;
+
+ position = -1;
+
+ while (index <= l->nbfeature) {
+
+ /*
+ Calculate the shortest distance between the set of given
+ coordinates and a point at the "index" position.
+ */
+
+ calcdistance = ((dbpoint[index].geopoint.x - coord->x)*(dbpoint[index].geopoint.x - coord->x)+
+ (dbpoint[index].geopoint.y - coord->y)*(dbpoint[index].geopoint.y - coord->y));
+
+ if (firstobj) {
+ distance = calcdistance;
+ position = index;
+ firstobj = FALSE;
+ } else {
+ if (calcdistance < distance) {
+ distance = calcdistance;
+ position = index;
+ }
+ }
+ index++;
+ }
+
+ if (position < 0) {
+ ecs_SetError(&(s->result),2,"No point found");
+ } else {
+ sprintf(buffer,"%d",position);
+ if(ecs_SetText(&(s->result),buffer)) {
+ ecs_SetSuccess(&(s->result));
+ }
+ }
+}
+
+/*
+ Text point database.
+ */
+
+int dbtextqty = 9;
+dbtexttype dbtext[9] = {{1,
+ {598924.242,4921629.735}},
+ {2,
+ {594678.030,4920190.341}},
+ {3,
+ {594138.258,4917851.326}},
+ {4,
+ {595937.500,4915224.432}},
+ {5,
+ {599140.152,4915692.235}},
+ {6,
+ {601119.318,4916987.689}},
+ {7,
+ {601227.273,4920082.386}},
+ {8,
+ {600543.561,4920946.023}},
+ {9,
+ {598924.242,4921629.735}}};
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getNextObjectText
+
+ DESCRIPTION
+ This function retrieves the Text data objects in a sequential
+ access.
+
+ In the current layer, the geographical objects are related to an
+ index. If the current position in the index is greater than the
+ number of objects in it, then the function will indicate that
+ the selection is completed. The attributes will be dummy values
+ set in the format defined in GetAttributesFormat.
+
+ The objects are filtered in a way that prevent them to be
+ returned if an object is outside the current region. A filter
+ could also be applied in the drivers with a filter expression
+ like VRF.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getNextObjectText(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ char buffer[3];
+
+ /*
+ Go to the next valid index position.
+ */
+
+ while (dbtext[l->index].geopoint.y < s->currentRegion.south ||
+ dbtext[l->index].geopoint.y > s->currentRegion.north ||
+ dbtext[l->index].geopoint.x < s->currentRegion.west ||
+ dbtext[l->index].geopoint.x > s->currentRegion.east) {
+ l->index++;
+ if (l->index >= l->nbfeature) {
+ break;
+ }
+ }
+
+ /*
+ If the index is superior to the number of geographical objects in
+ the database, the function returns an error message with an error
+ code of "2" that will simply indicate the end of the selection.
+ Code 1 is for a real error message.
+ */
+
+ if (l->index >= l->nbfeature) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /*
+ Extract the line at the position l->index. It's
+ a valid polygon.
+ */
+
+ sprintf(buffer,"%d",l->index);
+
+ ecs_SetGeomText(&(s->result),dbtext[l->index].geopoint.x,dbtext[l->index].geopoint.y,buffer);
+
+ ecs_SetObjectId(&(s->result),buffer);
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ dbtext[l->index].geopoint.x,
+ dbtext[l->index].geopoint.y,
+ dbtext[l->index].geopoint.x,
+ dbtext[l->index].geopoint.y);
+
+ ecs_SetObjectAttr(&(s->result),"{test d'attributs} 1 10.0");
+
+ l->index++;
+
+ ecs_SetSuccess((&(s->result)));
+ return;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectText
+
+ DESCRIPTION
+ This function retrieves the Text data objects with a dynamic access.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ char *id: A string with the object id number
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getObjectText(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ int index;
+ char buffer[3];
+
+ index = atoi(id);
+
+ if (index < 0 || index >= l->nbfeature) {
+ ecs_SetError(&(s->result),1,"Invalid text id");
+ return;
+ }
+
+ sprintf(buffer,"%d",index);
+
+ ecs_SetGeomText(&(s->result),dbtext[index].geopoint.x,dbtext[index].geopoint.y,buffer);
+
+ ecs_SetObjectId(&(s->result),buffer);
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ dbtext[index].geopoint.x,
+ dbtext[index].geopoint.y,
+ dbtext[index].geopoint.x,
+ dbtext[index].geopoint.y);
+
+ ecs_SetObjectAttr(&(s->result),"{test d'attributs} 1 10.0");
+
+ ecs_SetSuccess((&(s->result)));
+ return;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectIdText
+
+ DESCRIPTION
+ This function retrieves the object id of the nearest text point
+ of a set of coordinates.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ ecs_Coordinate *coord: Object coordinate
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getObjectIdText(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ double distance,calcdistance;
+ int firstobj;
+ int index,position;
+ char buffer[60];
+
+ firstobj = TRUE;
+ index = 0;
+
+ position = -1;
+
+ while (index <= l->nbfeature) {
+
+ /* Calculate the shortest distance between the coordinate and
+ the point at the position "index" */
+
+ calcdistance = ((dbtext[index].geopoint.x - coord->x)*(dbtext[index].geopoint.x - coord->x)+
+ (dbtext[index].geopoint.y - coord->y)*(dbtext[index].geopoint.y - coord->y));
+
+ if (firstobj) {
+ distance = calcdistance;
+ position = index;
+ firstobj = FALSE;
+ } else {
+ if (calcdistance < distance) {
+ distance = calcdistance;
+ position = index;
+ }
+ }
+ index++;
+ }
+
+ if (position < 0) {
+ ecs_SetError(&(s->result),2,"No text found");
+ } else {
+ sprintf(buffer,"%d",position);
+ if(ecs_SetText(&(s->result),buffer)) {
+ ecs_SetSuccess(&(s->result));
+ }
+ }
+}
+
+/*
+ The matrix extraction
+
+ The matrix extraction with OGDI is different than
+ usual. Actually, these functions do not extract a matrix but a
+ geographic region matrix. The objective is to fit the matrix
+ data selected in this layer into the matrix of the current
+ region.
+
+ There are two matrices to handle during this operation. The
+ current region matrix that should be considered as a "view" of a
+ given region and the matrix region itself. Both regions are
+ positionned inside a geospatial view. To fill the current region
+ matrix, the value related to each pixel is extracted point by
+ point. With a given pixel in the current region matrix, it is
+ easy to calculate its geographic position. Once this geographic
+ position is found, a resampling is carried out using a
+ nearest-neighbor algorithm to extract the value related to this
+ position in the matrix region.
+
+ We could do more, suppose your current region is actually a
+ region where the projection was previously changed. In that
+ case, the OGDI contain a RasterConversion module that will
+ automatically set variables in ecs_Server. This is simply a
+ point converter, for a given point in the current projection
+ matrix, the module indicate which point in the projected matrix
+ must be selected. All we need to do is to get the points
+ returned by these functions and get the value related to it as
+ described before.
+
+ Here is another point about how a raster layer, once transformed
+ and resampled, is returned to the OGDI. This is done row by row
+ in the current region. The values contained in these rows must
+ be non-negative values.
+
+ In the current example, all the functionality about how to use
+ the projections, the regions and the requests of the OGDI are
+ encapsulated inside the _getNextObjectMatrix and
+ _getObjectMatrix. All the driver programmer needs to do is to
+ modify the code inside _getValueFromCoord. What this function
+ does is to get value at the position i,j in the matrix layer
+ (the data itself). It is important that the region of this
+ matrix fits exactly the matrix region itself. It is also
+ important that the matrix resolution be correctly calculated
+ during the layer initialization.
+
+ In our example, the matrix contains four rectangular zone. The
+ first zone covers the first quarter of the total number of rows
+ and will be of category 1. The second zone cover the second
+ quarter of the total number of the matrix rows and will be of
+ category 2. The third zone covers the third quarter from the 3/4
+ of the total matrix rows and go to the last row. There is a gap
+ placed between the half matrix row to the 3/4 to illuatrate the
+ value 0. The 0 value is a non-existing category, all 0 values
+ are considered as empty pixels, and simply indicates those
+ pixels are not members of the layer matrix.
+ */
+
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getNextObjectMatrix
+
+ DESCRIPTION
+ Extract a row from the position of l->index and return it to
+ OGDI.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getNextObjectMatrix(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ int i,i2,j2;
+ char buffer[128];
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int totalcol,totalrow;
+ int value;
+ double pos;
+
+ totalcol = (int) ((s->currentRegion.east - s->currentRegion.west)/s->currentRegion.ew_res);
+ totalrow = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res);
+
+ lpriv->offsetx = (int) ((s->currentRegion.west - lpriv->matrixregion.west)/lpriv->matrixregion.ew_res);
+ lpriv->offsety = (int) ((lpriv->matrixregion.north - s->currentRegion.north)/lpriv->matrixregion.ns_res);
+
+ if (l->index >= totalrow) {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ ecs_SetGeomMatrix(&(s->result),totalcol);
+
+ if (s->rasterconversion.isProjEqual) {
+ for (i=0; i<totalcol; i++) {
+ value = _calcPosValue(s,l,i,l->index);
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),i,value);
+ }
+ } else {
+ for (i=0; i<totalcol; i++) {
+ i2 = ECSGETI(s,((double) l->index),((double)i));
+ j2 = ECSGETJ(s,((double) l->index),((double)i));
+ value = _calcPosValue(s,l,j2,i2);
+
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),i,value);
+ }
+ }
+
+ sprintf(buffer,"%d",l->index);
+ if (!ecs_SetObjectId(&(s->result),buffer)) {
+ return;
+ }
+
+ pos = s->currentRegion.north - l->index*s->currentRegion.ns_res;
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),s->currentRegion.west,
+ pos+s->currentRegion.ns_res,
+ s->currentRegion.east,pos)
+
+
+ l->index++;
+ ecs_SetSuccess(&(s->result));
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectMatrix
+
+ DESCRIPTION
+ This function retrieves the Matrix data row for the position in
+ "id".
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ char *id: A string with the object id number
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+
+void
+_getObjectMatrix(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ int index;
+ int i,i2,j2;
+ char buffer[128];
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int totalcol,totalrow;
+ int value;
+ double pos;
+
+ index = atoi(id);
+
+ totalcol = (int) ((s->currentRegion.east - s->currentRegion.west)/s->currentRegion.ew_res);
+ totalrow = (int) ((s->currentRegion.north - s->currentRegion.south)/s->currentRegion.ns_res);
+
+ lpriv->offsetx = (int) ((s->currentRegion.west - lpriv->matrixregion.west)/lpriv->matrixregion.ew_res);
+ lpriv->offsety = (int) ((lpriv->matrixregion.north - s->currentRegion.north)/lpriv->matrixregion.ns_res);
+
+ if (index < 0 || index >= totalrow) {
+ ecs_SetError(&(s->result),1,"Invalid matrix line id");
+ return;
+ }
+
+ ecs_SetGeomMatrix(&(s->result),totalcol);
+
+ if (s->rasterconversion.isProjEqual) {
+ for (i=0; i<totalcol; i++) {
+ value = _calcPosValue(s,l,i,index);
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),i,value);
+ }
+ } else {
+ for (i=0; i<totalcol; i++) {
+ i2 = ECSGETI(s,((double) index),((double)i));
+ j2 = ECSGETJ(s,((double) index),((double)i));
+ value = _calcPosValue(s,l,j2,i2);
+
+ ECS_SETGEOMMATRIXVALUE((&(s->result)),i,value);
+ }
+ }
+
+ sprintf(buffer,"%d",index);
+ if (!ecs_SetObjectId(&(s->result),buffer)) {
+ return;
+ }
+
+ pos = s->currentRegion.north - index*s->currentRegion.ns_res;
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),s->currentRegion.west,
+ pos+s->currentRegion.ns_res,
+ s->currentRegion.east,pos)
+
+
+ ecs_SetSuccess(&(s->result));
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getObjectIdMatrix
+
+ DESCRIPTION
+ This function retrieves the pixel value from a set of
+ coordinates.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ ecs_Coordinate *coord: Object coordinate
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_getObjectIdMatrix(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ char buffer[128];
+ int pix_c,pix_r;
+ int value;
+
+ pix_c = (int) ((coord->x - lpriv->matrixregion.west) / lpriv->matrixregion.ew_res);
+ pix_r = (int) ((coord->y - lpriv->matrixregion.south) / lpriv->matrixregion.ns_res);
+ value = 0;
+ if (pix_c >= 0 && pix_c < lpriv->matrixwidth &&
+ pix_r >= 0 && pix_r < lpriv->matrixheight) {
+
+ value = _getValueFromCoord(s,l,pix_c,pix_r);
+ }
+
+ sprintf(buffer,"%d",value);
+ if(ecs_SetText(&(s->result),buffer)) {
+ ecs_SetSuccess(&(s->result));
+ }
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _calcPosValue
+
+ DESCRIPTION
+ Get the value of a position i,j in the current region matrix.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ int i: Row in the matrix
+ int j: Column in the matrix
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : The category value found by this function
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+int _calcPosValue(s,l,i,j)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int i;
+ int j;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int pix_c,pix_r;
+ register int value;
+
+ /*
+ Calculate the geographic position in the current region matrix for
+ the point i,j.
+ */
+
+ /*
+ pos_x = s->currentRegion.west + i*s->currentRegion.ew_res;
+ pos_y = s->currentRegion.north - j*s->currentRegion.ns_res;
+
+
+ With geographic region calculated, found the nearest pixel
+ position where fall this coordinate.
+
+
+ pix_c = (int) ((pos_x - lpriv->matrixregion.west) / lpriv->matrixregion.ew_res);
+ pix_r = (int) ((pos_y - lpriv->matrixregion.south) / lpriv->matrixregion.ns_res);
+ */
+
+ pix_c = ((int) (i*s->currentRegion.ew_res/lpriv->matrixregion.ew_res))+lpriv->offsetx;
+ pix_r = ((int) (j*s->currentRegion.ns_res/lpriv->matrixregion.ns_res))+lpriv->offsety;
+
+ /*
+ Get the value at this pixel position with a special care
+ to check if the point fall inside the matrix.
+ */
+
+ if ((pix_c>=0) && (pix_c<lpriv->matrixwidth) &&
+ (pix_r>=0) && (pix_r<lpriv->matrixheight)) {
+ value = _getValueFromCoord(s,l,pix_c,pix_r);
+ } else {
+ value = 0;
+ }
+
+ return value;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _getValueFromCoord
+
+ DESCRIPTION
+ Get the value for a position pix_c,pix_r in the current layer
+ matrix.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ int i: Row in the matrix
+ int j: Column in the matrix
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : The category value found by this function
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+int _getValueFromCoord(s,l,pix_c,pix_r)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int pix_c;
+ int pix_r;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int value;
+
+ (void) pix_c;
+
+ if (pix_r < ((double) (lpriv->matrixheight/4.0)))
+ value = 1;
+ else if (pix_r < ((double) (lpriv->matrixheight/2.0)))
+ value = 2;
+ else if (pix_r < ((double) (3.0*lpriv->matrixheight/4.0)))
+ value = 0;
+ else value = 3;
+
+ return value;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/open.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/open.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/open.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,559 @@
+/*********************************************************************
+
+ CSOURCE_INFORMATION
+
+ NAME
+ open.c
+
+ DESCRIPTION
+ Implementation of skeleton open, close and rewind functions
+ END_DESCRIPTION
+
+ END_CSOURCE_INFORMATION
+
+ Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ ********************************************************************/
+
+#include "skeleton.h"
+
+extern int dbareaqty;
+extern int dblineqty;
+extern int dbpointqty;
+extern int dbtextqty;
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _openAreaLayer
+
+ DESCRIPTION
+ Open and initialize an area vector layer. In our case, this
+ function will do nothing except initializing the index to 0.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. TRUE if the operation is a success.
+ FALSE otherwise.
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+int
+_openAreaLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ l->index = 0;
+ l->nbfeature = dbareaqty;
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _closeAreaLayer
+
+ DESCRIPTION
+ Close a skeleton area vector layer.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_closeAreaLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _rewindAreaLayer
+
+ DESCRIPTION
+ Reset the area layer selection.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_rewindAreaLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ l->index = 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _openLineLayer
+
+ DESCRIPTION
+ Open and initialize a line vector layer. In our case, this
+ function will do nothing except setting the index to 0.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. TRUE if the operation is a success.
+ FALSE otherwise.
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+int
+_openLineLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ l->index = 0;
+ l->nbfeature = dblineqty;
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _closeLineLayer
+
+ DESCRIPTION
+ Close a skeleton line vector layer.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_closeLineLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _rewindLineLayer
+
+ DESCRIPTION
+ Reset the line layer selection.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_rewindLineLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ l->index = 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _openPointLayer
+
+ DESCRIPTION
+ Open and initialize a point vector layer. In our case, this
+ function will do nothing except setting the index to 0.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. TRUE if the operation is a success.
+ FALSE otherwise.
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+int
+_openPointLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ l->index = 0;
+ l->nbfeature = dbpointqty;
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _closePointLayer
+
+ DESCRIPTION
+ Close a skeleton point vector layer.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_closePointLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _rewindPointLayer
+
+ DESCRIPTION
+ Reset the point layer selection.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_rewindPointLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ l->index = 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _openTextLayer
+
+ DESCRIPTION
+ Open and initialize a text vector layer. In our case, this
+ function will do nothing except setting the index to 0.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. TRUE if the operation is a success.
+ FALSE otherwise.
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+int
+_openTextLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ l->index = 0;
+ l->nbfeature = dbtextqty;
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _closeTextLayer
+
+ DESCRIPTION
+ Close a skeleton text vector layer.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_closeTextLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _rewindTextLayer
+
+ DESCRIPTION
+ Reset the text layer selection.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_rewindTextLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ l->index = 0;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _openMatrixLayer
+
+ DESCRIPTION
+ Open and initialize a matrix vector layer. This function
+ will initialize the matrix region that will be used by
+ the matrix and the matrix width and height.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ RETURN_VALUE
+ int : An boolean code. TRUE if the operation is a success.
+ FALSE otherwise.
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+int
+_openMatrixLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+
+ (void) s;
+
+ l->index = 0;
+ lpriv->matrixregion.north = 4925000.0;
+ lpriv->matrixregion.south = 4918000.0;
+ lpriv->matrixregion.east = 597000.0;
+ lpriv->matrixregion.west = 592000.0;
+ lpriv->matrixwidth = 100;
+ lpriv->matrixheight = 100;
+ lpriv->matrixregion.ns_res = ((lpriv->matrixregion.north -
+ lpriv->matrixregion.south)/
+ ((double) lpriv->matrixwidth));
+ lpriv->matrixregion.ew_res = ((lpriv->matrixregion.east -
+ lpriv->matrixregion.west)/
+ ((double) lpriv->matrixheight));
+
+ return TRUE;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _closeMatrixLayer
+
+ DESCRIPTION
+ Close a skeleton matrix vector layer.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_closeMatrixLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _rewindMatrixLayer
+
+ DESCRIPTION
+ Reset the matrix layer selection.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Layer *l: Layer selection information
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+void
+_rewindMatrixLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ l->index = 0;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1182 @@
+/*********************************************************************
+
+ CSOURCE_INFORMATION
+
+ NAME
+ skeleton.c
+
+ DESCRIPTION
+ Implementation of the skeleton driver
+ END_DESCRIPTION
+
+ MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+ Procedures changed: dyn_CreateServer()
+ dyn_ReleaseLayer()
+
+ END_CSOURCE_INFORMATION
+
+ Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ ********************************************************************/
+
+#include "skeleton.h"
+#include "datadict.h"
+
+/*
+ Goal:
+
+ This driver is an example that helps developers to write new OGDI drivers.
+
+ Description:
+
+ The driver is divided in two parts: the usual driver part described
+ here and the "invisible part" that handles global operations
+ (server.c). That must be seen as an object oriented relationship
+ between the server.c and the driver. The server.c is the base class
+ where all common operations, common checks and calls to the driver
+ functions are done. The driver must be seen as an object that
+ inherits from this base class. Because we are working in standard
+ C, this is not totally "Object oriented". The functions are seen by
+ the OGDI as pointers but the ecs_Server structure must be seen as
+ the base class attributes. The ecs_Server structure contains many
+ attributes the driver programmer needs to know. Here is the list of
+ the attributes inside ecs_Server that needed to be used and
+ initialized by the driver.
+
+ void *priv: The private geographic information of the geographic driver
+ (spriv).
+ int currentLayer: The current layer in use in the driver
+ ecs_Region currentRegion: The current region of the geographic driver
+ ecs_Region globalRegion: The global region of the geographic driver
+ char *projection: The projection string for in case the projection
+ is undefined in the driver.
+ ecs_Result result: Returned structure to the OGDI user
+
+ The following attributes are handled by server.c. They must not be
+ modified by the driver.
+
+ char *hostname: The hostname extracted from the URL
+ char *server_type: The server type extracted from the URL
+ char *pathname: The path name extracted from the URL
+ ecs_RasterConversion rasterconversion: Used to convert rasters in the driver
+ ecs_Layer *layer: The table of the layer in use in the driver
+ int nblayer: Quantity of layers in layer.
+
+ As you notice, everything is handled by this structure. However,
+ this is global information and most of the drivers need to keep more
+ information. For this reason, there is a private structure in the
+ ecs_Server (priv). This is simply a pointer of the private
+ information for the driver. There is an example in skeleton.h
+ (ServerPrivateData).
+
+ Also, the URL is composed of three parts, the hostname, the driver
+ type and the pathname. The pathname is probably the most important
+ because it contains all the information a driver programmer really
+ needs. To facilitate the operation, the URL was preprocessed and
+ this part is already in the pathname attribute of the ecs_Server
+ structure.
+
+ The layers
+ ----------
+
+ Each time a request is passed to the SelectLayer, a structure is
+ created in memory which is the Layer structure. A layer contains all
+ the necessary information to handle a set of geographic data,
+ whatever the type. To handle a layer and its information, the OGDI
+ provides three important functions:
+
+ ecs_SetLayer: Create a layer in the driver and return its number
+ ecs_GetLayer: Check if a layer exists and return its number
+ ecs_FreeLayer: Remove a layer from the set of layers.
+
+ The layers are contained in the "layer" attribute of the ecs_Server
+ structure. We also know the number of layers open and the current
+ layer number, which is the last layer called by
+ ecs_SelectLayer. Here are the attributes available in ecs_Layer
+ useful for the driver programmer:
+
+ ecs_LayerSelection sel: Layer Selection Information
+ int index: For GetNextObject, the current object extracted
+ int nbfeature: The number of features in a layer. Optional.
+ void *priv: The private geographic information of the geographic driver
+ for a geographic layer.
+
+ As you notice, there is an equivalent structure pointer to handle
+ information specific to a driver for a particular layer. There is an
+ example of this in the skeleton.h (LayerPrivateData).
+ */
+
+static void _releaseAllLayers _ANSI_ARGS_((ecs_Server *s));
+
+/*
+ Layer oriented functions are kept in data structure to simplify the code
+ */
+
+LayerMethod layerMethod[11] = {
+ /* 0 */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Area */ { _openAreaLayer, _closeAreaLayer, _rewindAreaLayer, _getNextObjectArea, _getObjectArea, _getObjectIdArea },
+ /* Line */ { _openLineLayer, _closeLineLayer, _rewindLineLayer, _getNextObjectLine, _getObjectLine, _getObjectIdLine },
+ /* Point */ { _openPointLayer, _closePointLayer, _rewindPointLayer, _getNextObjectPoint, _getObjectPoint, _getObjectIdPoint },
+ /* Matrix */ { _openMatrixLayer, _closeMatrixLayer, _rewindMatrixLayer, _getNextObjectMatrix, _getObjectMatrix, _getObjectIdMatrix },
+ /* Image */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Text */ { _openTextLayer, _closeTextLayer, _rewindTextLayer, _getNextObjectText, _getObjectText, _getObjectIdText },
+ /* Edge */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Face */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Node */ { NULL, NULL, NULL, NULL, NULL, NULL },
+ /* Ring */ { NULL, NULL, NULL, NULL, NULL, NULL }
+};
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_CreateServer
+
+ DESCRIPTION
+ This function prepares a new skeleton driver interface to a
+ database. When this operation is completed, the user will be
+ able to perform other operations with the other functions of
+ this driver.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Driver info given by the OGDI API
+ char *Request: An complete URL string
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard return value to OGDI. This is a very complex
+ structure that handles all the different information
+ that could be returned to the application.
+
+ MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+ Description: Change the east bounding value from 600000 to 608000.
+ The previous value did not enclose all the objects.
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_CreateServer(s,Request)
+ ecs_Server *s;
+ char *Request;
+{
+ register ServerPrivateData *spriv;
+
+ (void) Request;
+
+ /*
+ This code creates the driver private structure. The main purpose
+ of this structure is to keep the global information related to
+ specific aspects of the geographic information accessed by this
+ driver. In this case, the only information initialized is the
+ attribute globaldummy. This attribute will be handled like a very
+ complex structure.
+ */
+
+ spriv = s->priv = (ServerPrivateData *) malloc(sizeof(ServerPrivateData));
+ if (s->priv == NULL) {
+
+ ecs_SetError(&(s->result), 1,
+ "Could not connect to the skeleton driver, not enough memory");
+ return &(s->result);
+ }
+
+ spriv->globaldummy = 1;
+
+ /*
+ Extract information from Request. Each OGDI driver gets a
+ specific URL that contains necessary information to access the
+ geographic data. Most of the time, the URL contains the file path
+ to a directory, a file or a database. However, this URL must be
+ verified here in order to prevent errors. For more information
+ about the format of the URL, please check the current OGDI
+ documentation.
+
+ In order to facilitate the operation, the specific information of
+ this driver is already extracted from the URL and placed in the
+ variable s->pathname.
+
+ For the skeleton driver, the URL will be in the following format
+ gltp:/skeleton/dummyinfo. That mean that s->pathname already
+ contains "dummyinfo"; if not, the driver must return an error
+ message.
+ */
+
+ if (strstr(s->pathname,"dummyinfo") == NULL) {
+ /* Don't forget to unallocate the previous priv */
+ free(s->priv);
+
+ ecs_SetError(&(s->result), 1,
+ "Incorrect URL format for the skeleton driver.");
+ return &(s->result);
+ }
+
+ /*
+ Check the database itself. The first operation a programmer
+ should do is to check if the database is in the right
+ format. Then, the programmer can perform the index creation to
+ the different layers and a database connection.
+ */
+
+ /*
+ Extracting the bounding rectangle is a difficult process for most
+ of the drivers. The global region could be used as the default
+ region but usually, it outlines the full area that contains all
+ the geographic information in the database. For the sake of the
+ demonstration, the area of Spearfish, South Dakota, will be used
+ in the following.
+
+ This region is represented in the UTM projection zone 13. The
+ ns_res and the ew_res parameters of the region are the
+ north-south and east-west resolution of each pixel. They are used
+ to calculate the width and the height of the matrix during its
+ extraction. Here, let's take the default size of the matrix to be
+ 100x100.
+ */
+
+ s->globalRegion.north = 4928000;
+ s->globalRegion.south = 4914000;
+/**MOD START**/
+ s->globalRegion.east = 608000;
+/**MOD END**/
+ s->globalRegion.west = 589000;
+ s->globalRegion.ns_res = (s->globalRegion.north - s->globalRegion.south)/100.0;
+ s->globalRegion.ew_res = (s->globalRegion.east - s->globalRegion.west)/100.0;
+
+ /*
+ Its very important to call ecs_SetSuccess before leaving. This
+ operation prepares the returned function with a success
+ message. This message simply indicates the correct completion of
+ the operation.
+ */
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_DestroyServer
+
+ DESCRIPTION
+ Deallocate an existing skeleton driver interface to a database.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_DestroyServer(s)
+ ecs_Server *s;
+{
+ register ServerPrivateData *spriv = s->priv;
+
+ /*
+ Release all layers selection.
+ */
+
+ _releaseAllLayers(s);
+
+ /*
+ Release spriv
+ */
+
+ if (spriv != NULL) {
+ spriv->globaldummy = 0;
+ free(spriv);
+ }
+
+ /*
+ It is very important to call ecs_SetSuccess before leaving. This
+ operation prepares the returned function with a success
+ message. This message simply indicates the correct completion of
+ the operation.
+ */
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_SelectLayer
+
+ DESCRIPTION
+ Make a layer selection and prepare the driver to receive
+ commands related to this layer. A layer is a set of geographic
+ objects of a certain type (Line, Area, Matrix, Point, Text,
+ etc.) This set could vary from one kind of database to another
+ but the role remains the same, i.e. define and prepare a layer
+ to perform different operations.
+
+ The selection request is formed by a string and a family. The
+ family could be Area, Line, Text, Point, Matrix, etc. The string
+ is a description of what to select. For example, VRF contains a
+ string of the form FEATURE_NAME at COVERAGE(REQUEST). That defines
+ a specific feature name (ex: roads), a coverage type (ex:
+ transportation) and a request which is the operation to perform
+ to the feature table (ex: TYPE==double_lane). This string is
+ different from one driver to another.
+
+ Ex: roads at transportation(roadtype == doubleline)
+
+ At the end of this operation, if everything goes right, the
+ driver will have access to a new LayerPrivateData in memory. It
+ will remain in memory until a ecs_ReleaseLayer is applied to
+ this layer. You could open as many layers as you want. The only
+ limit is the memory and some system specific limitations (nbr of
+ files on DOS).
+
+ For this example, the family information will be used to select
+ from various types of selection. However, the string must
+ contain "layername" or this operation will return an error
+ message.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_LayerSelection *sel: Selection information
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_SelectLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int layer;
+ register LayerPrivateData *lpriv;
+ char buffer[100];
+
+ /*
+ First, try to find an existing layer with same request and family
+ using ecs_GetLayer.
+ */
+
+ if ((layer = ecs_GetLayer(s,sel)) != -1) {
+
+ /*
+ If it already exists than assign currentLayer and set index to 0
+ to force a rewind.
+ */
+
+ s->currentLayer = layer;
+ s->layer[layer].index = 0;
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+ }
+
+ /*
+ It did not exist so we try to create it with ecs_SetLayer. Don't
+ forget to set the current layer to this new layer.
+ */
+
+ if ((layer = ecs_SetLayer(s,sel)) == -1) {
+ return &(s->result);
+ }
+ s->currentLayer = layer;
+
+ /*
+ Allocate memory to hold private information about this new
+ layer.
+ */
+
+ s->layer[layer].priv = (void *) malloc(sizeof(LayerPrivateData));
+ if (s->layer[layer].priv == NULL) {
+
+ /*
+ The operation failed, destroy the layer from the memory.
+ */
+
+ ecs_FreeLayer(s,layer);
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate layer private data");
+ return &(s->result);
+ }
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+
+ /*
+ At this point, you could prepare the information related to the
+ layer itself. All these operations are encapsulated in the "open"
+ attribute function in the layerMethod structure and could vary
+ from one family of geographic objects to another.
+ */
+
+ if ((layerMethod[s->layer[layer].sel.F].open) == NULL) {
+ dyn_ReleaseLayer(s,sel);
+ ecs_SetError(&(s->result),1,"Unable to open this layer");
+ } else {
+ if ((layerMethod[s->layer[layer].sel.F].open)(s,&(s->layer[layer]))) {
+ ecs_SetSuccess(&(s->result));
+ } else {
+
+ /*
+ The dyn_ReleaseLayer will change the content of s->result.
+ Don't forget to keep in a buffer the error message before the
+ call.
+ */
+
+ if (s->result.message != NULL)
+ strcpy(buffer,s->result.message);
+ dyn_ReleaseLayer(s,sel);
+ ecs_SetError(&(s->result),1,buffer);
+ }
+ }
+
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_ReleaseLayer
+
+ DESCRIPTION
+ This command will remove all information about a previously
+ select layer from the memory.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_LayerSelection *sel: Selection information
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+ Description: Addition of code to free the private layer structure
+ to avoid memory leaks.
+ Addition of information on the purpose of the "close"
+ attribute function.
+
+
+ END_FUNCTION_INFORMATION
+
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_ReleaseLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int layer;
+ char buffer[200];
+
+ /*
+ First, try to find an existing layer with same request and family.
+ */
+
+ if ((layer = ecs_GetLayer(s,sel)) == -1) {
+ sprintf(buffer,"Invalid layer %s",sel->Select);
+ ecs_SetError(&(s->result),1,buffer);
+ return &(s->result);
+ }
+
+ /* Close all related things to this layer and free, if any, all
+ allocated memory that the lpriv structure could contains.
+ All these operations are encapsulated in the "close"
+ attribute function in the layerMethod structure and could vary
+ from one family of geographic objects to another.
+ */
+ if ((layerMethod[s->layer[s->currentLayer].sel.F].close) != NULL)
+ {
+ (layerMethod[s->layer[s->currentLayer].sel.F].close)(s,&(s->layer[s->currentLayer]));
+ }
+
+ /*
+ Free the private layer structure pointer.
+ */
+ if (s->layer[layer].priv != NULL)
+ {
+ free( s->layer[layer].priv );
+ s->layer[layer].priv = NULL;
+ }
+
+ /*
+ Free the layer.
+ */
+
+ ecs_FreeLayer(s,layer);
+
+ if (s->currentLayer == layer) {
+ s->currentLayer = -1; /* just in case released layer was selected */
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ _releaseAllLayers
+
+ DESCRIPTION
+ This local command will whipe out of memory all the active
+ layers in this driver
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ END_PARAMETERS
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+static void
+_releaseAllLayers(s)
+ ecs_Server *s;
+{
+ int i;
+
+ for (i = 0; i < s->nblayer; ++i)
+ dyn_ReleaseLayer(s,&(s->layer[i].sel));
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_SelectRegion
+
+ DESCRIPTION
+ This command will change the currently used geographic region.
+ The default value of this region is the global region.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Region *gr: Geographical region
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_SelectRegion(s,gr)
+ ecs_Server *s;
+ ecs_Region *gr;
+{
+
+ s->currentRegion.north = gr->north;
+ s->currentRegion.south = gr->south;
+ s->currentRegion.east = gr->east;
+ s->currentRegion.west = gr->west;
+ s->currentRegion.ns_res = gr->ns_res;
+ s->currentRegion.ew_res = gr->ew_res;
+
+ /*
+ Reset currentLayer index to 0 to force a rewind.
+ */
+
+ if (s->currentLayer != -1) {
+ s->layer[s->currentLayer].index = 0;
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_GetDictionary
+
+ DESCRIPTION
+ Return the itcl_class object related to this driver.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_GetDictionary(s)
+ ecs_Server *s;
+{
+ if (ecs_SetText(&(s->result),datadict)) {
+ ecs_SetSuccess(&(s->result));
+ }
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_GetAttributesFormat
+
+ DESCRIPTION
+ Return the attribute format of the currently selected layer.
+
+ Each vector object contains a string attribute called attr.
+ This string contains the list of attribute values related to the
+ geographic object. This function indicates the complete format
+ and description of these attributes. The format of this
+ description is very similar to the ODBC format.
+
+ In this example, the attributes format will describe various
+ dummy information. These attributes will be described in the
+ geographic objects.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_GetAttributesFormat(s)
+ ecs_Server *s;
+{
+ if (s->layer[s->currentLayer].sel.F == Matrix) {
+ if (!ecs_SetObjAttributeFormat(&(s->result)))
+ return &(s->result);
+ ecs_AddAttributeFormat(&(s->result),"category",Integer,5,0,0);
+ ecs_AddAttributeFormat(&(s->result),"label",Char,80,0,0);
+ } else {
+
+ if (!ecs_SetObjAttributeFormat(&(s->result)))
+ return &(s->result);
+
+ /*
+ The first attribute is a string of variable length.
+ */
+
+ if(!ecs_AddAttributeFormat(&(s->result), "Variable string name", Varchar, 0, 0, 0))
+ return &(s->result);
+
+ /*
+ The second attribute is an integer with a maximum length of 10.
+ */
+
+ if(!ecs_AddAttributeFormat(&(s->result), "Integer name", Integer, 10, 0, 0))
+ return &(s->result);
+
+ /*
+ The third attribute is a float number with a maximum length of
+ 15 and a precision of 6.
+ */
+
+ if(!ecs_AddAttributeFormat(&(s->result), "Float name", Float, 15, 6, 0))
+ return &(s->result);
+
+ }
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_GetNextObject
+
+ DESCRIPTION
+ Return the next object for the current layer. In order to do
+ that, an increment (l->index) is used.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_GetNextObject(s)
+ ecs_Server *s;
+{
+ if (layerMethod[s->layer[s->currentLayer].sel.F].getNextObject != NULL) {
+ (layerMethod[s->layer[s->currentLayer].sel.F].getNextObject)(s,&(s->layer[s->currentLayer]));
+ } else {
+ ecs_SetError(&(s->result), 1, "GetNextObject is not implemented for this family");
+ }
+ return &(s->result);
+
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_GetObject
+
+ DESCRIPTION
+ Return a requested object for the current layer.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ char *Id: This string contains the object number
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_GetObject(s,Id)
+ ecs_Server *s;
+ char *Id;
+{
+ if (layerMethod[s->layer[s->currentLayer].sel.F].getObject != NULL) {
+ (layerMethod[s->layer[s->currentLayer].sel.F].getObject)(s,&(s->layer[s->currentLayer]),Id);
+ } else {
+ ecs_SetError(&(s->result), 1, "GetObject is not implemented for this family");
+ }
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_GetObjectIdFromCoord
+
+ DESCRIPTION
+ Return the object id sitting at (or near) a coordinate. Each
+ object in the database contain an Id. This function will return
+ the id of the nearest object in the current layer to a given set
+ of coordinates. Depending of the family type, that id could be a
+ vector object id for vector layers or a category for matrix
+ layers. For example, if we select a layer of polylines, this
+ function will return to the user the nearest polyline from the
+ set of coordinates.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ ecs_Coordinate *coord: Geographical coordinate
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_GetObjectIdFromCoord(s,coord)
+ ecs_Server *s;
+ ecs_Coordinate *coord;
+{
+ if (layerMethod[s->layer[s->currentLayer].sel.F].getObjectIdFromCoord != NULL) {
+ (layerMethod[s->layer[s->currentLayer].sel.F].getObjectIdFromCoord)(s,&(s->layer[s->currentLayer]),coord);
+ } else {
+ ecs_SetError(&(s->result), 1, "GetObjectIdFromCoord is not implemented for this family");
+ }
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_UpdateDictionary
+
+ DESCRIPTION
+ Return the content of this database data dictionary in a Tcl
+ List.
+
+ The content of the database data dictionary could be different
+ from one driver to another. That could be a simple list of file
+ names to a list of mapsets where each mapset is described by a
+ list of data types that is described by a list of datasets.
+
+ Theorically, each driver returns the database data dictionary in
+ a different format than the other. However, this is the role of
+ the applet (dyn_GetDictionary) to handle this list and to show
+ the user the content of this database.
+
+ For those who want to get specific information related to a
+ particular part of the database, another argument is
+ available. If this argument is empty, the dyn_UpdateDictionary
+ should work as usual.
+
+ In this example, a set of information lists will be returned.
+ The first list will be the list of Matrix layers, the second is
+ a list of Area layers, the third is a list of Line layers, the
+ forth is a list of Point layers and the last is a list of Text
+ layers.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ char *arg: A complementary information. Not used.
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_UpdateDictionary(s,arg)
+ ecs_Server *s;
+ char *arg;
+{
+ (void) arg;
+
+ /* Make sure an empty list is returned in all cases */
+
+ ecs_SetText(&(s->result),"");
+
+ /*
+ Matrix list
+ */
+
+ ecs_AddText(&(s->result), "{ layername dummydatamatrix } ");
+
+ /*
+ Area list
+ */
+
+ ecs_AddText(&(s->result), "{ layername dummydataarea } ");
+
+ /*
+ Line list
+ */
+
+ ecs_AddText(&(s->result), "{ layername dummydataline } ");
+
+ /*
+ Point list
+ */
+
+ ecs_AddText(&(s->result), "{ layername dummydatapoint } ");
+
+ /*
+ Text list
+ */
+
+ ecs_AddText(&(s->result), "{ layername dummydatatext } ");
+
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_GetServerProjection
+
+ DESCRIPTION
+ Return the driver cartographic projection. It is important to
+ say that the content of this database remains always constant
+ for all the geographical information of this database. That
+ means the driver can handle one geographic projection at the
+ time for a given database and this could not be changed during a
+ session. It also means that database must be in a uniform
+ projection.
+
+ The format of the projection is based on the USGS PROJ.4
+ system. The most important information is given in the OGDI
+ documentation. For more details, go to the following FTP site:
+
+ ftp://kai.er.usgs.gov/pub/proj.4
+
+ For this example, the projection is UTM, zone 13.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_GetServerProjection(s)
+ ecs_Server *s;
+{
+ ecs_SetText(&(s->result), "+proj=utm +ellps=clrk66 +zone=13");
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_GetGlobalBound
+
+ DESCRIPTION
+ Return the database global bounding rectangle.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_GetGlobalBound(s)
+ ecs_Server *s;
+{
+ ecs_SetGeoRegion(&(s->result),s->globalRegion.north, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.west, s->globalRegion.ns_res,
+ s->globalRegion.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+ ********************************************************************
+
+ FUNCTION_INFORMATION
+
+ NAME
+ dyn_SetServerLanguage
+
+ DESCRIPTION
+ Set this server language for error message; not yet implemented.
+ END_DESCRIPTION
+
+ PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by the OGDI API
+ u_int language: The Microsoft language number
+ END_PARAMETERS
+
+ RETURN_VALUE
+ ecs_Result* : Standard returned value to OGDI
+
+ END_FUNCTION_INFORMATION
+
+ ********************************************************************
+ */
+
+ecs_Result *dyn_SetServerLanguage(s,language)
+ ecs_Server *s;
+ u_int language;
+{
+ (void) language;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * _dyn_SetCompression:
+ *
+ * No compression is used in local databases.
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetCompression(s,compression)
+ ecs_Server *s;
+ ecs_Compression *compression;
+{
+ (void) compression;
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/*
+*******************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+
+ dyn_GetRasterInfo
+
+DESCRIPTION
+
+ Return the raster information for the current layer and set a
+ category table. The category table elements contain a color
+ description, a description of the category and a category number.
+
+ For this example, only three colors will be defined, and only if
+ the current layer is a matrix. The matrix will have a size of
+ 100x100.
+
+END_DESCRIPTION
+
+PRECONDITIONS
+
+ dyn_CreateServer must have been previously called. A SelectLayer
+ must have been successfully called previously.
+
+END_PRECONDITIONS
+
+POSTCONDITIONS
+
+ No post conditions
+
+END_POSTCONDITIONS
+
+PARAMETERS
+
+ INPUT
+ ecs_Server *s: The driver information
+
+END_PARAMETERS
+
+RETURN_VALUE
+
+ ecs_Result *: The result structure common to all OGDI calls.
+
+END_FUNCTION_INFORMATION
+
+*******************************************************************
+*/
+
+ecs_Result *dyn_GetRasterInfo(s)
+ ecs_Server *s;
+{
+ register LayerPrivateData *lpriv;
+
+ if (s->layer[s->currentLayer].sel.F != Matrix) {
+ ecs_SetError(&(s->result), 1, "The current layer is not a Matrix");
+ }
+
+ lpriv = (LayerPrivateData *) s->layer[s->currentLayer].priv;
+
+ /*
+ Put the table content in RasterInfo here
+ */
+
+ ecs_SetRasterInfo(&(s->result),lpriv->matrixwidth,lpriv->matrixheight);
+
+ /*
+ Add a category called red for the first category
+ */
+
+ ecs_AddRasterInfoCategory(&(s->result),1,255,0,0,"Red",0);
+
+ /*
+ Add a category called green for the second category
+ */
+
+ ecs_AddRasterInfoCategory(&(s->result),2,0,255,0,"Green",0);
+
+ /*
+ Add a category called blue for the third category
+ */
+
+ ecs_AddRasterInfoCategory(&(s->result),3,0,0,255,"Blue",0);
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,23 @@
+LIBRARY SKELETON
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_CreateServer
+ dyn_DestroyServer
+ dyn_SelectLayer
+ dyn_ReleaseLayer
+ dyn_SelectRegion
+ dyn_GetDictionary
+ dyn_GetAttributesFormat
+ dyn_GetNextObject
+ dyn_UpdateDictionary
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_GetObject
+ dyn_GetObjectIdFromCoord
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_SetServerLanguage
+ dyn_GetRasterInfo
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,268 @@
+/*********************************************************************
+
+ CSOURCE_INFORMATION
+
+ NAME
+ skeleton.h
+
+ DESCRIPTION
+ Data structure and prototype definition for the skeleton driver
+ END_DESCRIPTION
+
+ MOD: Bruno Savard, INFOMAR INC., bsavard at infomar.com, 1998/09/21
+ Description: Removal of th unused include "glutil.h"
+
+ END_CSOURCE_INFORMATION
+
+ Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ ********************************************************************/
+
+#ifndef SKELETON_H
+#define SKELETON_H
+
+
+/*********************************************************************
+
+ MODULE_INFORMATION
+
+ NAME
+ Skeleton driver
+
+ DESCRIPTION
+ This driver is an example to help developers to write new OGDI
+ drivers. It is part of the Open Geospatial Datastore Interface
+ (OGDI). This driver communicates dummy data to the OGDI API.
+ END_DESCRIPTION
+
+ EXPORTED_FUNCTIONS
+ dyn_CreateServer
+ dyn_DestroyServer
+ dyn_SelectLayer
+ dyn_ReleaseLayer
+ dyn_SelectRegion
+ dyn_GetDictionary
+ dyn_GetAttributesFormat
+ dyn_GetNextObject
+ dyn_GetObject
+ dyn_GetObjectIdFromCoord
+ dyn_UpdateDictionary
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_SetServerLanguage
+ END_EXPORTED_FUNCTIONS
+
+ C_SOURCES
+ skeleton.h
+ skeleton.c
+ object.c
+ open.c
+ utils.c
+ END_C_SOURCES
+
+ END_MODULE_INFORMATION
+
+ ****************************************************************/
+
+#include "ecs.h"
+
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ LayerPrivateData
+
+ DESCRIPTION
+ LayerPrivateData holds all the layer information private
+ data. The main idea of this structure is to give the driver
+ programmer a place where to keep specific driver information
+ related to a layer selection. If the layer selection of a driver
+ needs to open a file, this will be the ideal placeholder.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ ecs_Region matrixregion: For matrix layers, contain the region
+ occupied by the matrix.
+ int matrixwidth: For matrix layers, the width of the matrix
+ int matrixheight: For matrix layers, the height of the matrix
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+typedef struct {
+ ecs_Region matrixregion;
+ int matrixwidth;
+ int matrixheight;
+ int offsetx;
+ int offsety;
+} LayerPrivateData;
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ServerPrivateData
+
+ DESCRIPTION
+ ServerPrivateData holds all the driver private data. The idea of
+ this structure is to have a placeholder for the driver specific
+ information. For example, if the driver is a database interface,
+ the database information and its location will be kept in this
+ structure.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ int globaldummy: Dummy information. It's here only to show the
+ initialization of a value during dyn_CreateServer
+ operation.
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+typedef struct {
+ int globaldummy;
+} ServerPrivateData;
+
+/* open.c prototypes */
+
+int _openAreaLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _closeAreaLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _rewindAreaLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+int _openLineLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _closeLineLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _rewindLineLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+int _openPointLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _closePointLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _rewindPointLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+int _openMatrixLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _closeMatrixLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _rewindMatrixLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+int _openTextLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _closeTextLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _rewindTextLayer _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+
+/* object.c prototypes */
+
+void _getNextObjectArea _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _getObjectArea _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char *id));
+void _getObjectIdArea _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l,ecs_Coordinate *coord));
+void _getNextObjectLine _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _getObjectLine _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char *id));
+void _getObjectIdLine _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l,ecs_Coordinate *coord));
+void _getNextObjectPoint _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _getObjectPoint _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char *id));
+void _getObjectIdPoint _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l,ecs_Coordinate *coord));
+void _getNextObjectText _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _getObjectText _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char *id));
+void _getObjectIdText _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l,ecs_Coordinate *coord));
+void _getNextObjectMatrix _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l));
+void _getObjectMatrix _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char *id));
+void _getObjectIdMatrix _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l,ecs_Coordinate *coord));
+int _calcPosValue _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l,int i,int j));
+int _getValueFromCoord _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l,int pix_c,int pix_r));
+
+/*
+ utils.c prototype
+
+ Usually, all the utility functions are hold here. In our case, the
+ skeleton don't contain any specific functionnality. The utility
+ functions are internal functions for general purpose.
+ */
+
+/* layer structure */
+
+typedef int layerfunc();
+typedef void layervoidfunc();
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ LayerMethod
+
+ DESCRIPTION
+ LayerMethod holds all the pointers to geographical access functions.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ layerfunc *open: Pointer to a open function
+ layervoidfunc *close: Pointer to a close function
+ layervoidfunc *rewind: Pointer to a rewind function
+ layervoidfunc *getNextObject: Pointer to a GetNextObject function
+ layervoidfunc *getObject: Pointer to a GetObject function
+ layervoidfunc *getObjectIdFromCoord: Pointer to a GetObjectIdFromCoord function
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+typedef struct {
+ layerfunc *open;
+ layervoidfunc *close;
+ layervoidfunc *rewind;
+ layervoidfunc *getNextObject;
+ layervoidfunc *getObject;
+ layervoidfunc *getObjectIdFromCoord;
+} LayerMethod;
+
+/*
+ Here is the "Database" definition itself. Skeleton holds global
+ variables to contain data information of the database. The
+ definitions are in object.c.
+ */
+
+typedef struct {
+ double x,y;
+} point_data;
+
+typedef struct {
+ int id;
+ int arealistlength;
+ point_data arealist[15];
+ int islandlistlength;
+ point_data islandlist[15];
+ double north;
+ double south;
+ double east;
+ double west;
+} dbareatype;
+
+typedef struct {
+ int id;
+ int linelistlength;
+ point_data linelist[15];
+ double north;
+ double south;
+ double east;
+ double west;
+} dblinetype;
+
+typedef struct {
+ int id;
+ point_data geopoint;
+} dbpointtype;
+
+typedef struct {
+ int id;
+ point_data geopoint;
+} dbtexttype;
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.mta
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.mta 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeleton.mta 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,4 @@
+projection { +proj=utm +ellps=clrk66 +zone=13 }
+region { -n 4929630 -s 4910960 -e 611611 -w 589126 -res 110}
+coverage {{-enable 1 -family Matrix -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydatamatrix -symbology {{}} -cat {{ -type cat -from 1 -to 1 -color #ff0000 -desc "Red" } { -type cat -from 2 -to 2 -color #00ff00 -desc "Green" } { -type cat -from 3 -to 3 -color #0000ff -desc "Blue" } } -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0} {-enable 1 -family Area -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydataarea -symbology {{-type stipple -bitmap @$env(BITMAP)/stipple1.xbm -color gray -upscale 10000000000.00 -downscale 0.00} {-type linesegment -color black -width 1 -upscale 10000000000.00 -downscale 0.00}} -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0} {-enable 1 -family Line -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydataline -symbology {{-type linesegment -color #ff8040 -width 1 -upscale 10000000000.00 -downscale 0.00 -xoffset 0}} -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0} {-enable 1 -family Point -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydatapoint -symbology {{-type icon -color black -bitmap @$env(BITMAP)/plussign.xbm -upscale 100000000.0 -downscale 0.0}} -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0} {-enable 1 -family Text -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydatatext -symbology {{-type annotation -color black -font "-adobe-courier-medium-r-normal--*-120-*" -upscale 10000000000.00 -downscale 0.00}} -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0}}
+dynamic {}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeletonb.mta
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeletonb.mta 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/skeletonb.mta 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,4 @@
+projection { +proj=utm +ellps=clrk66 +zone=13 }
+region { -n 4929630 -s 4910960 -e 611611 -w 589126 -res 110}
+coverage {{-enable 1 -family Matrix -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydatamatrix -symbology {{}} -cat {{ -type cat -from 1 -to 1 -color #ff0000 -desc "Red" } { -type cat -from 2 -to 2 -color #00ff00 -desc "Green" } { -type cat -from 3 -to 3 -color #0000ff -desc "Blue" } } -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0} {-enable 1 -family Area -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydataarea -symbology {{-type stipple -bitmap @$env(BITMAP)/stipple1.xbm -color gray -upscale 10000000000.00 -downscale 0.00} {-type linesegment -color black -width 1 -upscale 10000000000.00 -downscale 0.00}} -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0} {-enable 1 -family Line -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydataline -symbology {{-type linesegment -color #ff8040 -width 1 -upscale 10000000000.00 -downscale 0.00 -xoffset 0}} -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0} {-enable 1 -family Point -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydatapoint -symbologyProc symbskl -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0} {-enable 1 -family Text -url gltp:/skeleton/C:/Grassland/demo/skeleton/dummyinfo -coverage dummydatatext -symbology {{-type annotation -color black -font "-adobe-courier-medium-r-normal--*-120-*" -upscale 10000000000.00 -downscale 0.00}} -upscale 1e+009 -downscale 0.0 -opaque 0 -cached 0}}
+dynamic {}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/utils.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/utils.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/skeleton/utils.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,29 @@
+/*********************************************************************
+
+ CSOURCE_INFORMATION
+
+ NAME
+ utils.c
+
+ DESCRIPTION
+ Implementation of ARC functions
+ END_DESCRIPTION
+
+ END_CSOURCE_INFORMATION
+
+ Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ Permission to use, copy, modify and distribute this software and
+ its documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies, that
+ both the copyright notice and this permission notice appear in
+ supporting documentation, and that the name of L.A.S. Inc not be used
+ in advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission. L.A.S. Inc. makes no
+ representations about the suitability of this software for any purpose.
+ It is provided "as is" without express or implied warranty.
+
+ ********************************************************************/
+
+#include "skeleton.h"
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/datadict.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/datadict.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/datadict.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,2140 @@
+static char datadict[] = {'\n'
+
+,'\n'
+,'#',' ','c','r','e','a','t','i','o','n',' ','d','e',' ','l','\'','a','p','p','l','e','t',' ','V','R','f'
+,'\n'
+
+,'\n'
+,'i','t','c','l','_','c','l','a','s','s',' ','V','R','F','_','D','a','t','a','D','i','c','t','i','o','n','a','r','y',' ','{'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','i','n','h','e','r','i','t',' ','d','d'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','c','o','n','s','t','r','u','c','t','o','r',' ','{','w','p','a','t','h',' ','l','o','c','a','t','i','o','n','}',' ','{'
+,'\n'
+,'\t','d','d',' ','$','w','p','a','t','h',' ','$','l','o','c','a','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','d','e','s','t','r','u','c','t','o','r',' ','{'
+,'\n'
+,'\t','c','a','t','c','h',' ','{','q','u','e','r','y','_','d','e','s','t','r','o','y','}'
+,'\n'
+,'\t','c','a','t','c','h',' ','{','m','e','t','a','_','d','e','s','t','r','o','y','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','l','a','y','o','u','t',' ','{','}',' ','{'
+,'\n'
+,'\t','p','r','e','v','i','o','u','s',' ','l','a','y','o','u','t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','b','u','t','t','o','n','s',' ','{','}',' ','{'
+,'\n'
+,'\t','p','r','e','v','i','o','u','s',' ','b','u','t','t','o','n','s'
+,'\n'
+,'\t','s','e','t',' ','w','(','b','u','t','t','o','n',')',' ','[','b','u','t','t','o','n',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1','.','d','i','s','m','e','t','a','d','a','t','a',' ','\\'
+,'\n'
+,'\t','\t','-','t','e','x','t',' ','\"','D','i','s','p','l','a','y',' ','m','e','t','a','d','a','t','a','\"',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','f','_','m','e','t','a','d','a','t','a','\"',']'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','w','(','a','d','d',')',' ','[','b','u','t','t','o','n',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1','.','a','d','d','s','e','l',' ','\\'
+,'\n'
+,'\t','\t','-','t','e','x','t',' ','\"','A','d','d',' ','S','e','l','e','c','t','i','o','n','\"',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','a','d','d','S','e','l','e','c','t','i','o','n','\"',']'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','w','(','d','e','l',')',' ','[','b','u','t','t','o','n',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1','.','d','e','l','s','e','l',' ','\\'
+,'\n'
+,'\t','\t','-','t','e','x','t',' ','\"','D','e','l','e','t','e',' ','S','e','l','e','c','t','i','o','n','\"',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','d','e','l','S','e','l','e','c','t','i','o','n','\"',']'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','w','(','e','d','i','t',')',' ','[','b','u','t','t','o','n',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1','.','e','d','i','t','s','e','l',' ','\\'
+,'\n'
+,'\t','\t','-','t','e','x','t',' ','\"','E','d','i','t',' ','S','e','l','e','c','t','i','o','n','\"',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','e','d','i','t','S','e','l','e','c','t','i','o','n','\"',']'
+,'\n'
+,'\t'
+,'\n'
+,'\t','p','a','c','k',' ',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1','.','d','i','s','m','e','t','a','d','a','t','a',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1','.','a','d','d','s','e','l',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1','.','d','e','l','s','e','l',' ','$','w','i','n','d','o','w','.','b','u','t','t','o','n','s','1','.','e','d','i','t','s','e','l',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','l','e','f','t',' ','\\'
+,'\n'
+,'\t','\t','-','p','a','d','x',' ','1',' ','\\'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','n','e','w','B','i','n','d','i','n','g',' ','{','w','i','d','g','e','t',' ','y','}',' ','{'
+,'\n'
+,'\t','p','r','e','v','i','o','u','s',' ','n','e','w','B','i','n','d','i','n','g',' ','$','w','i','d','g','e','t',' ','$','y'
+,'\n'
+,'\t','s','e','t',' ','s','_','n','e','a','r','e','s','t',' ','[','$','w','i','d','g','e','t',' ','n','e','a','r','e','s','t',' ','$','y',']'
+,'\n'
+,'\t','i','f',' ','{','$','s','_','n','e','a','r','e','s','t',' ','>','=',' ','0','}',' ','{','\t'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t','b','u','t','t','o','n','s',' ','[','$','w','i','d','g','e','t',' ','g','e','t',' ','$','s','_','n','e','a','r','e','s','t',']'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','s','e','t',' ','t','h','e',' ','b','u','t','t','o','n','s',' ','o','n','/','o','f','f',' ','b','a','s','e','d',' ','o','n',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','s','e','l','e','c','t','i','o','n','\'','s',' ','v','a','l','u','e'
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','s','e','t','b','u','t','t','o','n','s',' ','{','e','n','t','r','y','}',' ','{'
+,'\n'
+,'\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','e','n','t','r','y',' ','\"','\"',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','d','i','s','a','b','l','e','b','u','t','t','o','n','s'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','t','u','r','n'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','i','f',' ','[','r','e','g','e','x','p',' ','\"','^','\\','\\','$','u','s','e','r','c','h','a','r','\"',' ','$','e','n','t','r','y',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','#','p','u','t','s',' ','\"','j','e',' ','s','u','i','s',' ','d','a','n','s',' ','e','n','a','b','l','e','\"'
+,'\n'
+,'\t',' ',' ',' ',' ','e','n','a','b','l','e','b','u','t','t','o','n','s'
+,'\n'
+,'\t','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','d','i','s','a','b','l','e','b','u','t','t','o','n','s'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','c','h','a','n','g','e',' ','t','h','e',' ','t','i','t','l','e',' ','o','f',' ','t','h','e',' ','l','i','s','t','b','o','x'
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','m','a','p','L','i','s','t','b','o','x',' ','{','}',' ','{'
+,'\n'
+,'\t','p','r','e','v','i','o','u','s',' ','m','a','p','L','i','s','t','b','o','x'
+,'\n'
+,'\t','$','w','i','n','d','o','w','.','c','e','n','t','e','r','.','r','i','g','h','t','.','l','a','y','e','r','s',' ','c','o','n','f','i','g','u','r','e',' ','-','l','a','b','e','l',' ','\"','F','e','a','t','u','r','e','s','\"'
+,'\n'
+,'\t','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','c','o','n','f','i','g','u','r','e',' ','-','h','e','i','g','h','t',' ','5'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','e','n','a','b','l','e','b','u','t','t','o','n','s'
+,'\n'
+,' ',' ',' ',' ','#',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','e','n','a','b','l','e',' ','t','h','e',' ','\"','d','e','l','e','t','e','\"',' ','&',' ','\"','e','d','i','t','\"',' ','b','u','t','t','o','n','s',',',' ','e','n','a','b','l','e',' ','t','h','e',' ','\"','a','d','d','\"',' ','b','u','t','t','o','n','s'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','e','n','a','b','l','e','b','u','t','t','o','n','s',' ','{','}',' ','{'
+,'\n'
+,'\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','[','g','e','t','L','i','s','t','S','e','l','e','c','t','i','o','n',']',' ','\"','\"',']',' ','!','=',' ','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','w','(','a','d','d',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','d','i','s','a','b','l','e','d'
+,'\n'
+,'\t','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','w','(','a','d','d',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','e','n','a','b','l','e','d'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','$','w','(','a','d','d',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','d','i','s','a','b','l','e','d'
+,'\n'
+,'\t','$','w','(','d','e','l',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','n','o','r','m','a','l'
+,'\n'
+,'\t','$','w','(','e','d','i','t',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','n','o','r','m','a','l'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','d','i','s','a','b','l','e','b','u','t','t','o','n','s'
+,'\n'
+,' ',' ',' ',' ','#',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','d','i','s','a','b','l','e',' ','t','h','e',' ','\"','d','e','l','e','t','e','\"',' ','a','n','d',' ','\"','e','d','i','t','\"',' ','b','u','t','t','o','n','s',',',' ','e','n','a','b','l','e',' ','t','h','e',' ','\"','a','d','d','\"'
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','i','f',' ','t','h','e','r','e',' ','i','s',' ','s','o','m','e','t','h','i','n','g',' ','s','e','l','e','c','t','e','d','.'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','d','i','s','a','b','l','e','b','u','t','t','o','n','s',' ','{','}',' ','{'
+,'\n'
+,'\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','[','g','e','t','L','i','s','t','S','e','l','e','c','t','i','o','n',']',' ','\"','\"',']',' ','!','=',' ','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','w','(','a','d','d',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','n','o','r','m','a','l'
+,'\n'
+,'\t','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','w','(','a','d','d',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','d','i','s','a','b','l','e','d'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','$','w','(','d','e','l',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','d','i','s','a','b','l','e','d'
+,'\n'
+,'\t','$','w','(','e','d','i','t',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','d','i','s','a','b','l','e','d'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','a','d','d','S','e','l','e','c','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','o','p','e','n',' ','t','h','e',' ','q','u','e','r','y',' ','w','i','n','d','o','w',' ','f','o','r',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','s','e','l','e','c','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','a','d','d','S','e','l','e','c','t','i','o','n',' ','{','}',' ','{'
+,'\n'
+,'\t','q','u','e','r','y','_','c','r','e','a','t','e',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',']',' ','{','}',' ','[','g','e','t','L','i','s','t','S','e','l','e','c','t','i','o','n',']'
+,'\n'
+,'\t','#',' ','c','u','r','s','e','l','e','c','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','d','e','l','S','e','l','e','c','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','r','e','m','o','v','e',' ','t','h','e',' ','u','s','e','r','-','d','e','f','i','n','e','d',' ','e','x','p','r','e','s','s','i','o','n',' ','a','t',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','s','e','l','e','c','t','i','o','n',' '
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','d','e','l','S','e','l','e','c','t','i','o','n',' ','{','}',' ','{'
+,'\n'
+,'\t','r','e','m','o','v','e','E','x','p','r','e','s','s','i','o','n',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',']',' ','[','g','e','t','L','i','s','t','S','e','l','e','c','t','i','o','n',']'
+,'\n'
+,'\t','u','p','d','a','t','e','L','i','s','t','B','o','x',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',']'
+,'\n'
+,'\t','$','o','b','j','_','l','i','b','r','a','r','i','a','n',' ','i','n','f','o','r','m','B','o','o','k','m','a','r','k','s','C','h','a','n','g','e','d',' ','$','u','r','l',' ','$','t','h','i','s'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','e','d','i','t','S','e','l','e','c','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','o','p','e','n',' ','t','h','e',' ','q','u','e','r','y',' ','w','i','n','d','o','w',' ','w','i','t','h',' ','t','h','e',' ','u','s','e','r','-','d','e','f','i','n','e','d',' ','q','u','e','r','y',' ','i','n'
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','s','e','l','e','c','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','e','d','i','t','S','e','l','e','c','t','i','o','n',' ','{','}',' ','{'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','s','_','l','s','e','l',' ','[','s','t','r','i','n','g',' ','t','r','i','m','l','e','f','t',' ','[','g','e','t','L','i','s','t','S','e','l','e','c','t','i','o','n',']',' ','$','u','s','e','r','c','h','a','r',']'
+,'\n'
+,'\t','q','u','e','r','y','_','c','r','e','a','t','e',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',']',' ','$','s','_','l','s','e','l',' ','{','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','r','e','m','o','v','e','E','x','p','r','e','s','s','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','c','l','e','a','n','s',' ','u','p',' ','t','h','e',' ','p','r','i','v','a','t','e',' ','d','a','t','a',' ','a','r','r','a','y','s',' ','a','s','s','o','c','i','a','t','e','d',' ','w','i','t','h',' ','a'
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','u','s','e','r',' ','d','e','f','i','n','e','d',' ','e','x','p','r','e','s','s','i','o','n',' ','(','c','a','l','l','e','d',' ','o','n','l','y',' ','f','r','o','m',' ','d','e','l','S','e','l','e','c','t','i','o','n',')'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','r','e','m','o','v','e','E','x','p','r','e','s','s','i','o','n',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','n','a','m','e','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','i',' ','0'
+,'\n'
+,'\t','s','e','t',' ','i','n','d','e','x',' ','\"','$','c','o','v','e','r','a','g','e',' ','$','c','l','a','s','s','\"'
+,'\n'
+,'\t','s','e','t',' ','n','a','m','e',' ','[','s','t','r','i','n','g',' ','t','r','i','m','l','e','f','t',' ','$','n','a','m','e',' ','$','u','s','e','r','c','h','a','r',']'
+,'\n'
+,'\t','i','f',' ','[','i','n','f','o',' ','e','x','i','s','t','s',' ','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','i','n','d','e','x',')',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','f','o','r','e','a','c','h',' ','n','a','m','e','_','e','x','p','r',' ','$','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','i','n','d','e','x',')',' ','{'
+,'\n'
+,'\t','\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','[','s','t','r','i','n','g',' ','t','r','i','m','l','e','f','t',' ','[','g','e','t','N','a','m','e','F','r','o','m','E','x','p','r','e','s','s','i','o','n',' ','\\'
+,'\n'
+,'\t','\t','\t','$','n','a','m','e','_','e','x','p','r',']',' ','$','u','s','e','r','c','h','a','r',']',' ','$','n','a','m','e',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','s','e','t',' ','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','i','n','d','e','x',')',' ','[','l','r','e','p','l','a','c','e',' ','$','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','i','n','d','e','x',')',' ','$','i',' ','$','i',']',' '
+,'\n'
+,'\t','\t',' ',' ',' ',' ','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','[','s','t','r','i','n','g',' ','t','r','i','m',' ','$','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','i','n','d','e','x',')',']',' ','\"','\"',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t','\t','u','n','s','e','t',' ','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','i','n','d','e','x',')'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','\t',' ',' ',' ',' '
+,'\n'
+,'\t','\t',' ',' ',' ',' ','r','e','t','u','r','n',' ','{','}'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t','\t','i','n','c','r',' ','i'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','g','e','t','L','i','s','t','S','e','l','e','c','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','r','e','t','u','r','n',' ','t','h','e',' ','h','i','g','h','l','i','g','h','t','e','d',' ','*','s','t','r','i','n','g','*',' ','i','n',' ','t','h','e',' ','l','i','s','t','b','o','x',' ','(','i','f',' ','a','n','y',')','.'
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','r','e','t','u','r','n','s',' ','{','}',' ','i','f',' ','n','o','t','h','i','n','g',' ','h','i','g','h','l','i','g','h','t','e','d','.'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','L','i','s','t','S','e','l','e','c','t','i','o','n',' ','{','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','w','h','e','r','e',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','c','u','r','s','e','l','e','c','t','i','o','n',']'
+,'\n'
+,'\t','i','f',' ','{','$','w','h','e','r','e',' ','<',' ','0','}',' ','{','r','e','t','u','r','n',' ','{','}',' ','}'
+,'\n'
+,'\t','#','r','e','t','u','r','n',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','g','e','t',' ','$','w','h','e','r','e',']'
+,'\n'
+,'\t','s','e','t',' ','t','o','r','e','t',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','g','e','t',' ','$','w','h','e','r','e',']'
+,'\n'
+,'\t','s','e','t',' ','p','o','i','n','t','p','l','a','c','e',' ','[','l','s','e','a','r','c','h',' ','-','e','x','a','c','t',' ','$','t','o','r','e','t',' ',':',' ',']'
+,'\n'
+,'\t','i','f',' ','{','$','p','o','i','n','t','p','l','a','c','e',' ','>','=',' ','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','i','n','c','r',' ','p','o','i','n','t','p','l','a','c','e',' ','-','1'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','t','o','r','e','t',' ','[','l','r','a','n','g','e',' ','$','t','o','r','e','t',' ','0',' ','$','p','o','i','n','t','p','l','a','c','e',']',' ',' '
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','t','o','r','e','t',' ','[',' ','l','i','n','d','e','x',' ','$','t','o','r','e','t',' ','0',']'
+,'\n'
+,'\t','}',' '
+,'\n'
+,'\t','#','p','u','t','s',' ','\"','$','t','o','r','e','t','\"'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','t','o','r','e','t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','m','e','n','u','s',' ','{','}',' ','{'
+,'\n'
+,'\t','p','r','e','v','i','o','u','s',' ','m','e','n','u','s'
+,'\n'
+,'\t'
+,'\n'
+,'\t','t','i','x','L','a','b','e','l','F','r','a','m','e',' ','$','w','i','n','d','o','w','.','m','e','n','u','.','f','r','a','m','e',' ','\\'
+,'\n'
+,'\t','\t','-','l','a','b','e','l',' ','\"','O','p','t','i','o','n','s','\"',' ','\\'
+,'\n'
+,'\t','\t','-','l','a','b','e','l','s','i','d','e',' ','a','c','r','o','s','s','t','o','p'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','p','a','t','h',' ','[','$','w','i','n','d','o','w','.','m','e','n','u','.','f','r','a','m','e',' ','s','u','b','w','i','d','g','e','t',' ','f','r','a','m','e',']'
+,'\n'
+,'\t','#','y','k'
+,'\n'
+,'\t','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','r','e','s','e','t','T','i','x','L','a','b','e','l','F','r','a','m','e','O','p','t','i','o','n','s',' ','$','w','i','n','d','o','w','.','m','e','n','u','.','f','r','a','m','e'
+,'\n'
+
+,'\n'
+,'\t','s','e','t',' ','m','a','p','O','p','t','i','o','n','s',' ','$','p','a','t','h','.','c','o','v','e','r','a','g','e'
+,'\n'
+,'\t','t','i','x','O','p','t','i','o','n','M','e','n','u',' ','$','p','a','t','h','.','c','o','v','e','r','a','g','e',' ','-','l','a','b','e','l',' ','\"','C','o','v','e','r','a','g','e',':',' ','\"',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','u','p','d','a','t','e','C','o','v','e','r','a','g','e','S','e','l','e','c','t','i','o','n','\"',' ','\\'
+,'\n'
+,'\t','\t','-','o','p','t','i','o','n','s',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','l','a','b','e','l',' ','w','i','d','t','h',' ','1','0'
+,'\n'
+,'\t',' ',' ',' ',' ','l','a','b','e','l',' ','a','n','c','h','o','r',' ','w'
+,'\n'
+,'\t',' ',' ',' ',' ','m','e','n','u','b','u','t','t','o','n','.','w','i','d','t','h',' ','1','2'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','#','y','k'
+,'\n'
+,'\t','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','r','e','s','e','t','T','i','x','O','p','t','i','o','n','M','e','n','u','O','p','t','i','o','n','s',' ','$','p','a','t','h','.','c','o','v','e','r','a','g','e'
+,'\n'
+
+,'\n'
+,'\t','s','e','t',' ','c','l','a','s','s','O','p','t','i','o','n','s',' ','$','p','a','t','h','.','c','l','a','s','s'
+,'\n'
+,'\t','t','i','x','O','p','t','i','o','n','M','e','n','u',' ','$','p','a','t','h','.','c','l','a','s','s',' ','-','l','a','b','e','l',' ','\"','F','e','a','t','u','r','e',' ','C','l','a','s','s',':',' ','\"',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','u','p','d','a','t','e','L','i','s','t','B','o','x','\"',' ','\\'
+,'\n'
+,'\t','\t','-','o','p','t','i','o','n','s',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','l','a','b','e','l',' ','w','i','d','t','h',' ','1','0'
+,'\n'
+,'\t',' ',' ',' ',' ','l','a','b','e','l',' ','a','n','c','h','o','r',' ','w'
+,'\n'
+,'\t',' ',' ',' ',' ','m','e','n','u','b','u','t','t','o','n','.','w','i','d','t','h',' ','1','2'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','#','y','k'
+,'\n'
+,'\t','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','r','e','s','e','t','T','i','x','O','p','t','i','o','n','M','e','n','u','O','p','t','i','o','n','s',' ','$','p','a','t','h','.','c','l','a','s','s'
+,'\n'
+
+,'\n'
+,'\t','p','a','c','k',' ','a','p','p','e','n','d',' ','$','p','a','t','h',' ','\\'
+,'\n'
+,'\t','\t','$','p','a','t','h','.','c','o','v','e','r','a','g','e',' ','{',' ','l','e','f','t',' ','}',' ','\\'
+,'\n'
+,'\t','\t','$','p','a','t','h','.','c','l','a','s','s',' ','{',' ','r','i','g','h','t',' ','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','p','a','c','k',' ','a','p','p','e','n','d',' ','$','w','i','n','d','o','w','.','m','e','n','u',' ','\\'
+,'\n'
+,'\t','\t','$','w','i','n','d','o','w','.','m','e','n','u','.','f','r','a','m','e',' ','{','t','o','p',' ','e','x','p','a','n','d',' ','f','i','l','l','x','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','u','p','d','a','t','e','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','c','o','v','e','r','a','g','e',' ','$','c','o','v','e','r','a','g','e','D','a','t','a',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','m','a','p','O','p','t','i','o','n','s',' ','d','e','l','e','t','e',' ','[','l','i','n','d','e','x',' ','$','c','o','v','e','r','a','g','e',' ','0',']'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','c','o','v','e','r','a','g','e','D','a','t','a',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',' ','c','a','t','_','l','i','s','t',']'
+,'\n'
+,'\t','#','p','u','t','s',' ','\"','u','p','d','a','t','e','d','i','c','t',' ','u','r','l',':',' ','$','u','r','l','\"'
+,'\n'
+,'\t'
+,'\n'
+,'\t','$','m','a','p','O','p','t','i','o','n','s',' ','c','o','n','f','i','g',' ','-','d','i','s','a','b','l','e','c','a','l','l','b','a','c','k',' ','1'
+,'\n'
+,'\t','$','c','l','a','s','s','O','p','t','i','o','n','s',' ','c','o','n','f','i','g',' ','-','d','i','s','a','b','l','e','c','a','l','l','b','a','c','k',' ','1'
+,'\n'
+,'\t'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','c','o','v','e','r','a','g','e',' ','$','c','o','v','e','r','a','g','e','D','a','t','a',' ','{',' '
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','s','_','c','o','v','l','a','b','e','l',' ','[','l','i','n','d','e','x',' ','$','c','o','v','e','r','a','g','e',' ','1',']'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','s','_','c','o','v','l','a','b','e','l',' ','\"','\"',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','s','_','c','o','v','l','a','b','e','l',' ','[','l','i','n','d','e','x',' ','$','c','o','v','e','r','a','g','e',' ','0',']'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t',' ',' ',' ',' ','$','m','a','p','O','p','t','i','o','n','s',' ','a','d','d',' ','c','o','m','m','a','n','d',' ','$','s','_','c','o','v','l','a','b','e','l',' ','-','l','a','b','e','l',' ','$','s','_','c','o','v','l','a','b','e','l'
+,'\n'
+,'\t',' ',' ',' ',' ','#','i','n','d','e','x',' ','t','h','e',' ','c','o','v','e','r','a','g','e',' ','n','a','m','e',' ','b','y',' ','i','t','s',' ','l','a','b','e','l',' ','n','a','m','e',' ','e','.','g','.',' ','a','_','s','_','l','a','b','e','l','(','s','o','m','e','t','h','i','n','g',')','=','=','S','O'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','a','_','s','_','l','a','b','e','l','(','[','l','i','n','d','e','x',' ','$','c','o','v','e','r','a','g','e',' ','1',']',')',' ','[','l','i','n','d','e','x',' ','$','c','o','v','e','r','a','g','e',' ','0',']'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','c','l','a','s','s',' ','$','c','o','v','e','r','a','g','e','O','r','d','e','r',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','c','a','t','c','h',' ','{',' ','$','c','l','a','s','s','O','p','t','i','o','n','s',' ','a','d','d',' ','c','o','m','m','a','n','d',' ','$','c','l','a','s','s',' ','-','l','a','b','e','l',' ','$','c','l','a','s','s',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','$','c','l','a','s','s','O','p','t','i','o','n','s',' ','c','o','n','f','i','g',' ','-','d','i','s','a','b','l','e','c','a','l','l','b','a','c','k',' ','0'
+,'\n'
+,'\t','$','m','a','p','O','p','t','i','o','n','s',' ','c','o','n','f','i','g',' ','-','d','i','s','a','b','l','e','c','a','l','l','b','a','c','k',' ','0'
+,'\n'
+,'\t'
+,'\n'
+,'\t','u','p','d','a','t','e','C','o','v','e','r','a','g','e','S','e','l','e','c','t','i','o','n',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','u','p','d','a','t','e','C','o','v','e','r','a','g','e','S','e','l','e','c','t','i','o','n',' ','{','a','r','g','s','}',' ','{'
+,'\n'
+,'\t'
+,'\n'
+,'\t','u','p','d','a','t','e','L','i','s','t','B','o','x',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',']'
+,'\n'
+,'\t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e'
+,'\n'
+,' ',' ',' ',' ','#',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','r','e','t','u','r','n','s',' ','t','h','e',' ','l','a','b','e','l',' ','o','f',' ','t','h','e',' ','c','o','v','e','r','a','g','e',' ','a','s','s','o','c','i','a','t','e','d',' ','w','i','t','h',' ','t','h','e'
+,'\n'
+,' ',' ',' ',' ','#',' ','O','p','t','i','o','n',' ','m','e','n','u','\'','s',' ','s','e','l','e','c','t','i','o','n','.',' ',' ','e','.','g','.',' ','i','f',' ','\"','P','o','l','i','t','i','c','a','l',' ','L','i','n','e','s','\"',' ','i','s',' ','s','e','l','e','c','t','e','d',','
+,'\n'
+,' ',' ',' ',' ','#',' ','t','h','i','s',' ','r','e','t','u','r','n','s',' ','e','.','g','.',' ','\"','P','O','L','I','N','E','\"'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',' ','{','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','a','_','s','_','l','a','b','e','l','(','[','$','m','a','p','O','p','t','i','o','n','s',' ','c','g','e','t',' ','-','v','a','l','u','e',']',')'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',' ','{','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','[','$','c','l','a','s','s','O','p','t','i','o','n','s',' ','c','g','e','t',' ','-','v','a','l','u','e',']'
+,'\n'
+,'\t'
+,'\n'
+,'\t','#','p','u','t','s',' ','\"','c','l','a','s','s',' ','o','p','t','i','o','n',' ',':','$','c','l','a','s','s','O','p','t','i','o','n','s','\"'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','u','p','d','a','t','e','L','i','s','t','b','o','x'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','u','p','d','a','t','e','s',' ','t','h','e',' ','l','i','s','t','b','o','x',' ','w','i','t','h',' ','t','h','e',' ','s','e','l','e','c','t','e','d',' ','c','o','v','e','r','a','g','e',' ','a','n','d',' ','c','l','a','s','s','.'
+,'\n'
+,' ',' ',' ',' ','#',' ','p','r','e',':',' ','p','r','o','t','e','c','t','e','d',' ','v','a','r','i','a','b','l','e',' ','c','o','v','e','r','a','g','e','D','a','t','a',' ','h','a','s',' ','b','e','e','n',' ','s','e','t',' ','w','i','t','h',' ','l','i','s','t'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','u','p','d','a','t','e','L','i','s','t','B','o','x',' ','{','s','e','l','e','c','t','e','d','C','l','a','s','s','}',' ','{'
+,'\n'
+,'\t','#','p','u','t','s',' ','\"','s','e','l','e','c','t','e','d',' ','c','l','a','s','s',':',' ','$','s','e','l','e','c','t','e','d','C','l','a','s','s','\"'
+,'\n'
+,'\t','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','d','e','l','e','t','e',' ','0',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','s','i','z','e',']'
+,'\n'
+,'\t','#',' ','p','u','t','s',' ','\"','c','o','v','e','r','a','g','e','D','a','t','a',' ','i','s',' ','$','c','o','v','e','r','a','g','e','D','a','t','a','\"'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','c','o','v','e','r','a','g','e',' ','$','c','o','v','e','r','a','g','e','D','a','t','a',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','c','o','v','e','r','a','g','e','O','r','d','e','r',' ','\"','A','r','e','a',' ','L','i','n','e',' ','T','e','x','t',' ','P','o','i','n','t','\"'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','[','l','i','n','d','e','x',' ','$','c','o','v','e','r','a','g','e',' ','0',']',' ','=','=',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']','}',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','m','a','p','s',' ','[','l','i','n','d','e','x',' ','$','c','o','v','e','r','a','g','e',' ','[','e','x','p','r',' ','[','l','s','e','a','r','c','h',' ','$','c','o','v','e','r','a','g','e','O','r','d','e','r',' ','$','s','e','l','e','c','t','e','d','C','l','a','s','s',']',' ','+',' ','2',']',']'
+,'\n'
+,'\t','\t','b','r','e','a','k'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','s','e','t',' ','m','a','p','s',' ','[','c','o','n','c','a','t',' ','$','m','a','p','s',' ','[','g','e','t','U','s','e','r','D','e','f','i','n','e','d',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']',' ','$','s','e','l','e','c','t','e','d','C','l','a','s','s',']',']'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','m','a','p',' ','[','l','s','o','r','t',' ','$','m','a','p','s',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','a','p','p','e','n','d','M','a','p','I','t','e','m',' ','$','m','a','p'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','s','e','t','b','u','t','t','o','n','s',' ','{','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','a','p','p','e','n','d','M','a','p','I','t','e','m'
+,'\n'
+,' ',' ',' ',' ','#',' ',' ',' ',' ','a','p','p','e','n','d',' ','s','o','m','e','t','h','i','n','g',' ','t','o',' ','t','h','e',' ','l','i','s','t',' ','o','f',' ','m','a','p',' ','i','t','e','m','s','.'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','a','p','p','e','n','d','M','a','p','I','t','e','m',' ','{','i','t','e','m','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','m','e','t','a','t','e','x','t',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',']'
+,'\n'
+,'\t','s','e','t',' ','n','b',' ','[','l','l','e','n','g','t','h',' ','$','m','e','t','a','t','e','x','t',']'
+,'\n'
+,'\t','s','e','t',' ','d','b','l','i','b','m','e','t','a',' ','[','l','i','n','d','e','x',' ','$','m','e','t','a','t','e','x','t',' ','0',']',' '
+,'\n'
+,'\t','s','e','t',' ','a','l','l','c','o','v','s','t','r','i','n','g',' ','[','l','i','n','d','e','x',' ','$','m','e','t','a','t','e','x','t',' ','1',']'
+,'\n'
+,'\t','s','e','t',' ','d','b','l','i','b','m','e','t','a','2',' ','[','l','i','n','d','e','x',' ','$','d','b','l','i','b','m','e','t','a',' ','1',']'
+,'\n'
+,'\t','s','e','t',' ','d','d','b','m','e','t','a','d','a','t','a',' ','[','l','i','n','d','e','x',' ','$','d','b','l','i','b','m','e','t','a','2',' ','0',']'
+,'\n'
+,'\t','#','e','x','t','r','a','c','t','i','o','n',' ','l','i','b','r','a','r','y',' ','m','e','t','a','d','o','n','n','e','e','s'
+,'\n'
+,'\t','s','e','t',' ','l','i','b','m','e','t','a','d','a','t','a',' ','[','l','i','n','d','e','x',' ','$','d','b','l','i','b','m','e','t','a','2',' ','1',']'
+,'\n'
+,'\t','#','e','x','t','r','a','c','t','i','o','n',' ','c','o','v','e','r','a','g','e',' ','m','e','t','a','d','o','n','n','e','e','s','.'
+,'\n'
+,'\t','#','v','e','r','i','f','i','e',' ','s','i',' ','l','e',' ','c','o','v','e','r','a','g','e',' ','e','s','t',' ','c','e','l','u','i',' ','d','e','m','a','n','d','e',' ','p','a','r',' ','l','\'','u','t','i','l','i','s','a','t','e','u','r','.'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','c','o','v','s','t','r','i','n','g',' ','$','a','l','l','c','o','v','s','t','r','i','n','g',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','n','a','m','e','c','o','v',' ','[','l','i','n','d','e','x',' ','$','c','o','v','s','t','r','i','n','g',' ','1',']'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','s','e','l','e','c','t','c','o','v',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','n','a','m','e','c','o','v',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']',']',' ','=','=','0','}',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','c','o','v','c','o','m','p','l','e','t','e',' ','[','l','i','n','d','e','x',' ','$','c','o','v','s','t','r','i','n','g',' ','4',']'
+,'\n'
+,'\t','\t','s','e','t',' ','c','o','v','m','e','t','a','d','a','t','a',' ','[','l','i','n','d','e','x',' ','$','c','o','v','c','o','m','p','l','e','t','e',' ','1',']',' '
+,'\n'
+,'\t','\t','f','o','r','e','a','c','h',' ','f','e','a','t','u','r','e',' ','$','c','o','v','m','e','t','a','d','a','t','a',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','s','e','t',' ','f','e','a','t','u','r','e','n','a','m','e',' ','[','l','i','n','d','e','x',' ','$','f','e','a','t','u','r','e',' ','0',']'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','s','e','t',' ','f','e','a','t','u','r','e','d','e','s','c',' ','[','l','i','n','d','e','x',' ','$','f','e','a','t','u','r','e',' ','1',']'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','f','e','a','t','u','r','e','n','a','m','e',' ','$','i','t','e','m',']',' ','=','=','0','}',' ','{'
+,'\n'
+,'\t','\t','\t','s','e','t',' ','i','t','e','m',' ','[','c','o','n','c','a','t',' ','$','i','t','e','m',' ',':',' ','$','f','e','a','t','u','r','e','d','e','s','c',']'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}',' '
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','i','n','s','e','r','t',' ','e','n','d',' ','$','i','t','e','m'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','g','e','t','U','s','e','r','D','e','f','i','n','e','d'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','r','e','t','u','r','n',' ','a',' ','l','i','s','t',' ','o','f',' ','t','h','e',' ','u','s','e','r','d','e','f','i','n','e','d',' ','e','x','p','r','e','s','s','i','o','n','s'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','U','s','e','r','D','e','f','i','n','e','d',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s','}',' ','{'
+,'\n'
+,'\t','#',' ','e','x','p','r','e','s','s','i','o','n','s',' ','a','r','e',' ','i','n',' ','t','h','e',' ','f','o','r','m',' ','{','E','X','P','R','E','S','S','I','O','N',' ','{','<','c','o','v','e','r','a','g','e','>',' ','<','c','l','a','s','s','>','}',' ','{','<','n','a','m','e','>','}',' ','{','<','o','r','i','g','i','n','a','l',' ','l','a','y','e','r',' ','n','a','m','e','>','}',' ','{','<','e','x','p','r','e','s','s','i','o','n','>','}','}'
+,'\n'
+,'\t','#',' ','w','h','e','r','e',' ','<','n','a','m','e','>',' ','i','s',' ','s','u','p','p','l','i','e','d',' ','b','y',' ','t','h','e',' ','u','s','e','r','.'
+,'\n'
+,'\t','s','e','t',' ','x',' ','\"','$','c','o','v','e','r','a','g','e',' ','$','c','l','a','s','s','\"'
+,'\n'
+,'\t','i','f',' ','[','i','n','f','o',' ','e','x','i','s','t','s',' ','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','x',')',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','t','m','p',' ','\"','\"'
+,'\n'
+,'\t',' ',' ',' ',' ','f','o','r','e','a','c','h',' ','n','a','m','e','_','e','x','p','r',' ','$','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','x',')',' ','{'
+,'\n'
+,'\t','\t','l','a','p','p','e','n','d',' ','t','m','p',' ','[','g','e','t','N','a','m','e','F','r','o','m','E','x','p','r','e','s','s','i','o','n',' ','$','n','a','m','e','_','e','x','p','r',']'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','t','u','r','n',' ','$','t','m','p'
+,'\n'
+,'\t','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','t','u','r','n',' ','{','}'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','g','e','t','E','x','p','r','e','s','s','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','r','e','t','u','r','n',' ','a',' ','l','i','s','t',' ','o','f',' ','t','h','e',' ','u','s','e','r','d','e','f','i','n','e','d',' ','e','x','p','r','e','s','s','i','o','n','s'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','E','x','p','r','e','s','s','i','o','n',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','n','a','m','e','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','x',' ','\"','$','c','o','v','e','r','a','g','e',' ','$','c','l','a','s','s','\"'
+,'\n'
+,'\t','i','f',' ','[','i','n','f','o',' ','e','x','i','s','t','s',' ','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','x',')',']',' ','{','\t'
+,'\n'
+,'\t',' ',' ',' ',' ','f','o','r','e','a','c','h',' ','d','a','t','a',' ','$','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','x',')',' ','{'
+,'\n'
+,'\t','\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','[','l','i','n','d','e','x',' ','$','d','a','t','a',' ','0',']',' ','$','n','a','m','e',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','r','e','t','u','r','n',' ','[','l','i','n','d','e','x',' ','$','d','a','t','a',' ','2',']'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','{','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','g','e','t','O','r','i','g','i','n','a','l'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','r','e','t','u','r','n',' ','t','h','e',' ','o','r','i','g','i','n','a','l',' ','e','x','p','r','e','s','s','i','o','n','.'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','O','r','i','g','i','n','a','l',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','n','a','m','e','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','x',' ','\"','$','c','o','v','e','r','a','g','e',' ','$','c','l','a','s','s','\"'
+,'\n'
+,'\t','i','f',' ','[','i','n','f','o',' ','e','x','i','s','t','s',' ','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','x',')',']',' ','{','\t'
+,'\n'
+,'\t',' ',' ',' ',' ','f','o','r','e','a','c','h',' ','d','a','t','a',' ','$','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','x',')',' ','{'
+,'\n'
+,'\t','\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','[','l','i','n','d','e','x',' ','$','d','a','t','a',' ','0',']',' ','$','n','a','m','e',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','r','e','t','u','r','n',' ','[','l','i','n','d','e','x',' ','$','d','a','t','a',' ','1',']'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','{','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','g','e','t','O','r','i','g','i','n','a','l','N','a','m','e'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','r','e','t','u','r','n',' ','t','h','e',' ','o','r','i','g','i','n','a','l',' ','n','a','m','e',' ','f','o','r',' ','a','n',' ','e','x','p','r','e','s','s','i','o','n',' ','f','o','r',' ','w','h','e','n'
+,'\n'
+,' ',' ',' ',' ','#',' ','u','s','e','r',' ','e','d','i','t','s',' ','n','a','m','e',',',' ','t','h','e','n',' ','c','a','n','c','e','l','s','.'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','O','r','i','g','i','n','a','l','N','a','m','e',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','n','a','m','e','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','x',' ','\"','$','c','o','v','e','r','a','g','e',' ','$','c','l','a','s','s','\"'
+,'\n'
+,'\t','i','f',' ','[','i','n','f','o',' ','e','x','i','s','t','s',' ','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','x',')',']',' ','{','\t'
+,'\n'
+,'\t',' ',' ',' ',' ','f','o','r','e','a','c','h',' ','d','a','t','a',' ','$','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','x',')',' ','{'
+,'\n'
+,'\t','\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','[','l','i','n','d','e','x',' ','$','d','a','t','a',' ','0',']',' ','$','n','a','m','e',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','r','e','t','u','r','n',' ','[','l','i','n','d','e','x',' ','$','d','a','t','a',' ','1',']'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','s','e','t',' ','p','o','i','n','t','p','l','a','c','e',' ','[','l','s','e','a','r','c','h',' ','-','e','x','a','c','t',' ','$','n','a','m','e',' ',':',' ',']'
+,'\n'
+,'\t','i','f',' ','{','$','p','o','i','n','t','p','l','a','c','e',' ','>','=','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','i','n','c','r',' ','p','o','i','n','t','p','l','a','c','e',' ','-','1'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','n','a','m','e',' ','[','l','r','a','n','g','e',' ','$','n','a','m','e',' ','0',' ','$','p','o','i','n','t','p','l','a','c','e',']'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','n','a','m','e'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','g','e','t','P','a','t','h','n','a','m','e'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','c','o','n','s','t','r','u','c','t',' ','a',' ','p','a','t','h','n','a','m','e','.',' ',' ','I','f',' ','t','h','e','r','e',' ','i','s',' ','n','o',' ','e','x','p','r','e','s','s','i','o','n',',',' ','(','*',')',' ','i','s',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','a','p','p','e','n','d','e','d',' ','a','s',' ','a',' ','q','u','e','r','y','.'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','P','a','t','h','n','a','m','e',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','n','a','m','e','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','n','a','m','e',' ','[','s','t','r','i','n','g',' ','t','r','i','m','l','e','f','t',' ','$','n','a','m','e',' ','$','u','s','e','r','c','h','a','r',']'
+,'\n'
+,'\t','s','e','t',' ','e','x','p','r','e','s','s','i','o','n',' ','[','g','e','t','E','x','p','r','e','s','s','i','o','n',' ','$','c','o','v','e','r','a','g','e',' ','$','c','l','a','s','s',' ','$','n','a','m','e',']'
+,'\n'
+,'\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','e','x','p','r','e','s','s','i','o','n',' ','\"','\"',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','e','x','p','r','e','s','s','i','o','n',' ','{','*','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','s','e','t',' ','r','e','t','o','u','r',' ','[','g','e','t','O','r','i','g','i','n','a','l','N','a','m','e',' ','$','c','o','v','e','r','a','g','e',' ','$','c','l','a','s','s',' ','$','n','a','m','e',']','@','$','{','c','o','v','e','r','a','g','e','}','(','$','e','x','p','r','e','s','s','i','o','n',')'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','r','e','t','o','u','r'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','g','e','t','N','a','m','e','F','r','o','m','E','x','p','r','e','s','s','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','r','e','t','u','r','n','s',' ','a',' ','s','t','r','i','n','g',' ','t','h','a','t',' ','c','a','n',' ','b','e',' ','d','i','s','p','l','a','y','e','d',' ','i','n',' ','t','h','e',' ','l','i','s','t','b','o','x','.'
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','A',' ','s','t','a','r',' ','i','s',' ','a','p','p','e','n','d','e','d','.'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','N','a','m','e','F','r','o','m','E','x','p','r','e','s','s','i','o','n',' ','{','e','x','p','r','e','s','s','i','o','n','}',' ','{'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','{','u','s','e','r','c','h','a','r','}','[','l','i','n','d','e','x',' ','$','e','x','p','r','e','s','s','i','o','n',' ','0',']'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','_','i','n','s','e','r','t','E','l','e','m','e','n','t',' ',' ','i','n','s','e','r','t',' ','t','h','e',' ','o','p','e','r','a','t','o','r','s',' ','i','n',' ','t','h','e',' ','c','o','m','b','o','B','o','x',' ','o','f'
+,'\n'
+,' ',' ',' ',' ','#',' ','t','h','e',' '
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','q','u','e','r','y','_','d','e','s','t','r','o','y',' ','{','}',' ','{'
+,'\n'
+,'\t','i','f',' ','[','w','i','n','f','o',' ','e','x','i','s','t','s',' ','$','w','(','q','u','e','r','y',')',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','l','e','a','s','e','G','r','a','b'
+,'\n'
+,'\t',' ',' ',' ',' ','d','e','s','t','r','o','y',' ','$','w','(','q','u','e','r','y',')'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','d','i','c','t','_','d','e','s','t','r','o','y'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','q','u','e','r','y','_','d','o','b','u','t','t','o','n','s',' ','{','s','_','c','o','v','e','r','a','g','e',' ','s','_','c','l','a','s','s',' ','s','_','o','r','i','g',' ','w','_','b','f','r','}',' ','{'
+,'\n'
+
+,'\n'
+,'\t','u','p','d','a','t','e',' ','i','d','l','e','t','a','s','k','s'
+,'\n'
+,'\t','u','p','d','a','t','e'
+,'\n'
+,'\t','g','e','t','G','r','a','b',' ','$','w','(','q','u','e','r','y',')'
+,'\n'
+,'\t','i','f',' ','!','[','w','i','n','f','o',' ','e','x','i','s','t','s',' ','$','w','_','b','f','r','.','o','k',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','b','u','t','t','o','n',' ','$','w','_','b','f','r','.','o','k',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','-','t','e','x','t',' ','[','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','G','e','t','S','t','r','i','n','g',' ','M','E','S','S','A','G','E','-','O','K',']',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','-','w','i','d','t','h',' ','1','0'
+,'\n'
+,'\t',' ',' ',' ',' '
+,'\n'
+,'\t',' ',' ',' ',' ','b','u','t','t','o','n',' ','$','w','_','b','f','r','.','d','a','t','a','d','i','c','t',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','-','t','e','x','t',' ','\"','D','i','c','t','i','o','n','a','r','y','\"','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','-','w','i','d','t','h',' ','1','0'
+,'\n'
+,'\t',' ',' ',' ',' '
+,'\n'
+,'\t',' ',' ',' ',' ','b','u','t','t','o','n',' ','$','w','_','b','f','r','.','c','a','n','c','e','l',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','-','t','e','x','t',' ','[','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','G','e','t','S','t','r','i','n','g',' ','M','E','S','S','A','G','E','-','C','A','N','C','E','L',']',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','q','u','e','r','y','_','c','a','n','c','e','l','\"',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','-','w','i','d','t','h',' ','1','0'
+,'\n'
+,'\t',' ',' ',' ',' '
+,'\n'
+,'\t',' ',' ',' ',' ','p','a','c','k',' ','a','p','p','e','n','d',' ','$','w','_','b','f','r',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','$','w','_','b','f','r','.','o','k',' ','{',' ','l','e','f','t',' ','p','a','d','x',' ','1',' ','e','x','p','a','n','d',' ','}',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','$','w','_','b','f','r','.','d','a','t','a','d','i','c','t',' ','{',' ','l','e','f','t',' ','p','a','d','x',' ','1',' ','e','x','p','a','n','d',' ','}',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','$','w','_','b','f','r','.','c','a','n','c','e','l',' ','{',' ','l','e','f','t',' ','p','a','d','x',' ','1',' ','e','x','p','a','n','d',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','$','w','_','b','f','r','.','o','k',' ','c','o','n','f','i','g','u','r','e',' ','-','c','o','m','m','a','n','d',' ','[','l','i','s','t',' ','$','t','h','i','s',' ','q','u','e','r','y','_','s','a','v','e',' ','$','s','_','c','o','v','e','r','a','g','e',' ','$','s','_','c','l','a','s','s',' ','$','s','_','o','r','i','g',' ','[','$','w','(','e','n','t','r','y',')',' ','g','e','t',']',']'
+,'\n'
+,'\t','$','w','_','b','f','r','.','d','a','t','a','d','i','c','t',' ','c','o','n','f','i','g','u','r','e',' ','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','d','i','c','t','_','s','h','o','w','d','i','c','t',';',' ','$','t','h','i','s',' ','d','i','c','t','_','u','p','d','a','t','e',' ','$','s','_','c','o','v','e','r','a','g','e',' ','$','s','_','c','l','a','s','s',' ','$','s','_','o','r','i','g','\"','\\'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','q','u','e','r','y','_','s','a','v','e',' ','{','s','_','c','o','v','e','r','a','g','e',' ','s','_','c','l','a','s','s',' ','s','_','o','r','i','g',' ','s','_','o','l','d','n','a','m','e','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','s','_','n','a','m','e',' ','[','s','t','r','i','n','g',' ','t','r','i','m',' ','[','$','w','(','e','n','t','r','y',')',' ','g','e','t',']',']'
+,'\n'
+,'\t','s','e','t',' ','s','_','n','a','m','e',' ','[','s','t','r','i','n','g',' ','t','r','i','m','l','e','f','t',' ','$','s','_','n','a','m','e',' ','$','u','s','e','r','c','h','a','r',']'
+,'\n'
+
+,'\n'
+,'\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','s','_','n','a','m','e',' ','\"','\"',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','e','r','r','o','r','M','s','g',' ','\"','Y','o','u',' ','m','u','s','t',' ','s','p','e','c','i','f','y',' ','a',' ','n','a','m','e',' ','f','o','r',' ','t','h','i','s',' ','e','x','p','r','e','s','s','i','o','n','.','\"'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','t','u','r','n'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','s','e','t',' ','s','_','t','e','x','t',' ','[','s','t','r','i','n','g',' ','t','r','i','m',' ','[','$','w','(','t','e','x','t',')',' ','g','e','t',']',']',' ',';','#','y','k',' ','1','.','0'
+,'\n'
+,'\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','s','_','t','e','x','t',' ','\"','\"',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','e','r','r','o','r','M','s','g',' ','\"','Y','o','u',' ','m','u','s','t',' ','e','n','t','e','r',' ','a','n',' ','e','x','p','r','e','s','s','i','o','n','.','\"'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','t','u','r','n'
+,'\n'
+,'\t','}'
+,'\n'
+
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','s','_','e','x','i','s','t','i','n','g',' ','[','$','m','a','p','L','i','s','t',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',' ','g','e','t',' ','0',' ','e','n','d',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','s','_','n','a','m','e',' ','[','s','t','r','i','n','g',' ','t','r','i','m','l','e','f','t',' ','$','s','_','e','x','i','s','t','i','n','g',' ','$','u','s','e','r','c','h','a','r',']',']',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','s','_','o','l','d','n','a','m','e',' ','$','s','_','n','a','m','e',']',' ','!','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','e','r','r','o','r','M','s','g',' ','\"','S','o','m','e','t','h','i','n','g',' ','w','i','t','h',' ','t','h','i','s',' ','n','a','m','e',' ','a','l','r','e','a','d','y',' ','e','x','i','s','t','s','.','\"'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','r','e','t','u','r','n'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+
+,'\n'
+,'\t','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','s','_','o','l','d','n','a','m','e',' ','\"','\"',']',' ','!','=',' ','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','m','o','v','e','E','x','p','r','e','s','s','i','o','n',' ','$','s','_','c','o','v','e','r','a','g','e',' ','$','s','_','c','l','a','s','s',' ','$','s','_','o','l','d','n','a','m','e'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','a','p','p','e','n','d','E','x','p','r','e','s','s','i','o','n',' ','$','s','_','c','o','v','e','r','a','g','e',' ','$','s','_','c','l','a','s','s',' ','[','l','i','s','t',' ','$','s','_','n','a','m','e',' ','$','s','_','o','r','i','g',' ','$','s','_','t','e','x','t',']'
+,'\n'
+,'\t','#',' ','i','f',' ','t','h','i','s',' ','c','o','v','e','r','a','g','e','/','c','l','a','s','s',' ','i','s',' ','s','t','i','l','l',' ','v','i','s','i','b','l','e',',',' ','s','h','o','w',' ','i','t'
+,'\n'
+,'\t','i','f',' ','{','(','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','s','_','c','o','v','e','r','a','g','e',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']',']',' ','=','=',' ','0',')',' ','&','&'
+,'\n'
+,'\t','(','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','s','_','c','l','a','s','s',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',']',']',' ','=','=',' ','0',')','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','#','a','p','p','e','n','d','M','a','p','I','t','e','m',' ','$','{','u','s','e','r','c','h','a','r','}','$','s','_','n','a','m','e'
+,'\n'
+,'\t',' ',' ',' ',' ','u','p','d','a','t','e','L','i','s','t','B','o','x',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',']'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','$','o','b','j','_','l','i','b','r','a','r','i','a','n',' ','i','n','f','o','r','m','B','o','o','k','m','a','r','k','s','C','h','a','n','g','e','d',' ','$','u','r','l',' ','$','t','h','i','s'
+,'\n'
+,'\t','q','u','e','r','y','_','d','e','s','t','r','o','y'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','q','u','e','r','y','_','c','a','n','c','e','l',' ','{','}',' ','{'
+,'\n'
+,'\t','q','u','e','r','y','_','d','e','s','t','r','o','y'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','q','u','e','r','y','_','i','n','i','t','i','a','l','i','z','e',' ','{','s','_','s','t','r','}',' ','{'
+,'\n'
+,'\t','$','w','(','t','e','x','t',')',' ','d','e','l','e','t','e',' ','1','.','0',' ','e','n','d'
+,'\n'
+,'\t','$','w','(','t','e','x','t',')',' ','i','n','s','e','r','t',' ','e','n','d',' ','$','s','_','s','t','r'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','t','h','e',' ','d','a','t','a',' ','d','i','c','t','i','o','n','a','r','y',' ','w','i','n','d','o','w','.','.','.','.'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','d','i','c','t','_','s','h','o','w','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','w','(','d','d',')',' ','.','d','i','c','t','_','$','{','t','h','i','s','}'
+,'\n'
+,'\t','i','f',' ','[','w','i','n','f','o',' ','e','x','i','s','t','s',' ','$','w','(','d','d',')',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','w','m',' ','d','e','i','c','o','n','i','f','y',' ','$','w','(','d','d',')'
+,'\n'
+,'\t',' ',' ',' ',' ','r','a','i','s','e',' ','$','w','(','d','d',')'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','t','u','r','n'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','d','i','c','t','_','l','a','y','o','u','t','d','i','c','t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','d','i','c','t','_','l','a','y','o','u','t','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+,'\t','t','o','p','l','e','v','e','l',' ','$','w','(','d','d',')'
+,'\n'
+,'\t','w','m',' ','t','i','t','l','e',' ','$','w','(','d','d',')',' ','\"','D','a','t','a',' ','D','i','c','t','i','o','n','a','r','y','\"'
+,'\n'
+,'\t','p','a','c','k',' ','[','t','i','x','L','a','b','e','l','F','r','a','m','e',' ','$','w','(','d','d',')','.','f','r',' ','-','l','a','b','e','l',' ','\"','D','a','t','a',' ','D','i','c','t','i','o','n','a','r','y','\"',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','t','o','p',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','t','r','u','e',' ','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','b','o','t','h'
+,'\n'
+,'\t','#','y','k'
+,'\n'
+,'\t','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','r','e','s','e','t','T','i','x','L','a','b','e','l','F','r','a','m','e','O','p','t','i','o','n','s',' ','$','w','(','d','d',')','.','f','r'
+,'\n'
+,'\t','s','e','t',' ','w','(','d','d','f','r',')',' ','[','$','w','(','d','d',')','.','f','r',' ','s','u','b','w','i','d','g','e','t',' ','f','r','a','m','e',']'
+,'\n'
+,'\t','p','a','c','k',' ','[','s','e','t',' ','w','(','d','d','t','e','x','t',')',' ','[','t','e','x','t',' ','$','w','(','d','d','f','r',')','.','t','e','x','t',' ','\\'
+,'\n'
+,'\t','\t','-','h','e','i','g','h','t',' ','2','4',' ','\\'
+,'\n'
+,'\t','\t','-','w','i','d','t','h',' ','8','0','\\'
+,'\n'
+,'\t','\t','-','y','s','c','r','o','l','l','c','o','m','m','a','n','d',' ','\"','$','w','(','d','d','f','r',')','.','s','b','y',' ','s','e','t','\"',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','l','e','f','t',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','t','r','u','e','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','b','o','t','h',' '
+,'\n'
+,'\t','p','a','c','k',' ','[','s','c','r','o','l','l','b','a','r',' ','$','w','(','d','d','f','r',')','.','s','b','y',' ','\\'
+,'\n'
+,'\t','\t','-','o','r','i','e','n','t',' ','v','e','r','t','i','c','a','l',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','[','l','i','s','t',' ','$','w','(','d','d','t','e','x','t',')',' ','y','v','i','e','w',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','r','i','g','h','t',' ','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','y'
+,'\n'
+
+,'\n'
+,'\t','p','a','c','k',' ','[','s','e','t',' ','w','_','b','f','r',' ','[','f','r','a','m','e',' ','$','w','(','d','d',')','.','b','f','r',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','t','o','p',' ','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','x',' ','\\'
+,'\n'
+,'\t','\t','-','p','a','d','y',' ','2',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','f','a','l','s','e'
+,'\n'
+,'\t','p','a','c','k',' ','[','b','u','t','t','o','n',' ','$','w','_','b','f','r','.','o','k',' ','-','t','e','x','t',' ','O','K',' ','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','d','i','c','t','_','k','i','l','l','d','i','c','t','\"',' ','-','w','i','d','t','h',' ','1','0',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','t','o','p',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','f','a','l','s','e'
+,'\n'
+,'\t','s','e','t',' ','x',' ','[','e','x','p','r',' ','[','w','i','n','f','o',' ','s','c','r','e','e','n','w','i','d','t','h',' ','$','w','(','d','d',')',']','/','2',' ','-',' ','[','w','i','n','f','o',' ','r','e','q','w','i','d','t','h',' ','$','w','(','d','d',')',']','/','2',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','-',' ','[','w','i','n','f','o',' ','v','r','o','o','t','x',' ','[','w','i','n','f','o',' ','p','a','r','e','n','t',' ','$','w','(','q','u','e','r','y',')',']',']',']'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','$','x',' ','<',' ','0','}',' ','{','s','e','t',' ','x',' ','0','}'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','y',' ','[','e','x','p','r',' ','[','w','i','n','f','o',' ','s','c','r','e','e','n','h','e','i','g','h','t',' ','$','w','(','d','d',')',']','/','2',' ','-',' ','[','w','i','n','f','o',' ','r','e','q','h','e','i','g','h','t',' ','$','w','(','d','d',')',']','/','2',' ','\\'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','-',' ','[','w','i','n','f','o',' ','v','r','o','o','t','y',' ','[','w','i','n','f','o',' ','p','a','r','e','n','t',' ','$','w','(','d','d',')',']',']',']'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','$','y',' ','<',' ','0','}',' ','{','s','e','t',' ','y',' ','0','}'
+,'\n'
+,'\t',' ',' ',' ',' ','w','m',' ','g','e','o','m',' ','$','w','(','d','d',')',' ',' ','+','$','x','+','$','y'
+,'\n'
+
+,'\n'
+,'\t','u','p','d','a','t','e',' ','i','d','l','e','t','a','s','k','s'
+,'\n'
+,'\t','u','p','d','a','t','e'
+,'\n'
+,'\t','g','e','t','G','r','a','b',' ','$','w','(','d','d',')','\t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','d','i','c','t','_','d','e','s','t','r','o','y',' ','{','}',' ','{'
+,'\n'
+,'\t','i','f',' ','[',':',':','i','n','f','o',' ','e','x','i','s','t','s',' ','w','(','d','d',')',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','[','w','i','n','f','o',' ','e','x','i','s','t','s',' ','$','w','(','d','d',')',']',' ','{'
+,'\n'
+,'\t','\t','r','e','l','e','a','s','e','G','r','a','b'
+,'\n'
+,'\t','\t','d','e','s','t','r','o','y',' ','$','w','(','d','d',')'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','d','i','c','t','_','u','p','d','a','t','e',' ','{','s','_','c','o','v','e','r','a','g','e',' ','s','_','c','l','a','s','s',' ','s','_','o','r','i','g','}',' ','{'
+,'\n'
+,'\t','#','$','w','(','d','d','t','e','x','t',')',' ','d','e','l','e','t','e',' ','1','.','0',' ','e','n','d'
+,'\n'
+,' ',' ',' ',' ',' ',' ',' ',' ','i','f',' ','[','c','a','t','c','h',' ','{','$','w','(','d','d','t','e','x','t',')',' ','i','n','s','e','r','t',' ','e','n','d',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',' ','[','g','e','t','P','a','t','h','n','a','m','e',' ','$','s','_','c','o','v','e','r','a','g','e',' ','$','s','_','c','l','a','s','s',' ','$','s','_','o','r','i','g',']',']','}',' ','s','_','r','e','s','u','l','t',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','e','r','r','o','r','M','s','g',' ','\"','C','o','u','l','d',' ','n','o','t',' ','r','e','t','r','i','e','v','e',' ','t','h','e',' ','d','i','c','t','i','o','n','a','r','y','\"'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','d','i','c','t','_','k','i','l','l','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+,'\t','#','y','k'
+,'\n'
+,'\t','r','e','l','e','a','s','e','G','r','a','b'
+,'\n'
+,'\t','d','e','s','t','r','o','y',' ','$','w','(','d','d',')'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','S','O','M','E',' ','O','V','E','R','R','I','D','D','E','N',' ','P','R','O','C','E','D','U','R','E','S',':'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','p','a','r','s','e','E','x','p','r','e','s','s','i','o','n',' ','{','s','_','s','t','r','i','n','g','}',' ','{'
+,'\n'
+,'\t','#',' ','e','x','p','r','e','s','s','i','o','n','s',' ','a','r','e',' ','i','n',' ','t','h','e',' ','f','o','r','m',' ','{','{','E','X','P','R','E','S','S','I','O','N',' ','{','{','<','c','o','v','e','r','a','g','e','>',' ','<','c','l','a','s','s','>','}',' ','{','<','n','a','m','e','>',' ','<','o','r','i','g','>',' ','<','e','x','p','r','e','s','s','i','o','n','>','}',' ','.','.','.','}',' ','\\'
+,'\n'
+,'\t','#','{','{','<','c','o','v','e','r','a','g','e','>',' ','<','c','l','a','s','s','>','}',' ','{','<','n','a','m','e','>',' ','<','o','r','i','g','>',' ','<','e','x','p','r','e','s','s','i','o','n','>','}',' ','.','.','.',' ','}',' ','.','.','.','}','}'
+,'\n'
+,'\t','#',' ','w','h','e','r','e',' ','<','n','a','m','e','>',' ','i','s',' ','s','u','p','p','l','i','e','d',' ','b','y',' ','t','h','e',' ','u','s','e','r','.'
+,'\n'
+,' ',' ',' ',' ',' ',' ',' ',' ','f','o','r','e','a','c','h',' ','c','o','v','_','c','l','a','s','s',' ','[','l','i','n','d','e','x',' ','$','s','_','s','t','r','i','n','g',' ','1',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','f','o','r','e','a','c','h',' ','n','a','m','e','_','e','x','p','r',' ','[','l','i','n','d','e','x',' ','$','c','o','v','_','c','l','a','s','s',' ','1',']',' ','{'
+,'\n'
+,'\t','\t','e','v','a','l',' ','a','p','p','e','n','d','E','x','p','r','e','s','s','i','o','n',' ','[','l','i','n','d','e','x',' ','$','c','o','v','_','c','l','a','s','s',' ','0',']',' ','{','[','l','i','s','t',' ','[','l','i','n','d','e','x',' ','$','n','a','m','e','_','e','x','p','r',' ','0',']',' ','[','l','i','n','d','e','x',' ','$','n','a','m','e','_','e','x','p','r',' ','1',']',' ','[','l','i','n','d','e','x',' ','$','n','a','m','e','_','e','x','p','r',' ','2',']',']','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','s','e','t','M','B','R',' ','{','s','_','s','t','r','i','n','g','}',' ','{'
+,'\n'
+,'\t','#',' ','m','a','x','i','m','u','m',' ','b','o','u','n','d','i','n','g',' ','r','e','c','t','a','n','g','l','e',' ','i','s',' ','i','n',' ','t','h','e',' ','f','o','r','m',' ','{','M','B','R',' ','N',' ','E',' ','S',' ','W','}','.'
+,'\n'
+,'\t','s','e','t',' ','p','r','i','v','d','a','t','a','(','m','b','r',')',' ','[','l','i','n','d','e','x',' ','$','s','_','s','t','r','i','n','g',' ','1',']'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','s','e','t','s',' ','t','h','e',' ','d','a','t','a',' ','s','t','r','u','c','t','u','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','i','v','a','t','e',' ','d','a','t','a'
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','s','e','t','P','r','i','v','a','t','e','D','a','t','a',' ','{','l','_','s','t','r','i','n','g','}',' ','{'
+,'\n'
+,'\t','p','r','e','v','i','o','u','s',' ','s','e','t','P','r','i','v','a','t','e','D','a','t','a',' ','$','l','_','s','t','r','i','n','g'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','s','_','s','t','r','i','n','g',' ','$','l','_','s','t','r','i','n','g',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','s','_','t','y','p','e',' ','[','s','t','r','i','n','g',' ','t','o','l','o','w','e','r',' ','[','l','i','n','d','e','x',' ','$','s','_','s','t','r','i','n','g',' ','0',']',']'
+,'\n'
+,'\t',' ',' ',' ',' ','s','w','i','t','c','h',' ','-','-',' ','$','s','_','t','y','p','e',' ','{'
+,'\n'
+,'\t','\t','e','x','p','r','e','s','s','i','o','n',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','p','a','r','s','e','E','x','p','r','e','s','s','i','o','n',' ','$','s','_','s','t','r','i','n','g'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t','\t','m','b','r',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','s','e','t','M','B','R',' ','$','s','_','s','t','r','i','n','g'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t','\t','d','e','f','a','u','l','t',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','#','p','u','t','s',' ','\"','c','o','u','l','d','n','\'','t',' ','u','n','d','e','r','s','t','a','n','d',' ','$','s','_','t','y','p','e','\"'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#',' ','e','x','p','r','e','s','s','i','o','n',' ','i','s',' ','i','n',' ','t','h','e',' ','f','o','r','m',' ','{','<','n','a','m','e','>',' ','<','o','r','i','g','>',' ','<','e','x','p','r','e','s','s','i','o','n','>','}'
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','a','p','p','e','n','d','E','x','p','r','e','s','s','i','o','n',' ','{','c','o','v','e','r','a','g','e',' ','c','l','a','s','s',' ','e','x','p','r','e','s','s','i','o','n','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','x',' ','\"','$','c','o','v','e','r','a','g','e',' ','$','c','l','a','s','s','\"'
+,'\n'
+,'\t','l','a','p','p','e','n','d',' ','p','r','i','v','d','a','t','a','(','e','x','p','r','e','s','s','i','o','n',',','$','x',')',' ','$','e','x','p','r','e','s','s','i','o','n'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','g','e','t','B','o','o','k','m','a','r','k','E','n','t','r','y'
+,'\n'
+,' ',' ',' ',' ','#',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','r','e','t','u','r','n','s',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','s','t','a','t','e',' ','o','f',' ','t','h','e',' ','b','o','o','k','m','a','r','k','.',' ',' ','T','h','i','s',' ','i','s'
+,'\n'
+,' ',' ',' ',' ','#',' ','c','a','l','l','e','d',' ','b','y',' ','t','h','e',' ','l','i','b','r','a','r','i','a','n',' ','a','s',' ','s','o','o','n',' ','a','s',' ','t','h','e',' ','d','d',' ','i','n','f','o','r','m','s'
+,'\n'
+,' ',' ',' ',' ','#',' ','i','t',' ','t','h','a','t',' ','t','h','e',' ','b','o','o','k','m','a','r','k','s',' ','h','a','v','e',' ','c','h','a','n','g','e','d','.'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','B','o','o','k','m','a','r','k','E','n','t','r','y',' ','{','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','t','m','p',' ','\"','\"'
+,'\n'
+,'\t','s','e','t',' ','a','l','l','f','i','e','l','d','s',' ','\"','\"'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','p','r','i','v',' ','[','a','r','r','a','y',' ','n','a','m','e','s',' ','p','r','i','v','d','a','t','a',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','[','r','e','g','s','u','b',' ','{','e','x','p','r','e','s','s','i','o','n',',','}',' ','$','p','r','i','v',' ','{','}',' ','i','n','d','e','x',']',' ','{'
+,'\n'
+,'\t','\t','l','a','p','p','e','n','d',' ','t','m','p',' ','[','l','i','s','t',' ','$','i','n','d','e','x',' ','$','p','r','i','v','d','a','t','a','(','$','p','r','i','v',')',']'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','i','f',' ','{','[','l','l','e','n','g','t','h',' ','$','t','m','p',']',' ','>',' ','0','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','l','a','p','p','e','n','d',' ','a','l','l','f','i','e','l','d','s',' ','[','l','i','s','t',' ','E','X','P','R','E','S','S','I','O','N',' ','$','t','m','p',']'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','#',' ','i','f',' ','t','h','e','r','e',' ','i','s',' ','n','o',' ','m','b','r',',',' ','f','i','g','u','r','e',' ','o','u','t',' ','w','h','a','t',' ','i','t',' ','i','s','.'
+,'\n'
+,'\t','i','f',' ','!','[',':',':','i','n','f','o',' ','e','x','i','s','t','s',' ','p','r','i','v','d','a','t','a','(','m','b','r',')',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','!','[','c','a','t','c','h',' ','{','s','e','t',' ','l','_','g','g','b',' ','[','l','r','a','n','g','e',' ','[','e','c','s','_','G','e','t','G','l','o','b','a','l','B','o','u','n','d',' ','$','u','r','l',']',' ','0',' ','3',']','}',']',' ','{'
+,'\n'
+,'\t','\t','l','a','p','p','e','n','d',' ','a','l','l','f','i','e','l','d','s',' ','[','l','i','s','t',' ','M','B','R',' ','$','l','_','g','g','b',']'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','l','a','p','p','e','n','d',' ','a','l','l','f','i','e','l','d','s',' ','[','l','i','s','t',' ','M','B','R',' ','$','p','r','i','v','d','a','t','a','(','m','b','r',')',']'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','#','p','u','t','s',' ','\"','a','l','l','f','i','e','l','d','s',' ','i','s',' ','>','$','a','l','l','f','i','e','l','d','s','<','\"'
+,'\n'
+,'\t','r','e','t','u','r','n',' ','$','a','l','l','f','i','e','l','d','s'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','g','e','t','a','l','l',' ','{','}',' ','{'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','p','r',' ','[','a','r','r','a','y',' ','n','a','m','e','s',' ','p','r','i','v','d','a','t','a',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','p','u','t','s',' ','\"','p','r','i','v','d','a','t','a','(','$','p','r',')','=','>','$','p','r','i','v','d','a','t','a','(','$','p','r',')','\"'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','_','i','n','s','e','r','t','A','t','t','r','i','b','u','t','e','s',' ','{',' ','w','_','c','o','m','b','o','b','o','x','A','t','t','r','}',' ','{'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','x',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',' ','[','$','t','h','i','s',' ','g','e','t','C','u','r','r','e','n','t','P','a','t','h','n','a','m','e',']',']'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','p',' ','[','$','t','h','i','s',' ','g','e','t','C','u','r','r','e','n','t','S','e','l','e','c','t','i','o','n',']'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','l',' ','[','s','p','l','i','t',' ','$','x',' ','\\','n',']'
+,'\n'
+,'\t','s','e','t',' ','c','l','a','s','s','e',' ','[','v','i','r','t','u','a','l',' ','g','e','t','S','e','l','e','c','t','e','d','C','l','a','s','s',']'
+,'\n'
+,'\t'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','x',' ','$','l',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','#','\t','s','e','t',' ','a','t','t','r','i','b','u','t','e',' ','[','s','t','r','i','n','g',' ','m','a','t','c','h',' ','$','x',' ','[','=',']',']'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','a','t','t','r','i','b','u','t','e',' ','[','r','e','g','e','x','p',' ',' ','-','n','o','c','a','s','e',' ','{','^',' ',' ','}',' ','$','x',' ','t','m','p',']'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','$','a','t','t','r','i','b','u','t','e',' ','=','=',' ','1',' ','}',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','a','t','t','r','i','b','u','t','e','2',' ','[','s','t','r','i','n','g',' ','m','a','t','c','h',' ','\"','*','=','*','\"',' ','$','x',']'
+,'\n'
+,'\t','\t','i','f',' ','{','$','a','t','t','r','i','b','u','t','e','2',' ','=','=',' ','0','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','$','w','_','c','o','m','b','o','b','o','x','A','t','t','r',' ','i','n','s','e','r','t',' ','e','n','d',' ','[','s','t','r','i','n','g',' ','t','r','i','m',' ','$','x',' ','\"',' ','\"',']'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','_','i','n','s','e','r','t','V','a','l','u','e','s',' ','i','n','s','e','r','t',' ','t','h','e',' ','v','a','l','u','e','s',' ','i','n',' ','t','h','e',' ','l','i','s','t',' ','o','f',' ','v','a','l','u','e','s','.'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','_','i','n','s','e','r','t','V','a','l','u','e','s',' ','{',' ','w','_','c','o','m','b','o','b','o','x','V','a','l','u','e','s',' ','a','t','t','r','i','b','u','t','e','}',' ','{'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','x',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',' ','[','$','t','h','i','s',' ','g','e','t','C','u','r','r','e','n','t','P','a','t','h','n','a','m','e',']',']'
+,'\n'
+,'\t','i','f',' ','{','$','a','t','t','r','i','b','u','t','e',' ','=','=',' ','\"','\"',' ','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','t','u','r','n'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','s','e','t',' ','c','o','m','b','o',' ','[','$','w','_','c','o','m','b','o','b','o','x','V','a','l','u','e','s',' ','s','u','b','w','i','d','g','e','t',' ','l','i','s','t','b','o','x',']'
+,'\n'
+,'\t','$','c','o','m','b','o',' ','d','e','l','e','t','e',' ','0',' ','e','n','d'
+,'\n'
+,'\t','#','p','u','t','s',' ','\"','a','t','t','r','i','b','u','t','e',' ','$','a','t','t','r','i','b','u','t','e','\"'
+,'\n'
+,'\t','s','e','t',' ','p',' ','$','x'
+,'\n'
+,'\t','s','e','t',' ','l',' ','[','s','p','l','i','t',' ','$','x',' ','\\','n',']'
+,'\n'
+,'\t','s','e','t',' ','g','g',' ','[','s','t','r','i','n','g',' ','r','a','n','g','e',' ','$','l',' ','[','s','t','r','i','n','g',' ','l','a','s','t',' ','$','a','t','t','r','i','b','u','t','e',' ','$','l',']',' ','e','n','d',' ',']'
+,'\n'
+,'\t','i','f',' ','{',' ','$','g','g',' ','=','=',' ','\"','\"',' ','}',' ','{',' '
+,'\n'
+,'\t','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','g','g','2',' ','[','s','t','r','i','n','g',' ','r','a','n','g','e',' ','$','g','g',' ','[','e','x','p','r',' ','[','s','t','r','i','n','g',' ','l','e','n','g','t','h',' ','$','a','t','t','r','i','b','u','t','e',']',' ','+',' ','2',']',' ','e','n','d',']'
+,'\n'
+,'\t',' ',' ',' ',' ','f','o','r','e','a','c','h',' ','y',' ','$','g','g','2',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','a','t','t','r','i','b','u','t','e','3',' ','[','s','t','r','i','n','g',' ','m','a','t','c','h',' ','\"','*','-','*','\"',' ','$','y',']'
+,'\n'
+,'\t','\t','i','f',' ','{',' ','$','a','t','t','r','i','b','u','t','e','3',' ','=','=',' ','1',' ','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','r','e','t','u','r','n'
+,'\n'
+,'\t','\t','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','$','w','_','c','o','m','b','o','b','o','x','V','a','l','u','e','s',' ','i','n','s','e','r','t',' ','e','n','d',' ','[','s','t','r','i','n','g',' ','t','r','i','m',' ','$','y',' ','\"',' ','\"',']'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}','\t','\t','\t'
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','\t','_','u','p','d','a','t','e','Q','u','e','r','y',' ','\t','\t','a','l','l','o','w',' ','t','o',' ','m','o','d','i','f','y',' ','t','h','e',' ','f','i','e','l','d',' ','o','f',' ','t','h','e',' ','q','u','e','r','y'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','\t','R','e','t','u','r','n','e','d',' ','v','a','l','u','e','s',' ',':',' ','n','o','t','h','i','n','g'
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','_','u','p','d','a','t','e','Q','u','e','r','y',' ','{','}',' ','{'
+,'\n'
+,'\t','g','l','o','b','a','l',' ','a','t','t','r','1',' ','o','p','1',' ','v','a','l','u','e','1'
+,'\n'
+,'\t','g','l','o','b','a','l',' ','a','t','t','r','2',' ','o','p','2',' ','v','a','l','u','e','2'
+,'\n'
+,'\t','g','l','o','b','a','l',' ','a','t','t','r','3',' ','o','p','3',' ','v','a','l','u','e','3'
+,'\n'
+,'\t','g','l','o','b','a','l',' ','r','e','q','u','e','t','e','1',' ','r','e','q','u','e','t','e','2',' ','r','e','q','u','e','t','e','3',' ','q','u','e','r','y','v','r','f'
+,'\n'
+,'\t','g','l','o','b','a','l',' ','a','n','d','o','r','1',' ','a','n','d','o','r','2'
+,'\n'
+,'\t','i','f',' ','{','$','v','a','l','u','e','1',' ','=','=',' ','\"','\"',' ','|','|',' ','$','a','t','t','r','1',' ','=','=',' ','\"','\"',' ','|','|',' ','$','o','p','1',' ','=','=',' ','\"','\"','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','r','e','q','u','e','t','e','1',' ','\"','\"'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','i','f',' ','{','$','v','a','l','u','e','2',' ','=','=',' ','\"','\"',' ','|','|',' ','$','a','t','t','r','2',' ','=','=',' ','\"','\"',' ','|','|',' ','$','o','p','2',' ','=','=',' ','\"','\"','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','r','e','q','u','e','t','e','2',' ','\"','\"'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','i','f',' ','{','$','v','a','l','u','e','3',' ','=','=',' ','\"','\"',' ','|','|',' ','$','a','t','t','r','3',' ','=','=',' ','\"','\"',' ','|','|',' ','$','o','p','3',' ','=','=',' ','\"','\"','}',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','r','e','q','u','e','t','e','3',' ','\"','\"'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','s','w','i','t','c','h',' ','$','a','n','d','o','r','1',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','1',' ','{'
+,'\n'
+,'\t','\t','s','w','i','t','c','h',' ',' ','$','a','n','d','o','r','2',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','1',' ','{'
+,'\n'
+,'\t','\t','\t','s','e','t',' ','c','o','n','d','1',' ','\"','A','N','D','\"'
+,'\n'
+,'\t','\t','\t','s','e','t',' ','c','o','n','d','2',' ','\"','A','N','D','\"'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','0',' ','{'
+,'\n'
+,'\t','\t','\t','s','e','t',' ','c','o','n','d','1',' ','\"','A','N','D','\"'
+,'\n'
+,'\t','\t','\t','s','e','t',' ','c','o','n','d','2',' ','\"','O','R','\"','\t','\t','\t','\t','\t','\t','\t','\t','\t'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','d','e','f','a','u','l','t',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t',' ',' ',' ',' ','0',' ','{'
+,'\n'
+,'\t','\t','s','w','i','t','c','h',' ','$','a','n','d','o','r','2',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','1',' ','{'
+,'\n'
+,'\t','\t','\t','s','e','t',' ','c','o','n','d','1',' ','\"','O','R','\"'
+,'\n'
+,'\t','\t','\t','s','e','t',' ','c','o','n','d','2',' ','\"','A','N','D','\"'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','0',' ','{'
+,'\n'
+,'\t','\t','\t','s','e','t',' ','c','o','n','d','1',' ','\"','O','R','\"'
+,'\n'
+,'\t','\t','\t','s','e','t',' ','c','o','n','d','2',' ','\"','O','R','\"'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','d','e','f','a','u','l','t',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','\t','}','\t','\t','\t','\t','\t'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t',' ',' ',' ',' ','d','e','f','a','u','l','t',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','s','e','t',' ','q','u','e','r','y','v','r','f',' ','\"','\"'
+,'\n'
+,'\t','i','f',' ','{','$','r','e','q','u','e','t','e','1',' ','!','=',' ','\"','\"',' ','}',' ','{',' '
+,'\n'
+,'\t',' ',' ',' ',' ','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','[','e','v','a','l',' ','c','o','n','c','a','t',' ','$','r','e','q','u','e','t','e','1',']'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','$','r','e','q','u','e','t','e','2',' ','!','=',' ','\"','\"',' ','}',' ','{'
+,'\n'
+,'\t','\t','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','$','c','o','n','d','1'
+,'\n'
+,'\t','\t','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','[','e','v','a','l',' ','c','o','n','c','a','t',' ','$','r','e','q','u','e','t','e','2',']'
+,'\n'
+,'\t','\t','i','f',' ','{','$','r','e','q','u','e','t','e','3',' ','!','=',' ','\"','\"','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','$','c','o','n','d','2'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','[','e','v','a','l',' ','c','o','n','c','a','t',' ','$','r','e','q','u','e','t','e','3',']'
+,'\n'
+,'\t','\t','}',' '
+,'\n'
+,'\t',' ',' ',' ',' ','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t','\t','i','f',' ','{','$','r','e','q','u','e','t','e','3',' ','!','=',' ','\"','\"','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','$','c','o','n','d','1'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','[','e','v','a','l',' ','c','o','n','c','a','t',' ','$','r','e','q','u','e','t','e','3',']'
+,'\n'
+,'\t','\t','}',' '
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}',' ','e','l','s','e',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','$','r','e','q','u','e','t','e','2',' ','!','=',' ','\"','\"',' ','}',' ','{'
+,'\n'
+,'\t','\t','#','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','$','c','o','n','d'
+,'\n'
+,'\t','\t','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','$','r','e','q','u','e','t','e','2'
+,'\n'
+,'\t','\t','i','f',' ','{','$','r','e','q','u','e','t','e','3',' ','!','=',' ','\"','\"','}',' ','{'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','$','c','o','n','d','2'
+,'\n'
+,'\t','\t',' ',' ',' ',' ','l','a','p','p','e','n','d',' ','q','u','e','r','y','v','r','f',' ','[','e','v','a','l',' ','c','o','n','c','a','t',' ','$','r','e','q','u','e','t','e','3',']'
+,'\n'
+,'\t','\t','}'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','$','w','(','t','e','x','t',')',' ','d','e','l','e','t','e',' ','0',' ','e','n','d'
+,'\n'
+,'\t','$','w','(','t','e','x','t',')',' ','i','n','s','e','r','t',' ','e','n','d',' ','[','e','v','a','l',' ','c','o','n','c','a','t',' ','$','q','u','e','r','y','v','r','f',']'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','_','i','n','s','e','r','t','O','p','e','r','a','t','o','r',' ','i','n','s','e','r','t',' ','t','h','e',' ','o','p','e','r','a','t','o','r','s',' ','i','n',' ','t','h','e',' ','l','i','s','t',' ','o','f',' ','o','p','e','r','a','t','o','r','s'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','_','i','n','s','e','r','t','O','p','e','r','a','t','o','r',' ','{',' ','w','_','c','o','m','b','o','b','o','x','O','p','}',' ','{'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','l','i','s','t','_','o','p',' ','{','=',' ','>',' ','<',' ','>','=',' ','<','=',' ','!','=','}'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','v','a','r',' ','$','l','i','s','t','_','o','p',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','w','_','c','o','m','b','o','b','o','x','O','p',' ','i','n','s','e','r','t',' ','e','n','d',' ','$','v','a','r'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#','#','#','#','#','E','d','i','t',' ','m','e','t','a','d','a','d','a','t','a',' ','c','o','d','e',' ','a','d','d',' ','b','y',' ','p','c'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','m','e','t','a','d','a','t','a'
+,'\n'
+,' ',' ',' ',' ','#',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ',' ','o','p','e','n',' ','t','h','e',' ','m','e','t','a','d','a','t','a',' ','w','i','n','d','o','w'
+,'\n'
+,' ',' ',' ',' ','#'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','f','_','m','e','t','a','d','a','t','a',' ','{','}',' ','{'
+,'\n'
+,'\t','$','w','(','b','u','t','t','o','n',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','d','i','s','a','b','l','e','d'
+,'\n'
+,'\t','m','e','t','a','_','s','h','o','w','d','i','c','t'
+,'\n'
+,'\t','m','e','t','a','_','u','p','d','a','t','e'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' ','#',' ','t','h','e',' ','m','e','t','a','d','a','t','a',' ','w','i','n','d','o','w','.','.','.','.'
+,'\n'
+,' ',' ',' ',' ','#',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','m','e','t','a','_','s','h','o','w','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','w','(','d','d',')',' ','.','m','e','t','a','_','$','{','t','h','i','s','}'
+,'\n'
+,'\t','i','f',' ','[','w','i','n','f','o',' ','e','x','i','s','t','s',' ','$','w','(','d','d',')',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','w','m',' ','d','e','i','c','o','n','i','f','y',' ','$','w','(','d','d',')'
+,'\n'
+,'\t',' ',' ',' ',' ','r','a','i','s','e',' ','$','w','(','d','d',')'
+,'\n'
+,'\t',' ',' ',' ',' ','r','e','t','u','r','n'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','m','e','t','a','_','l','a','y','o','u','t','d','i','c','t'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','m','e','t','a','_','u','p','d','a','t','e',' ','{',' ','}',' ','{'
+,'\n'
+,'\t'
+,'\n'
+,'\t','s','e','t',' ','m','e','t','a','t','e','x','t',' ','[','e','c','s','_','U','p','d','a','t','e','D','i','c','t','i','o','n','a','r','y',' ','$','u','r','l',']'
+,'\n'
+,'\t','s','e','t',' ','n','b',' ','[','l','l','e','n','g','t','h',' ','$','m','e','t','a','t','e','x','t',']'
+,'\n'
+,'\t','s','e','t',' ','d','b','l','i','b','m','e','t','a',' ','[','l','i','n','d','e','x',' ','$','m','e','t','a','t','e','x','t',' ','0',']'
+,'\n'
+,'\t','s','e','t',' ','a','l','l','c','o','v','s','t','r','i','n','g',' ','[','l','i','n','d','e','x',' ','$','m','e','t','a','t','e','x','t',' ','1',']'
+,'\n'
+,'\t','s','e','t',' ','d','b','l','i','b','m','e','t','a','2',' ','[','l','i','n','d','e','x',' ','$','d','b','l','i','b','m','e','t','a',' ','1',']'
+,'\n'
+,'\t','#',' ','e','x','t','r','a','c','t','i','o','n',' ','d','d','b',' ','m','e','t','a','d','o','n','n','e','e','s'
+,'\n'
+,'\t','s','e','t',' ','d','d','b','m','e','t','a','d','a','t','a',' ','[','l','i','n','d','e','x',' ','$','d','b','l','i','b','m','e','t','a','2',' ','0',']'
+,'\n'
+,'\t','s','e','t',' ','l','i','b','m','e','t','a','d','a','t','a',' ','[','l','i','n','d','e','x',' ','$','d','b','l','i','b','m','e','t','a','2',' ','1',']'
+,'\n'
+,'\t','f','o','r','e','a','c','h',' ','c','o','v','s','t','r','i','n','g',' ','$','a','l','l','c','o','v','s','t','r','i','n','g',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','n','a','m','e','c','o','v',' ','[','l','i','n','d','e','x',' ','$','c','o','v','s','t','r','i','n','g',' ','1',']'
+,'\n'
+,'\t',' ',' ',' ',' ','s','e','t',' ','s','e','l','e','c','t','c','o','v',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','{','[','s','t','r','i','n','g',' ','c','o','m','p','a','r','e',' ','$','n','a','m','e','c','o','v',' ','[','g','e','t','S','e','l','e','c','t','e','d','C','o','v','e','r','a','g','e',']',']',' ','=','=','0','}',' ','{'
+,'\n'
+,'\t','\t','s','e','t',' ','c','o','v','c','o','m','p','l','e','t','e',' ','[','l','i','n','d','e','x',' ','$','c','o','v','s','t','r','i','n','g',' ','4',']'
+,'\n'
+,'\t','\t','s','e','t',' ','c','o','v','m','e','t','a','d','a','t','a',' ','[','l','i','n','d','e','x',' ','$','c','o','v','c','o','m','p','l','e','t','e',' ','2',']',' '
+,'\n'
+,'\t',' ',' ',' ',' ','}',' '
+,'\n'
+,'\t','}'
+,'\n'
+,'\t','i','f',' ','[','c','a','t','c','h',' ','{','$','w','(','d','d','t','e','x','t',')',' ','i','n','s','e','r','t',' ','e','n','d',' ','$','d','d','b','m','e','t','a','d','a','t','a','}',' ','s','_','r','e','s','u','l','t',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','e','r','r','o','r','M','s','g',' ','\"','C','o','u','l','d',' ','n','o','t',' ','r','e','t','r','i','e','v','e',' ','t','h','e',' ','m','e','t','a','d','a','t','a','\"'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','i','f',' ','[','c','a','t','c','h',' ','{','$','w','(','d','d','t','e','x','t','1',')',' ','i','n','s','e','r','t',' ','e','n','d',' ','$','l','i','b','m','e','t','a','d','a','t','a','}',' ','s','_','r','e','s','u','l','t',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','e','r','r','o','r','M','s','g',' ','\"','C','o','u','l','d',' ','n','o','t',' ','r','e','t','r','i','e','v','e',' ','t','h','e',' ','m','e','t','a','d','a','t','a','\"'
+,'\n'
+,'\t','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','i','f',' ','[','c','a','t','c','h',' ','{','$','w','(','d','d','t','e','x','t','2',')',' ','i','n','s','e','r','t',' ','e','n','d',' ','$','c','o','v','m','e','t','a','d','a','t','a','}',' ','s','_','r','e','s','u','l','t',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','e','r','r','o','r','M','s','g',' ','\"','C','o','u','l','d',' ','n','o','t',' ','r','e','t','r','i','e','v','e',' ','t','h','e',' ','m','e','t','a','d','a','t','a','\"'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','m','e','t','a','_','l','a','y','o','u','t','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+,'\t','t','o','p','l','e','v','e','l',' ','$','w','(','d','d',')'
+,'\n'
+,'\t','w','m',' ','t','i','t','l','e',' ','$','w','(','d','d',')',' ','[','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','G','e','t','S','t','r','i','n','g',' ','M','E','S','S','A','G','E','-','M','E','T','A','D','A','T','A',']'
+,'\n'
+,'\t','p','a','c','k',' ','[','t','i','x','L','a','b','e','l','F','r','a','m','e',' ','$','w','(','d','d',')','.','f','r',' ','-','l','a','b','e','l',' ',' ','[','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','G','e','t','S','t','r','i','n','g',' ','M','E','S','S','A','G','E','-','M','E','T','A','D','A','T','A',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','t','o','p',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','t','r','u','e',' ','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','b','o','t','h'
+,'\n'
+,'\t','#','y','k'
+,'\n'
+,'\t','$','o','b','j','_','E','n','v','i','r','o','n','m','e','n','t',' ','r','e','s','e','t','T','i','x','L','a','b','e','l','F','r','a','m','e','O','p','t','i','o','n','s',' ','$','w','(','d','d',')','.','f','r'
+,'\n'
+,'\t','s','e','t',' ','w','(','d','d','f','r',')',' ','[','$','w','(','d','d',')','.','f','r',' ','s','u','b','w','i','d','g','e','t',' ','f','r','a','m','e',']'
+,'\n'
+,'\t','f','r','a','m','e',' ','$','w','(','d','d','f','r',')','.','g','r','o','o','v','e',' ','\\'
+,'\n'
+,'\t','\t','-','b','o','r','d','e','r','w','i','d','t','h',' ','2',' ','\\'
+,'\n'
+,'\t','\t','-','r','e','l','i','e','f',' ','g','r','o','o','v','e'
+,'\n'
+,'\t'
+,'\n'
+,'\t','f','r','a','m','e',' ','$','w','(','d','d','f','r',')','.','g','r','o','o','v','e','.','s','u','n','k','e','n',' ','\\'
+,'\n'
+,'\t','\t','-','b','o','r','d','e','r','w','i','d','t','h',' ','2',' ','\\'
+,'\n'
+,'\t','\t','-','r','e','l','i','e','f',' ','s','u','n','k','e','n'
+,'\n'
+,'\t','s','e','t',' ','m','_','n','o','t','e','b','o','o','k',' ','[','t','i','x','N','o','t','e','B','o','o','k',' ','$','w','(','d','d','f','r',')','.','g','r','o','o','v','e','.','s','u','n','k','e','n','.','n','o','t','e','b','o','o','k',']'
+,'\n'
+,'\t','p','a','c','k',' ','a','p','p','e','n','d',' ','$','w','(','d','d','f','r',')','.','g','r','o','o','v','e','.','s','u','n','k','e','n',' ','\\'
+,'\n'
+,'\t','\t','$','w','(','d','d','f','r',')','.','g','r','o','o','v','e','.','s','u','n','k','e','n','.','n','o','t','e','b','o','o','k',' ','{','t','o','p',' ','e','x','p','a','n','d',' ','f','i','l','l','x',' ','f','i','l','l','y','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','p','a','c','k',' ','a','p','p','e','n','d',' ','$','w','(','d','d','f','r',')','.','g','r','o','o','v','e',' ','\\'
+,'\n'
+,'\t','\t','$','w','(','d','d','f','r',')','.','g','r','o','o','v','e','.','s','u','n','k','e','n',' ','{','t','o','p',' ','e','x','p','a','n','d',' ','f','i','l','l','x',' ','f','i','l','l','y','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','p','a','c','k',' ','a','p','p','e','n','d',' ','$','w','(','d','d','f','r',')','\\'
+,'\n'
+,'\t','\t','$','w','(','d','d','f','r',')','.','g','r','o','o','v','e',' ','{','t','o','p',' ','e','x','p','a','n','d',' ','f','i','l','l','x',' ','f','i','l','l','y','}'
+,'\n'
+,'\t'
+,'\n'
+,'\t','$','m','_','n','o','t','e','b','o','o','k',' ','a','d','d',' ','d','d','b','t','a','b',' ','\\'
+,'\n'
+,'\t','\t','-','l','a','b','e','l',' ','D','a','t','a','b','a','s','e','_','t','a','b','l','e'
+,'\n'
+,'\t'
+,'\n'
+,'\t','$','m','_','n','o','t','e','b','o','o','k',' ','a','d','d',' ','l','i','b','t','a','b',' ','\\'
+,'\n'
+,'\t','\t','-','l','a','b','e','l',' ','L','i','b','r','a','r','y','_','t','a','b','l','e'
+,'\n'
+,'\t'
+,'\n'
+,'\t','$','m','_','n','o','t','e','b','o','o','k',' ','a','d','d',' ','c','o','v','t','a','b',' ','\\'
+,'\n'
+,'\t','\t','-','l','a','b','e','l',' ','C','o','v','e','r','a','g','e','_','t','a','b','l','e'
+,'\n'
+,'\t'
+,'\n'
+,'\t','#','c','r','e','e',' ','u','n','e',' ','v','a','r','i','a','b','l','e',' ','u','t','i','l','i','s','a','b','l','e',' '
+,'\n'
+,'\t','s','e','t',' ','p','a','t','h','d','d','b','t','a','b',' ','[','$','m','_','n','o','t','e','b','o','o','k',' ','s','u','b','w','i','d','g','e','t',' ','d','d','b','t','a','b',']'
+,'\n'
+,'\t','s','e','t',' ','p','a','t','h','l','i','b','t','a','b',' ','[','$','m','_','n','o','t','e','b','o','o','k',' ','s','u','b','w','i','d','g','e','t',' ','l','i','b','t','a','b',']'
+,'\n'
+,'\t','s','e','t',' ','p','a','t','h','c','o','v','t','a','b',' ','[','$','m','_','n','o','t','e','b','o','o','k',' ','s','u','b','w','i','d','g','e','t',' ','c','o','v','t','a','b',']'
+,'\n'
+,'\t'
+,'\n'
+,'\t','#','c','r','e','e',' ','l','a',' ','f','e','n','e','t','r','e',' ','a',' ','l','\'','i','n','t','e','r','i','e','u','r',' ','d','e',' ','l','a',' ','c','a','r','t','e'
+,'\n'
+,'\t','p','a','c','k',' ','[','s','e','t',' ','w','(','d','d','t','e','x','t',')',' ','[','t','e','x','t',' ','$','p','a','t','h','d','d','b','t','a','b','.','t','e','x','t',' ','\\'
+,'\n'
+,'\t','\t','-','h','e','i','g','h','t',' ','2','0',' ','\\'
+,'\n'
+,'\t','\t','-','w','i','d','t','h',' ','8','0','\\'
+,'\n'
+,'\t','\t','-','y','s','c','r','o','l','l','c','o','m','m','a','n','d',' ','\"','$','p','a','t','h','d','d','b','t','a','b','.','s','b','y',' ','s','e','t','\"',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','l','e','f','t',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','t','r','u','e','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','b','o','t','h',' '
+,'\n'
+,'\t'
+,'\n'
+,'\t','p','a','c','k',' ','[','s','c','r','o','l','l','b','a','r',' ','$','p','a','t','h','d','d','b','t','a','b','.','s','b','y',' ','\\'
+,'\n'
+,'\t','\t','-','o','r','i','e','n','t',' ','v','e','r','t','i','c','a','l',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','[','l','i','s','t',' ','$','w','(','d','d','t','e','x','t',')',' ','y','v','i','e','w',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','r','i','g','h','t',' ','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','y'
+,'\n'
+,'\t'
+,'\n'
+,'\t','p','a','c','k',' ','[','s','e','t',' ','w','(','d','d','t','e','x','t','1',')',' ','[','t','e','x','t',' ','$','p','a','t','h','l','i','b','t','a','b','.','t','e','x','t',' ','\\'
+,'\n'
+,'\t','\t','-','h','e','i','g','h','t',' ','2','0',' ','\\'
+,'\n'
+,'\t','\t','-','w','i','d','t','h',' ','8','0','\\'
+,'\n'
+,'\t','\t','-','y','s','c','r','o','l','l','c','o','m','m','a','n','d',' ','\"','$','p','a','t','h','l','i','b','t','a','b','.','s','b','y',' ','s','e','t','\"',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','l','e','f','t',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','t','r','u','e','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','b','o','t','h',' '
+,'\n'
+,'\t'
+,'\n'
+,'\t','p','a','c','k',' ','[','s','c','r','o','l','l','b','a','r',' ','$','p','a','t','h','l','i','b','t','a','b','.','s','b','y',' ','\\'
+,'\n'
+,'\t','\t','-','o','r','i','e','n','t',' ','v','e','r','t','i','c','a','l',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','[','l','i','s','t',' ','$','w','(','d','d','t','e','x','t','1',')',' ','y','v','i','e','w',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','r','i','g','h','t',' ','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','y'
+,'\n'
+,'\t'
+,'\n'
+,'\t','p','a','c','k',' ','[','s','e','t',' ','w','(','d','d','t','e','x','t','2',')',' ','[','t','e','x','t',' ','$','p','a','t','h','c','o','v','t','a','b','.','t','e','x','t',' ','\\'
+,'\n'
+,'\t','\t','-','h','e','i','g','h','t',' ','2','0',' ','\\'
+,'\n'
+,'\t','\t','-','w','i','d','t','h',' ','8','0','\\'
+,'\n'
+,'\t','\t','-','y','s','c','r','o','l','l','c','o','m','m','a','n','d',' ','\"','$','p','a','t','h','c','o','v','t','a','b','.','s','b','y',' ','s','e','t','\"',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','l','e','f','t',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','t','r','u','e','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','b','o','t','h',' '
+,'\n'
+,'\t'
+,'\n'
+,'\t','p','a','c','k',' ','[','s','c','r','o','l','l','b','a','r',' ','$','p','a','t','h','c','o','v','t','a','b','.','s','b','y',' ','\\'
+,'\n'
+,'\t','\t','-','o','r','i','e','n','t',' ','v','e','r','t','i','c','a','l',' ','\\'
+,'\n'
+,'\t','\t','-','c','o','m','m','a','n','d',' ','[','l','i','s','t',' ','$','w','(','d','d','t','e','x','t','2',')',' ','y','v','i','e','w',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','r','i','g','h','t',' ','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','y','\t'
+,'\n'
+,'\t','#','#','#'
+,'\n'
+,'\t','p','a','c','k',' ','[','s','e','t',' ','w','_','b','f','r',' ','[','f','r','a','m','e',' ','$','w','(','d','d',')','.','b','f','r',']',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','t','o','p',' ','\\'
+,'\n'
+,'\t','\t','-','f','i','l','l',' ','x',' ','\\'
+,'\n'
+,'\t','\t','-','p','a','d','y',' ','2',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','f','a','l','s','e'
+,'\n'
+,'\t','p','a','c','k',' ','[','b','u','t','t','o','n',' ','$','w','_','b','f','r','.','o','k',' ','-','t','e','x','t',' ','O','K',' ','-','c','o','m','m','a','n','d',' ','\"','$','t','h','i','s',' ','m','e','t','a','_','k','i','l','l','d','i','c','t','\"',' ','-','w','i','d','t','h',' ','1','0',']',' ','\\'
+,'\n'
+,'\t','\t','-','s','i','d','e',' ','t','o','p',' ','\\'
+,'\n'
+,'\t','\t','-','e','x','p','a','n','d',' ','f','a','l','s','e'
+,'\n'
+,'\t','s','e','t',' ','x',' ','[','e','x','p','r',' ','[','w','i','n','f','o',' ','s','c','r','e','e','n','w','i','d','t','h',' ','$','w','(','d','d',')',']','/','2',' ','-',' ','[','w','i','n','f','o',' ','r','e','q','w','i','d','t','h',' ','$','w','(','d','d',')',']','/','2',' ','\\'
+,'\n'
+,'\t','\t','-',' ','[','w','i','n','f','o',' ','v','r','o','o','t','x',' ','[','w','i','n','f','o',' ','p','a','r','e','n','t',' ','$','w','(','d','d',')',']',']',']'
+,'\n'
+,'\t','i','f',' ','{','$','x',' ','<',' ','0','}',' ','{','s','e','t',' ','x',' ','0','}'
+,'\n'
+,'\t','s','e','t',' ','y',' ','[','e','x','p','r',' ','[','w','i','n','f','o',' ','s','c','r','e','e','n','h','e','i','g','h','t',' ','$','w','(','d','d',')',']','/','2',' ','-',' ','[','w','i','n','f','o',' ','r','e','q','h','e','i','g','h','t',' ','$','w','(','d','d',')',']','/','2',' ','\\'
+,'\n'
+,'\t','\t','-',' ','[','w','i','n','f','o',' ','v','r','o','o','t','y',' ','[','w','i','n','f','o',' ','p','a','r','e','n','t',' ','$','w','(','d','d',')',']',']',']'
+,'\n'
+,'\t','i','f',' ','{','$','y',' ','<',' ','0','}',' ','{','s','e','t',' ','y',' ','0','}'
+,'\n'
+,'\t','w','m',' ','g','e','o','m',' ','$','w','(','d','d',')',' ',' ','+','$','x','+','$','y'
+,'\n'
+
+,'\n'
+,'\t','u','p','d','a','t','e',' ','i','d','l','e','t','a','s','k','s'
+,'\n'
+,'\t','u','p','d','a','t','e',' '
+,'\n'
+,'\t','g','e','t','G','r','a','b',' ','$','w','(','d','d',')'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','m','e','t','a','_','d','e','s','t','r','o','y',' ','{','}',' ','{'
+,'\n'
+,'\t','i','f',' ','[',':',':','i','n','f','o',' ','e','x','i','s','t','s',' ','w','(','d','d',')',']',' ','{'
+,'\n'
+,'\t',' ',' ',' ',' ','i','f',' ','[','w','i','n','f','o',' ','e','x','i','s','t','s',' ','$','w','(','d','d',')',']',' ','{'
+,'\n'
+,'\t','\t','r','e','l','e','a','s','e','G','r','a','b'
+,'\n'
+,'\t','\t','d','e','s','t','r','o','y',' ','$','w','(','d','d',')'
+,'\n'
+,'\t',' ',' ',' ',' ','}'
+,'\n'
+,'\t','}'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','m','e','t','a','_','k','i','l','l','d','i','c','t',' ','{','}',' ','{'
+,'\n'
+,'\t'
+,'\n'
+,'\t','r','e','l','e','a','s','e','G','r','a','b'
+,'\n'
+,'\t','d','e','s','t','r','o','y',' ','$','w','(','d','d',')'
+,'\n'
+,'\t','$','w','(','b','u','t','t','o','n',')',' ','c','o','n','f','i','g','u','r','e',' ','-','s','t','a','t','e',' ','n','o','r','m','a','l'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','#','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'
+,'\n'
+,' ',' ',' ',' ','#',' ','P','R','O','C','E','D','U','R','E',':',' ','s','e','t','C','u','r','r','e','n','t'
+,'\n'
+,' ',' ',' ',' ','#',' ','A','R','G','U','M','E','N','T','S',':',' ','l','o','c','a','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','#',' ','R','E','T','U','R','N','E','D',' ','V','A','L','U','E','S',':',' ','n','o','n','e'
+,'\n'
+,' ',' ',' ',' ','#',' ','A','C','C','E','S','S',':',' ','p','r','i','v','a','t','e'
+,'\n'
+,' ',' ',' ',' ','#',' ','D','E','S','C','R','I','P','T','I','O','N',':'
+,'\n'
+,' ',' ',' ',' ','#','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','m','e','t','h','o','d',' ','s','e','t','C','u','r','r','e','n','t',' ','{','l','o','c','a','t','i','o','n','}',' ','{'
+,'\n'
+,'\t','s','e','t',' ','s','_','d','d','b','t','a','b','l','e',' ','$','l','o','c','a','t','i','o','n'
+,'\n'
+,' ',' ',' ',' ','}'
+,'\n'
+,' ',' ',' ',' ','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'
+,'\n'
+,' ',' ',' ',' '
+,'\n'
+,' ',' ',' ',' ','p','r','o','t','e','c','t','e','d',' ','a','_','s','_','l','a','b','e','l','\t','\t',';','#',' ','t','h','e',' ','i','n','d','e','x',' ','b','e','t','w','e','e','n',' ','l','a','b','e','l','s',' ','a','n','d',' ','n','a','m','e','s','.',' ',' '
+,'\n'
+,' ',' ',' ',' ',';','#',' ','e','.','g','.',' ','a','_','s','_','l','a','b','e','l','(','P','o','l','i','t','i','c','a','l',' ','B','o','u','n','d','a','r','i','e','s',')','=','P','O'
+,'\n'
+,' ',' ',' ',' ','p','r','o','t','e','c','t','e','d',' ','u','s','e','r','c','h','a','r',' ','\"','*','\"',' ',' ',';','#',' ','c','h','a','r','a','c','t','e','r',' ','t','h','a','t',' ','p','r','e','f','i','x','e','s',' ','m','a','p','s',' ','d','e','f','i','n','e','d',' ','b','y',' ','e','x','p','r'
+,'\n'
+,' ',' ',' ',' ','p','r','o','t','e','c','t','e','d',' ','c','o','v','e','r','a','g','e','O','r','d','e','r',' ','{','A','r','e','a',' ','L','i','n','e',' ','T','e','x','t',' ','P','o','i','n','t','}'
+,'\n'
+,'}'
+,'\n'
+
+,'\n'
+
+,'\n'
+,'\0'};
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/feature.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/feature.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/feature.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1497 @@
+/******************************************************************************
+ *
+ * Component: OGDI VRF Driver
+ * Purpose: Implementation of vrf Server getObject* functions
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: feature.c,v $
+ * Revision 1.15 2007/02/12 15:52:57 cbalint
+ *
+ * Preliminary cleanup.
+ * Get rif of unitialized variables, and unused ones.
+ *
+ * Revision 1.14 2004/10/26 20:29:43 warmerda
+ * Removed hack that was dropping some inner rings from polygons unnecessarily.
+ * The hack appears to be to deal with some problem of inner rings duplicating
+ * outer rings in browse products, but I don't know how to check the original
+ * case. See bug report 692844.
+ *
+ * Revision 1.13 2004/04/04 04:33:01 warmerda
+ * added vrf_free_ObjAttributeBuffer
+ *
+ * Revision 1.12 2004/02/19 05:46:28 warmerda
+ * fixed memory leak of edge coords with dangles
+ *
+ * Revision 1.11 2003/05/22 17:04:05 warmerda
+ * Removed debug statement.
+ *
+ * Revision 1.10 2003/05/22 16:58:01 warmerda
+ * Several fixes related to reading VITD area geometries properly even if
+ * the datasets face information seems to be corrupt. See bug:
+ * http://sf.net/tracker/index.php?func=detail&aid=741854&group_id=11181&atid=111181
+ *
+ * Revision 1.9 2003/05/21 18:50:19 warmerda
+ * verify that table_pos(COORDINATE) succeeds in point/line feature read
+ *
+ * Revision 1.8 2001/08/16 21:02:37 warmerda
+ * Removed MAXSEGS and MAXRINGS fixed limits
+ *
+ * Revision 1.7 2001/08/16 20:40:34 warmerda
+ * applied VITD fixes - merge primitive lines into a feature
+ *
+ * Revision 1.6 2001/06/21 20:30:15 warmerda
+ * added ECS_CVSID
+ *
+ * Revision 1.5 2001/06/13 17:33:59 warmerda
+ * upgraded source headers
+ *
+ */
+
+
+#include "ecs.h"
+#include "vrf.h"
+#include <assert.h>
+
+ECS_CVSID("$Id: feature.c,v 1.15 2007/02/12 15:52:57 cbalint Exp $");
+
+vpf_projection_type NOPROJ = {DDS, 0.0, 0.0, 0.0, 0.0, 0, 0.0, 0.0,
+ NULL, NULL, "Decimal Degrees "};
+
+
+/*********************************************************************
+ vrf_merge_line_prim()
+
+ Local service routine for vrf_get_merged_line_feature, which applies
+ the algorithm to merge a single new line segment into an existing
+ aggregated line.
+
+ IN
+ ecs_Server *s: ecs_Server structure
+ ecs_Layer *layer: Layer information structure
+ int primCount,primList: Primitive ID list
+
+ OUT
+ return int: Error code. True if the function execute correctly,
+ false else.
+
+ ********************************************************************/
+
+static int vrf_merge_line_prim( int *vertCount, double * vertX, double *vertY,
+ ecs_Line * line )
+
+{
+ int insertFlag = FALSE, reverseFlag = FALSE, i, insertStart;
+ int line_vert = line->c.c_len;
+
+ /*
+ Figure out the end points that match, if any, so we know how to
+ organize
+ */
+
+ if( vertX[0] == line->c.c_val[0].x
+ && vertY[0] == line->c.c_val[0].y )
+ {
+ insertFlag = TRUE;
+ reverseFlag = TRUE;
+ }
+ else if( vertX[*vertCount - 1] == line->c.c_val[0].x
+ && vertY[*vertCount - 1] == line->c.c_val[0].y )
+ {
+ /* append to end, no reverse */
+ }
+ else if( vertX[*vertCount - 1] == line->c.c_val[line_vert-1].x
+ && vertY[*vertCount - 1] == line->c.c_val[line_vert-1].y )
+ {
+ reverseFlag = TRUE;
+ }
+ else if( vertX[0] == line->c.c_val[line_vert-1].x
+ && vertY[0] == line->c.c_val[line_vert-1].y )
+ {
+ insertFlag = TRUE;
+ }
+ else
+ {
+ /* there is no coincident end points ... give up */
+ return FALSE;
+ }
+
+ /*
+ If we are inserting the new primitive in front of the existing
+ vertices, then we will have to push the existing ones down ...
+ */
+
+ if( insertFlag )
+ {
+ for( i = *vertCount - 1; i >= 0; i-- )
+ {
+ vertX[i + line_vert - 1] = vertX[i];
+ vertY[i + line_vert - 1] = vertY[i];
+ }
+ }
+
+ /*
+ Insert the new primitives vertices
+ */
+
+ if( insertFlag )
+ insertStart = 0;
+ else
+ insertStart = *vertCount - 1;
+
+ for( i = 0; i < line_vert; i++ )
+ {
+ if( reverseFlag )
+ {
+ vertX[insertStart + i] = line->c.c_val[line_vert - i - 1].x;
+ vertY[insertStart + i] = line->c.c_val[line_vert - i - 1].y;
+ }
+ else
+ {
+ vertX[insertStart + i] = line->c.c_val[i].x;
+ vertY[insertStart + i] = line->c.c_val[i].y;
+ }
+ }
+
+ *vertCount += (line_vert - 1);
+
+ return TRUE;
+}
+
+/*********************************************************************
+ vrf_get_merged_line_feature
+
+ Fill the ecs_Result with the merged coordinates of the passed primitive list.
+
+ IN
+ ecs_Server *s: ecs_Server structure
+ ecs_Layer *layer: Layer information structure
+ int primCount,primList: Primitive ID list
+
+ OUT
+ return int: Error code. True if the function execute correctly,
+ false else.
+
+ ********************************************************************/
+
+int vrf_get_merged_line_feature (s, layer, primCount, primList)
+ ecs_Server *s;
+ ecs_Layer *layer;
+ int primCount;
+ int32 *primList;
+{
+ int iPrim;
+ ecs_Result *primResults;
+ double *vertX, *vertY;
+ int vertCount, maxVertCount, i, *primConsumed, work_done;
+ int primsRemaining;
+ ecs_Line *line;
+
+ /*
+ simple case, no merging of primitives.
+ */
+
+ if( primCount == 1 )
+ {
+ return vrf_get_line_feature( s, layer, primList[0],
+ &(s->result) );
+ }
+
+ /*
+ Collect geometry for each of the primitives.
+ */
+ primResults = (ecs_Result *) calloc(sizeof(ecs_Result),primCount);
+ maxVertCount = 0;
+
+ for( iPrim = 0; iPrim < primCount; iPrim++ )
+ {
+ if( !vrf_get_line_feature( s, layer, primList[iPrim],
+ primResults+iPrim ) )
+ return FALSE; /* is it worth cleaning up? */
+
+ maxVertCount += ECSGEOM((primResults+iPrim)).line.c.c_len;
+ }
+
+ /*
+ * Initialize our aggregate feature with the first primitive.
+ */
+
+ vertX = (double *) malloc(sizeof(double) * maxVertCount);
+ vertY = (double *) malloc(sizeof(double) * maxVertCount);
+ primConsumed = (int *) calloc(sizeof(int),primCount);
+
+ line = &(ECSGEOM((primResults+0)).line);
+ vertCount = line->c.c_len;
+ for( i = 0; i < (int) line->c.c_len; i++ )
+ {
+ vertX[i] = line->c.c_val[i].x;
+ vertY[i] = line->c.c_val[i].y;
+ }
+
+ /*
+ * Merge in new features one at a time. If we make a pass through all
+ * the unmerged features without being able to merge another one
+ * at either end we give up, abandoning any remaining primitives.
+ */
+
+ primsRemaining = primCount - 1;
+ work_done = TRUE;
+ while( work_done && primsRemaining > 0 )
+ {
+ work_done = FALSE;
+
+ for( iPrim = 1; iPrim < primCount; iPrim++ )
+ {
+ line = &(ECSGEOM((primResults+iPrim)).line);
+
+ if( primConsumed[iPrim] )
+ continue;
+
+ if( vrf_merge_line_prim( &vertCount, vertX, vertY, line ) )
+ {
+ work_done = TRUE;
+ primConsumed[iPrim] = TRUE;
+ primsRemaining--;
+ }
+ }
+ }
+
+ /*
+ Build returned line structure.
+ */
+ if (!ecs_SetGeomLine(&(s->result), vertCount))
+ return FALSE;
+
+ for( i = 0; i < vertCount; i++ )
+ {
+ ECS_SETGEOMLINECOORD((&(s->result)), i, vertX[i], vertY[i]);
+ }
+
+ /*
+ Cleanup datastructures.
+ */
+
+ free( vertX );
+ free( vertY );
+ free( primConsumed );
+
+ for( iPrim = 0; iPrim < primCount; iPrim++ )
+ ecs_CleanUp( primResults + iPrim );
+
+ free( primResults );
+
+ return TRUE;
+}
+
+/*********************************************************************
+ vrf_get_line_feature
+
+ Fill the ecs_Result with the vrf information directly extract
+ from the table.
+
+ IN
+ ecs_Server *s: ecs_Server structure
+ ecs_Layer *layer: Layer information structure
+ int prim_id: Primitive ID
+
+ OUT
+ return int: Error code. True if the function execute correctly,
+ false else.
+
+ ********************************************************************/
+
+int vrf_get_line_feature (s, layer, prim_id, result)
+ ecs_Server *s;
+ ecs_Layer *layer;
+ int prim_id;
+ ecs_Result *result;
+{
+ int32 pos, count;
+ row_type row;
+ int i;
+ coordinate_type *ptr1=NULL;
+ tri_coordinate_type *ptr2=NULL;
+ double_coordinate_type *ptr3=NULL;
+ double_tri_coordinate_type *ptr4=NULL;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) layer->priv;
+
+ /*
+ -----------------------------------------------------------
+
+ Check the tables to see if they are open
+
+ -----------------------------------------------------------
+ */
+
+ if (!vrf_checkLayerTables(s,layer)) {
+ return FALSE;
+ }
+
+ /*
+ -----------------------------------------------------------
+
+ Extract table informations from the ecs_Server structure "s".
+
+ -----------------------------------------------------------
+ */
+
+ row = read_row (prim_id, lpriv->l.line.edgeTable);
+ if (row == NULL) {
+ ecs_SetError(result, 1,"Unable to extract the edge");
+ return FALSE;
+ }
+ pos = table_pos ("COORDINATES", lpriv->l.line.edgeTable);
+
+ if( pos == -1 )
+ {
+ ecs_SetError(result, 2, "No COORDINATE column");
+ free_row(row,lpriv->l.line.edgeTable);
+ return FALSE;
+ }
+
+ /*
+ -----------------------------------------------------------
+
+ Get the coordinates in the table
+
+ -----------------------------------------------------------
+ */
+
+ switch (lpriv->l.line.edgeTable.header[pos].type) {
+ case 'C':
+ ptr1 = get_table_element (pos, row, lpriv->l.line.edgeTable, NULL, &count);
+ break;
+ case 'Z':
+ ptr2 = get_table_element (pos, row, lpriv->l.line.edgeTable, NULL, &count);
+ break;
+ case 'B':
+ ptr3 = get_table_element (pos, row, lpriv->l.line.edgeTable, NULL, &count);
+ break;
+ case 'Y':
+ ptr4 = get_table_element (pos, row, lpriv->l.line.edgeTable, NULL, &count);
+ break;
+ default:
+ ecs_SetError(result, 2, "Undefined VRF table type");
+ }
+
+ free_row(row,lpriv->l.line.edgeTable);
+
+ /*
+ -----------------------------------------------------------
+
+ Initialize line structure
+
+ -----------------------------------------------------------
+ */
+
+ if (!ecs_SetGeomLine(result, count))
+ return FALSE;
+
+ /*
+ -----------------------------------------------------------
+
+ Fill the table line structure and free the old structure ptr
+
+ -----------------------------------------------------------
+ */
+
+ switch (lpriv->l.line.edgeTable.header[pos].type) {
+ case 'C':
+ {
+ if ((count == 1) && (ptr1 == (coordinate_type*)NULL)) {
+ ecs_SetError(result, 2, "Only one coordinate found for a line");
+ } else {
+ for (i=0; i<count; i++) {
+ ECS_SETGEOMLINECOORD((result),i,
+ ((double) ptr1[i].x),
+ ((double) ptr1[i].y))
+ }
+ if (ptr1)
+ xvt_free ((char*)ptr1);
+ break;
+ }
+ }
+ case 'Z':
+ {
+ if ((count == 1) && (ptr2 == (tri_coordinate_type*)NULL)) {
+ ecs_SetError(result, 2, "Only one coordinate found for a line");
+ } else {
+ for (i=0; i<count; i++) {
+ ECS_SETGEOMLINECOORD((result),i,((double) ptr2[i].x),((double) ptr2[i].y))
+ }
+ if (ptr2)
+ xvt_free ((char*)ptr2);
+ break;
+ }
+ }
+ case 'B':
+ {
+ if ((count == 1) && (ptr3 == (double_coordinate_type*)NULL)) {
+ ecs_SetError(result, 2, "Only one coordinate found for a line");
+ } else {
+ for (i=0; i<count; i++) {
+ ECS_SETGEOMLINECOORD((result),i,((double) ptr3[i].x),((double) ptr3[i].y))
+ }
+ }
+ if (ptr3)
+ xvt_free ((char*)ptr3);
+ break;
+ }
+ case 'Y':
+ {
+ if ((count == 1) && (ptr4 == (double_tri_coordinate_type*)NULL)) {
+ ecs_SetError(result, 2, "Only one coordinate found for a line");
+ } else {
+ for (i=0; i<count; i++) {
+ ECS_SETGEOMLINECOORD((result),i,((double) ptr4[i].x),((double) ptr4[i].y))
+ }
+ }
+ if (ptr4)
+ xvt_free ((char*)ptr4);
+ break;
+ }
+ default:
+ break;
+ } /* switch type */
+ return TRUE;
+}
+
+/*********************************************************************
+ vrf_get_line_mbr
+
+ Get the related mbr of a primitive line
+
+ IN
+ ecs_Server *s: ecs_Server structure
+ ecs_Layer *layer: Layer information structure
+ int prim_id: Primitive ID
+
+ OUT
+ return int: Error code. True if the function execute correctly,
+ false else.
+ double *xmin, *xmax, *ymin, *ymax: Returned bounding box
+
+ ********************************************************************/
+
+int vrf_get_line_mbr (layer, prim_id, xmin, ymin, xmax, ymax)
+ ecs_Layer *layer;
+ int32 prim_id;
+ double *xmin;
+ double *ymin;
+ double *xmax;
+ double *ymax;
+{
+ int32 count;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) layer->priv;
+ float temp;
+ row_type row;
+
+ if (lpriv->l.line.mbrTable.fp == NULL) {
+ return FALSE;
+ }
+
+ row = read_row (prim_id, lpriv->l.line.mbrTable);
+
+ get_table_element (table_pos("XMIN",lpriv->l.line.mbrTable), row, lpriv->l.line.mbrTable, &temp, &count);
+ *xmin = (double) temp;
+ get_table_element (table_pos("XMAX",lpriv->l.line.mbrTable), row, lpriv->l.line.mbrTable, &temp, &count);
+ *xmax = (double) temp;
+ get_table_element (table_pos("YMIN",lpriv->l.line.mbrTable), row, lpriv->l.line.mbrTable, &temp, &count);
+ *ymin = (double) temp;
+ get_table_element (table_pos("YMAX",lpriv->l.line.mbrTable), row, lpriv->l.line.mbrTable, &temp, &count);
+ *ymax = (double) temp;
+
+ free_row(row,lpriv->l.line.mbrTable);
+
+ return TRUE;
+}
+
+/*********************************************************************
+ vrf_get_lines_mbr
+
+ Get the related mbr of a list of primitive lines
+
+ IN
+ ecs_Layer *layer: Layer information structure
+ int primCount: primitive count
+ int primList: list of Primitive IDs
+
+ OUT
+ return int: Error code. True if the function execute correctly,
+ false else.
+ double *xmin, *xmax, *ymin, *ymax: Returned bounding box
+
+ ********************************************************************/
+
+int vrf_get_lines_mbr (layer, primCount, primList, xmin, ymin, xmax, ymax)
+ ecs_Layer *layer;
+ int32 primCount;
+ int32 *primList;
+ double *xmin;
+ double *ymin;
+ double *xmax;
+ double *ymax;
+{
+ int i;
+
+ if( !vrf_get_line_mbr( layer, primList[0], xmin, ymin, xmax, ymax ) )
+ return FALSE;
+
+ for( i = 1; i < primCount; i++ )
+ {
+ double x2min, x2max, y2min, y2max;
+
+ if( !vrf_get_line_mbr( layer, primList[i],
+ &x2min, &y2min, &x2max, &y2max ) )
+ return FALSE;
+
+ if( x2min < *xmin )
+ *xmin = x2min;
+ if( y2min < *ymin )
+ *ymin = y2min;
+ if( x2max > *xmax )
+ *xmax = x2max;
+ if( y2max > *ymax )
+ *ymax = y2max;
+ }
+
+ return TRUE;
+}
+
+/*********************************************************************
+ GET_TEXT_FEATURE
+ ********************************************************************/
+
+int vrf_get_text_feature (s, layer, prim_id)
+ ecs_Server *s;
+ ecs_Layer *layer;
+ int prim_id;
+{
+ row_type row; /* Row type in the text primitive table */
+ vpf_table_type table; /* VRF table type format */
+ int32 pos; /* Position in the text primitive table */
+ int32 count; /* Number of caracters that were read */
+ double x,y; /* coordinates of the text */
+ int code; /* success or failure of the operation */
+ LayerPrivateData *PrivData; /* Private information on the layer */
+ char * desc;
+
+ /*
+ -----------------------------------------------------------
+
+ Check the tables to see if they are open
+
+ -----------------------------------------------------------
+ */
+
+ if (!vrf_checkLayerTables(s,layer)) {
+ return FALSE;
+ }
+
+ PrivData = (LayerPrivateData *) layer->priv; /* casting the private data for a VPF Point layer from */
+ table = PrivData->l.text.textTable; /* our interest here is the primitive table */
+ row = read_row (prim_id, table); /* Read the prim_id row from the text primitive table */
+
+ pos = table_pos ("STRING", table); /* find the position in the primitive table */
+ desc = (char *) get_table_element (pos, row, table, NULL, &count); /* get the text string */
+
+ pos = table_pos ("SHAPE_LINE", table);
+ /* get the text coordinate, code will receive the result of th 0 = problem, 1 = success */
+ if ((code = vrf_get_xy (table, row, pos, &x, &y)) == TRUE) {
+ code = ecs_SetGeomText(&(s->result),x,y,desc);
+ } else {
+ ecs_SetError(&(s->result), 1, "Unable to get coordinates");
+ }
+
+ free_row(row,PrivData->l.text.textTable);
+ xvt_free(desc);
+ /* here all the information needed is known in result (ecs_Result) that is in s (ecs_Server) */
+ return code;
+
+}
+
+/*********************************************************************
+ GET_POINT_FEATURE
+ Derived from draw_point_row [vpfdraw.c]
+ ********************************************************************/
+
+int vrf_get_point_feature (s, layer, prim_id)
+ ecs_Server *s;
+ ecs_Layer *layer;
+ int prim_id;
+{
+ row_type row; /* Row type in the point primitive table */
+ vpf_table_type table; /* VRF table type format */
+ int32 pos; /* Position in the point primitive table */
+ double x,y; /* Coordinates of the point */
+ int code; /* Success or failure of the operation */
+ LayerPrivateData *PrivData; /* Private information on the layer */
+
+ /*
+ -----------------------------------------------------------
+
+ Check the tables to see if they are open
+
+ -----------------------------------------------------------
+ */
+
+ if (!vrf_checkLayerTables(s,layer)) {
+ return FALSE;
+ }
+
+ PrivData = (LayerPrivateData *) layer->priv; /* casting the private data for a VPF Point layer from */
+ table = PrivData->l.point.primTable; /* our interest here is the primitive table */
+ row = read_row (prim_id, table); /* Read the prim_id row from the point primitive table */
+ pos = table_pos ("COORDINATE", table); /* find the position in the primitive table */
+ /* get the point coordinate, code will receive the result of th 0 = problem, 1 = success */
+ if ( pos != -1 && (code = vrf_get_xy (table, row, pos, &x, &y)) == TRUE) {
+ code = ecs_SetGeomPoint(&(s->result),x,y);
+ } else {
+ ecs_SetError(&(s->result), 1, "Unable to get coordinates");
+ code = FALSE;
+ }
+ free_row(row,PrivData->l.point.primTable);
+ /* here all the information needed is known in result (ecs_Result) that is in s (ecs_Server) */
+ return code;
+}
+
+/*********************************************************************
+ GET_AREA_FEATURE
+ Derived from outline_face [vpfdraw.c]
+ ********************************************************************/
+
+int vrf_get_area_feature (s, layer, prim_id)
+ ecs_Server *s;
+ ecs_Layer *layer;
+ int prim_id;
+{
+ int32 n=0;
+ int code,i,j,k,qty;
+ face_rec_type face_rec;
+ ring_rec_type ring_rec;
+ vpf_table_type facetable, ringtable, edgetable;
+ AREA_FEATURE area;
+ double x,y;
+ int firstlength, max_rings;
+
+ /*
+ -----------------------------------------------------------
+
+ Check the tables to see if they are open
+
+ -----------------------------------------------------------
+ */
+
+ if (!vrf_checkLayerTables(s,layer)) {
+ return FALSE;
+ }
+
+ facetable = ((LayerPrivateData *) layer->priv)->l.area.faceTable;
+ ringtable = ((LayerPrivateData *) layer->priv)->l.area.ringTable;
+ edgetable = ((LayerPrivateData *) layer->priv)->l.area.edgeTable;
+ face_rec = read_face (prim_id, facetable);
+ ring_rec = read_ring (face_rec.ring, ringtable);
+
+ /*
+ Allocate space to store addresses of all the ring structures
+ */
+ max_rings = 5;
+ area.rings = (RING**)xvt_zmalloc (max_rings * sizeof (RING*));
+ if (area.rings == NULL) {
+ ecs_SetError(&(s->result), 2, "No enough memory");
+ return FALSE;
+ }
+
+ /*
+ Get the outer ring coords
+ */
+ area.rings[n] = (RING*)xvt_zmalloc (sizeof (RING));
+ if (area.rings[n] == NULL) {
+ ecs_SetError(&(s->result), 2, "No enough memory");
+ xvt_free ((char*)area.rings);
+ return FALSE;
+ }
+
+ area.rings[n]->id = n+1;
+
+ if (!vrf_get_ring_coords (s,area.rings[n], prim_id, ring_rec.edge, edgetable)) {
+ xvt_free((char*)area.rings[0]);
+ xvt_free ((char*)area.rings);
+ return FALSE;
+ }
+ firstlength = area.rings[n]->nr_segs;
+ n++;
+
+ /*
+ Get the coords for any inner rings that exist
+ */
+ while (ring_rec.face == prim_id) {
+ ring_rec = read_next_ring (ringtable);
+
+ if (feof (ringtable.fp))
+ break;
+
+ /*
+ ** The Browse Case: It is possible the last island cover the same
+ ** region than the first one.
+ **
+ ** NFW/2004: The following logic seems unreasonably broad and has for
+ ** certain been causing some island polygons (such as for the island at
+ ** 14.85E, 60.55N in inwatera at hydro(*) of the eurasia VMAP0 dataset) to
+ ** disappear without reason. There may be a case where this logic should
+ ** apply, but without detail on how to reproduce the original issue, I am
+ ** just removing the logic completely.
+ **
+ ** See ogdi.sf.net bug tracker bug: 692844
+ */
+#ifdef notdef
+ if (n>=2 && ring_rec.face != prim_id && area.rings[n-1]->nr_segs == firstlength) {
+ n--;
+ break;
+ }
+#endif
+
+ if (ring_rec.face == prim_id) {
+ if( n == max_rings )
+ {
+ max_rings *= 2;
+ area.rings = (RING **) xvt_realloc(area.rings,
+ sizeof(RING *) * max_rings);
+ }
+
+ area.rings[n] = (RING*)xvt_zmalloc (sizeof (RING));
+ if (area.rings[n] == NULL) {
+ for(i=0;i<n-1;i++) {
+ for(j=0;j<area.rings[i]->nr_segs;j++) {
+ xvt_free((char*) area.rings[i]->segs[j]->coords);
+ xvt_free((char*) area.rings[i]->segs[j]);
+ }
+ xvt_free((char*)area.rings[i]->segs);
+ xvt_free((char*)area.rings[i]);
+ }
+ xvt_free ((char*)area.rings);
+ ecs_SetError(&(s->result), 2, "No enough memory");
+ return FALSE;
+ }
+
+ area.rings[n]->id = n+1;
+
+ if (!vrf_get_ring_coords (s,area.rings[n], prim_id, ring_rec.edge, edgetable)) {
+ for(i=0;i<n-1;i++) {
+ for(j=0;j<area.rings[i]->nr_segs;j++) {
+ xvt_free((char*) area.rings[i]->segs[j]->coords);
+ xvt_free((char*) area.rings[i]->segs[j]);
+ }
+ xvt_free((char*)area.rings[i]->segs);
+ xvt_free((char*)area.rings[i]);
+ }
+ xvt_free ((char*)area.rings);
+ ecs_SetError(&(s->result), 2, "No enough memory");
+ return FALSE;
+ }
+
+ n++;
+ }
+ }
+ area.nr_rings = n;
+ assert( n <= max_rings );
+
+ /*
+ Extract all coordinates from area and put them in a ecs_Area
+ */
+
+ code = TRUE;
+ if ((code = ecs_SetGeomArea(&(s->result), area.nr_rings))) {
+ for(i=0;i<area.nr_rings;i++) {
+
+ if (!code)
+ break;
+
+ /*
+ For all the ring segments, calculate the total number of points
+ */
+
+ qty = 0;
+ for(j=0;j<area.rings[i]->nr_segs;j++)
+ qty += area.rings[i]->segs[j]->nr_coords;
+
+ /*
+ Initialise the ring and add all the coordinates
+ */
+
+ if( (code = ecs_SetGeomAreaRing(&(s->result), i, qty, 0.0, 0.0)) ) {
+ qty = 0;
+ for(j=0;j<area.rings[i]->nr_segs;j++) {
+ for(k=0; k<area.rings[i]->segs[j]->nr_coords;k++) {
+ x = (double) area.rings[i]->segs[j]->coords[k].x;
+ y = (double) area.rings[i]->segs[j]->coords[k].y;
+ ECS_SETGEOMAREACOORD((&(s->result)), i, qty, x, y);
+ qty++;
+ }
+ }
+ }
+ }
+ }
+
+ for(i=0;i < area.nr_rings;i++) {
+ for(j=0;j<area.rings[i]->nr_segs;j++) {
+ xvt_free((char*) area.rings[i]->segs[j]->coords);
+ xvt_free((char*) area.rings[i]->segs[j]);
+ }
+ xvt_free((char*)area.rings[i]->segs);
+ xvt_free((char*)area.rings[i]);
+ }
+ xvt_free ((char*)area.rings);
+
+ return code;
+}
+
+/*********************************************************************
+ GET_RING_COORDS
+ Derived from outline_face_ring [vpfdraw.c]
+ ********************************************************************/
+
+int vrf_get_ring_coords (s,ring, face_id, start_edge, edgetable)
+ ecs_Server *s;
+ RING *ring;
+ int32 face_id, start_edge;
+ vpf_table_type edgetable;
+{
+ edge_rec_type edge_rec;
+ int32 next_edge, prevnode, i, n=0;
+ boolean done=FALSE;
+ vpf_projection_type proj;
+ double_coordinate_type dcoord;
+ SEGMENT **temp;
+ long eqlface1=0L, eqlface2=0L;
+ long eqlnpts;
+ long eqlleft_edge=0L, eqlright_edge=0L;
+ long maxsegs;
+ char buffer[120];
+ char start_dir = '+';
+
+ maxsegs = 5;
+ proj = NOPROJ;
+
+ edge_rec = read_edge (start_edge, edgetable, proj.inverse_proj);
+ if (edge_rec.npts == 0) {
+ sprintf(buffer,"Unable to read the edge %d in the face %d",
+ (int) start_edge, (int) face_id);
+ ecs_SetError(&(s->result), 1,buffer);
+ return FALSE;
+ }
+ edge_rec.dir = '+';
+ prevnode = edge_rec.start_node;
+
+ if (edge_rec.start_node == edge_rec.end_node)
+ done = TRUE;
+ next_edge = vrf_next_face_edge (&edge_rec, &prevnode, face_id);
+ if ((edge_rec.right_face == face_id) && (edge_rec.left_face == face_id))
+ {
+ eqlface1 = 1L;
+ eqlnpts = edge_rec.npts;
+ eqlleft_edge = edge_rec.left_edge;
+ eqlright_edge = edge_rec.right_edge;
+ start_dir = edge_rec.dir;
+ }
+ else
+ eqlface1 = 0L;
+
+ /* Allocate plenty of space for array of segment addresses */
+ ring->segs = (SEGMENT**)xvt_zmalloc (maxsegs * sizeof (SEGMENT*));
+
+ /* Load the first segment of the ring */
+ ring->segs[n] = (SEGMENT*)xvt_zmalloc (sizeof (SEGMENT));
+ ring->segs[n]->nr_coords = edge_rec.npts;
+ ring->segs[n]->id = n+1;
+
+ /* Allocate space for the coordinates of the first segment */
+ ring->segs[n]->coords = (COORDINATE*)xvt_zmalloc ((size_t)ring->segs[n]->nr_coords * sizeof (COORDINATE));
+
+ /* If the direction is - load in reverse order */
+ if (edge_rec.dir == '-')
+ {
+ for (i=(edge_rec.npts-1); i>=0; i--)
+ {
+ dcoord = next_edge_coordinate (&edge_rec);
+ ring->segs[n]->coords[i].x = (float)dcoord.x;
+ ring->segs[n]->coords[i].y = (float)dcoord.y;
+ }
+ } else {
+ for (i=0; i<edge_rec.npts; i++) {
+ dcoord = next_edge_coordinate (&edge_rec);
+ ring->segs[n]->coords[i].x = (float)dcoord.x;
+ ring->segs[n]->coords[i].y = (float)dcoord.y;
+ }
+ }
+
+ n++;
+ if (edge_rec.coords)
+ xvt_free ((char*)edge_rec.coords);
+
+ while (!done)
+ {
+ if (next_edge < 0)
+ {
+ done = TRUE;
+ }
+
+ if (next_edge == 0)
+ {
+ done = TRUE;
+ }
+
+ if (next_edge == start_edge && !eqlface1)
+ {
+ done = TRUE;
+ continue;
+ }
+
+ if (next_edge == start_edge && eqlface1 &&
+ eqlleft_edge == 0L && eqlright_edge == 0L)
+ {
+ done = TRUE;
+ }
+
+ if (!done)
+ {
+ edge_rec = read_edge( next_edge, edgetable, (long)proj.inverse_proj);
+ if (edge_rec.npts == 0) {
+ sprintf(buffer,"Unable to read the edge %d in the face %d",
+ (int) next_edge, (int) face_id);
+ ecs_SetError(&(s->result), 1,buffer);
+ return FALSE;
+ }
+
+ next_edge = vrf_next_face_edge( &edge_rec, &prevnode, face_id );
+ if ((edge_rec.right_face == face_id) && (edge_rec.left_face ==face_id))
+ eqlface2 = 1L;
+ else
+ eqlface2 = 0L;
+
+ /*
+ * This is to catch cases where there would appear to be a dangle
+ * (so we set eqlface1), but when we go to repeat the start edge
+ * we find we are going the same direction as the first time.
+ * This occurs with some VITD dataset as per bug 741854 on
+ * http://ogdi.sf.net/
+ */
+#ifndef SKIP_BUG_741854_FIX
+ if( edge_rec.id == start_edge && edge_rec.dir == start_dir )
+ {
+ if (edge_rec.coords)
+ xvt_free ((char*)edge_rec.coords);
+ done = TRUE;
+ continue;
+ }
+#endif
+ /* Allocate space for the next segment */
+ if (eqlface1 && edge_rec.id == eqlleft_edge)
+ eqlleft_edge = 0L;
+ if (eqlface1 && edge_rec.id == eqlright_edge)
+ eqlright_edge = 0L;
+
+ if( n == maxsegs )
+ {
+ maxsegs *= 2;
+ ring->segs = (SEGMENT**)
+ xvt_realloc(ring->segs, maxsegs * sizeof (SEGMENT*));
+ }
+
+ ring->segs[n] = (SEGMENT*)xvt_zmalloc (sizeof (SEGMENT));
+ ring->segs[n]->nr_coords = edge_rec.npts;
+ ring->segs[n]->id = n+1;
+
+ /* Allocate space for the segment coordinates */
+ ring->segs[n]->coords = (COORDINATE*)xvt_zmalloc ((size_t)ring->segs[n]->nr_coords * sizeof (COORDINATE));
+
+ /* If the direction is - load in reverse order */
+ if (edge_rec.dir == '-')
+ {
+ for (i=(edge_rec.npts-1); i>=0; i--)
+ {
+ dcoord = next_edge_coordinate (&edge_rec);
+ ring->segs[n]->coords[i].x = (float)dcoord.x;
+ ring->segs[n]->coords[i].y = (float)dcoord.y;
+ }
+ }
+ else
+ {
+ for (i=0; i<edge_rec.npts; i++)
+ {
+ dcoord = next_edge_coordinate (&edge_rec);
+ ring->segs[n]->coords[i].x = (float)dcoord.x;
+ ring->segs[n]->coords[i].y = (float)dcoord.y;
+ }
+ }
+ n++;
+ if (edge_rec.coords)
+ xvt_free ((char*)edge_rec.coords);
+
+ } /* if (!done) */
+ } /* while */
+ ring->nr_segs = n;
+ assert( ring->nr_segs <= maxsegs );
+
+ /* Realloc the segs array to free unused memory */
+ temp = (SEGMENT**)xvt_zmalloc (ring->nr_segs * sizeof (SEGMENT*));
+ memcpy ((char*)temp, (char*)ring->segs, (ring->nr_segs * sizeof (SEGMENT*)));
+ xvt_free ((char*)ring->segs);
+ ring->segs = temp;
+
+ return TRUE;
+}
+
+/*********************************************************************
+ NEXT_FACE_EDGE
+ Derived from next_face_edge [vpfdraw.c]
+ ********************************************************************/
+int32 vrf_next_face_edge (edge_rec, prevnode, face_id)
+ edge_rec_type *edge_rec;
+ int32 *prevnode, face_id;
+{
+ int32 next;
+
+ if ((edge_rec->right_face == face_id) &&
+ (edge_rec->left_face == face_id)) {
+ /*
+ Dangle - go the opposite dir to continue aint32 the boundary
+ */
+ if (*prevnode == edge_rec->start_node) {
+ edge_rec->dir = '+';
+ next = edge_rec->right_edge;
+ *prevnode = edge_rec->end_node;
+ } else if (*prevnode == edge_rec->end_node) {
+ edge_rec->dir = '-';
+ next = edge_rec->left_edge;
+ *prevnode = edge_rec->start_node;
+ } else {
+ next = -1;
+ }
+ } else if (edge_rec->right_face == face_id) {
+ /*
+ The face is on the right - take the right forward edge
+ */
+ next = edge_rec->right_edge;
+ edge_rec->dir = '+';
+ *prevnode = edge_rec->end_node;
+ } else if (edge_rec->left_face == face_id) {
+ /*
+ The face is on the left - take the left forward edge
+ */
+ next = edge_rec->left_edge;
+ edge_rec->dir = '-';
+ *prevnode = edge_rec->start_node;
+ }
+ /*
+ * I think we only end up here if the face information is wrong for some
+ * reason. I have this problem with most layers in some VITD datasets
+ * 04KOREA (Edition 1) VITD data. In this case we fall back to establishing
+ * the correction edge direction based on the start and end node.
+ *
+ * See bug 741854 on http://ogdi.sf.net/
+ */
+ else {
+ if (*prevnode == edge_rec->start_node) {
+ edge_rec->dir = '+';
+ next = edge_rec->right_edge;
+ *prevnode = edge_rec->end_node;
+ } else if (*prevnode == edge_rec->end_node) {
+ edge_rec->dir = '-';
+ next = edge_rec->left_edge;
+ *prevnode = edge_rec->start_node;
+ } else {
+ next = -1;
+ }
+ }
+
+ return next;
+}
+
+/*********************************************************************
+ vrf_get_area_mbr
+
+ Get the related mbr of a primitive face
+
+ IN
+ ecs_Server *s: ecs_Server structure
+ ecs_Layer *layer: Layer information structure
+ int prim_id: Primitive ID
+
+ OUT
+ return int: Error code. True if the function execute correctly,
+ false else.
+ double *xmin, *xmax, *ymin, *ymax: Returned bounding box
+
+ ********************************************************************/
+
+int vrf_get_area_mbr (layer, prim_id, xmin, ymin, xmax, ymax)
+ ecs_Layer *layer;
+ int32 prim_id;
+ double *xmin;
+ double *ymin;
+ double *xmax;
+ double *ymax;
+{
+ int32 count;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) layer->priv;
+ float temp;
+ row_type row;
+
+ if (lpriv->l.area.mbrTable.fp == NULL) {
+ return FALSE;
+ }
+
+ row = read_row (prim_id, lpriv->l.area.mbrTable);
+
+ get_table_element (table_pos("XMIN",lpriv->l.area.mbrTable), row, lpriv->l.area.mbrTable, &temp, &count);
+ *xmin = (double) temp;
+ get_table_element (table_pos("XMAX",lpriv->l.area.mbrTable), row, lpriv->l.area.mbrTable, &temp, &count);
+ *xmax = (double) temp;
+ get_table_element (table_pos("YMIN",lpriv->l.area.mbrTable), row, lpriv->l.area.mbrTable, &temp, &count);
+ *ymin = (double) temp;
+ get_table_element (table_pos("YMAX",lpriv->l.area.mbrTable), row, lpriv->l.area.mbrTable, &temp, &count);
+ *ymax = (double) temp;
+
+ free_row(row,lpriv->l.area.mbrTable);
+
+ return TRUE;
+}
+
+
+/****************************************************************************
+
+ vrf_get_xy
+
+ Extract from the database the point contain at the "pos" column of
+ the table "table" at the row "row". If the structure found is a list
+ of coordinate, only the first one will be returned.
+
+ IN
+ vpf_table_type table : Table of primitives (already open)
+ row_type row : Table row in "table"
+ long pos : Column position in "table" for "COORDINATE"
+
+ OUT
+ double *x,*y : Point extract from structure
+ return int : This flag indicate the success or the failure
+ of the function.
+
+ ***************************************************************************/
+
+int vrf_get_xy (table, row, pos, x, y)
+ vpf_table_type table;
+ row_type row;
+ int32 pos;
+ double *x;
+ double *y;
+{
+ int32 count;
+ coordinate_type temp1, *ptr1;
+ tri_coordinate_type temp2, *ptr2;
+ double_coordinate_type temp3, *ptr3;
+ double_tri_coordinate_type temp4, *ptr4;
+
+ switch (table.header[pos].type) {
+ case 'C':
+ {
+ ptr1 = get_table_element (pos, row, table, &temp1, &count);
+
+ if ((count == 1) && (ptr1 == (coordinate_type*)NULL)) {
+ *x = (double) temp1.x;
+ *y = (double) temp1.y;
+ } else {
+ *x = (double) ptr1->x;
+ *y = (double) ptr1->y;
+ if (ptr1)
+ free(ptr1);
+ }
+ break;
+ }
+ case 'Z':
+ {
+ ptr2 = get_table_element (pos, row, table, &temp2, &count);
+ if ((count == 1) && (ptr2 == (tri_coordinate_type*)NULL)) {
+ *x = temp2.x;
+ *y = temp2.y;
+ } else {
+ *x = (double) ptr2[0].x;
+ *y = (double) ptr2[0].y;
+ if (ptr2)
+ xvt_free ((char*)ptr2);
+ }
+ break;
+ }
+ case 'B':
+ {
+ ptr3 = get_table_element (pos, row, table, &temp3, &count);
+ if ((count == 1) && (ptr3 == (double_coordinate_type*)NULL)) {
+ *x = (double) temp3.x;
+ *y = (double) temp3.y;
+ } else {
+ *x = (double) ptr3[0].x;
+ *y = (double) ptr3[0].y;
+ if (ptr3)
+ xvt_free ((char*)ptr3);
+ }
+ break;
+ }
+ case 'Y':
+ {
+ ptr4 = get_table_element (pos, row, table, &temp4, &count);
+ if ((count == 1) && (ptr4 == (double_tri_coordinate_type*)NULL)) {
+ *x = (double) temp4.x;
+ *y = (double) temp4.y;
+ } else {
+ *x = (double) ptr4[0].x;
+ *y = (double) ptr4[0].y;
+ if (ptr4)
+ xvt_free ((char*)ptr4);
+ }
+ break;
+ }
+ default:
+ break;
+ } /* switch type */
+ return TRUE;
+}
+
+
+
+/****************************************************************************
+
+ vrf_get_ObjAttributes
+
+ Get the attributes from the feature table and generate a string with
+ it.
+
+ IN
+ vpf_table_type table : Table of primitives (already open)
+ int32 row_pos : Row position in table
+
+ OUT
+ return char *: The returned string. If NULL, the operation
+ was unsuccessul.
+
+ ***************************************************************************/
+
+static char *returnString = NULL;
+
+char *vrf_get_ObjAttributes(table, row_pos)
+ vpf_table_type table;
+ int32 row_pos;
+{
+ int i;
+ char buffer[255];
+ row_type row;
+ int32 lenght;
+ char temp1, *ptr1;
+ float temp2;
+ double temp3;
+ short int temp4;
+ int temp5;
+ date_type temp6;
+ long count;
+
+ if (returnString != NULL) {
+ free(returnString);
+ returnString = NULL;
+ }
+
+ row = read_row(row_pos,table);
+
+ lenght = 1;
+ returnString = (char *) malloc(lenght);
+ strcpy(returnString,"");
+
+ for(i = 0; i < table.nfields; ++i) {
+ switch(table.header[i].type) {
+ case 'T':
+ ptr1 = get_table_element (i, row, table, &temp1, &count);
+ if ((count == 1) && (ptr1 == (char *) NULL)) {
+ lenght += 6;
+ returnString = (char *) realloc(returnString,lenght);
+ if (returnString == NULL) {
+ free_row(row,table);
+ return NULL;
+ }
+ sprintf(buffer,"%c",temp1);
+ strcat(returnString,"{ ");
+ strcat(returnString,buffer);
+ strcat(returnString," } ");
+ } else {
+ lenght += count + 6;
+ returnString = (char *) realloc(returnString,lenght);
+ if (returnString == NULL) {
+ free_row(row,table);
+ free(ptr1);
+ return NULL;
+ }
+ strcat(returnString,"{ ");
+ strcat(returnString,ptr1);
+ strcat(returnString," } ");
+ free(ptr1);
+ }
+ break;
+ /*added 5-28-97 case "D" */
+ case 'D': /* Date */
+ ptr1 = get_table_element (i, row, table, &temp6, &count);
+ if ((count == 1) && (ptr1 == (char *) NULL)) {
+ lenght += 5 + sizeof(date_type); /*Changed from += 6 to += 5 + sizeof(date_type)*/
+ returnString = (char *) realloc(returnString,lenght);
+ if (returnString == NULL) {
+ free_row(row,table);
+ return NULL;
+ }
+ sprintf(buffer,"%20s",temp6); /*dap Changed %c to %20s*/
+ strcat(returnString,"{ ");
+ strcat(returnString,buffer);
+ strcat(returnString," } ");
+ } else {
+ /* Changed from += count + 6 to += 5 + (count * sizeof(date_type))*/
+ lenght += 5 + (count * sizeof(date_type));
+ returnString = (char *) realloc(returnString,lenght);
+ if (returnString == NULL) {
+ free_row(row,table);
+ free(ptr1);
+ return NULL;
+ }
+ strcat(returnString,"{ ");
+ strcat(returnString,ptr1);
+ strcat(returnString," } ");
+ free(ptr1);
+ }
+ break;
+ case 'F':
+ get_table_element (i, row, table, &temp2, &count);
+ sprintf(buffer,"%f",temp2);
+ lenght += strlen(buffer) + 2;
+ returnString = (char *) realloc(returnString,lenght);
+ if (returnString == NULL) {
+ free_row(row,table);
+ return NULL;
+ }
+ strcat(returnString,buffer);
+ strcat(returnString," ");
+ break;
+ case 'R':
+ get_table_element (i, row, table, &temp3, &count);
+ sprintf(buffer,"%f",temp3);
+ lenght += strlen(buffer) + 2;
+ returnString = (char *) realloc(returnString,lenght);
+ if (returnString == NULL) {
+ free_row(row,table);
+ return NULL;
+ }
+ strcat(returnString,buffer);
+ strcat(returnString," ");
+ break;
+ case 'S':
+ get_table_element (i, row, table, &temp4, &count);
+ sprintf(buffer,"%d",temp4);
+ lenght += strlen(buffer) + 2;
+ returnString = (char *) realloc(returnString,lenght);
+ if (returnString == NULL) {
+ free_row(row,table);
+ return NULL;
+ }
+ strcat(returnString,buffer);
+ strcat(returnString," ");
+ break;
+ case 'I':
+ get_table_element (i, row, table, &temp5, &count);
+ sprintf(buffer,"%d",temp5);
+ lenght += strlen(buffer) + 2;
+ returnString = (char *) realloc(returnString,lenght);
+ if (returnString == NULL) {
+ free_row(row,table);
+ return NULL;
+ }
+ strcat(returnString,buffer);
+ strcat(returnString," ");
+ break;
+ }
+ }
+
+ free_row(row,table);
+ return returnString;
+}
+
+void vrf_free_ObjAttributeBuffer()
+
+{
+ if( returnString != NULL )
+ {
+ free( returnString );
+ returnString = NULL;
+ }
+}
+
+int vrf_checkLayerTables(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ register LayerPrivateData *lpriv;
+
+ lpriv = (LayerPrivateData *) l->priv;
+ switch(l->sel.F) {
+ case Area:
+ if (lpriv->l.area.faceTable.fp == NULL) {
+ ecs_SetError(&(s->result), 1, "VRF table fac not open");
+ return FALSE;
+ }
+ if (lpriv->l.area.mbrTable.fp == NULL) {
+ ecs_SetError(&(s->result), 1, "VRF table mbr not open");
+ return FALSE;
+ }
+ if (lpriv->l.area.ringTable.fp == NULL) {
+ ecs_SetError(&(s->result), 1, "VRF table rng not open");
+ return FALSE;
+ }
+ if (lpriv->l.area.edgeTable.fp == NULL) {
+ ecs_SetError(&(s->result), 1, "VRF table edg not open");
+ return FALSE;
+ }
+
+ break;
+ case Line:
+ if (lpriv->l.line.mbrTable.fp == NULL) {
+ ecs_SetError(&(s->result), 1, "VRF table mbr not open");
+ return FALSE;
+ }
+ if (lpriv->l.line.edgeTable.fp == NULL) {
+ ecs_SetError(&(s->result), 1, "VRF table edg not open");
+ return FALSE;
+ }
+ break;
+ case Point:
+ if (lpriv->l.point.primTable.fp == NULL) {
+ ecs_SetError(&(s->result), 1, "VRF table end or cnd not open");
+ return FALSE;
+ }
+ break;
+ case Text:
+ if (lpriv->l.text.textTable.fp == NULL) {
+ ecs_SetError(&(s->result), 1, "VRF table txt not open");
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = vrf
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = vrf.c utils.c feature.c object.c open.c swq.c vrfswq.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) $(VPF_INCLUDE) $(PROJ_INCLUDE) $(GLUTIL_INCLUDE)
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(WIN_LINKLIB) $(VPF_STATICLIB) $(MATH_LINKLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR datadict.h
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/object.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/object.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/object.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1637 @@
+/******************************************************************************
+ *
+ * Component: OGDI VRF Driver
+ * Purpose: Implementation of vrf Server getObject* functions
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: object.c,v $
+ * Revision 1.8 2004/10/19 14:17:03 warmerda
+ * primList leak fixed in vrf driver
+ *
+ * Revision 1.7 2001/08/16 20:40:34 warmerda
+ * applied VITD fixes - merge primitive lines into a feature
+ *
+ * Revision 1.6 2001/06/21 20:30:15 warmerda
+ * added ECS_CVSID
+ *
+ * Revision 1.5 2001/06/13 17:33:59 warmerda
+ * upgraded source headers
+ *
+ */
+
+#include "ecs.h"
+#include "vrf.h"
+
+ECS_CVSID("$Id: object.c,v 1.8 2004/10/19 14:17:03 warmerda Exp $");
+
+/*
+********************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+ _getTileAndPrimId
+
+DESCRIPTION
+ With a object id, this function return the feature id
+ of the object, and the tile id and primitive id related
+ to it.
+END_DESCRIPTION
+
+PARAMETERS
+
+ INPUT
+ ecs_Server *s: Server info given by OGDI API
+ ecs_Layer *l: The current layer
+ int32 object_id: The object id
+ OUTPUT
+ int32 *feature_id: The feature id
+ short *tile_id: The tile id of the primitive object
+ int32 *prim_id: The primitive id related to the feature
+
+END_PARAMETERS
+
+END_FUNCTION_INFORMATION
+
+PSEUDO-CODE
+
+Set tile_id, feature_id and prim_id to -1.
+
+If the layer is not tiled (the primitives are in tiles)
+Begin
+
+ Set tile_id to 1
+
+End
+
+If the primitive id at the position object_id is negative (not
+calculated yet)
+Begin
+ If a join table exist (the joinTableName is valid)
+ Begin
+
+ // 1:n relation, get the feature id in the join table
+
+ Get the row object id in the join table
+
+ If a join table feature id row don't exist in the join table
+ Begin
+ Set the feature table with object id (relation 1:1).
+ End
+ Else
+ Begin
+ Get the position of the feature attribute in the join
+ table (with the join table feature id name). Read the
+ content of the join table at this position and set
+ feature_id.
+ End
+
+ If the tile_id is -1
+ Begin
+
+ Get the position of the tile id attribute in the
+ join table. Read the content of the join table at
+ this position and set tile_id.
+
+ End
+
+ Get the position of the prim id attribute in the join
+ table (with featureTablePrimIdName). Read the content
+ of the join table at this position and set prim_id.
+
+ Free the row in the join table.
+
+ End
+ Else
+ Begin
+
+ // 1:1 relation without a join table.
+
+ Set the feature id with object id.
+
+ Get the row object id in the feature table.
+
+ If the tile_id is -1
+ Begin
+
+ Get the position of the tile id attribute in the feature
+ table. Read the content of the feature table at this
+ position and set tile_id.
+
+ End
+
+ Get the position of the prim id attribute in the feature table
+ (with featureTablePrimIdName). Read the content of the
+ feature table at this position and set prim_id.
+
+ Free the row in the feature table.
+
+ End
+
+ Set the index at the position object_id with the feature_id, the
+ tile_id and the prim_id.
+
+End
+
+********************************************************************
+*/
+
+void
+_getTileAndPrimId(s,l,object_id,feature_id,tile_id,prim_id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int32 object_id;
+ int32 *feature_id;
+ short *tile_id;
+ int32 *prim_id;
+{
+ int32 count;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ row_type row,join_row;
+ int pos;
+
+ (void) s;
+
+ *tile_id = -1;
+ *prim_id = -1;
+ *feature_id = -1;
+
+ if (!lpriv->isTiled) {
+ *tile_id = 1;
+ }
+
+ if (lpriv->index[object_id].prim_id == -1) {
+ if ((lpriv->joinTableName != NULL) &&
+ (*tile_id != -1 || (table_pos("TILE_ID",lpriv->joinTable) != -1)) &&
+ (table_pos(lpriv->featureTablePrimIdName,lpriv->joinTable) != -1)) {
+ join_row = get_row(object_id+1, lpriv->joinTable);
+
+ if (lpriv->joinTableFeatureIdName == NULL) {
+ *feature_id = object_id+1;
+ } else {
+ pos = table_pos(lpriv->joinTableFeatureIdName,lpriv->joinTable);
+ if (pos != -1) {
+ get_table_element(pos, join_row, lpriv->joinTable, feature_id, &count);
+ } else {
+ return;
+ }
+ }
+
+ if (*tile_id != 1) {
+ pos = table_pos("TILE_ID",lpriv->joinTable);
+ if (pos != -1) {
+ /* DAP TR326 */
+ if (lpriv->joinTable.nrows <= 0) {
+ *tile_id = -2;
+ *prim_id = -1;
+ return;
+ } else {
+ get_table_element(pos,join_row, lpriv->joinTable, tile_id, &count);
+ }
+ } else {
+ return;
+ }
+ }
+
+ pos = table_pos(lpriv->featureTablePrimIdName,lpriv->joinTable);
+ if (pos != -1) {
+ get_table_element(pos,join_row, lpriv->joinTable, prim_id, &count);
+ } else {
+ *feature_id = -1;
+ *tile_id = -1;
+ return;
+ }
+
+ free_row(join_row,lpriv->joinTable);
+ } else {
+ row = get_row(object_id+1, lpriv->featureTable);
+ *feature_id = object_id+1;
+ if (*tile_id != 1) {
+ pos = table_pos("TILE_ID",lpriv->featureTable);
+ if (pos != -1) {
+ get_table_element(pos, row, lpriv->featureTable, tile_id, &count);
+ } else {
+ return;
+ }
+ }
+ pos = table_pos(lpriv->featureTablePrimIdName,lpriv->featureTable);
+ if (pos != -1) {
+ get_table_element(pos, row, lpriv->featureTable, prim_id, &count);
+ } else {
+ return;
+ }
+ free_row(row, lpriv->featureTable);
+ }
+ lpriv->index[object_id].feature_id = *feature_id;
+ lpriv->index[object_id].tile_id = *tile_id;
+ lpriv->index[object_id].prim_id = *prim_id;
+ } else {
+ *feature_id = lpriv->index[object_id].feature_id;
+ *tile_id = lpriv->index[object_id].tile_id;
+ *prim_id = lpriv->index[object_id].prim_id;
+ }
+}
+
+/*
+ * --------------------------------------------------------------------------
+ * _getPrimList()
+ *
+ * Build list of primitives joined to the same feature.
+ * This function assumes that all the primitives for a given feature
+ * will occur together in the join table. While this appears to be
+ * true of test datasets, it might not be true in general. Eventually
+ * an efficient for relating a feature id with it's list of primitives
+ * should be build, and maintained over the access to this join table
+ * if this is to be safe.
+ *
+ * Note the object_id passed to this function is supposed to be the
+ * row number of the first primitive in the join table when using
+ * join tables and merging features.
+ * --------------------------------------------------------------------------
+ */
+
+void _getPrimList( ecs_Server *s,
+ ecs_Layer *l,
+ int32 object_id,
+ int32 *feature_id,
+ short *tile_id,
+ int32 *primCount,
+ int32 **primList,
+ int32 *next_index )
+
+{
+ LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int32 edg_id;
+ int maxCount = 0;
+
+ /*
+ Get the first primitive for this feature.
+ */
+
+ _getTileAndPrimId(s,l,object_id,feature_id,tile_id,&edg_id);
+ object_id++;
+
+ /*
+ If we aren't operating in merged format, just return this primiitive
+ */
+ maxCount = 1;
+ *primCount = 1;
+ *primList = (int32 *) malloc(sizeof(int32) * maxCount);
+ (*primList)[0] = edg_id;
+
+ if( !lpriv->mergeFeatures )
+ {
+ *next_index = object_id;
+ return;
+ }
+
+ /*
+ Collect all other primitives with the same line id. Note we are
+ incrementing the global index value.
+ */
+
+ while( object_id < lpriv->joinTable.nrows )
+ {
+ int32 this_feature_id;
+ short this_tile_id;
+
+ _getTileAndPrimId(s,l,object_id,
+ &this_feature_id,&this_tile_id,&edg_id);
+
+ if( this_feature_id != *feature_id )
+ break;
+
+ /*
+ This primitive matches our feature_id, add to the list.
+ */
+
+ if( *primCount == maxCount )
+ {
+ maxCount += 100;
+ *primList = (int32*) realloc(*primList, sizeof(int32) * maxCount);
+ }
+
+ (*primList)[*primCount] = edg_id;
+ (*primCount)++;
+
+ object_id++;
+ }
+
+ *next_index = object_id;
+}
+
+/*
+ * --------------------------------------------------------------------------
+ * _getPrimListByFeatureId()
+ *
+ * Build list of primitives joined to the same feature based on the
+ * feature id as a key. This can be kind of slow since the join
+ * table is scanned linearly.
+ * --------------------------------------------------------------------------
+ */
+
+static void
+_getPrimListByFeatureId( ecs_Server *s,
+ ecs_Layer *l,
+ int32 object_id, /* this should be feature id */
+ short *tile_id,
+ int32 *primCount,
+ int32 **primList,
+ int32 *next_index )
+
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int edgeCount, edgeId;
+
+ if( lpriv->mergeFeatures )
+ edgeCount = lpriv->joinTable.nrows;
+ else
+ edgeCount = l->nbfeature;
+
+ for( edgeId = 0; edgeId < edgeCount; edgeId++ )
+ {
+ int32 prim_id, this_feature_id;
+
+ _getTileAndPrimId( s, l, edgeId, &this_feature_id, tile_id, &prim_id );
+
+ if( object_id == this_feature_id )
+ {
+ _getPrimList( s, l, edgeId, &this_feature_id, tile_id,
+ primCount, primList, next_index );
+ return;
+ }
+ }
+
+ *primCount = 0;
+ *primList = NULL;
+}
+
+/*
+ * --------------------------------------------------------------------------
+ * _get*Object*Area:
+ *
+ * a set of functions to acheive Area objects retrieval
+ * --------------------------------------------------------------------------
+ */
+
+void
+_getNextObjectArea(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ char buffer[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ short tile_id;
+ int32 area_id;
+ int32 fac_id;
+ int found = 0;
+ char *temp;
+ double xmin, xmax, ymin, ymax;
+
+
+ while(!found && l->index < l->nbfeature) {
+ _getTileAndPrimId(s,l,l->index,&area_id,&tile_id, &fac_id);
+
+ /*
+ Check the case of the polygon with all the database polygon as
+ island. The case only appear with DCW
+ */
+
+ if ((l->index == 0) && (spriv->isDCW == TRUE)) {
+ l->index++;
+ continue;
+ }
+
+ if (set_member(area_id,lpriv->feature_rows)) {
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ if (lpriv->isTiled == 0 || spriv->tile[tile_id-1].isSelected) {
+ _selectTileArea(s,l,tile_id);
+ if (!vrf_get_area_mbr(l,fac_id,&xmin,&ymin,&xmax,&ymax)) {
+ ecs_SetError(&(s->result), 1, "VRF table mbr not open");
+ return;
+ }
+ if (!vrf_IsOutsideRegion(ymax,ymin,xmax,xmin,
+ &(s->currentRegion))) {
+ found = 1;
+ break;
+ }
+ }
+ }
+ l->index++;
+ }
+
+ /* if a feature is found, get the feature info */
+
+ if (found) {
+ if (!vrf_get_area_feature(s,l,fac_id))
+ return;
+ l->index++;
+ } else {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /* Add the identifier to the object */
+
+ sprintf(buffer,"%d",(int) area_id);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ /* Add the attributes to the object */
+
+ temp =vrf_get_ObjAttributes(lpriv->featureTable, area_id);
+ if (temp != NULL)
+ ecs_SetObjectAttr(&(s->result),temp);
+ else
+ ecs_SetObjectAttr(&(s->result),"");
+
+ /* Add the bounding box to the object */
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),xmin,ymin,xmax,ymax);
+
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_getObjectArea(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int object_id;
+ int32 area_id;
+ short tile_id;
+ int32 fac_id;
+ double xmin, xmax, ymin, ymax;
+ char *temp;
+
+ object_id = atoi(id);
+
+ if (object_id > l->nbfeature || object_id < 0) {
+ ecs_SetError(&(s->result),1,"Invalid area id");
+ return;
+ }
+
+ _getTileAndPrimId(s,l,object_id,&area_id,&tile_id, &fac_id);
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ _selectTileArea(s,l,tile_id);
+
+ if (!vrf_get_area_feature(s,l,fac_id))
+ return;
+
+ /* Add the identifier to the object */
+
+ ecs_SetObjectId(&(s->result),id);
+
+ if (vrf_get_area_mbr(l,fac_id,&xmin,&ymin,&xmax,&ymax)) {
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),xmin,ymin,xmax,ymax);
+ } else {
+ ecs_SetError(&(s->result), 1, "VRF table mbr not open");
+ return;
+ }
+
+ /* Add the attributes to the object */
+
+ temp =vrf_get_ObjAttributes(lpriv->featureTable, area_id);
+ if (temp != NULL)
+ ecs_SetObjectAttr(&(s->result),temp);
+ else
+ ecs_SetObjectAttr(&(s->result),"");
+
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_getObjectIdArea(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ char buffer[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ short tile_id;
+ int32 fac_id;
+ int feature_id;
+ int32 area_id;
+ double xmin, xmax, ymin, ymax;
+ int32 index;
+ double distance,result;
+
+ distance = HUGE_VAL;
+ feature_id = -1;
+
+ for(index = 0; index < l->nbfeature; index++) {
+ _getTileAndPrimId(s,l,index,&area_id,&tile_id, &fac_id);
+ if (set_member(area_id,lpriv->feature_rows)) {
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ if (!(lpriv->isTiled) ||
+ ((coord->x > spriv->tile[tile_id-1].xmin) &&
+ (coord->x < spriv->tile[tile_id-1].xmax) &&
+ (coord->y > spriv->tile[tile_id-1].ymin) &&
+ (coord->y < spriv->tile[tile_id-1].ymax))) {
+
+ _selectTileArea(s,l,tile_id);
+ if (!vrf_get_area_mbr(l,fac_id,&xmin,&ymin,&xmax,&ymax)) {
+ ecs_SetError(&(s->result), 1, "VRF table mbr not open");
+ return;
+ }
+ if ((coord->x>xmin) && (coord->x<xmax) &&
+ (coord->y>ymin) && (coord->y<ymax)) {
+ if (!vrf_get_area_feature(s,l,fac_id))
+ return;
+
+ result = ecs_DistanceObjectWithTolerance((&(ECSOBJECT((&(s->result))))),
+ coord->x, coord->y);
+ if (result < distance) {
+ distance = result;
+ feature_id = index;
+ }
+ }
+ }
+ }
+ }
+
+ if (feature_id < 0) {
+ ecs_SetError(&(s->result),1,"Can't find any area at this location");
+ return;
+ }
+
+ sprintf(buffer,"%d",feature_id);
+ ecs_SetText(&(s->result),buffer);
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_selectTileArea(s,l,tile_id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int tile_id;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ char buffer[256];
+
+ if (lpriv->isTiled) {
+ if (lpriv->current_tileid != tile_id) {
+ if (lpriv->current_tileid != -1) {
+ /* fermeture des tables ouvertes precedemment */
+
+#ifdef TESTOPENTABLE
+ printf("close lpriv->l.area.faceTable\n");
+ printf("close lpriv->l.area.edgeTable\n");
+ printf("close lpriv->l.area.ringTable\n");
+ printf("close lpriv->l.area.mbrTable\n");
+#endif
+
+ vpf_close_table(&(lpriv->l.area.faceTable));
+ vpf_close_table(&(lpriv->l.area.ringTable));
+ vpf_close_table(&(lpriv->l.area.edgeTable));
+ vpf_close_table(&(lpriv->l.area.mbrTable));
+ }
+ /* ouverture des tables de primitives dans la bonne tuile */
+
+#ifdef TESTOPENTABLE
+ printf("open lpriv->l.area.faceTable\n");
+ printf("open lpriv->l.area.edgeTable\n");
+ printf("open lpriv->l.area.ringTable\n");
+ printf("open lpriv->l.area.mbrTable\n");
+#endif
+
+ if (tile_id != 0) {
+ sprintf(buffer,"%s/%s/%s/fac",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/%s/FAC",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ }
+ lpriv->l.area.faceTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/%s/edg",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/%s/EDG",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ }
+ lpriv->l.area.edgeTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/%s/rng",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/%s/RNG",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ }
+ lpriv->l.area.ringTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/%s/fbr",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/%s/FBR",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ }
+ lpriv->l.area.mbrTable = vpf_open_table(buffer, disk, "rb", NULL);
+ } else {
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,lpriv->primitiveTableName);
+ lpriv->l.area.faceTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/edg",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/EDG",spriv->library,lpriv->coverage);
+ }
+ lpriv->l.area.edgeTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/rng",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/RNG",spriv->library,lpriv->coverage);
+ }
+ lpriv->l.area.ringTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/fbr",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/FBR",spriv->library,lpriv->coverage);
+ }
+ lpriv->l.area.mbrTable = vpf_open_table(buffer, disk, "rb", NULL);
+ }
+
+ lpriv->current_tileid = tile_id;
+ }
+ } else {
+ if (lpriv->current_tileid == -1) {
+
+ /* ouverture des tables de primitives non-tuilees */
+
+#ifdef TESTOPENTABLE
+ printf("open lpriv->l.area.faceTable\n");
+ printf("open lpriv->l.area.edgeTable\n");
+ printf("open lpriv->l.area.ringTable\n");
+ printf("open lpriv->l.area.mbrTable\n");
+#endif
+
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,lpriv->primitiveTableName);
+ lpriv->l.area.faceTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/edg",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/EDG",spriv->library,lpriv->coverage);
+ }
+ lpriv->l.area.edgeTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/rng",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/RNG",spriv->library,lpriv->coverage);
+ }
+ lpriv->l.area.ringTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/fbr",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/FBR",spriv->library,lpriv->coverage);
+ }
+ lpriv->l.area.mbrTable = vpf_open_table(buffer, disk, "rb", NULL);
+
+ lpriv->current_tileid = 1;
+ }
+ }
+
+}
+
+/*
+ * --------------------------------------------------------------------------
+ * _get*Object*Line:
+ *
+ * a set of functions to acheive Line objects retrieval
+ * --------------------------------------------------------------------------
+ */
+
+void
+_getNextObjectLine(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ char buffer[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ short tile_id;
+ int32 line_id;
+ int found = 0;
+ char *temp;
+ double xmin, xmax, ymin, ymax;
+ int edgeCount;
+ int32 *primList = NULL, primCount = 0;
+
+ if( lpriv->mergeFeatures )
+ edgeCount = lpriv->joinTable.nrows;
+ else
+ edgeCount = l->nbfeature;
+
+ while(!found && l->index < edgeCount) {
+
+ if( primList != NULL )
+ {
+ free( primList );
+ primList = NULL;
+ }
+
+ _getPrimList( s, l, l->index, &line_id, &tile_id, &primCount, &primList,
+ (int32 *) &(l->index));
+
+ if (set_member(line_id,lpriv->feature_rows)) {
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ if (lpriv->isTiled == 0 || spriv->tile[tile_id-1].isSelected) {
+
+ _selectTileLine(s,l,tile_id);
+ if (!vrf_get_lines_mbr(l,primCount,primList,&xmin,&ymin,&xmax,&ymax)) {
+ ecs_SetError(&(s->result),1,"Unable to open mbr");
+ return;
+ }
+ if (!vrf_IsOutsideRegion(ymax,ymin,xmax,xmin,
+ &(s->currentRegion))) {
+ found = 1;
+ break;
+ }
+ }
+ }
+ }
+
+ /* if a feature is found, get the feature info */
+
+ if (found) {
+ if( !vrf_get_merged_line_feature(s,l,primCount,primList) )
+ {
+ free( primList );
+ return;
+ }
+
+ } else {
+ free( primList );
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ free( primList );
+
+ /* Add the identifier to the object */
+
+ sprintf(buffer,"%d", (int) line_id);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ /* Add the bounding box to the object */
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),xmin,ymin,xmax,ymax);
+
+ /* Add the attributes to the object */
+
+ temp =vrf_get_ObjAttributes(lpriv->featureTable, line_id);
+ if (temp != NULL)
+ ecs_SetObjectAttr(&(s->result),temp);
+ else
+ ecs_SetObjectAttr(&(s->result),"");
+
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_getObjectLine(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int object_id;
+ short tile_id;
+ double xmin, xmax, ymin, ymax;
+ char *temp;
+ int32 primCount, *primList, next_object;
+
+ object_id = atoi(id);
+
+ _getPrimListByFeatureId( s, l, object_id, &tile_id,
+ &primCount, &primList, &next_object );
+ if (primCount == 0) {
+ ecs_SetError(&(s->result), 1,
+ "No primitives identified for this feature.");
+ return;
+ }
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ _selectTileLine(s,l,tile_id);
+
+ if (!vrf_get_merged_line_feature(s,l,primCount,primList))
+ return;
+
+ /* Add the identifier to the object */
+
+ ecs_SetObjectId(&(s->result),id);
+
+ if (vrf_get_lines_mbr(l,primCount,primList,&xmin,&ymin,&xmax,&ymax)) {
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),xmin,ymin,xmax,ymax);
+ } else {
+ free( primList );
+ ecs_SetError(&(s->result), 1, "VRF table mbr not open");
+ return;
+ }
+
+ free( primList );
+
+ /* Add the attributes to the object */
+
+ temp =vrf_get_ObjAttributes(lpriv->featureTable, object_id);
+ if (temp != NULL)
+ ecs_SetObjectAttr(&(s->result),temp);
+ else
+ ecs_SetObjectAttr(&(s->result),"");
+
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_getObjectIdLine(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ char buffer[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ short tile_id;
+ int feature_id;
+ int32 line_id, primCount, *primList;
+ double xmin, xmax, ymin, ymax;
+ int32 index, edgeCount;
+ double distance,result;
+
+ distance = HUGE_VAL;
+ feature_id = -1;
+
+ if( lpriv->mergeFeatures )
+ edgeCount = lpriv->joinTable.nrows;
+ else
+ edgeCount = l->nbfeature;
+
+ index = 0;
+ while( index < edgeCount ) {
+ _getPrimList( s, l, index, &line_id, &tile_id, &primCount, &primList,
+ &index);
+ if (set_member(line_id,lpriv->feature_rows)) {
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ if (!(lpriv->isTiled) ||
+ ((coord->x > spriv->tile[tile_id-1].xmin) &&
+ (coord->x < spriv->tile[tile_id-1].xmax) &&
+ (coord->y > spriv->tile[tile_id-1].ymin) &&
+ (coord->y < spriv->tile[tile_id-1].ymax))) {
+
+ _selectTileLine(s,l,tile_id);
+ if (!vrf_get_lines_mbr(l,primCount,primList,&xmin,&ymin,&xmax,&ymax)) {
+ ecs_SetError(&(s->result), 1, "VRF table mbr not open");
+ return;
+ }
+ if ((coord->x>xmin) && (coord->x<xmax) &&
+ (coord->y>ymin) && (coord->y<ymax)) {
+ if (!vrf_get_merged_line_feature(s,l,primCount,primList))
+ return;
+
+ result = ecs_DistanceObjectWithTolerance((&(ECSOBJECT((&(s->result))))),
+ coord->x, coord->y);
+ if (result < distance) {
+ distance = result;
+ feature_id = line_id;
+ }
+ }
+ }
+ }
+ }
+
+ if (feature_id < 0) {
+ ecs_SetError(&(s->result),1,"Can't find any line at this location");
+ return;
+ }
+
+ sprintf(buffer,"%d",feature_id);
+ ecs_SetText(&(s->result),buffer);
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_selectTileLine(s,l,tile_id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int tile_id;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ char buffer[256];
+
+ if (lpriv->isTiled) {
+ if (lpriv->current_tileid != tile_id) {
+ if (lpriv->current_tileid != -1) {
+ /* fermeture des tables ouvertes precedemment */
+
+#ifdef TESTOPENTABLE
+ printf("close lpriv->l.line.mbrTable\n");
+ printf("close lpriv->l.line.edgeTable\n");
+#endif
+
+ vpf_close_table(&(lpriv->l.line.edgeTable));
+ vpf_close_table(&(lpriv->l.line.mbrTable));
+ }
+
+ /*
+ ouverture des tables de primitives dans la bonne tuile
+ */
+
+#ifdef TESTOPENTABLE
+ printf("open lpriv->l.line.edgeTable\n");
+ printf("open lpriv->l.line.mbrTable\n");
+#endif
+
+ if (tile_id != 0) {
+ sprintf(buffer,"%s/%s/%s/%s",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path,lpriv->primitiveTableName);
+ lpriv->l.line.edgeTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/%s/ebr",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/%s/EBR",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path);
+ }
+ lpriv->l.line.mbrTable = vpf_open_table(buffer, disk, "rb", NULL);
+ } else {
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,lpriv->primitiveTableName);
+ lpriv->l.line.edgeTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/ebr",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/EBR",spriv->library,lpriv->coverage);
+ }
+ lpriv->l.line.mbrTable = vpf_open_table(buffer, disk, "rb", NULL);
+ }
+
+ lpriv->current_tileid = tile_id;
+ }
+ } else {
+ if (lpriv->current_tileid == -1) {
+
+ /*
+ ouverture des tables de primitives non-tuilees
+ */
+
+#ifdef TESTOPENTABLE
+ printf("open lpriv->l.line.edgeTable\n");
+ printf("open lpriv->l.line.mbrTable\n");
+#endif
+
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,lpriv->primitiveTableName);
+ lpriv->l.line.edgeTable = vpf_open_table(buffer, disk, "rb", NULL);
+ sprintf(buffer,"%s/%s/ebr",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/EBR",spriv->library,lpriv->coverage);
+ }
+ lpriv->l.line.mbrTable = vpf_open_table(buffer, disk, "rb", NULL);
+
+ lpriv->current_tileid = 1;
+ }
+ }
+}
+
+/*
+ * --------------------------------------------------------------------------
+ * _get*Object*Point:
+ *
+ * a set of functions to acheive Point objects retrieval
+ * --------------------------------------------------------------------------
+ */
+
+void
+_getNextObjectPoint(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ char buffer[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ short tile_id;
+ int32 point_id;
+ int32 fpoint_id;
+ int found = 0;
+ char *temp;
+
+ while(!found && l->index < l->nbfeature) {
+ _getTileAndPrimId(s,l,l->index,&fpoint_id,&tile_id, &point_id);
+ if (set_member(fpoint_id,lpriv->feature_rows)) {
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ if (lpriv->isTiled == 0 || spriv->tile[tile_id-1].isSelected) {
+
+ _selectTilePoint(s,l,tile_id);
+ if (!vrf_get_point_feature(s,l,point_id))
+ return;
+ if ((ECSGEOM((&(s->result))).point.c.x>s->currentRegion.west) &&
+ (ECSGEOM((&(s->result))).point.c.x<s->currentRegion.east) &&
+ (ECSGEOM((&(s->result))).point.c.y>s->currentRegion.south) &&
+ (ECSGEOM((&(s->result))).point.c.y<s->currentRegion.north)) {
+ found = 1;
+ break;
+ }
+ }
+ }
+ l->index++;
+ }
+
+ /* if a feature is found, get the feature info */
+
+ if (found) {
+ l->index++;
+ } else {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /* Add the identifier to the object */
+
+ sprintf(buffer,"%d",(int) point_id+1);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ /* Add the bounding box to the object */
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ ECSGEOM((&(s->result))).point.c.x,
+ ECSGEOM((&(s->result))).point.c.y,
+ ECSGEOM((&(s->result))).point.c.x,
+ ECSGEOM((&(s->result))).point.c.y);
+
+ /* Add the attributes to the object */
+
+ temp =vrf_get_ObjAttributes(lpriv->featureTable, fpoint_id);
+ if (temp != NULL)
+ ecs_SetObjectAttr(&(s->result),temp);
+ else
+ ecs_SetObjectAttr(&(s->result),"");
+
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_getObjectPoint(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int object_id;
+ int32 point_id;
+ short tile_id;
+ int32 prim_id;
+ char *temp;
+
+ object_id = atoi(id);
+
+ if (object_id > l->nbfeature || object_id < 0) {
+ ecs_SetError(&(s->result),1,"Invalid point id");
+ return;
+ }
+
+ _getTileAndPrimId(s,l,object_id,&point_id,&tile_id, &prim_id);
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+
+ _selectTilePoint(s,l,tile_id);
+
+ if (!vrf_get_point_feature(s,l,prim_id))
+ return;
+
+ /* Add the identifier to the object */
+
+ ecs_SetObjectId(&(s->result),id);
+
+ /* Add the attributes to the object */
+
+ temp =vrf_get_ObjAttributes(lpriv->featureTable, point_id);
+ if (temp != NULL)
+ ecs_SetObjectAttr(&(s->result),temp);
+ else
+ ecs_SetObjectAttr(&(s->result),"");
+
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_getObjectIdPoint(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ char buffer[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ short tile_id;
+ int32 prim_id;
+ int32 point_id;
+ int feature_id;
+ int32 index;
+ double distance,result;
+
+ distance = HUGE_VAL;
+ feature_id = -1;
+
+ for(index = 0; index < l->nbfeature; index++) {
+ _getTileAndPrimId(s,l,index,&point_id,&tile_id, &prim_id);
+ if (set_member(point_id,lpriv->feature_rows)) {
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ if (!(lpriv->isTiled) ||
+ ((coord->x > spriv->tile[tile_id-1].xmin) &&
+ (coord->x < spriv->tile[tile_id-1].xmax) &&
+ (coord->y > spriv->tile[tile_id-1].ymin) &&
+ (coord->y < spriv->tile[tile_id-1].ymax))) {
+
+ _selectTilePoint(s,l,tile_id);
+ if (!vrf_get_point_feature(s,l,prim_id))
+ return;
+
+ result = ecs_DistanceObjectWithTolerance((&(ECSOBJECT((&(s->result))))),
+ coord->x, coord->y);
+ if (result < distance) {
+ distance = result;
+ feature_id = index;
+ }
+ }
+ }
+ }
+
+ if (feature_id < 0) {
+ ecs_SetError(&(s->result),1,"Can't find any point at this location");
+ return;
+ }
+
+ sprintf(buffer,"%d",feature_id);
+ ecs_SetText(&(s->result),buffer);
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_selectTilePoint(s,l,tile_id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int tile_id;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ char buffer[256];
+
+ if (lpriv->isTiled) {
+ if (lpriv->current_tileid != tile_id) {
+ if (lpriv->current_tileid != -1) {
+#ifdef TESTOPENTABLE
+ printf("close lpriv->l.point.primTable\n");
+#endif
+
+ /* fermeture des tables ouvertes precedemment */
+ vpf_close_table(&(lpriv->l.point.primTable));
+ }
+ /* ouverture des tables de primitives dans la bonne tuile */
+#ifdef TESTOPENTABLE
+ printf("open lpriv->l.point.primTable\n");
+#endif
+
+ if (tile_id != 0) {
+ sprintf(buffer,"%s/%s/%s/%s",spriv->library,lpriv->coverage,
+ spriv->tile[tile_id-1].path,lpriv->primitiveTableName);
+ lpriv->l.point.primTable = vpf_open_table(buffer, disk, "rb", NULL);
+ } else {
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,
+ lpriv->primitiveTableName);
+ lpriv->l.point.primTable = vpf_open_table(buffer, disk, "rb", NULL);
+ }
+
+ lpriv->current_tileid = tile_id;
+ }
+ } else {
+ if (lpriv->current_tileid == -1) {
+
+ /* ouverture des tables de primitives non-tuilees */
+#ifdef TESTOPENTABLE
+ printf("open lpriv->l.point.primTable\n");
+#endif
+
+ sprintf(buffer,"%s/%s/%s",spriv->library,
+ lpriv->coverage,lpriv->primitiveTableName);
+ lpriv->l.point.primTable = vpf_open_table(buffer, disk, "rb", NULL);
+
+ lpriv->current_tileid = 1;
+ }
+ }
+}
+
+/*************************************/
+
+/*
+ * --------------------------------------------------------------------------
+ * _get*Object*Text:
+ *
+ * a set of functions to acheive Text objects retrieval
+ * --------------------------------------------------------------------------
+ */
+
+void
+_getNextObjectText(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ char buffer[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ short tile_id;
+ int32 text_id;
+ int32 prim_id;
+ int found = 0;
+ char *temp;
+
+ while(!found && l->index < l->nbfeature) {
+ _getTileAndPrimId(s,l,l->index,&text_id,&tile_id, &prim_id);
+ if (set_member(text_id,lpriv->feature_rows)) {
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ if (lpriv->isTiled == 0 || spriv->tile[tile_id-1].isSelected) {
+
+ _selectTileText(s,l,tile_id);
+ if (!vrf_get_text_feature(s,l,prim_id))
+ return;
+ if ((ECSGEOM((&(s->result))).text.c.x>s->currentRegion.west) &&
+ (ECSGEOM((&(s->result))).text.c.x<s->currentRegion.east) &&
+ (ECSGEOM((&(s->result))).text.c.y>s->currentRegion.south) &&
+ (ECSGEOM((&(s->result))).text.c.y<s->currentRegion.north)) {
+ found = 1;
+ break;
+ }
+ }
+ }
+ l->index++;
+ }
+
+ /* if a feature is found, get the feature info */
+
+ if (found) {
+ l->index++;
+ } else {
+ ecs_SetError(&(s->result),2,"End of selection");
+ return;
+ }
+
+ /* Add the identifier to the object */
+
+ sprintf(buffer,"%d", (int) text_id);
+ ecs_SetObjectId(&(s->result),buffer);
+
+ /* Add the bounding box to the object */
+
+ ECS_SETGEOMBOUNDINGBOX((&(s->result)),
+ ECSGEOM((&(s->result))).text.c.x,
+ ECSGEOM((&(s->result))).text.c.y,
+ ECSGEOM((&(s->result))).text.c.x,
+ ECSGEOM((&(s->result))).text.c.y);
+
+ /* Add the attributes to the object */
+
+ temp =vrf_get_ObjAttributes(lpriv->featureTable, text_id);
+ if (temp != NULL)
+ ecs_SetObjectAttr(&(s->result),temp);
+ else
+ ecs_SetObjectAttr(&(s->result),"");
+
+ ecs_SetSuccess(&(s->result));
+
+}
+
+/*************************************/
+
+void
+_getObjectText(s,l,id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ char *id;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ int object_id;
+ short tile_id;
+ int32 prim_id;
+ int32 text_id;
+ char *temp;
+
+ object_id = atoi(id);
+
+ if (object_id > l->nbfeature || object_id < 0) {
+ ecs_SetError(&(s->result),1,"Invalid text id");
+ return;
+ }
+
+ _getTileAndPrimId(s,l,object_id,&text_id,&tile_id, &prim_id);
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ _selectTileText(s,l,tile_id);
+
+ if (!vrf_get_text_feature(s,l,prim_id))
+ return;
+
+ /* Add the identifier to the object */
+
+ ecs_SetObjectId(&(s->result),id);
+
+ /* Add the attributes to the object */
+
+ temp =vrf_get_ObjAttributes(lpriv->featureTable, text_id);
+ if (temp != NULL)
+ ecs_SetObjectAttr(&(s->result),temp);
+ else
+ ecs_SetObjectAttr(&(s->result),"");
+
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_getObjectIdText(s,l,coord)
+ ecs_Server *s;
+ ecs_Layer *l;
+ ecs_Coordinate *coord;
+{
+ char buffer[256];
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ short tile_id;
+ int32 prim_id;
+ int32 text_id;
+ int feature_id;
+ int32 index;
+ double distance,result;
+
+ distance = HUGE_VAL;
+ feature_id = -1;
+
+ for(index = 0; index < l->nbfeature; index++) {
+ _getTileAndPrimId(s,l,index,&text_id,&tile_id, &prim_id);
+ if (set_member(text_id,lpriv->feature_rows)) {
+ if (tile_id == -1) {
+ ecs_SetError(&(s->result), 1, "The VRF tiles are badly defined");
+ return;
+ }
+ if (tile_id == -2) {
+ ecs_SetError(&(s->result), 1, "The join table is empty");
+ return;
+ }
+
+ if (!(lpriv->isTiled) ||
+ ((coord->x > spriv->tile[tile_id-1].xmin) &&
+ (coord->x < spriv->tile[tile_id-1].xmax) &&
+ (coord->y > spriv->tile[tile_id-1].ymin) &&
+ (coord->y < spriv->tile[tile_id-1].ymax))) {
+
+ _selectTileText(s,l,tile_id);
+ if (!vrf_get_text_feature(s,l,prim_id))
+ return;
+
+ result = ecs_DistanceObjectWithTolerance((&(ECSOBJECT((&(s->result))))),
+ coord->x, coord->y);
+ if (result < distance) {
+ distance = result;
+ feature_id = index;
+ }
+ }
+ }
+ }
+
+ if (feature_id < 0) {
+ ecs_SetError(&(s->result),1,"Can't find any text at this location");
+ return;
+ }
+
+ sprintf(buffer,"%d",feature_id);
+ ecs_SetText(&(s->result),buffer);
+ ecs_SetSuccess(&(s->result));
+}
+
+/*************************************/
+
+void
+_selectTileText(s,l,tile_id)
+ ecs_Server *s;
+ ecs_Layer *l;
+ int tile_id;
+{
+ register LayerPrivateData *lpriv = (LayerPrivateData *) l->priv;
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ char buffer[256];
+
+ if (lpriv->isTiled) {
+ if (lpriv->current_tileid != tile_id) {
+ if (lpriv->current_tileid != -1) {
+ /* fermeture des tables ouvertes precedemment */
+#ifdef TESTOPENTABLE
+ printf("close lpriv->l.text.textTable\n");
+#endif
+ vpf_close_table(&(lpriv->l.text.textTable));
+ }
+ /* ouverture des tables de primitives dans la bonne tuile */
+
+ if (tile_id != 0) {
+ sprintf(buffer,"%s/%s/%s/%s",spriv->library,lpriv->coverage,spriv->tile[tile_id-1].path,lpriv->primitiveTableName);
+ } else {
+ sprintf(buffer,"%s/%s/txt",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0 ) {
+ sprintf(buffer,"%s/%s/TXT",spriv->library,lpriv->coverage);
+ }
+ }
+#ifdef TESTOPENTABLE
+ printf("open lpriv->l.text.textTable\n");
+#endif
+ lpriv->l.text.textTable = vpf_open_table(buffer, disk, "rb", NULL);
+
+ lpriv->current_tileid = tile_id;
+ }
+ } else {
+ if (lpriv->current_tileid == -1) {
+
+#ifdef TESTOPENTABLE
+ printf("open lpriv->l.text.textTable\n");
+#endif
+ /* ouverture des tables de primitives non-tuilees */
+
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,lpriv->primitiveTableName);
+ lpriv->l.text.textTable = vpf_open_table(buffer, disk, "rb", NULL);
+
+ lpriv->current_tileid = 1;
+ }
+ }
+}
+
+
+void _closeLayerTable(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ register LayerPrivateData *lpriv;
+
+ (void) s;
+
+ lpriv = (LayerPrivateData *) l->priv;
+
+ if (lpriv->current_tileid == -1) {
+ return;
+ }
+
+ switch(l->sel.F) {
+ case Area:
+#ifdef TESTOPENTABLE
+ printf("close: lpriv->l.area.faceTable\n");
+ printf("close: lpriv->l.area.mbrTable\n");
+ printf("close: lpriv->l.area.ringTable\n");
+ printf("close: lpriv->l.area.edgeTable\n");
+#endif
+ if (&(lpriv->l.area.faceTable) != NULL)
+ vpf_close_table(&(lpriv->l.area.faceTable));
+ if (&(lpriv->l.area.mbrTable) != NULL)
+ vpf_close_table(&(lpriv->l.area.mbrTable));
+ if (&(lpriv->l.area.ringTable) != NULL)
+ vpf_close_table(&(lpriv->l.area.ringTable));
+ if (&(lpriv->l.area.edgeTable) != NULL)
+ vpf_close_table(&(lpriv->l.area.edgeTable));
+
+ break;
+ case Line:
+#ifdef TESTOPENTABLE
+ printf("close: lpriv->l.line.edgeTable\n");
+ printf("close: lpriv->l.line.mbrTable\n");
+#endif
+ if (&(lpriv->l.line.edgeTable) != NULL)
+ vpf_close_table(&(lpriv->l.line.edgeTable));
+ if (&(lpriv->l.line.mbrTable) != NULL)
+ vpf_close_table(&(lpriv->l.line.mbrTable));
+ break;
+ case Point:
+#ifdef TESTOPENTABLE
+ printf("close: lpriv->l.point.primTable\n");
+#endif
+ if (&(lpriv->l.point.primTable) != NULL)
+ vpf_close_table(&(lpriv->l.point.primTable));
+ break;
+ case Text:
+#ifdef TESTOPENTABLE
+ printf("close: lpriv->l.text.textTable\n");
+#endif
+ if (&(lpriv->l.text.textTable) != NULL)
+ vpf_close_table(&(lpriv->l.text.textTable));
+ break;
+ default:
+ return;
+ }
+
+ lpriv->current_tileid = -1;
+
+ return;
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/open.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/open.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/open.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,182 @@
+/******************************************************************************
+ *
+ * Component: OGDI VRF Driver
+ * Purpose: Implementation of vrf Server open, close and rewind functions
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: open.c,v $
+ * Revision 1.6 2001/06/21 20:30:15 warmerda
+ * added ECS_CVSID
+ *
+ * Revision 1.5 2001/06/13 17:33:59 warmerda
+ * upgraded source headers
+ *
+ */
+
+#include "ecs.h"
+#include "vrf.h"
+
+ECS_CVSID("$Id: open.c,v 1.6 2001/06/21 20:30:15 warmerda Exp $");
+
+/*
+ * --------------------------------------------------------------------------
+ * _openAreaLayer:
+ *
+ * open an initialize a new vrf area vector layer
+ * --------------------------------------------------------------------------
+ */
+
+void
+_openAreaLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+void
+_closeAreaLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+void
+_rewindAreaLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+/*
+ * --------------------------------------------------------------------------
+ * _openLineLayer:
+ *
+ * open an initialize a new vrf line vector layer
+ * --------------------------------------------------------------------------
+ */
+
+void
+_openLineLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+void
+_closeLineLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+void
+_rewindLineLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+
+/*
+ * --------------------------------------------------------------------------
+ * _openPointLayer:
+ *
+ * open an initialize a new vrf sites layer
+ * --------------------------------------------------------------------------
+ */
+
+void
+_openPointLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+
+void
+_closePointLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+void
+_rewindPointLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+
+/*
+ * --------------------------------------------------------------------------
+ * _openTextLayer:
+ *
+ * open an initialize a new vrf paint/label layer
+ * --------------------------------------------------------------------------
+ */
+
+void
+_openTextLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+
+void
+_closeTextLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+
+void
+_rewindTextLayer(s,l)
+ ecs_Server *s;
+ ecs_Layer *l;
+{
+ (void) s;
+ (void) l;
+}
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/swq.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/swq.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/swq.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,632 @@
+/******************************************************************************
+ *
+ * Component: OGDI Driver Support Library
+ * Purpose: Generic SQL WHERE Expression Implementation.
+ * Author: Frank Warmerdam <warmerdam at pobox.com>
+ *
+ ******************************************************************************
+ * Copyright (C) 2001 Information Interoperability Institute (3i)
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of 3i not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. 3i makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: swq.c,v $
+ * Revision 1.3 2001/06/26 00:57:34 warmerda
+ * fixed strcasecmp on WIN32
+ *
+ * Revision 1.2 2001/06/21 20:30:15 warmerda
+ * added ECS_CVSID
+ *
+ * Revision 1.1 2001/06/20 21:49:16 warmerda
+ * New
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "swq.h"
+#include "ecs.h"
+
+ECS_CVSID("$Id: swq.c,v 1.3 2001/06/26 00:57:34 warmerda Exp $");
+
+#ifndef SWQ_MALLOC
+#define SWQ_MALLOC(x) malloc(x)
+#define SWQ_FREE(x) free(x)
+#endif
+
+#ifndef TRUE
+# define TRUE 1
+#endif
+
+#ifndef FALSE
+# define FALSE 0
+#endif
+
+#ifdef WIN32
+# define strcasecmp stricmp
+#endif
+
+char swq_error[1024];
+
+/************************************************************************/
+/* swq_isalphanum() */
+/* */
+/* Is the passed character in the set of things that could */
+/* occur in an alphanumeric token, or a number? */
+/************************************************************************/
+
+static int swq_isalphanum( char c )
+
+{
+
+ if( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
+ || (c >= '0' && c <= '9') || c == '.' || c == '+' || c == '-'
+ || c == '_' )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+/************************************************************************/
+/* swq_token() */
+/************************************************************************/
+
+static char *swq_token( const char *expression, char **next )
+
+{
+ char *token;
+ int i_token;
+
+ while( *expression == ' ' || *expression == '\t' )
+ expression++;
+
+ if( *expression == '\0' )
+ {
+ *next = (char *) expression;
+ return NULL;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Handle string constants. */
+/* -------------------------------------------------------------------- */
+ if( *expression == '"' )
+ {
+ expression++;
+
+ token = (char *) SWQ_MALLOC(strlen(expression)+1);
+ i_token = 0;
+
+ while( *expression != '\0' )
+ {
+ if( *expression == '\\' && expression[1] == '"' )
+ expression++;
+ else if( *expression == '"' )
+ {
+ expression++;
+ break;
+ }
+
+ token[i_token++] = *(expression++);
+ }
+ token[i_token] = '\0';
+ }
+
+/* -------------------------------------------------------------------- */
+/* Handle alpha-numerics. */
+/* -------------------------------------------------------------------- */
+ else if( swq_isalphanum( *expression ) )
+ {
+ token = (char *) SWQ_MALLOC(strlen(expression)+1);
+ i_token = 0;
+
+ while( swq_isalphanum( *expression ) )
+ {
+ token[i_token++] = *(expression++);
+ }
+
+ token[i_token] = '\0';
+ }
+
+/* -------------------------------------------------------------------- */
+/* Handle special tokens. */
+/* -------------------------------------------------------------------- */
+ else
+ {
+ token = (char *) SWQ_MALLOC(3);
+ token[0] = *expression;
+ token[1] = '\0';
+ expression++;
+
+ /* special logic to group stuff like '>=' into one token. */
+
+ if( (*token == '<' || *token == '>' || *token == '=' || *token == '!')
+ && (*expression == '<' || *expression == '>' || *expression == '='))
+ {
+ token[1] = *expression;
+ token[2] = '\0';
+ expression++;
+ }
+ }
+
+ *next = (char *) expression;
+
+ return token;
+}
+
+/************************************************************************/
+/* swq_identify_field() */
+/************************************************************************/
+
+static swq_op swq_identify_op( const char *token )
+
+{
+ if( strcasecmp(token,"OR") == 0 )
+ return SWQ_OR;
+
+ if( strcasecmp(token,"AND") == 0 )
+ return SWQ_AND;
+
+ if( strcasecmp(token,"NOT") == 0 )
+ return SWQ_NOT;
+
+ if( strcasecmp(token,"<=") == 0 )
+ return SWQ_LE;
+
+ if( strcasecmp(token,">=") == 0 )
+ return SWQ_GE;
+
+ if( strcasecmp(token,"=") == 0 )
+ return SWQ_EQ;
+
+ if( strcasecmp(token,"!=") == 0 )
+ return SWQ_NE;
+
+ if( strcasecmp(token,"<>") == 0 )
+ return SWQ_NE;
+
+ if( strcasecmp(token,"<") == 0 )
+ return SWQ_LT;
+
+ if( strcasecmp(token,">") == 0 )
+ return SWQ_GT;
+
+ return SWQ_UNKNOWN;
+}
+
+/************************************************************************/
+/* swq_op_is_logical() */
+/************************************************************************/
+
+static int swq_op_is_logical( swq_op op )
+
+{
+ return op == SWQ_OR || op == SWQ_AND || op == SWQ_NOT;
+}
+
+
+/************************************************************************/
+/* swq_identify_field() */
+/************************************************************************/
+
+static int swq_identify_field( const char *token,
+ int field_count,
+ char **field_list,
+ swq_field_type *field_types,
+ swq_field_type *this_type )
+
+{
+ int i;
+
+ for( i = 0; i < field_count; i++ )
+ {
+ if( strcasecmp( field_list[i], token ) == 0 )
+ {
+ if( field_types != NULL )
+ *this_type = field_types[i];
+ else
+ *this_type = SWQ_OTHER;
+
+ return i;
+ }
+ }
+
+ *this_type = SWQ_OTHER;
+ return -1;
+}
+
+/************************************************************************/
+/* swq_subexpr_compile() */
+/************************************************************************/
+
+static const char *
+swq_subexpr_compile( char **tokens,
+ int field_count,
+ char **field_list,
+ swq_field_type *field_types,
+ swq_expr **expr_out,
+ int *tokens_consumed )
+
+{
+ swq_expr *op;
+ const char *error;
+
+ *tokens_consumed = 0;
+ *expr_out = NULL;
+
+ if( tokens[0] == NULL || tokens[1] == NULL )
+ {
+ sprintf( swq_error, "Not enough tokens to complete expression." );
+ return swq_error;
+ }
+
+ op = (swq_field_op *) SWQ_MALLOC(sizeof(swq_field_op));
+ memset( op, 0, sizeof(swq_field_op) );
+ op->field_index = -1;
+
+ if( strcmp(tokens[0],"(") == 0 )
+ {
+ int sub_consumed = 0;
+
+ error = swq_subexpr_compile( tokens + 1, field_count, field_list,
+ field_types,
+ (swq_expr **) &(op->first_sub_expr),
+ &sub_consumed );
+ if( error != NULL )
+ {
+ swq_expr_free( op );
+ return error;
+ }
+
+ if( strcmp(tokens[sub_consumed+1],")") != 0 )
+ {
+ swq_expr_free( op );
+ sprintf(swq_error,"Unclosed brackets, or incomplete expression.");
+ return swq_error;
+ }
+
+ *tokens_consumed += sub_consumed + 2;
+
+ /* If we are at the end of the tokens, we should return our subnode */
+ if( tokens[*tokens_consumed] == NULL
+ || strcmp(tokens[*tokens_consumed],")") == 0 )
+ {
+ *expr_out = (swq_expr *) op->first_sub_expr;
+ op->first_sub_expr = NULL;
+ swq_expr_free( op );
+ return NULL;
+ }
+ }
+ else
+ {
+ op->field_index =
+ swq_identify_field( tokens[*tokens_consumed],
+ field_count, field_list, field_types,
+ &(op->field_type) );
+
+ if( op->field_index < 0 )
+ {
+ swq_expr_free( op );
+ sprintf( swq_error, "Failed to identify field:" );
+ strncat( swq_error, tokens[*tokens_consumed],
+ sizeof(swq_error) - strlen(swq_error) - 1 );
+ return swq_error;
+ }
+
+ (*tokens_consumed)++;
+ }
+
+ /*
+ ** Identify the operation.
+ */
+ if( tokens[*tokens_consumed] == NULL || tokens[*tokens_consumed+1] == NULL)
+ {
+ sprintf( swq_error, "Not enough tokens to complete expression." );
+ return swq_error;
+ }
+
+ op->operation = swq_identify_op( tokens[*tokens_consumed] );
+ if( op->operation == SWQ_UNKNOWN )
+ {
+ swq_expr_free( op );
+ sprintf( swq_error, "Failed to identify operation:" );
+ strncat( swq_error, tokens[*tokens_consumed],
+ sizeof(swq_error) - strlen(swq_error) - 1 );
+ return swq_error;
+ }
+
+ if( swq_op_is_logical( op->operation ) && op->first_sub_expr == NULL )
+ {
+ swq_expr_free( op );
+ strcpy( swq_error, "Used logical operation with non-logical operand.");
+ return swq_error;
+ }
+
+ if( op->field_index != -1 && op->field_type == SWQ_STRING
+ && (op->operation != SWQ_EQ && op->operation != SWQ_NE) )
+ {
+ sprintf( swq_error,
+ "Attempt to use STRING field `%s' with numeric comparison `%s'.",
+ field_list[op->field_index], tokens[*tokens_consumed] );
+ swq_expr_free( op );
+ return swq_error;
+ }
+
+ (*tokens_consumed)++;
+
+ /*
+ ** Collect the second operand as a subexpression.
+ */
+
+ if( tokens[*tokens_consumed] == NULL )
+ {
+ sprintf( swq_error, "Not enough tokens to complete expression." );
+ return swq_error;
+ }
+
+ if( swq_op_is_logical( op->operation ) )
+ {
+ int sub_consumed = 0;
+
+ error = swq_subexpr_compile( tokens + *tokens_consumed,
+ field_count, field_list, field_types,
+ (swq_expr **) &(op->second_sub_expr),
+ &sub_consumed );
+ if( error != NULL )
+ {
+ swq_expr_free( op );
+ return error;
+ }
+
+ *tokens_consumed += sub_consumed;
+ }
+
+ /*
+ ** Otherwise collect it as a literal value.
+ */
+ else
+ {
+ op->string_value = (char *)
+ SWQ_MALLOC(strlen(tokens[*tokens_consumed])+1);
+ strcpy( op->string_value, tokens[*tokens_consumed] );
+ op->int_value = atoi(op->string_value);
+ op->float_value = atof(op->string_value);
+
+ if( op->field_index != -1
+ && (op->field_type == SWQ_INTEGER || op->field_type == SWQ_FLOAT)
+ && op->string_value[0] != '-'
+ && op->string_value[0] != '+'
+ && op->string_value[0] != '.'
+ && (op->string_value[0] < '0' || op->string_value[0] > '9') )
+ {
+ sprintf( swq_error,
+ "Attempt to compare numeric field `%s' to non-numeric"
+ " value `%s' is illegal.",
+ field_list[op->field_index], op->string_value );
+ swq_expr_free( op );
+ return swq_error;
+ }
+
+ (*tokens_consumed)++;
+ }
+
+ *expr_out = op;
+ op = NULL;
+
+ /*
+ ** Are we part of an unparantized logical expression chain? If so,
+ ** grab the remainder of the expression at "this level" and add to the
+ ** local tree.
+ */
+ if( tokens[*tokens_consumed] != NULL
+ && swq_op_is_logical(swq_identify_op( tokens[*tokens_consumed] )) )
+ {
+ swq_expr *remainder = NULL;
+ swq_expr *parent;
+ int sub_consumed;
+
+ error = swq_subexpr_compile( tokens + *tokens_consumed + 1,
+ field_count, field_list, field_types,
+ &remainder, &sub_consumed );
+ if( error != NULL )
+ {
+ swq_expr_free( *expr_out );
+ *expr_out = NULL;
+ return error;
+ }
+
+ parent = (swq_field_op *) SWQ_MALLOC(sizeof(swq_field_op));
+ memset( parent, 0, sizeof(swq_field_op) );
+ parent->field_index = -1;
+
+ parent->first_sub_expr = (struct swq_node_s *) *expr_out;
+ parent->second_sub_expr = (struct swq_node_s *) remainder;
+ parent->operation = swq_identify_op( tokens[*tokens_consumed] );
+
+ *expr_out = parent;
+
+ *tokens_consumed += sub_consumed + 1;
+ }
+
+ return NULL;
+}
+
+
+
+/************************************************************************/
+/* swq_expr_compile() */
+/************************************************************************/
+
+const char *swq_expr_compile( const char *where_clause,
+ int field_count,
+ char **field_list,
+ swq_field_type *field_types,
+ swq_expr **expr_out )
+
+{
+#define MAX_TOKEN 1024
+ char *token_list[MAX_TOKEN], *rest_of_expr;
+ int token_count = 0;
+ int tokens_consumed, i;
+ const char *error;
+
+ /*
+ ** Collect token array.
+ */
+ rest_of_expr = (char *) where_clause;
+ while( token_count < MAX_TOKEN )
+ {
+ token_list[token_count] = swq_token( rest_of_expr, &rest_of_expr );
+ if( token_list[token_count] == NULL )
+ break;
+
+ token_count++;
+ }
+ token_list[token_count] = NULL;
+
+ /*
+ ** Parse the expression.
+ */
+ *expr_out = NULL;
+ error =
+ swq_subexpr_compile( token_list, field_count, field_list, field_types,
+ expr_out, &tokens_consumed );
+
+ for( i = 0; i < token_count; i++ )
+ SWQ_FREE( token_list[i] );
+
+ if( error != NULL )
+ return error;
+
+ if( tokens_consumed < token_count )
+ {
+ swq_expr_free( *expr_out );
+ *expr_out = NULL;
+ sprintf( swq_error, "Syntax error, %d extra tokens",
+ token_count - tokens_consumed );
+ return swq_error;
+ }
+
+ return NULL;
+}
+
+/************************************************************************/
+/* swq_expr_free() */
+/************************************************************************/
+
+void swq_expr_free( swq_expr *expr )
+
+{
+ if( expr == NULL )
+ return;
+
+ if( expr->first_sub_expr != NULL )
+ swq_expr_free( (swq_expr *) expr->first_sub_expr );
+ if( expr->second_sub_expr != NULL )
+ swq_expr_free( (swq_expr *) expr->second_sub_expr );
+
+ if( expr->string_value != NULL )
+ SWQ_FREE( expr->string_value );
+
+ SWQ_FREE( expr );
+}
+
+/************************************************************************/
+/* swq_expr_evaluate() */
+/************************************************************************/
+
+int swq_expr_evaluate( swq_expr *expr, swq_op_evaluator fn_evaluator,
+ void *record_handle )
+
+{
+ if( expr->operation == SWQ_OR )
+ {
+ return swq_expr_evaluate( (swq_expr *) expr->first_sub_expr,
+ fn_evaluator,
+ record_handle)
+ || swq_expr_evaluate( (swq_expr *) expr->second_sub_expr,
+ fn_evaluator,
+ record_handle);
+ }
+ else if( expr->operation == SWQ_AND )
+ {
+ return swq_expr_evaluate( (swq_expr *) expr->first_sub_expr,
+ fn_evaluator,
+ record_handle)
+ && swq_expr_evaluate( (swq_expr *) expr->second_sub_expr,
+ fn_evaluator,
+ record_handle);
+ }
+ else
+ {
+ return fn_evaluator( expr, record_handle );
+ }
+
+ return FALSE;
+}
+
+/************************************************************************/
+/* swq_expr_dump() */
+/************************************************************************/
+
+void swq_expr_dump( swq_expr *expr, FILE * fp, int depth )
+
+{
+ char spaces[60];
+ int i;
+ const char *op_name = "unknown";
+
+ for( i = 0; i < depth*2 && i < sizeof(spaces); i++ )
+ spaces[i] = ' ';
+ spaces[i] = '\0';
+
+ /*
+ ** first term.
+ */
+ if( expr->first_sub_expr != NULL )
+ swq_expr_dump( (swq_expr *) expr->first_sub_expr, fp, depth + 1 );
+ else
+ fprintf( fp, "%s Field %d\n", spaces, expr->field_index );
+
+ /*
+ ** Operation.
+ */
+ if( expr->operation == SWQ_OR )
+ op_name = "OR";
+ if( expr->operation == SWQ_AND )
+ op_name = "AND";
+ if( expr->operation == SWQ_NOT)
+ op_name = "NOT";
+ if( expr->operation == SWQ_GT )
+ op_name = ">";
+ if( expr->operation == SWQ_LT )
+ op_name = "<";
+ if( expr->operation == SWQ_EQ )
+ op_name = "=";
+ if( expr->operation == SWQ_NE )
+ op_name = "!=";
+ if( expr->operation == SWQ_GE )
+ op_name = ">=";
+ if( expr->operation == SWQ_LE )
+ op_name = "<=";
+
+ fprintf( fp, "%s%s\n", spaces, op_name );
+
+ /*
+ ** Second term.
+ */
+ if( expr->second_sub_expr != NULL )
+ swq_expr_dump( (swq_expr *) expr->second_sub_expr, fp, depth + 1 );
+ else
+ fprintf( fp, "%s %s\n", spaces, expr->string_value );
+}
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/swq.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/swq.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/swq.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ *
+ * Component: OGDI Driver Support Library
+ * Purpose: Generic SQL WHERE Expression Evaluator Declarations.
+ * Author: Frank Warmerdam <warmerdam at pobox.com>
+ *
+ ******************************************************************************
+ * Copyright (C) 2001 Information Interoperability Institute (3i)
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of 3i not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. 3i makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: swq.h,v $
+ * Revision 1.1 2001/06/20 21:49:16 warmerda
+ * New
+ *
+ */
+
+#ifndef _SWQ_H_INCLUDED_
+#define _SWQ_H_INCLUDED_
+
+typedef enum {
+ SWQ_OR,
+ SWQ_AND,
+ SWQ_NOT,
+ SWQ_EQ,
+ SWQ_NE,
+ SWQ_GE,
+ SWQ_LE,
+ SWQ_LT,
+ SWQ_GT,
+ SWQ_UNKNOWN
+} swq_op;
+
+typedef enum {
+ SWQ_INTEGER,
+ SWQ_FLOAT,
+ SWQ_STRING,
+ SWQ_BOOLEAN,
+ SWQ_OTHER
+} swq_field_type;
+
+typedef struct {
+ swq_op operation;
+
+ /* only for logical expression on subexpression */
+ struct swq_node_s *first_sub_expr;
+ struct swq_node_s *second_sub_expr;
+
+ /* only for binary field operations */
+ int field_index;
+ swq_field_type field_type;
+ char *string_value;
+ int int_value;
+ double float_value;
+} swq_field_op;
+
+typedef swq_field_op swq_expr;
+
+typedef int (*swq_op_evaluator)(swq_field_op *op, void *record_handle);
+
+/* Compile an SQL WHERE clause into an internal form. The field_list is
+** the list of fields in the target 'table', used to render where into
+** field numbers instead of names.
+*/
+const char *swq_expr_compile( const char *where_clause,
+ int field_count,
+ char **field_list,
+ swq_field_type *field_types,
+ swq_expr **expr );
+
+/*
+** Evaluate an expression for a particular record using an application
+** provided field operation evaluator, and abstract record handle.
+*/
+int swq_expr_evaluate( swq_expr *expr, swq_op_evaluator fn_evaluator,
+ void *record_handle );
+
+void swq_expr_free( swq_expr * );
+
+#endif /* def _SWQ_H_INCLUDED_ */
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/utils.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/utils.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/utils.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,2093 @@
+/******************************************************************************
+ *
+ * Component: OGDI VRF Driver
+ * Purpose: Various VRF supporting functions.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: utils.c,v $
+ * Revision 1.16 2004/10/26 19:57:36 warmerda
+ * Fixed problem where "reg" regular expression was freed, but the change
+ * was not recognised since compiled was not being reset. Got rid of
+ * compiled flag entirely.
+ *
+ * Revision 1.15 2004/10/25 19:34:31 warmerda
+ * The Level "buffint" should be short, not int, when forming the metadata.
+ *
+ * Revision 1.14 2004/02/18 21:33:18 warmerda
+ * free regex memory
+ *
+ * Revision 1.13 2003/05/21 18:47:31 warmerda
+ * initialize spriv->tile[0].path in untiled (VITD) case
+ *
+ * Revision 1.12 2001/08/16 19:59:08 warmerda
+ * partially rewrite vrf_build_coverage_capabilities to avoid repeating entries
+ *
+ * Revision 1.11 2001/07/05 14:16:06 warmerda
+ * fixed vrf_GetMetadata error duplicating first layer in a class, bug 111181
+ *
+ * Revision 1.10 2001/06/29 19:17:00 warmerda
+ * fixed unterminated 'temp' string
+ *
+ * Revision 1.9 2001/06/21 20:30:15 warmerda
+ * added ECS_CVSID
+ *
+ * Revision 1.8 2001/06/13 17:33:59 warmerda
+ * upgraded source headers
+ *
+ */
+
+#include "ecs.h"
+#include "vrf.h"
+
+ECS_CVSID("$Id: utils.c,v 1.16 2004/10/26 19:57:36 warmerda Exp $");
+
+#ifdef _WINDOWS
+#define SEPARATOR '\\'
+#else
+#define SEPARATOR '/'
+#endif
+
+/* ----------------------------------------------------------------------
+ * vrf_parsePath:
+ *
+ * decomposition du pathname en database, location et mapset
+ * ----------------------------------------------------------------------
+ */
+
+#define SYNTAXERRORMESSAGE "Badly formed pathname: %s, must be fclass at coverage(expression)"
+
+int vrf_parsePath(s,lpriv,sel)
+ ecs_Server *s;
+ LayerPrivateData *lpriv;
+ ecs_LayerSelection *sel;
+{
+ return vrf_parsePathValue(s,sel->Select,&(lpriv->fclass),&(lpriv->coverage),&(lpriv->expression));
+}
+
+/* ----------------------------------------------------------------------
+ * vrf_parsePathValues:
+ *
+ * decomposition du pathname en database, location et mapset
+ * ----------------------------------------------------------------------
+ */
+
+static ecs_regexp *reg = NULL;
+
+int vrf_parsePathValue(s,request,fclass,coverage,expression)
+ ecs_Server *s;
+ char *request;
+ char **fclass;
+ char **coverage;
+ char **expression;
+{
+ char buffer[512],*temp;
+ int i,pos;
+
+ /* Found the first "(" */
+
+ pos = 0;
+ for(i=0;i<(int) strlen(request);i++) {
+ if (request[i] == '(') {
+ pos = i;
+ break;
+ }
+ }
+
+ temp = malloc(pos+1);
+ if (temp == NULL) {
+ ecs_SetError(&(s->result),1,"not enough memory");
+ return 0;
+ }
+ strncpy(temp,request,pos);
+ temp[pos] = '\0';
+
+ if ((int) strlen(request) > pos) {
+ *expression = malloc(strlen(request)-pos+1);
+ if (*expression == NULL) {
+ free(temp);
+ ecs_SetError(&(s->result),1,"not enough memory");
+ return 0;
+ }
+ strncpy(*expression,request+pos+1,strlen(request)-pos-2);
+ (*expression)[strlen(request)-pos-2] = '\0';
+ } else {
+ free(temp);
+ ecs_SetError(&(s->result),1,"no expressions set in this request");
+ return 0;
+ }
+
+ if ( reg == NULL ) {
+ reg = EcsRegComp("(.*)@(.*)");
+ }
+
+ if (!EcsRegExec(reg,temp,NULL)) {
+ sprintf(buffer,SYNTAXERRORMESSAGE,request);
+ ecs_SetError(&(s->result),1,buffer);
+ free(temp);
+ free(*expression);
+ return 0;
+ }
+
+ if (!ecs_GetRegex(reg,1,fclass)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ free(temp);
+ free(*expression);
+ return 0;
+ }
+
+ if (strlen(*fclass) == 0) {
+ sprintf(buffer,SYNTAXERRORMESSAGE,s->pathname);
+ ecs_SetError(&(s->result),1,buffer);
+ free(temp);
+ free(*expression);
+ return 0;
+ }
+
+
+ if (!ecs_GetRegex(reg,2,coverage)) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate server");
+ free(temp);
+ free(*expression);
+ return 0;
+ }
+
+ if (strlen(*coverage) == 0) {
+ sprintf(buffer,SYNTAXERRORMESSAGE,s->pathname);
+ ecs_SetError(&(s->result),1,buffer);
+ free(temp);
+ free(*expression);
+ return 0;
+ }
+
+ free(temp);
+ return 1;
+}
+
+/* ----------------------------------------------------------------------
+ * vrf_freePathRegex()
+ *
+ * free resources related to regex path checker.
+ * ----------------------------------------------------------------------
+ */
+
+void vrf_freePathRegex()
+
+{
+ if( reg != NULL )
+ {
+ free( reg );
+ reg = NULL;
+ }
+}
+
+/*
+********************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+vrf_getFileNameFromFcs
+
+DESCRIPTION
+
+ Extract from the FCS the important information needed
+ by a given layer.
+
+END_DESCRIPTION
+
+PARAMETERS
+
+ INPUT
+ ecs_Server *s: Server info given by OGDI API
+ ecs_Layer *lpriv: The current layer private information
+
+END_PARAMETERS
+
+END_FUNCTION_INFORMATION
+
+PSEUDO-CODE
+
+Check with muse access see if in the coverage there is a FCS. If it
+exist, open it in fcsTable.
+
+For each row in the fcs table
+Begin
+
+ Get the current row in the table.
+
+ If the first element of the row get the same name than the current
+ feature class
+ Begin
+
+ Set the variable found to 1
+
+ Check if a join table exist and get it's name. Set isJointed
+ to TRUE if one is found for this coverage.
+
+ Get the feature table name attribute in the row (position 2).
+ Set this value in lpriv->featureTableName.
+
+ Get the primitive table name attribute in the row (position
+ 4). Set this value in lpriv->primitiveTableName.
+
+ If there is a joint table
+ Begin
+
+ If the primitive table name is a join table.
+ Begin
+
+ Clear from the memory the lpriv->primitiveTableName.
+
+ Get the join table name attribute in the row (position
+ 4). Set this value in lpriv->joinTableName.
+
+ Get the join table foreign key name attribute in the
+ row (position 3). Set this value in
+ lpriv->joinTableForeignKeyName.
+
+ Get the join table feature id name attribute in the
+ row (position 5). Set this value in
+ lpriv->joinTableFeatureIdName.
+
+ Check the remaining rows in the fcs table one by one
+ Begin
+
+ Set buf2 at the second position of the row.
+
+ Set buf3 at the fourth position of the row.
+
+ If buf2 contain the joinTableName and buf3 don't
+ contain the featureTableName Begin
+
+ Get the primitive table name attribute in the
+ row (position 4). Set this value in
+ lpriv->primitiveTableName.
+
+ Get the join table primitive id name attribute
+ in the row (position 3). Set this value in
+ lpriv->featureTablePrimIdName.
+
+ End
+
+ Free buf2
+
+ Free buf3
+
+ End
+
+ End
+ Else
+ Begin
+
+ // No links are define between the join table and the
+ // feature table in fcs. We suppose a relation 1:1.
+
+ Set the lpriv->joinTableName with the join filename
+ found previously.
+
+ Set lpriv->joinTableForeignKeyName to NULL.
+
+ Get the feature table primitive id name attribute in
+ the row (position 3). Set this value in
+ lpriv->featureTablePrimIdName.
+
+ End
+
+ End
+ Else
+ Begin
+
+ // There is no join table
+
+ Set the lpriv->joinTableName to NULL.
+
+ Set lpriv->joinTableForeignKeyName to NULL.
+
+ Get the feature table primitive id name attribute in the
+ row (position 3). Set this value in
+ lpriv->featureTablePrimIdName.
+
+ End
+
+ End
+
+ Free the row
+
+End
+
+Close the fcs table
+
+Return a success message
+
+********************************************************************
+*/
+
+int
+vrf_getFileNameFromFcs(s,lpriv)
+ ecs_Server *s;
+ LayerPrivateData *lpriv;
+{
+ char buffer[512];
+ char *buf1;
+ char *buf2;
+ char *buf3;
+ int count;
+ int i,j;
+ int found = 0;
+ row_type row;
+ char code;
+ register ServerPrivateData *spriv = s->priv;
+ FILE *tempfile;
+ char tempfilename[100];
+ int isJointed;
+
+ sprintf(buffer,"%s/%s/fcs",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0) {
+ sprintf(buffer,"%s/%s/FCS",spriv->library,lpriv->coverage);
+ if (muse_access(buffer,0) != 0) {
+ ecs_SetError(&(s->result),1,"Can't open the FCS table, invalid VRF coverage");
+ return 0;
+ }
+ }
+
+#ifdef TESTOPENTABLE
+ printf("open lpriv->fcsTable:%s\n",buffer);
+#endif
+
+
+
+ lpriv->fcsTable = vpf_open_table(buffer, disk, "rb", NULL);
+ if (lpriv->fcsTable.path == NULL) {
+ ecs_SetError(&(s->result),1,"Can't open the FCS table, invalid VRF coverage");
+ return 0;
+
+ }
+
+ for (i = 1; i <= lpriv->fcsTable.nrows && !found; ++i) {
+ row = get_row(i, lpriv->fcsTable);
+ buf1 = justify((char*)get_table_element(1, row, lpriv->fcsTable, NULL, &count));
+ if (stricmp(buf1,lpriv->fclass) == 0) {
+ found = 1;
+
+ /* Check if a join table exist and get it's name */
+
+ isJointed = TRUE;
+ strcpy(tempfilename,lpriv->fclass);
+ strcat(tempfilename,".ajt");
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,tempfilename);
+ if ((tempfile = fopen(buffer,"r")) == NULL) {
+ strcpy(tempfilename,lpriv->fclass);
+ strcat(tempfilename,".AJT");
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,tempfilename);
+ if ((tempfile = fopen(buffer,"r")) == NULL) {
+ strcpy(tempfilename,lpriv->fclass);
+ strcat(tempfilename,".ljt");
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,tempfilename);
+ if ((tempfile = fopen(buffer,"r")) == NULL) {
+ strcpy(tempfilename,lpriv->fclass);
+ strcat(tempfilename,".LJT");
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,tempfilename);
+ if ((tempfile = fopen(buffer,"r")) == NULL) {
+ strcpy(tempfilename,lpriv->fclass);
+ strcat(tempfilename,".rjt");
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,tempfilename);
+ if ((tempfile = fopen(buffer,"r")) == NULL) {
+ strcpy(tempfilename,lpriv->fclass);
+ strcat(tempfilename,".RJT");
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,tempfilename);
+ if ((tempfile = fopen(buffer,"r")) == NULL) {
+ strcpy(tempfilename,lpriv->fclass);
+ strcat(tempfilename,".njt");
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,tempfilename);
+ if ((tempfile = fopen(buffer,"r")) == NULL) {
+ strcpy(tempfilename,lpriv->fclass);
+ strcat(tempfilename,".NJT");
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,tempfilename);
+ if ((tempfile = fopen(buffer,"r")) == NULL) {
+ isJointed = FALSE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (tempfile != NULL)
+ fclose(tempfile);
+
+ /* Access information in fcs */
+
+ lpriv->featureTableName = justify((char *)get_table_element(2, row,
+ lpriv->fcsTable, NULL, &count));
+ lpriv->primitiveTableName = justify((char *)get_table_element(4, row,
+ lpriv->fcsTable, NULL, &count));
+ code = lpriv->primitiveTableName[strlen(lpriv->primitiveTableName)-2];
+
+ if (isJointed) {
+ if ( (code == 'j') || (code == 'J')) {
+ free(lpriv->primitiveTableName);
+ lpriv->joinTableName = justify((char *)get_table_element(4, row,
+ lpriv->fcsTable, NULL, &count));
+ lpriv->joinTableForeignKeyName = justify((char *)get_table_element(3, row,
+ lpriv->fcsTable, NULL, &count));
+ lpriv->joinTableFeatureIdName = justify((char *)get_table_element(5, row,
+ lpriv->fcsTable, NULL, &count));
+ for (j = i+1; j <= lpriv->fcsTable.nrows; ++j) {
+ row = get_row(j, lpriv->fcsTable);
+
+ buf2 = justify((char*)get_table_element(2, row, lpriv->fcsTable, NULL, &count));
+ buf3 = justify((char*)get_table_element(4, row, lpriv->fcsTable, NULL, &count));
+ if ((stricmp(buf2,lpriv->joinTableName) == 0) && (stricmp(buf3,lpriv->featureTableName) != 0)) {
+
+ lpriv->primitiveTableName = justify((char *)get_table_element(4, row,
+ lpriv->fcsTable, NULL, &count));
+ lpriv->featureTablePrimIdName = justify((char *)get_table_element(3, row,
+ lpriv->fcsTable, NULL, &count));
+ }
+ free(buf2);
+ free(buf3);
+ }
+ } else {
+ lpriv->joinTableName = malloc(strlen(tempfilename)+1);
+ strcpy(lpriv->joinTableName,tempfilename);
+ lpriv->joinTableForeignKeyName = NULL;
+ lpriv->joinTableFeatureIdName = NULL;
+ lpriv->featureTablePrimIdName = justify((char *)get_table_element(3, row,
+ lpriv->fcsTable, NULL, &count));
+ }
+ } else {
+ lpriv->joinTableName = NULL;
+ lpriv->joinTableForeignKeyName = NULL;
+ lpriv->featureTablePrimIdName = justify((char *)get_table_element(3, row,
+ lpriv->fcsTable, NULL, &count));
+ }
+ }
+ free(buf1);
+ free_row(row, lpriv->fcsTable);
+ }
+
+#ifdef TESTOPENTABLE
+ printf("close: spriv->fcsTable\n");
+#endif
+
+ vpf_close_table(&(lpriv->fcsTable));
+
+ if (!found) {
+ ecs_SetError(&(s->result),1,"Can't open the FCS table, invalid VRF coverage");
+ return 0;
+ } else {
+ return 1;
+ }
+
+}
+
+/* ----------------------------------------------------------
+ * vrf_VerifyCATFile:
+ *
+ * Verify if s->pathname is really a LAT file
+ * ----------------------------------------------------------
+ */
+
+
+int
+vrf_verifyCATFile(s)
+ ecs_Server *s;
+{
+ char buffer[512];
+ register ServerPrivateData *spriv = s->priv;
+
+
+ /* verification code must be inserted here */
+
+ sprintf(buffer,"%s/cat",spriv->library);
+ if (muse_access(buffer,0) != 0) {
+ sprintf(buffer,"%s/CAT",spriv->library);
+ if (muse_access(buffer,0) != 0) {
+ ecs_SetError(&(s->result),1,"Can't open CAT file, invalid VRF database");
+ return 0;
+ }
+ }
+
+#ifdef TESTOPENTABLE
+ printf("open spriv->catTable:%s\n",buffer);
+#endif
+ spriv->catTable = vpf_open_table(buffer, disk, "rb", NULL);
+ if (spriv->catTable.path == NULL) {
+ ecs_SetError(&(s->result),1,"Can't open CAT file, invalid VRF database");
+ return 0;
+ }
+
+ return 1;
+}
+
+
+/* -------------------------------------------------------------------------
+ * vrf_Getmetadata:
+ *
+ * preparation de la fenetre globale pour le server
+ * --------------------------------------------------------------------------
+ */
+
+int
+vrf_GetMetadata(s)
+ ecs_Server *s;
+{
+
+ int i,j;
+ char *buf1;
+ char *buf2;
+ char *bufname;
+ char *bufdesc;
+ int count;
+ row_type row;
+ row_type rowcat;
+ row_type rowcomp;
+ row_type rowfca;
+ float buffloat;
+ short buffint;
+ register ServerPrivateData *spriv = s->priv;
+ char buffer[256];
+ char tab[3][7]={"char","float","int"};
+ char *covname;
+
+ int z,k,it_pos,val_pos,des_pos,att_pos;
+ char *item_buf, *att_buf, *des_buf, *tval;
+ vpf_table_type table;
+ storage_type stor = disk;
+ date_type datee;
+ /* row_type row;*/
+ float fval;
+ int32 n;
+ int intval;
+ int existtableflag;
+ char separator[2]={SEPARATOR,'\0'};
+ int flag;
+ int test;
+
+ /* int32 count; */
+
+ buf1 = NULL;
+
+ /* build the begining of metadatastring*/
+ sprintf (spriv->metadatastring,"{<Grassland>displaymetada { { CURRENT DATABASE:%s\n\nDATA HEADER TABLE(DHT):\n\n",spriv->database);
+
+
+ /* code pour recuperer les valeurs de DHT */
+
+ sprintf(buffer,"%s%sdht",spriv->database,separator);
+
+ if (muse_access(buffer,0) ==0) {
+
+#ifdef TESTOPENTABLE
+ printf("open spriv->dhtTable:%s\n",buffer);
+#endif
+
+ spriv->dhtTable = vpf_open_table(buffer, disk, "rb", NULL);
+ for (i = 1; i <= spriv->dhtTable.nrows; ++i) {
+ row = get_row(i, spriv->dhtTable);
+
+ test=table_pos("DATABASE_NAME",spriv->dhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("DATABASE_NAME",spriv->dhtTable), row, spriv->dhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sDatabase_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("DATABASE_DESC",spriv->dhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("DATABASE_DESC",spriv->dhtTable), row, spriv->dhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sDatabase_description: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("MEDIA_STANDARD",spriv->dhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("MEDIA_STANDARD",spriv->dhtTable), row, spriv->dhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sMedia_Standard: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("ORIGINATOR",spriv->dhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("ORIGINATOR",spriv->dhtTable), row, spriv->dhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sOriginator: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("ADDRESSEE",spriv->dhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("ADDRESSEE",spriv->dhtTable), row, spriv->dhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sAddressee: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+
+ test=table_pos("DOWNGRADE_DATE",spriv->dhtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("DOWNGRADE_DATE",spriv->dhtTable), row, spriv->dhtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sDowngrade_date: %s\n",spriv->metadatastring,datee);
+ }
+
+ test=table_pos("RELEASABILITY",spriv->dhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("RELEASABILITY",spriv->dhtTable), row, spriv->dhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sReleasability: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test = table_pos("OTHER_STD_NAME", spriv->dhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("OTHER_STD_NAME", spriv->dhtTable), row, spriv->dhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sOther_STD_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+
+ test = table_pos("OTHER_STD_DATE",spriv->dhtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("OTHER_STD_DATE",spriv->dhtTable), row, spriv->dhtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sOther_std_date: %s\n",spriv->metadatastring,datee);
+ }
+
+ test = table_pos("OTHER_STD_VER",spriv->dhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("OTHER_STD_VER",spriv->dhtTable), row, spriv->dhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sOther_STD_ver: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test = table_pos("OTHER_STD_VER",spriv->dhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("OTHER_STD_VER",spriv->dhtTable), row, spriv->dhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sEdition_number: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("EDITION_DATE",spriv->dhtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("EDITION_DATE",spriv->dhtTable), row, spriv->dhtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sEdition_date: %s\n",spriv->metadatastring,datee);
+ }
+
+ free_row(row, spriv->dhtTable);
+ }
+ }
+ vpf_close_table(&(spriv->dhtTable));
+
+ /*
+ code pour recuperer les valeurs de LAT
+ */
+
+ sprintf (spriv->metadatastring,"%s\n\n\nLIBRARY ATTRIBUTE TABLE(LAT):\n\n",spriv->metadatastring);
+
+ for (i = 1; i <= spriv->latTable.nrows; ++i) {
+ row = get_row(i, spriv->latTable);
+ buf1 = justify((char*)get_table_element(1, row, spriv->latTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sCoverage name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ get_table_element(2, row, spriv->latTable, &buffloat, &count);
+ sprintf(spriv->metadatastring,"%sXMIN: %f\n",spriv->metadatastring,buffloat);
+ get_table_element(3, row, spriv->latTable, &buffloat, &count);
+ sprintf(spriv->metadatastring,"%sYMIN: %f\n",spriv->metadatastring,buffloat);
+ get_table_element(4, row, spriv->latTable, &buffloat, &count);
+ sprintf(spriv->metadatastring,"%sXMAX: %f\n",spriv->metadatastring,buffloat);
+ get_table_element(5, row, spriv->latTable, &buffloat, &count);
+ sprintf(spriv->metadatastring,"%sYMAX: %f\n",spriv->metadatastring,buffloat);
+ free_row(row, spriv->latTable);
+ }
+
+ /*ferme la liste de la ddb et ouvre la liste de la librairie*/
+
+ sprintf(spriv->metadatastring,"%s } { ",spriv->metadatastring);
+
+ /* code pour recuperer les valeurs dans LHT */
+
+ sprintf(buffer,"%s%slht",spriv->library,separator);
+ if (muse_access(buffer,0) ==0)
+ {
+ sprintf (spriv->metadatastring,"%sCURRENT DATABASE:%s\n\nLIBRARY LIBRARY HEADER TABLE(LHT):\n\n",spriv->metadatastring,spriv->database);
+
+#ifdef TESTOPENTABLE
+ printf("open spriv->lhtTable:%s\n",buffer);
+#endif
+ spriv->lhtTable = vpf_open_table(buffer,disk,"rb",NULL);
+
+ for (i = 1; i <= spriv->lhtTable.nrows; ++i) {
+ row = get_row(i, spriv->lhtTable);
+
+ test=table_pos("PRODUCT_TYPE",spriv->lhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("PRODUCT_TYPE",spriv->lhtTable), row, spriv->lhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sProduct_type: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("LIBRARY_NAME",spriv->lhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("LIBRARY_NAME",spriv->lhtTable), row, spriv->lhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sLibrary_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("DESCRIPTION",spriv->lhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("DESCRIPTION",spriv->lhtTable), row, spriv->lhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sDescription: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+
+ test=table_pos("SOURCE_SERIES",spriv->lhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("SOURCE_SERIES",spriv->lhtTable), row, spriv->lhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sSource_series: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("SOURCE_ID",spriv->lhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("SOURCE_ID",spriv->lhtTable), row, spriv->lhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sSource_ID: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("SOURCE_EDITION",spriv->lhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("SOURCE_EDITION",spriv->lhtTable), row, spriv->lhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sSource_edition: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("SOURCE_NAME",spriv->lhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("SOURCE_NAME",spriv->lhtTable), row, spriv->lhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sSource_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("SOURCE_DATE",spriv->lhtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("SOURCE_DATE",spriv->lhtTable), row, spriv->lhtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sSource_date: %s\n",spriv->metadatastring,datee);
+ }
+
+ test=table_pos("DOWNGRADING",spriv->lhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("DOWNGRADING",spriv->lhtTable), row, spriv->lhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sDowngrading: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("DOWNGRADING_DATE",spriv->lhtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("DOWNGRADING_DATE_DATE",spriv->lhtTable), row, spriv->lhtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sDowngrading_date: %s\n",spriv->metadatastring,datee);
+ }
+
+ test=table_pos("RELEASABILITY",spriv->lhtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(table_pos("RELEASABILITY",spriv->lhtTable), row, spriv->lhtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sReleasability: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+ free_row(row, spriv->lhtTable);
+ }
+ }
+
+
+
+ /* code pour recuperer les valeurs dans CAT */
+ sprintf (spriv->metadatastring,"%s\n\n\nCOVERAGE ATTRIBUTE TABLE(CAT):\n\n",spriv->metadatastring);
+
+ for (i = 1; i <= spriv->catTable.nrows; ++i) {
+ row = get_row(i, spriv->catTable);
+ buf1 = justify( (char *) get_table_element(1, row, spriv->catTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sCoverage_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ buf1 = justify( (char *) get_table_element(2, row, spriv->catTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sDescription: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ get_table_element(3, row, spriv->catTable, &buffint, &count);
+ sprintf(spriv->metadatastring,"%sLevel: %d\n",spriv->metadatastring,buffint);
+ free_row(row, spriv->catTable);
+ }
+
+
+ /* code pour recuperer les valeurs dans GRT */
+
+
+ sprintf(buffer,"%s%sgrt",spriv->library,separator);
+
+ if (muse_access(buffer,0) ==0)
+ {
+ sprintf (spriv->metadatastring,"%s\n\n\nGEOGRAPHIC REFERENCE TABLE(GRT):\n\n",spriv->metadatastring);
+#ifdef TESTOPENTABLE
+ printf("open spriv->grtTable:%s\n",buffer);
+#endif
+ spriv->grtTable = vpf_open_table(buffer,disk,"rb",NULL);
+
+ for (i = 1; i <= spriv->grtTable.nrows; ++i) {
+ row = get_row(i, spriv->grtTable);
+
+
+ test=table_pos("DATA_TYPE",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sData_type: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("UNITS",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sUnits: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("ELLIPSOID",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sEllipsoid: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("ELLIPSOID_DETAIL",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sEllipsoid_detail: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("VERT_DATUM_REF",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sVert_datum_ref: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("VERT_DATUM_CODE",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sVert_datum_code: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("SOUND_DATUM_NAME",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sSound_datum_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("SOUND_DATUM_CODE",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sSound_datum_code: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("GEO_DATUM_NAME",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sGeo_datum_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("GEO_DATUM_CODE",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sGeo_datum_code: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("PROJECTION NAME",spriv->grtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->grtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sProjection_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ free_row(row, spriv->grtTable);
+ }
+ }
+ vpf_close_table(&(spriv->grtTable));
+
+ /* code pour recuperer les valeurs dans DQT */
+
+
+ sprintf(buffer,"%s%sdqt",spriv->library,separator);
+ if (muse_access(buffer,0) ==0)
+ {
+ sprintf (spriv->metadatastring,"%s\n\n\nDATA QUALITY TABLE(DQT):\n\n",spriv->metadatastring);
+#ifdef TESTOPENTABLE
+ printf("open spriv->dqtTable:%s\n",buffer);
+#endif
+ spriv->dqtTable = vpf_open_table(buffer,disk,"rb",NULL);
+
+ for (i = 1; i <= spriv->dqtTable.nrows; ++i) {
+ row = get_row(i, spriv->dqtTable);
+
+ test=table_pos("VPF_LEVEL",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sVpf_level: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("VPF_LEVEL_NAME",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sVpf_level_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("FEATURE_COMPLETE",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sFeature_complete: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("ATTRIB_COMPLETE",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sAttrib_complete: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("LOGICAL_CONSIST",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sLogical_consist: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("EDITION_NUM",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sEdition_num: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+
+ test=table_pos("CREATION_DATE",spriv->dqtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("CREATION_DATE",spriv->dqtTable), row, spriv->dqtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sCration date: %s\n",spriv->metadatastring,datee);
+ }
+
+ test=table_pos("REVISION_DATE",spriv->dqtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("REVISION_DATE",spriv->dqtTable), row, spriv->dqtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sRevision date: %s\n",spriv->metadatastring,datee);
+ }
+
+
+ test=table_pos("SPEC_NAME",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sSpec_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+
+ test=table_pos("SPEC_DATE",spriv->dqtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("SPEC_DATE",spriv->dqtTable), row, spriv->dqtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sSpecification date: %s\n",spriv->metadatastring,datee);
+ }
+
+ test=table_pos("EARLIEST_SOURCE",spriv->dqtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("EARLIEST_SOURCE",spriv->dqtTable), row, spriv->dqtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sEarliest source: %s\n",spriv->metadatastring,datee);
+ }
+
+ test=table_pos("LATEST_SOURCE",spriv->dqtTable);
+ if (test >= 0) {
+ get_table_element(table_pos("LATEST_SOURCE",spriv->dqtTable), row, spriv->dqtTable, (void *)&datee, &count);
+ sprintf(spriv->metadatastring,"%sLatest source: %s\n",spriv->metadatastring,datee);
+ }
+
+
+ test=table_pos("QUANT_ATT_ACC",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sQuant_att_acc: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("QUAL_ATT_ACC",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sQual_att_acc: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("COLLECTION_SPEC",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sCollection_spec: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("SOURCE_FILE_NAME",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sSource_file_name: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("ABS_HORIZ_ACC",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sAbs_horiz_acc: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("ABS_HORIZ_UNITS",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sAbs_horiz_units: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("ABS_VERT_ACC",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sAbs_vert_acc: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("ABS_VERT_UNITS",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sAbs_vert_units: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("REL_HORIZ_ACC",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%s:Rel_horiz_acc: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("REL_HORIZ_UNITS",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%s:Rel_horiz_units: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("REL_VERT_ACC",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%s:Rel_vert_acc %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("REL_VERT_UNITS",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%s:Rel_vert_units: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ test=table_pos("COMMENTS",spriv->dqtTable);
+ if (test >= 0) {
+ buf1 = justify((char*)get_table_element(test, row, spriv->dqtTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%sComments: %s\n",spriv->metadatastring,buf1);
+ free(buf1);
+ }
+
+ free_row(row, spriv->dqtTable);
+ }
+ }
+ vpf_close_table(&(spriv->dqtTable));
+
+
+ /*ferme la premiere partie de la chaine*/
+
+ sprintf(spriv->metadatastring,"%s} } } { ",spriv->metadatastring);
+
+
+ /*
+ code pour construire la chaine des coverages.Pour chaque coverage
+ ouvre les fichiers ../coverage/INT.VDT, ../coverage/FLOAT.VDT,
+ ../coverage/CHAR.VDT
+ */
+
+
+ for (z = 1; z <= spriv->catTable.nrows; z++) {
+ existtableflag=0;
+ rowcat = get_row(z, spriv->catTable);
+
+ /*ajoute debut chaine*/
+ sprintf(spriv->metadatastring,"%s {",spriv->metadatastring);
+
+ /*ajoute class et nom coverage*/
+ covname = justify( (char *) get_table_element(1, rowcat, spriv->catTable, NULL, &count));
+ sprintf(spriv->metadatastring,"%s family %s class",spriv->metadatastring,covname);
+
+ /*ajoute description et debut du covinfo*/
+ buf1 = justify( (char *) get_table_element(2, rowcat, spriv->catTable, NULL, &count));
+
+ sprintf(spriv->metadatastring,"%s {%s} {<Grassland>displaymetadata {",spriv->metadatastring, buf1);
+ free(buf1);
+
+ /********/
+
+ /*ouvre fcs*/
+ sprintf(buffer,"%s/%s/fcs",spriv->library,covname);
+#ifdef TESTOPENTABLE
+ printf("open spriv->fcsTable:%s\n",buffer);
+#endif
+ spriv->fcsTable = vpf_open_table(buffer, disk, "rb", NULL);
+
+ /*ouvre fca*/
+ sprintf(buffer,"%s/%s/fca",spriv->library,covname);
+ if (muse_access(buffer,0) == 0) {
+
+#ifdef TESTOPENTABLE
+ printf("open spriv->fcaTable:%s\n",buffer);
+#endif
+ spriv->fcaTable = vpf_open_table(buffer, disk, "rb", NULL);
+
+ if (spriv->fcsTable.path == NULL)
+ {
+ ecs_SetError(&(s->result),1,"Can't open the FCS table, invalid VRF coverage");
+ return 0;
+ }
+
+ for (i = 1; i <= spriv->fcsTable.nrows; ++i)
+ {
+ flag=0;
+ row = get_row(i, spriv->fcsTable);
+ rowcomp=get_row(i-1, spriv->fcsTable);
+ if (i>=2)
+ {
+ buf2 = justify((char*)get_table_element(1, rowcomp, spriv->fcsTable, NULL, &count));
+ buf1 = justify((char*)get_table_element(1, row, spriv->fcsTable, NULL, &count));
+ }else{
+
+ buf1 = justify((char*)get_table_element(1, row, spriv->fcsTable, NULL, &count));
+ buf2 = justify( (char *) get_table_element(2, row, spriv->lhtTable, NULL, &count));
+ }
+
+ if (strcmp(buf1,buf2)!=0)
+ {
+ for (j = 1;j<= spriv->fcaTable.nrows; j++)
+ {
+ rowfca = get_row(j, spriv->fcaTable);
+ bufname = justify((char*)get_table_element(table_pos("FCLASS",spriv->fcaTable), rowfca, spriv->fcaTable, NULL, &count));
+ bufdesc = justify((char*)get_table_element(table_pos("DESCR",spriv->fcaTable), rowfca, spriv->fcaTable, NULL, &count));
+ /*intbuf = get_table_element(, rowfca, spriv->fcaTable, NULL, &count));*/
+ if (flag==0)
+ {
+ if (strcmp(buf1,bufname)==0)
+ {
+ sprintf(spriv->metadatastring,"%s { %s { %s } } ",spriv->metadatastring,bufname,bufdesc);
+ flag=1;
+ }
+ }
+ free_row(rowfca, spriv->fcaTable);
+ free(bufname);
+ free(bufdesc);
+ }
+ }
+
+ free(buf1);
+ free(buf2);
+ free_row(row, spriv->fcsTable);
+ free_row(rowcomp, spriv->fcsTable);
+ }
+ vpf_close_table(&(spriv->fcaTable));
+ }
+
+ sprintf(spriv->metadatastring,"%s } {",spriv->metadatastring);
+ vpf_close_table(&(spriv->fcsTable));
+
+
+ /********/
+ /* free(buf1); */
+ /*lit les metadonnees de INT FLOAT et CHAR.VDT dans une boucle*/
+
+ for (j=0;j<3;j++)
+ {
+ sprintf(buffer,"%s%s%s%s%s.vdt",spriv->library,separator,covname,separator,tab[j]);
+
+ if (muse_access(buffer,0) ==0)
+ {
+ existtableflag=1;
+ sprintf(spriv->metadatastring,"%s \nVALUE DESCRIPTION TABLE (%s.vdt)\n\n",spriv->metadatastring,tab[j]);
+
+
+#ifdef TESTOPENTABLE
+ printf("open table:%s\n",buffer);
+#endif
+ table = vpf_open_table(buffer,disk,"rb",NULL);
+ it_pos = table_pos("TABLE",table);
+ val_pos = table_pos("VALUE",table);
+ des_pos = table_pos("DESCRIPTION",table);
+ att_pos = table_pos("ATTRIBUTE",table);
+
+ for(k=1;k<=table.nrows;k++)
+ /*for(k=1;k<=10;k++) */
+ {
+ if (stor == disk)
+ row = read_next_row(table);
+ else
+ row = get_row(k,table);
+
+ item_buf = (char *)get_table_element( it_pos,row,table,NULL,&n);
+ rightjust(item_buf);
+
+
+ att_buf = (char *)get_table_element(att_pos,row,table,NULL,&n);
+ rightjust(att_buf);
+
+ des_buf = (char *)get_table_element(des_pos,row,table,NULL,&n);
+
+
+ if ((strnicmp ("char",tab[j],5)) ==0) {
+ tval = (char *)get_table_element(val_pos,row,table,NULL,&n);
+ sprintf(buffer," %s = %s \n",tval,des_buf);
+ sprintf(spriv->metadatastring,"%s%s",spriv->metadatastring,buffer);
+ free(tval);
+ }
+
+ if ((strnicmp ("int",tab[j],6)) ==0
+ && table.header[val_pos].type == 'I' ) {
+ get_table_element(val_pos,row,table,&intval,&n);
+ sprintf(buffer," %12ld = %s \n",
+ (long)intval,des_buf);
+ sprintf(spriv->metadatastring,"%s%s",
+ spriv->metadatastring,buffer);
+ }
+
+ if ((strnicmp ("int",tab[j],6)) ==0
+ && table.header[val_pos].type == 'S' ) {
+ short short_val;
+
+ get_table_element(val_pos,row,table,&short_val,&n);
+ sprintf(buffer," %12ld = %s \n",
+ (long)short_val,des_buf);
+ sprintf(spriv->metadatastring,"%s%s",
+ spriv->metadatastring,buffer);
+ }
+
+
+ if ((strnicmp ("float",tab[j],6) ==0)) {
+ get_table_element(val_pos,row,table,&fval,&n);
+ sprintf(buffer," %12f = %s \n",fval,des_buf);
+ sprintf(spriv->metadatastring,"%s%s",spriv->metadatastring,buffer);
+ }
+
+ free(des_buf);
+ free(item_buf);
+ free(att_buf);
+ free_row(row, table);
+ } /** for k on table.nrows **/
+#ifdef TESTOPENTABLE
+ printf("close: table\n");
+#endif
+ vpf_close_table(&table);
+ } /**if muse access**/
+
+
+ } /**for j=1,j<=3**/
+
+ free(covname);
+
+ if (existtableflag==0)
+ sprintf(spriv->metadatastring,"%snodata",spriv->metadatastring);
+
+ /* ferme la chaine covinfo*/
+ sprintf(spriv->metadatastring,"%s} } } ",spriv->metadatastring);
+ free_row(rowcat, spriv->catTable);
+ } /**(i = 1; i <= spriv->catTable.nrows**/
+ /*ferme la chaine generale*/
+ sprintf(spriv->metadatastring,"%s }",spriv->metadatastring);
+ /*printf ("%s",spriv->metadatastring);*/
+ vpf_close_table(&(spriv->lhtTable));
+
+ return 1;
+}
+
+
+/* -------------------------------------------------------------------------
+ * vrf_initRegionWithDefault:
+ *
+ * preparation de la fenetre globale pour le server
+ * --------------------------------------------------------------------------
+ */
+
+int
+vrf_initRegionWithDefault(s)
+ ecs_Server *s;
+{
+ int i;
+ int found = 0;
+ char *buf1;
+ int count;
+ row_type row;
+ float buffloat;
+ register ServerPrivateData *spriv = s->priv;
+
+ /* code to get global bounding box of library is inserted here */
+
+ for (i = 1; i <= spriv->latTable.nrows && !found; ++i) {
+ row = get_row(i, spriv->latTable);
+ buf1 = justify((char*)get_table_element(1, row, spriv->latTable, NULL, &count));
+ if (stricmp(buf1,spriv->libname) == 0) {
+ found = 1;
+ get_table_element(5, row, spriv->latTable, &buffloat, &count);
+ s->globalRegion.north = buffloat;
+ get_table_element(3, row, spriv->latTable, &buffloat, &count);
+ s->globalRegion.south = buffloat;
+ get_table_element(4, row, spriv->latTable, &buffloat, &count);
+ s->globalRegion.east = buffloat;
+ get_table_element(2, row, spriv->latTable, &buffloat, &count);
+ s->globalRegion.west = buffloat;
+ }
+ free(buf1);
+ free_row(row, spriv->latTable);
+ }
+
+ if (!found) {
+ ecs_SetError(&(s->result),1,"Can't find entry in LAT table, invalid VRF library");
+ return 0;
+ }
+
+ /* If the west is higher than east, add 360 deg to east */
+
+ if (s->globalRegion.west > s->globalRegion.east)
+ s->globalRegion.east += 360.0;
+
+ s->globalRegion.ns_res = 0.01;
+ s->globalRegion.ew_res = 0.01;
+
+ dyn_SelectRegion(s,&(s->globalRegion));
+
+ return 1;
+}
+
+
+/* -------------------------------------------------------------------------
+ * vrf_initTiling:
+ *
+ * Lecture de la table de reference de toutes les tuiles
+ * --------------------------------------------------------------------------
+ */
+
+int
+vrf_initTiling(s)
+ ecs_Server *s;
+{
+ char buffer[256];
+ int i;
+ int32 fac_id,count;
+ void *dummy = NULL;
+ vpf_table_type tile_table, mbr_tile_table;
+ register ServerPrivateData *spriv = s->priv;
+
+ sprintf(buffer,"%s/tileref/tileref.aft",spriv->library);
+ if (muse_access(buffer,0)!=0) {
+ sprintf(buffer,"%s/TILEREF/TILEREF.AFT",spriv->library);
+ if (muse_access(buffer,0)!=0) {
+ spriv->isTiled = 0;
+ spriv->tile = (VRFTile *) malloc(sizeof(VRFTile));
+ spriv->tile[0].isSelected = 1;
+ spriv->tile[0].xmin = (float) s->globalRegion.south;
+ spriv->tile[0].xmax = (float) s->globalRegion.north;
+ spriv->tile[0].ymin = (float) s->globalRegion.west;
+ spriv->tile[0].ymax = (float) s->globalRegion.east;
+ spriv->tile[0].path = NULL;
+ spriv->nbTile = 1;
+ return 1;
+ }
+ }
+
+
+ spriv->isTiled = 1;
+#ifdef TESTOPENTABLE
+ printf("open tile_table:%s\n",buffer);
+#endif
+ tile_table = vpf_open_table(buffer,ram,"rb",NULL);
+
+
+ spriv->tile = (VRFTile *) malloc(sizeof(VRFTile) * tile_table.nrows);
+ if (spriv->tile == NULL) {
+#ifdef TESTOPENTABLE
+ printf("close: tile_table\n");
+#endif
+
+ vpf_close_table(&(tile_table));
+ ecs_SetError(&(s->result),1,"Can't allocate enough memory to read tile reference");
+ return 0;
+ }
+ memset( spriv->tile, 0, sizeof(VRFTile) * tile_table.nrows );
+
+ sprintf(buffer,"%s/tileref/fbr",spriv->library);
+ if (muse_access(buffer,0)!=0) {
+ sprintf(buffer,"%s/TILEREF/FBR",spriv->library);
+ if (muse_access(buffer,0)!=0) {
+#ifdef TESTOPENTABLE
+ printf("close: tile_table\n");
+#endif
+ vpf_close_table(&tile_table);
+ ecs_SetError(&(s->result),1,"Can't open tileref/fbr file");
+ return 0;
+ }
+ }
+
+#ifdef TESTOPENTABLE
+ printf("open mbr_tile_table:%s\n",buffer);
+#endif
+
+#ifdef VRF_DEBUG
+ printf("NbTile in _initTiling:%d\n",spriv->nbTile);
+#endif
+
+ mbr_tile_table = vpf_open_table(buffer,ram,"rb",NULL);
+
+ spriv->nbTile = tile_table.nrows;
+ for (i = 0; i < spriv->nbTile; ++i) {
+
+ /* Check if fac_id exist */
+
+ if (table_pos("FAC_ID", tile_table) == -1) {
+ fac_id = i+1;
+ } else {
+ named_table_element("FAC_ID",i+1,tile_table,&fac_id,&count);
+ }
+
+ spriv->tile[i].path = justify((char *) named_table_element("TILE_NAME",i+1,tile_table,dummy,&count));
+
+ named_table_element("XMIN",fac_id,mbr_tile_table,&(spriv->tile[i].xmin),&count);
+ named_table_element("XMAX",fac_id,mbr_tile_table,&(spriv->tile[i].xmax),&count);
+ named_table_element("YMIN",fac_id,mbr_tile_table,&(spriv->tile[i].ymin),&count);
+ named_table_element("YMAX",fac_id,mbr_tile_table,&(spriv->tile[i].ymax),&count);
+
+ spriv->tile[i].isSelected = 0;
+ }
+
+#ifdef TESTOPENTABLE
+ printf("close: tile_table\n");
+ printf("close: mbr_tile_table\n");
+#endif
+
+ vpf_close_table(&tile_table);
+ vpf_close_table(&mbr_tile_table);
+
+ return 1;
+}
+
+
+int vrf_IsOutsideRegion(n,s,e,w,region)
+ double n,s,e,w;
+ ecs_Region *region;
+{
+ if ((n <= region->south) ||
+ (s >= region->north) ||
+ (e <= region->west) ||
+ (w >= region->east)) {
+ return 1;
+ }
+ return 0;
+}
+
+
+void vrf_AllFClass(s,coverage)
+ ecs_Server *s;
+ char *coverage;
+{
+ vpf_table_type table;
+ row_type row;
+ unsigned int i, j, n, k, count=0;
+ char *temp;
+ char *name, *fclass, **list;
+ char ftype[8] = {'A', 'L', 'T', 'P', 'a', 'l', 't', 'p' };
+ BOOLEAN found;
+ char buffer[256];
+ register ServerPrivateData *spriv = s->priv;
+
+ /* Build path to feature class atrribute table */
+
+ sprintf(buffer,"%s/%s/fcs",spriv->library,coverage);
+ if (muse_access(buffer,0) != 0) {
+ sprintf(buffer,"%s/%s/FCS",spriv->library,coverage);
+ }
+
+ if (muse_access(buffer,0) == 0) {
+#ifdef TESTOPENTABLE
+ printf("open table:%s\n",buffer);
+#endif
+
+ table = vpf_open_table (buffer, DISK, "rb", NULL);
+ list =(char**) malloc ((table.nrows+1) * sizeof(char *));
+
+ for (i=0; i < (unsigned int) table.nrows; i++) {
+
+ row = get_row ((i+1), table);
+ fclass = (char*)get_table_element (1, row, table, NULL, &n); /* Get feature class name */
+ fclass = justify (fclass);
+
+ /* Now find the name of the feature table that matches the feature class */
+
+ name = (char*)get_table_element (2, row, table, NULL, &n);
+ temp = (char*) malloc (strlen (fclass) + 1);
+ strncpy (temp, name, strlen (fclass));
+
+ if (strcmp (fclass, temp) != 0) {
+ free (name);
+ name = (char*) get_table_element (4, row, table, NULL, &n);
+ }
+ free (temp);
+
+ /* Start the name list with the first record */
+
+ if (i == 0) {
+ list[count] = (char*) malloc ((n+1) * sizeof (char));
+ strcpy (list[count], name);
+ count++;
+ }
+
+ /* Check to see if the feature class name has already been added to the list */
+
+ found = FALSE;
+ for (j=0; j<count; j++) {
+ if (strncmp (fclass, list[j],strlen(fclass)) == 0) {
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (found == FALSE) {
+ list[count] = (char*) malloc ((n+1) * sizeof (char));
+ strcpy (list[count], name);
+ count++;
+ }
+
+ free (name);
+ free_row (row, table);
+ }
+
+#ifdef TESTOPENTABLE
+ printf("close: table\n");
+#endif
+
+ vpf_close_table (&table);
+
+ /* Add the list of Area fclass */
+
+ ecs_AddText(&(s->result)," ");
+
+ for(k=0; k < 4; ++k) {
+
+ ecs_AddText(&(s->result),"{ ");
+
+ for (i=0; i<count; i++) {
+
+ found = FALSE;
+
+ for(j = 0; j < strlen(list[i]); ++j) {
+ if (list[i][j] == '.') {
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (found) {
+
+ if (list[i][j+1] == ftype[k] || list[i][j+1] == ftype[k+4]) {
+ strncpy(buffer,list[i],j);
+ buffer[j] = 0;
+ ecs_AddText(&(s->result),buffer);
+ ecs_AddText(&(s->result)," ");
+ }
+ }
+ }
+
+ ecs_AddText(&(s->result),"} ");
+ }
+
+
+ for (i=0; i<count; i++)
+ free (list[i]);
+
+ free ((char*)list);
+ }
+
+}
+
+
+int vrf_feature_class_dictionary(s,request)
+ ecs_Server *s;
+ char *request;
+{
+ int i,k,it_pos,val_pos,des_pos,att_pos;
+ short int sintval;
+ char *line,temp[128],temp2[128],*item_buf, *att_buf, *des_buf, *tval;
+ vpf_table_type ft,table,nar,fcstable;
+ storage_type stor = disk;
+ row_type row;
+ float fval;
+ int32 ival,n;
+ char buffer[128];
+ register ServerPrivateData *spriv = s->priv;
+ char *buf1;
+ int found = 0;
+ char *featureTableName;
+ char *fclass;
+ char *coverage;
+ char *expression;
+ int32 count;
+
+ /*
+ Extract the request info
+ */
+
+ if (!vrf_parsePathValue(s,request,&fclass,&coverage,&expression))
+ return FALSE;
+
+ /*
+ Print the main informations in the dictionary
+ */
+
+ sprintf(buffer,"FEATURE CLASS: %s \nCOVERAGE : %s \n",fclass,coverage);
+ if (!ecs_SetText(&(s->result),buffer)) {
+ free(fclass); free(coverage); free(expression); return FALSE;
+ }
+
+ /*
+ Found in the FCS the tables
+ */
+
+ sprintf(buffer,"%s/%s/fcs",spriv->library,coverage);
+ if (muse_access(buffer,0) != 0) {
+ sprintf(buffer,"%s/%s/FCS",spriv->library,coverage);
+ if (muse_access(buffer,0) != 0) {
+ ecs_SetError(&(s->result),1,"Can't open the FCS table, invalid VRF coverage");
+ free(fclass); free(coverage); free(expression);
+ return FALSE;
+ }
+ }
+
+
+#ifdef TESTOPENTABLE
+ printf("open fcstable:%s\n",buffer);
+#endif
+ fcstable = vpf_open_table(buffer, disk, "rb", NULL);
+ if (fcstable.path == NULL) {
+ ecs_SetError(&(s->result),1,"Can't open the FCS table, invalid VRF coverage");
+ free(fclass); free(coverage); free(expression);
+ return FALSE;
+ }
+
+ for (i = 1; i <= fcstable.nrows && !found; ++i) {
+ row = get_row(i, fcstable);
+ buf1 = justify((char*)get_table_element(1, row, fcstable,
+ NULL, &count));
+ if (stricmp(buf1,fclass) == 0) {
+ found = 1;
+ featureTableName = justify((char *)get_table_element(2, row, fcstable, NULL, &count));
+ sprintf(buffer,"%s/%s/%s",spriv->library,coverage,featureTableName);
+ free(featureTableName);
+ }
+ free(buf1);
+ free_row(row, fcstable);
+ }
+
+#ifdef TESTOPENTABLE
+ printf("close: fcstable\n");
+#endif
+
+ vpf_close_table(&fcstable);
+
+ /*
+ For each attribute. Get all the informations.
+ */
+
+#ifdef TESTOPENTABLE
+ printf("open ft:%s\n",buffer);
+#endif
+
+ ft = vpf_open_table(buffer,stor,"rb",NULL);
+
+ sprintf(buffer,"ATTRIBUTES:\n");
+ if (!ecs_AddText(&(s->result),buffer)) {
+ free(fclass); free(coverage); free(expression); return FALSE;
+ }
+
+ for(i=0;i<ft.nfields;i++) {
+ sprintf(buffer," %s - %s \n",ft.header[i].name,ft.header[i].description);
+ if (!ecs_AddText(&(s->result),buffer)) {
+ free(fclass); free(coverage); free(expression); return FALSE;
+ }
+
+ if(ft.header[i].vdt[0] != '\0')
+ /** create table name **/
+ {
+ sprintf(temp,"%s\\%s",spriv->library,coverage);
+
+ /** add to the path the new table name **/
+ strcpy(temp2,temp);
+ strcat(temp2,"\\");
+ strcat(temp2,ft.header[i].vdt);
+ if(muse_access(temp2,0) == 0) {
+#ifdef TESTOPENTABLE
+ printf("open table:%s\n",temp2);
+#endif
+ table = vpf_open_table(temp2,stor,"rb",NULL);
+ it_pos = table_pos("TABLE",table);
+ val_pos = table_pos("VALUE",table);
+ des_pos = table_pos("DESCRIPTION",table);
+ att_pos = table_pos("ATTRIBUTE",table);
+
+ for(k=1;k<=table.nrows;k++) {
+ if (stor == disk)
+ row = read_next_row(table);
+ else
+ row = get_row(k,table);
+ item_buf = (char *)get_table_element( it_pos,row,table,NULL,&n);
+ rightjust(item_buf);
+ if (strlen(item_buf) > strlen(fclass))
+ item_buf[strlen(fclass)] = '\0';
+
+ att_buf = (char *)get_table_element(att_pos,row,table,NULL,&n);
+ rightjust(att_buf);
+ if(stricmp(item_buf,fclass) == 0 &&
+ stricmp(att_buf,ft.header[i].name) == 0) {
+ des_buf = (char *)get_table_element(des_pos,row,table,NULL,&n);
+ switch (ft.header[i].type) {
+ case 'T':
+ tval = (char *)get_table_element(val_pos,row,table,NULL,&n);
+ sprintf(buffer," %s = %s \n",tval,des_buf);
+ if (!ecs_AddText(&(s->result),buffer)) {
+ free(fclass); free(coverage); free(expression); return FALSE;
+ }
+ free(tval);break;
+ case 'I':
+ get_table_element(val_pos,row,table,&ival,&n);
+ sprintf(buffer," %12ld = %s \n",ival,des_buf);
+ if (!ecs_AddText(&(s->result),buffer)) {
+ free(fclass); free(coverage); free(expression); return FALSE;
+ }
+ break;
+ case 'S':
+ get_table_element(val_pos,row,table,&sintval,&n);
+ sprintf(buffer," %d = %s \n",sintval,des_buf);
+ if (!ecs_AddText(&(s->result),buffer)) {
+ free(fclass); free(coverage); free(expression); return FALSE;
+ }
+ break;
+ case 'F':
+ get_table_element(val_pos,row,table,&fval,&n);
+ sprintf(buffer," %12f = %s \n",fval,des_buf);
+ if (!ecs_AddText(&(s->result),buffer)) {
+ free(fclass); free(coverage); free(expression); return FALSE;
+ }
+ break;
+ } /** switch **/
+ free(des_buf);
+ } /** if strcmp **/
+
+ free(item_buf);
+ free(att_buf);
+ free_row(row,table);
+ } /** for k on table.nrows **/
+#ifdef TESTOPENTABLE
+ printf("close: table\n");
+#endif
+ vpf_close_table(&table);
+ } /** if access **/
+ } /** if there is vdt **/
+ } /** for fields **/
+
+ /** get information from narrative file if it exists **/
+ if(ft.narrative[0] != '\0') {
+ sprintf(temp,"%s%s",ft.path,ft.narrative);
+ if (muse_access(temp,0)==0) {
+ sprintf(buffer,"\n\n");
+ if (!ecs_AddText(&(s->result),buffer)) {
+ free(fclass); free(coverage); free(expression); return FALSE;
+ }
+#ifdef TESTOPENTABLE
+ printf("open nar:%s\n",temp);
+#endif
+ nar = vpf_open_table(temp,disk,"rb",NULL);
+ for (i=1;i<=nar.nrows;i++) {
+ row = read_next_row(nar);
+ line = (char *)get_table_element(1,row,nar,NULL,&n);
+ rightjust(line);
+ sprintf(buffer,"%s\n",line);
+ if (!ecs_AddText(&(s->result),buffer)) {
+ free(fclass); free(coverage); free(expression); return FALSE;
+ }
+ free(line);
+ free_row(row,nar);
+ }
+
+#ifdef TESTOPENTABLE
+ printf("close: nar\n");
+#endif
+ vpf_close_table(&nar);
+ }
+ }
+
+ /** clean up **/
+#ifdef TESTOPENTABLE
+ printf("close: ft\n");
+#endif
+ vpf_close_table(&ft);
+
+ free(fclass);
+ free(coverage);
+ free(expression);
+
+
+ return 1;
+}
+
+static void vrf_build_layer_capabilities( ecs_Server *s, const char *coverage,
+ const char *name )
+
+{
+ char line[512];
+ char short_name[128];
+ const char *family;
+ int i;
+
+/* -------------------------------------------------------------------- */
+/* Establish the family of this feature type, and the shortened name.*/
+/* -------------------------------------------------------------------- */
+ for( i = 0; name[i] != '.' && name[i] != '\0'; i++ ) {}
+
+ if( strncmp(name+i,".A",2) == 0 || strncmp(name+i,".a",2) == 0 )
+ family = "Area";
+ else if( strncmp(name+i,".L",2) == 0 || strncmp(name+i,".l",2) == 0 )
+ family = "Line";
+ else if( strncmp(name+i,".p",2) == 0 || strncmp(name+i,".p",2) == 0 )
+ family = "Point";
+ else if( strncmp(name+i,".T",2) == 0 || strncmp(name+i,".t",2) == 0 )
+ family = "Text";
+ else
+ {
+ /* It isn't a geographic feature type, skip it */
+ return;
+ }
+
+ strncpy( short_name, name, i );
+ short_name[i] = '\0';
+
+/* -------------------------------------------------------------------- */
+/* Create the various entries. */
+/* -------------------------------------------------------------------- */
+ ecs_AddText(&(s->result),
+ " <FeatureType>\n");
+
+ sprintf( line,
+ " <Name>%s@%s(*)</Name>\n",
+ short_name, coverage );
+ ecs_AddText(&(s->result), line);
+
+ ecs_AddText(&(s->result),
+ " <SRS>PROJ4:+proj=longlat +datum=nad83</SRS>\n" );
+
+ sprintf( line,
+ " <Family>%s</Family>\n",
+ family );
+ ecs_AddText(&(s->result), line);
+
+ sprintf( line,
+ " <QueryExpression qe_prefix=\"%s@%s(\"\n"
+ " qe_suffix=\")\"\n"
+ " qe_format=\"restricted_where\" />\n",
+ short_name, coverage );
+ ecs_AddText(&(s->result), line);
+
+ sprintf(line,
+ " <LatLonBoundingBox minx=\"%.9f\" miny=\"%.9f\"\n"
+ " maxx=\"%.9f\" maxy=\"%.9f\" />\n",
+ s->globalRegion.west, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.north );
+
+ ecs_AddText(&(s->result),line);
+
+ sprintf(line,
+ " <BoundingBox minx=\"%.9f\" miny=\"%.9f\"\n"
+ " maxx=\"%.9f\" maxy=\"%.9f\"\n"
+ " resx=\"%.9f\" resy=\"%.9f\" />\n",
+ s->globalRegion.west, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.north,
+ s->globalRegion.ew_res, s->globalRegion.ns_res );
+ ecs_AddText(&(s->result),line);
+
+ ecs_AddText(&(s->result),
+ " </FeatureType>\n");
+}
+
+/* based on vrf_AllFClass() */
+
+static void
+vrf_build_coverage_capabilities( ecs_Server *s, const char *coverage)
+
+{
+ vpf_table_type table;
+ row_type row;
+ unsigned int i, n;
+ char *name, *fclass;
+ char buffer[256];
+ register ServerPrivateData *spriv = s->priv;
+
+ /* Build path to feature class atrribute table */
+
+ sprintf(buffer,"%s/%s/fcs",spriv->library,coverage);
+ if (muse_access(buffer,0) != 0) {
+ sprintf(buffer,"%s/%s/FCS",spriv->library,coverage);
+ }
+
+ if (muse_access(buffer,0) == 0) {
+ char **list;
+ int count = 0, j;
+
+ table = vpf_open_table (buffer, DISK, "rb", NULL);
+
+ list = (char**) malloc ((table.nrows+1) * sizeof(char *));
+
+ for (i=0; i < (unsigned int) table.nrows; i++) {
+
+ row = get_row ((i+1), table);
+ fclass = (char*)get_table_element (1, row, table, NULL, &n); /* Get feature class name */
+ fclass = justify (fclass);
+
+ /* Now find the name of the feature table that matches the feature class */
+
+ name = (char*)get_table_element (2, row, table, NULL, &n);
+ if (strncmp (fclass, name, strlen(fclass)) != 0) {
+ free (name);
+ name = (char*) get_table_element (4, row, table, NULL, &n);
+ }
+ free( fclass );
+
+ /* Have we already processed this name? */
+ for( j = 0; j < count && strcmp(list[j],name) != 0; j++ ) {}
+
+ if( j == count )
+ {
+ vrf_build_layer_capabilities( s, coverage, name );
+ list[count++] = name;
+ }
+ else
+ free( name );
+
+ free_row (row, table);
+ }
+
+ vpf_close_table (&table);
+
+ for( i = 0; i < count; i++ )
+ free( list[i] );
+
+ free( list );
+ }
+}
+
+int vrf_build_capabilities(ecs_Server *s, const char *request)
+{
+ ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+
+ ecs_SetText(&(s->result), "" );
+
+ ecs_AddText(&(s->result),
+ "<?xml version=\"1.0\" ?>\n"
+ "<OGDI_Capabilities version=\"3.1\">\n"
+ " <Capability>\n"
+ " <Extension>ogdi_unique_identity</Extension>\n"
+ " </Capability>\n" );
+
+ if( strcmp(request,"ogdi_server_capabilities") != 0 )
+ {
+ int i;
+
+ ecs_AddText(&(s->result),
+ " <FeatureTypeList>\n" );
+
+ for (i = 1; i <= spriv->catTable.nrows; ++i)
+ {
+ row_type row;
+ char *coverage;
+ char *description;
+ int count;
+
+ row = get_row(i, spriv->catTable);
+ coverage = justify( (char *) get_table_element(1, row, spriv->catTable, NULL, &count));
+ description = justify( (char *) get_table_element(2, row, spriv->catTable, NULL, &count));
+
+ free_row(row, spriv->catTable);
+
+ ecs_AddText(&(s->result),
+ " <FeatureTypeList>\n" );
+
+ ecs_AddText(&(s->result)," <Name>" );
+ ecs_AddText(&(s->result),coverage);
+ ecs_AddText(&(s->result),"</Name>\n" );
+
+ ecs_AddText(&(s->result)," <Title>" );
+ ecs_AddText(&(s->result),description);
+ ecs_AddText(&(s->result),"</Title>\n" );
+
+ vrf_build_coverage_capabilities(s,coverage);
+
+ free(coverage);
+ free(description);
+
+ ecs_AddText(&(s->result),
+ " </FeatureTypeList>\n" );
+ }
+
+ ecs_AddText(&(s->result),
+ " </FeatureTypeList>\n" );
+ }
+
+ ecs_AddText(&(s->result),
+ "</OGDI_Capabilities>\n" );
+ return TRUE;
+}
+
+
+#ifndef _WINDOWS
+
+/*
+int stricmp(a,b)
+ const char *a;
+ const char *b;
+{
+ return strcasecmp(a,b);
+}
+
+int _stricmp(a,b)
+ const char *a;
+ const char *b;
+{
+ return strcasecmp(a,b);
+}
+*/
+
+#endif
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,961 @@
+/******************************************************************************
+ *
+ * Component: OGDI VRF Driver
+ * Purpose: Implementation of the dyn_* entry points to the VRF driver.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: vrf.c,v $
+ * Revision 1.18 2007/02/12 21:01:48 cbalint
+ * Fix win32 target. It build and works now. (tested with VC6)
+ *
+ * Revision 1.17 2007/02/12 15:52:57 cbalint
+ *
+ * Preliminary cleanup.
+ * Get rif of unitialized variables, and unused ones.
+ *
+ * Revision 1.16 2006/05/05 19:10:54 warmerda
+ * VRF fix when doing feature merging with index sizing (ie. with DNC 13 dataset)
+ *
+ * Revision 1.15 2004/02/19 06:56:43 warmerda
+ * fixed serious bug in releaseAllLayers() with multiple layers
+ *
+ * Revision 1.14 2004/02/19 05:59:22 warmerda
+ * Removed temporary debug messages.
+ *
+ * Revision 1.13 2004/02/18 21:49:18 warmerda
+ * Fixed typo in last fix.
+ *
+ * Revision 1.12 2004/02/18 21:33:18 warmerda
+ * free regex memory
+ *
+ * Revision 1.11 2001/08/16 20:40:34 warmerda
+ * applied VITD fixes - merge primitive lines into a feature
+ *
+ * Revision 1.10 2001/06/29 19:16:30 warmerda
+ * fixed memory leak if FCS not found
+ *
+ * Revision 1.9 2001/06/21 20:30:15 warmerda
+ * added ECS_CVSID
+ *
+ * Revision 1.8 2001/06/20 21:49:31 warmerda
+ * added improved query support (swq)
+ *
+ * Revision 1.7 2001/06/13 17:33:59 warmerda
+ * upgraded source headers
+ *
+ */
+
+#include "ecs.h"
+#include "vrf.h"
+#include "datadict.h"
+
+ECS_CVSID("$Id: vrf.c,v 1.18 2007/02/12 21:01:48 cbalint Exp $");
+
+/* layer oriented functions are keeped in data structure to simplify code */
+
+LayerMethod layerMethod[11] = {
+ /* 0 */ { NULL, NULL, NULL,NULL },
+ /* Area */ { _getNextObjectArea, _getObjectArea, _getObjectIdArea, _selectTileArea },
+ /* Line */ { _getNextObjectLine, _getObjectLine, _getObjectIdLine, _selectTileLine },
+ /* Point */ { _getNextObjectPoint, _getObjectPoint, _getObjectIdPoint, _selectTilePoint },
+ /* Matrix */ { NULL, NULL, NULL, NULL },
+ /* Image */ { NULL, NULL, NULL, NULL },
+ /* Text */ { _getNextObjectText, _getObjectText, _getObjectIdText, _selectTileText },
+ /* Edge */ { NULL, NULL, NULL, NULL },
+ /* Face */ { NULL, NULL, NULL, NULL },
+ /* Node */ { NULL, NULL, NULL, NULL },
+ /* Ring */ { NULL, NULL, NULL, NULL }
+};
+
+/* ----------------------------------------------------------------------
+ * _dyn_CreateServer:
+ *
+ * Creation of a new GRASS server
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_CreateServer(s,Request)
+ ecs_Server *s;
+ char *Request;
+{
+ char buffer[256];
+ char *ptr;
+ int i;
+ register ServerPrivateData *spriv;
+
+ (void) Request;
+
+#ifdef VRF_DEBUG
+ printf("dyn_CreateServer\n");
+#endif
+
+ spriv = s->priv = (void *) calloc(1,sizeof(ServerPrivateData));
+ if (s->priv == NULL) {
+ ecs_SetError(&(s->result), 1, "Could not create VRF server, not enough memory");
+ return &(s->result);
+ }
+
+ spriv->nbTile = 1;
+ spriv->tile = NULL;
+ spriv->isTiled = 0;
+ spriv->isMetaLoad = FALSE;
+
+ /* Check if s->pathname is valid */
+
+ if (strlen(s->pathname) == 0) {
+ ecs_SetError(&(s->result), 1, "Could not create VRF server, invalid URL");
+ return &(s->result);
+ }
+
+ /* extract full library pathname from s->pathname */
+
+ if (s->pathname[2] == ':') { /* if it contain something like /e:/cdrom/dcw, strip first slash */
+ strcpy(spriv->library,&(s->pathname[1]));
+ } else {
+ strcpy(spriv->library,s->pathname);
+ }
+
+ /* extract full database pathname and library short name from s->pathname */
+
+ for(i = strlen(spriv->library) - 1; spriv->library[i] != '/'; --i);
+ strncpy(spriv->database,spriv->library,i);
+ spriv->database[i] = 0;
+ strcpy(spriv->libname,&(spriv->library[i+1]));
+
+ /* verify if this is really a VRF database */
+
+ if (!vrf_verifyCATFile(s)) {
+ return &(s->result);
+ }
+
+ /* Is it a DCW database (in the path) */
+
+ spriv->isDCW = FALSE;
+ for (i=0;i<(int) (strlen(s->pathname)-3);i++) {
+ ptr = &(s->pathname[i]);
+ if (strnicmp(ptr,"dcw",3) == 0) {
+ spriv->isDCW = TRUE;
+ break;
+ }
+ }
+
+ /* open schema files */
+
+ sprintf(buffer,"%s/lat",spriv->database);
+ if (muse_access(buffer,0) != 0) {
+ sprintf(buffer,"%s/LAT",spriv->database);
+ }
+#ifdef TESTOPENTABLE
+ printf("open spriv->latTable:%s\n",buffer);
+#endif
+
+ spriv->latTable = vpf_open_table(buffer, disk, "rb", NULL);
+
+ if (spriv->latTable.fp == NULL) {
+ ecs_SetError(&(s->result),1,"Unable to open the LAT table");
+ return &(s->result);
+ }
+
+ /* initialize the server globalRegion with the one found in the LAT file */
+
+ if (!vrf_initRegionWithDefault(s)) {
+ return &(s->result);
+ }
+
+ /* read all tile reference */
+
+ if (!vrf_initTiling(s)) {
+ return &(s->result);
+ }
+
+ s->nblayer = 0; /* no layer selected so far */
+ s->currentLayer = -1;
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_DestroyServer:
+ *
+ * Destruction of this GRASS server
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_DestroyServer(s)
+ ecs_Server *s;
+{
+ register ServerPrivateData *spriv = s->priv;
+
+#ifdef VRF_DEBUG
+ printf("dyn_DestroyServer\n");
+#endif
+
+ /* Release all layer */
+
+ vrf_releaseAllLayers(s);
+
+ /* if dynamic mapset than remove directory contents */
+
+#ifdef TESTOPENTABLE
+ printf("close: spriv->catTable\n");
+ printf("close: spriv->latTable\n");
+#endif
+
+ vpf_close_table(&(spriv->catTable));
+ vpf_close_table(&(spriv->latTable));
+
+ /* DAP 6/19/97 */
+ if (spriv->tile != NULL) {
+ int iTile;
+
+ for( iTile=0; iTile < spriv->nbTile; iTile++ )
+ {
+ if( spriv->tile[iTile].path != NULL )
+ free( spriv->tile[iTile].path );
+ }
+ free(spriv->tile);
+ spriv->tile = NULL;
+ }
+
+ s->currentLayer = -1;
+ s->nblayer = 0; /* no layer selected so far */
+
+ free(spriv);
+
+ vrf_freePathRegex();
+ vrf_free_ObjAttributeBuffer();
+
+ ecs_SetSuccess(&(s->result));
+
+ return &(s->result);
+
+}
+
+/*
+********************************************************************
+
+FUNCTION_INFORMATION
+
+NAME
+ dyn_SelectLayer
+
+DESCRIPTION
+ Select a VRF layer
+END_DESCRIPTION
+
+PARAMETERS
+ INPUT
+ ecs_Server *s: Server info given by OGDI API
+END_PARAMETERS
+
+END_FUNCTION_INFORMATION
+
+PSEUDO-CODE
+
+Check if a layer exist with ecs_GetLayer. If a layer exist
+Begin
+
+ Close the current layer table if it exist
+ The current layer is now the layer returned by ecs_GetLayer
+ The index of this layer is set to 0
+ Return a success message.
+
+End
+
+Close the current layer table if it exist
+
+Set a new layer in the layer structure with ecs_SetLayer.
+
+Allocate the memory needed to hold private infor about the new layer
+
+Decompose sel into library, coverage, feature class and
+expression with vrf_parsePath.
+
+Obtain the feature and primitive table file name from the
+FCS file with vrf_getFileNameFromFcs
+
+Open the feature table. If the feature table don`t open correctly,
+return an error message.
+
+If a joint table exist for this feature table, open it. If the
+join table don't open correctly, return an error message.
+
+Process the expression and create a table of selected features.
+
+Set the current layer with the current layer.
+
+Set the index of the current layer to 0 to force the object extract
+to start from the first object.
+
+Calculate the number of objects. If there is a join table, use the
+length of the join table. Else, use the lenght of the feature table.
+
+Define the current tile id to -1 to indicate to the driver there is
+no tile already defined.
+
+Allocate and initialize the VPF index with the number of objects.
+Initialize the contain of this table with -1 for each argument.
+
+Return a success message
+
+********************************************************************
+*/
+
+ecs_Result *dyn_SelectLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ char buffer[256];
+ int layer,i, index_size;
+ register ServerPrivateData *spriv = s->priv;
+ register LayerPrivateData *lpriv;
+
+#ifdef VRF_DEBUG
+ printf("dyn_SelectLayer\n");
+#endif
+
+ /* first, try to find an existing layer with same request and family */
+
+ if ((layer = ecs_GetLayer(s,sel)) != -1) {
+
+ if (s->currentLayer != -1)
+ _closeLayerTable(s,&(s->layer[s->currentLayer]));
+
+ /* Close the join table for the previous layer */
+
+ lpriv = (LayerPrivateData *) s->layer[s->currentLayer].priv;
+ if (lpriv->joinTableName != NULL) {
+
+#ifdef TESTOPENTABLE
+ printf("close lpriv->joinTable\n");
+#endif
+
+ if (lpriv->joinTable.fp == NULL)
+ vpf_close_table(&(lpriv->joinTable));
+ }
+
+
+ /* if it already exists than assign currentLayer and set index to 0 to force rewind */
+
+ s->currentLayer = layer;
+ s->layer[layer].index = 0;
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+
+ /* Open the current join table */
+
+ if (lpriv->joinTableName != NULL) {
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,lpriv->joinTableName);
+ if (muse_access(buffer,0) == 0 ) {
+#ifdef TESTOPENTABLE
+ printf("open lpriv->joinTable:%s\n",buffer);
+#endif
+ lpriv->joinTable = vpf_open_table(buffer,disk,"rb",NULL);
+ if (lpriv->joinTable.fp == NULL) {
+ ecs_SetError(&(s->result),1,"Unable to open the join table");
+ vpf_close_table(lpriv->featureTable);
+ free(s->layer[layer].priv);
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+ }
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+ }
+
+ if (s->currentLayer != -1)
+ _closeLayerTable(s,&(s->layer[s->currentLayer]));
+
+ /* it did not exists so we are going to try to create it */
+
+ if ((layer = ecs_SetLayer(s,sel)) == -1) {
+ return &(s->result);
+ }
+
+ /* allocate memory to hold private info about this new layer */
+
+ if ((s->layer[layer].priv = (void *) malloc(sizeof(LayerPrivateData))) == NULL) {
+ ecs_SetError(&(s->result),1,"Not enough memory to allocate layer private data");
+ return &(s->result);
+ }
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+ lpriv->index = NULL;
+ lpriv->coverage = NULL;
+ lpriv->fclass = NULL;
+ lpriv->expression = NULL;
+ lpriv->featureTableName = NULL;
+ lpriv->featureTablePrimIdName = NULL;
+ lpriv->joinTableName = NULL;
+ lpriv->joinTableForeignKeyName = NULL;
+ lpriv->joinTableFeatureIdName = NULL;
+ lpriv->primitiveTableName = NULL;
+ lpriv->isTiled = spriv->isTiled;
+
+ /* decompose sel into library, coverage, feature class and expression */
+
+ if (!vrf_parsePath(s,lpriv,sel)) {
+ free(s->layer[layer].priv);
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+
+ if (stricmp(lpriv->coverage,"tileref") == 0 ||
+ stricmp(lpriv->coverage,"gazette") == 0 ||
+ stricmp(lpriv->coverage,"libref") == 0) {
+ lpriv->isTiled = 0;
+ }
+
+ /* obtain the feature and primitive table file name from the FCS file */
+
+
+ if (!vrf_getFileNameFromFcs(s,lpriv)) {
+ free( lpriv->coverage );
+ free( lpriv->fclass );
+ free( lpriv->expression );
+ free(s->layer[layer].priv);
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+
+ /* open layer */
+
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,lpriv->featureTableName);
+ if (muse_access(buffer,0) == 0 ) {
+#ifdef TESTOPENTABLE
+ printf("open spriv->featureTable:%s\n",buffer);
+#endif
+
+ lpriv->featureTable = vpf_open_table(buffer,disk,"rb",NULL);
+ if (lpriv->featureTable.fp == NULL) {
+ ecs_SetError(&(s->result),1,"Unable to open the feature table");
+ free(s->layer[layer].priv);
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+
+ if (lpriv->joinTableName != NULL) {
+ sprintf(buffer,"%s/%s/%s",spriv->library,lpriv->coverage,lpriv->joinTableName);
+ if (muse_access(buffer,0) == 0 ) {
+#ifdef TESTOPENTABLE
+ printf("open lpriv->joinTable:%s\n",buffer);
+#endif
+ lpriv->joinTable = vpf_open_table(buffer,disk,"rb",NULL);
+ if (lpriv->joinTable.fp == NULL) {
+ ecs_SetError(&(s->result),1,"Unable to open the join table");
+ vpf_close_table(lpriv->featureTable);
+ free(s->layer[layer].priv);
+ ecs_FreeLayer(s,layer);
+ return &(s->result);
+ }
+ }
+
+ /*
+ Check if Tile_ID is defined in the join table for tiled datasets, if
+ not, it's an attribute join.
+
+ There is no apparent way of identifying whether this is an
+ attribute join or not for non-tiled datasets such as VITD which don't
+ have TILE_ID, but do have feature joins so we assume in this case that
+ it is a feature join.
+ */
+#ifdef TESTOPENTABLE
+ printf("close lpriv->joinTable:%s\n");
+#endif
+
+ if (table_pos("TILE_ID",lpriv->joinTable) == -1
+ && lpriv->isTiled ) {
+ vpf_close_table(&(lpriv->joinTable));
+ free(lpriv->joinTableName);
+ lpriv->joinTableName = NULL;
+ }
+ }
+
+ } else {
+ free(s->layer[layer].priv);
+ ecs_FreeLayer(s,layer);
+ ecs_SetError(&(s->result),1,"Can't open this feature class");
+ return &(s->result);
+ }
+
+
+ lpriv->feature_rows = query_table2(lpriv->expression,lpriv->featureTable);
+
+ /* process result */
+
+ s->currentLayer = layer;
+ s->layer[layer].index = 0;
+
+ lpriv->mergeFeatures = FALSE;
+#ifdef VRF_LINE_JOIN_HACK
+ if( s->layer[layer].sel.F == Line && lpriv->joinTableName != NULL )
+ lpriv->mergeFeatures = TRUE;
+#endif
+
+ if (lpriv->joinTableName != NULL && !lpriv->mergeFeatures)
+ s->layer[layer].nbfeature = lpriv->joinTable.nrows;
+ else
+ s->layer[layer].nbfeature = lpriv->featureTable.nrows;
+
+ lpriv->current_tileid = -1;
+
+ if( lpriv->joinTableName != NULL )
+ index_size = lpriv->joinTable.nrows + 1;
+ else
+ index_size = lpriv->featureTable.nrows + 1;
+
+ lpriv->index = (VRFIndex *) malloc(sizeof(VRFIndex) * index_size);
+
+ for (i=0; i < index_size; ++i) {
+ lpriv->index[i].prim_id = -1;
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * dyn_ReleaseLayer:
+ *
+ * deselect a layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_ReleaseLayer(s,sel)
+ ecs_Server *s;
+ ecs_LayerSelection *sel;
+{
+ int layer;
+ char buffer[128];
+ register LayerPrivateData *lpriv;
+
+#ifdef VRF_DEBUG
+ printf("dyn_ReleaseLayer\n");
+#endif
+
+ /* first, try to find an existing layer with same request and family */
+
+ if ((layer = ecs_GetLayer(s,sel)) == -1) {
+ sprintf(buffer,"Invalid layer %s",sel->Select);
+ ecs_SetError(&(s->result),1,buffer);
+ return &(s->result);
+ }
+
+ lpriv = (LayerPrivateData *) s->layer[layer].priv;
+
+ if (s->currentLayer != -1) {
+ _closeLayerTable(s,&(s->layer[s->currentLayer]));
+ s->currentLayer = -1;
+ }
+
+#ifdef TESTOPENTABLE
+ printf("close: spriv->featureTable\n");
+ printf("close: spriv->fcsTable\n");
+#endif
+
+ if (lpriv->joinTableName != NULL) {
+#ifdef TESTOPENTABLE
+ printf("close lpriv->joinTable:%s\n");
+#endif
+ vpf_close_table(&(lpriv->joinTable));
+ }
+ vpf_close_table(&(lpriv->featureTable));
+ vpf_close_table(&(lpriv->fcsTable));
+
+ set_nuke(&(lpriv->feature_rows));
+
+ if (lpriv->joinTableFeatureIdName) {
+ free(lpriv->joinTableFeatureIdName);
+ lpriv->joinTableFeatureIdName = NULL;
+ }
+ if (lpriv->joinTableForeignKeyName) {
+ free(lpriv->joinTableForeignKeyName);
+ lpriv->joinTableForeignKeyName = NULL;
+ }
+ if (lpriv->joinTableName) {
+ free(lpriv->joinTableName);
+ lpriv->joinTableName = NULL;
+ }
+ free(lpriv->coverage);
+ free(lpriv->fclass);
+ free(lpriv->expression);
+ free(lpriv->featureTableName);
+ free(lpriv->primitiveTableName);
+ free(lpriv->featureTablePrimIdName);
+ free(lpriv->index);
+ free(lpriv);
+
+ ecs_FreeLayer(s,layer);
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* deselect all layer */
+
+void
+vrf_releaseAllLayers(s)
+ ecs_Server *s;
+{
+ int i;
+
+ /* count down since nblayer will change as we go */
+ for (i = s->nblayer-1; i >= 0; i--)
+ dyn_ReleaseLayer(s,&(s->layer[i].sel));
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_SelectRegion:
+ *
+ * selection current geographic region.
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_SelectRegion(s,gr)
+ ecs_Server *s;
+ ecs_Region *gr;
+{
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+ int i;
+
+#ifdef VRF_DEBUG
+ printf("dyn_SelectRegion\n");
+#endif
+
+ s->currentRegion.north = gr->north;
+ s->currentRegion.south = gr->south;
+ s->currentRegion.east = gr->east;
+ s->currentRegion.west = gr->west;
+ s->currentRegion.ns_res = gr->ns_res;
+ s->currentRegion.ew_res = gr->ew_res;
+
+ /* reset currentLayer index to 0 to force rewind */
+
+ if (s->currentLayer != -1) {
+ s->layer[s->currentLayer].index = 0;
+ }
+
+#ifdef VRF_DEBUG
+ printf("nbtile: %d\n",spriv->nbTile);
+#endif
+
+
+ for(i = 0; i < spriv->nbTile; ++i) {
+ if (spriv->isTiled) {
+ if (vrf_IsOutsideRegion(spriv->tile[i].ymax,
+ spriv->tile[i].ymin,
+ spriv->tile[i].xmax,
+ spriv->tile[i].xmin,
+ &(s->currentRegion))) {
+ spriv->tile[i].isSelected = 0;
+ } else {
+ spriv->tile[i].isSelected = 1;
+ }
+ }
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetDictionary:
+ *
+ * return the itcl_class object
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetDictionary(s)
+ ecs_Server *s;
+{
+
+ ecs_SetText(&(s->result),datadict);
+ ecs_SetSuccess(&(s->result));
+
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetAttributesFormat:
+ *
+ * return the attribute format of the currently selected layer
+ * ----------------------------------------------------------------------
+ */
+
+
+
+ecs_Result *dyn_GetAttributesFormat(s)
+ ecs_Server *s;
+{
+ int i;
+ register LayerPrivateData *lpriv;
+ ecs_AttributeFormat type=0;
+ int length=0;
+ int precision=0;
+
+ lpriv = (LayerPrivateData *) s->layer[s->currentLayer].priv;
+
+ ecs_SetObjAttributeFormat(&(s->result));
+
+ /* the code to retreive attribute format of a specific layer is inserted here */
+
+ for(i = 0; i < lpriv->featureTable.nfields; ++i) {
+
+ switch(lpriv->featureTable.header[i].type) {
+
+ case 'T':
+ length = lpriv->featureTable.header[i].count;
+ if (length == -1) {
+ type = Varchar;
+ length = 0;
+ }
+ else
+ type = Char;
+ precision = 0;
+ break;
+
+ case 'F':
+ type = Float;
+ length = 15;
+ precision = 6;
+ break;
+
+ case 'R':
+ type = Double;
+ length = 25;
+ precision = 12;
+ break;
+
+ case 'D':
+ type = Char;
+ length = 20;
+ precision = 0;
+ break;
+
+ case 'S':
+ type = Smallint;
+ length = 5;
+ precision = 0;
+ break;
+
+ case 'I':
+ type = Integer;
+ length = 10;
+ precision = 0;
+ break;
+
+ }
+
+ ecs_AddAttributeFormat(&(s->result), lpriv->featureTable.header[i].name, type, length, precision, 0);
+ }
+
+
+ ecs_SetSuccess(&(s->result));
+
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetNextObject:
+ *
+ * return the next object for the current layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetNextObject(s)
+ ecs_Server *s;
+{
+
+ (layerMethod[s->layer[s->currentLayer].sel.F].getNextObject)(s,&(s->layer[s->currentLayer]));
+ return &(s->result);
+
+}
+
+
+/* ----------------------------------------------------------------------
+ * dyn_GetObject:
+ *
+ * return an object for the current layer
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObject(s,Id)
+ ecs_Server *s;
+ char *Id;
+{
+
+ (layerMethod[s->layer[s->currentLayer].sel.F].getObject)(s,&(s->layer[s->currentLayer]),Id);
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * dyn_GetObjectIdFromCoord:
+ *
+ * return the object id sitting at (or near) to a coordinate
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetObjectIdFromCoord(s,coord)
+ ecs_Server *s;
+ ecs_Coordinate *coord;
+{
+ (layerMethod[s->layer[s->currentLayer].sel.F].getObjectIdFromCoord)(s,&(s->layer[s->currentLayer]),coord);
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_UpdateDictionary:
+ *
+ * Return the content of this location data dictionary in a Tcl List
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_UpdateDictionary(s,arg)
+ ecs_Server *s;
+ char *arg;
+{
+ int i,count;
+ row_type row;
+ char *coverage;
+ char *description;
+ register ServerPrivateData *spriv = (ServerPrivateData *) s->priv;
+
+ /* Get all the metadata and store them in a string*/
+
+ if (spriv->isMetaLoad == FALSE) {
+ if (!vrf_GetMetadata(s)) {
+ return &(s->result);
+ }
+ spriv->isMetaLoad = TRUE;
+ }
+
+ if ((arg == NULL) || (strcmp(arg,"") == 0))
+ {
+
+ ecs_SetText(&(s->result)," ");
+ ecs_AddText(&(s->result),spriv->metadatastring);
+ }
+ else if (strcmp(arg,"ogdi_capabilities") == 0
+ || strcmp(arg,"ogdi_server_capabilities") == 0 )
+ {
+ if( !vrf_build_capabilities( s, arg ) )
+ return &(s->result);
+ }
+ else if ((strncmp(arg,"cat_list",8)) == 0)
+ {
+ ecs_SetText(&(s->result)," ");
+ for (i = 1; i <= spriv->catTable.nrows; ++i)
+ {
+
+
+ row = get_row(i, spriv->catTable);
+ coverage = justify( (char *) get_table_element(1, row, spriv->catTable, NULL, &count));
+ description = justify( (char *) get_table_element(2, row, spriv->catTable, NULL, &count));
+
+ free_row(row, spriv->catTable);
+ /* if (strcmp(coverage,"libref") != 0 && strcmp(coverage,"tileref") != 0) {*/
+ ecs_AddText(&(s->result),"{ ");
+ ecs_AddText(&(s->result),coverage);
+ ecs_AddText(&(s->result)," {");
+ ecs_AddText(&(s->result),description);
+ ecs_AddText(&(s->result),"}");
+ vrf_AllFClass(s,coverage);
+ ecs_AddText(&(s->result),"} ");
+ /* }*/
+ free(coverage);
+ free(description);
+ }
+ } else {
+ if (!vrf_feature_class_dictionary(s,arg))
+ return &(s->result);
+ }
+
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+
+}
+
+
+
+/* ----------------------------------------------------------------------
+ * _dyn_GetServerProjection:
+ *
+ * Return this server cartographic projection
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_GetServerProjection(s)
+ ecs_Server *s;
+{
+ ecs_SetText(&(s->result), "+proj=longlat +datum=nad83");
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+
+/* ----------------------------------------------------------------------
+ * _dyn_GetGlobalBound:
+ *
+ * Return this server global bounding region
+ * ----------------------------------------------------------------------
+ */
+
+
+ecs_Result *dyn_GetGlobalBound(s)
+ ecs_Server *s;
+{
+ ecs_SetGeoRegion(&(s->result),s->globalRegion.north, s->globalRegion.south,
+ s->globalRegion.east, s->globalRegion.west, s->globalRegion.ns_res,
+ s->globalRegion.ew_res);
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_SetServerLanguage:
+ *
+ * Set this server lnaguage for error message; not yet implemented
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetServerLanguage(s,language)
+ ecs_Server *s;
+ u_int language;
+{
+ (void) language;
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
+
+/* ----------------------------------------------------------------------
+ * _dyn_SetCompression:
+ *
+ * No compression used in local databases.
+ * ----------------------------------------------------------------------
+ */
+
+ecs_Result *dyn_SetCompression(s,compression)
+ ecs_Server *s;
+ ecs_Compression *compression;
+{
+ (void) compression;
+ ecs_SetSuccess(&(s->result));
+ return &(s->result);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,23 @@
+LIBRARY VRF
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ dyn_CreateServer
+ dyn_DestroyServer
+ dyn_SelectLayer
+ dyn_ReleaseLayer
+ dyn_SelectRegion
+ dyn_GetDictionary
+ dyn_GetAttributesFormat
+ dyn_GetNextObject
+ dyn_UpdateDictionary
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_GetObject
+ dyn_GetObjectIdFromCoord
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_SetServerLanguage
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrf.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,461 @@
+/******************************************************************************
+ *
+ * Component: OGDI VRF Driver
+ * Purpose: Data structure and prototype definition for the VRF driver
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: vrf.h,v $
+ * Revision 1.10 2004/04/04 04:33:01 warmerda
+ * added vrf_free_ObjAttributeBuffer
+ *
+ * Revision 1.9 2004/02/18 21:33:18 warmerda
+ * free regex memory
+ *
+ * Revision 1.8 2001/08/16 21:02:37 warmerda
+ * Removed MAXSEGS and MAXRINGS fixed limits
+ *
+ * Revision 1.7 2001/08/16 20:40:34 warmerda
+ * applied VITD fixes - merge primitive lines into a feature
+ *
+ * Revision 1.6 2001/06/20 21:49:31 warmerda
+ * added improved query support (swq)
+ *
+ * Revision 1.5 2001/06/13 17:33:59 warmerda
+ * upgraded source headers
+ *
+ */
+
+/*********************************************************************
+
+ MODULE_INFORMATION
+
+ NAME
+ VRF driver
+
+ DESCRIPTION
+ This driver access VRF database. It is part a of the Open Geospatial
+ Datastore Interface (OGDI). This driver communicate VRF data to
+ the OGDI API.
+ END_DESCRIPTION
+
+ EXPORTED_FUNCTIONS
+ dyn_CreateServer
+ dyn_DestroyServer
+ dyn_SelectLayer
+ dyn_ReleaseLayer
+ dyn_SelectRegion
+ dyn_GetDictionary
+ dyn_GetAttributesFormat
+ dyn_GetNextObject
+ dyn_GetObject
+ dyn_GetObjectIdFromCoord
+ dyn_UpdateDictionary
+ dyn_GetServerProjection
+ dyn_GetGlobalBound
+ dyn_SetServerLanguage
+ END_EXPORTED_FUNCTIONS
+
+ C_SOURCES
+ vrf.c
+ vrf.h
+ object.c
+ feature.c
+ open.c
+ utils.c
+ END_C_SOURCES
+
+ END_MODULE_INFORMATION
+
+ ****************************************************************/
+
+/* #define TESTOPENTABLE 1 */
+
+#include <sys/stat.h>
+#ifdef _WINDOWS
+#include <direct.h>
+#include "compat/dirent.h"
+#else
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
+#endif
+
+#include "glutil.h"
+#include "vpfview.h"
+#include "vpfquery.h"
+#include "vpfprim.h"
+#include "musedir.h"
+#include "strfunc.h"
+
+
+
+/* ----------------------------------------
+ * Define VRF_LINE_JOIN_HACK to enable
+ * merging of line features based on the
+ * join table.
+ * ----------------------------------------
+ */
+
+#define VRF_LINE_JOIN_HACK
+
+/* ----------------------------------------
+ * Definition of VRF specific structures
+ * ----------------------------------------
+ */
+
+#ifndef max
+#define max(x,y) ((x > y) ? x : y)
+#endif
+
+
+/* private data for a VPF Line layer */
+
+typedef struct {
+
+ vpf_table_type edgeTable;
+ vpf_table_type mbrTable;
+
+} VRFLine;
+
+
+
+/* private data for a VPF Area layer */
+
+typedef struct {
+
+ vpf_table_type faceTable;
+ vpf_table_type mbrTable;
+ vpf_table_type ringTable;
+ vpf_table_type edgeTable;
+
+} VRFArea;
+
+
+
+/* private data for a VPF Point layer */
+
+typedef struct {
+
+ vpf_table_type primTable;
+
+} VRFPoint;
+
+
+
+/* private data for a VPF text layer */
+
+typedef struct {
+
+ vpf_table_type textTable;
+
+} VRFText;
+
+typedef struct {
+ char *path; /* directory where the tiled info sits */
+ float xmin; /* geographic extents of this tile */
+ float xmax;
+ float ymin;
+ float ymax;
+ int isSelected; /* is within the current geographic region or not */
+} VRFTile;
+
+
+/*********************************************************************
+
+STRUCTURE_INFORMATION
+
+NAME
+ VRFIndex
+
+DESCRIPTION
+ Description of one cell of the index table
+END_DESCRIPTION
+
+ATTRIBUTES
+
+ int32 feature_id: The identifier of the feature identifiant
+ short tile_id: The tile id of the primitive data
+ int32 prim_id: The identifier of the primitive identifiant
+
+END_ATTRIBUTES
+
+END_STRUCTURE_INFORMATION
+
+********************************************************************/
+
+typedef struct {
+ int32 feature_id;
+ short tile_id;
+ int32 prim_id;
+} VRFIndex;
+
+/*********************************************************************
+
+STRUCTURE_INFORMATION
+
+NAME
+LayerPrivateData
+
+DESCRIPTION
+Layer private data description.
+END_DESCRIPTION
+
+ATTRIBUTES
+ vpf_table_type featureTable: The feature table
+ vpf_table_type joinTable: The join table
+ set_type feature_rows: A set over the feature table showing the selection accordingly to the expression.
+ int current_tileid: Indicate which tile is currently selected.
+ VRFIndex *index: The index of feature to primitives relations.
+ char *coverage: The current coverage of the layer
+ char *fclass: The feature class of the coverage
+ char *expression: The selection expression over the features.
+ vpf_table_type fcsTable: The FCS table.
+ char *featureTableName: The feature table name.
+ char *featureTablePrimIdName: The feature table PrimId attribute name.
+ char *joinTableName: The join table name.
+ char *joinTableForeignKeyName: The join table foreign key name
+ char *joinTableFeatureIdName: The join table FeatureId attribute name.
+ char *primitiveTableName: The primitive table name.
+
+ union {
+
+ VRFArea area;
+ VRFLine line;
+ VRFPoint point;
+ VRFText text;
+
+ } l; : This union contain the specialization for each data type.
+
+END_ATTRIBUTES
+
+END_STRUCTURE_INFORMATION
+
+********************************************************************/
+
+typedef struct {
+
+ vpf_table_type featureTable;
+ vpf_table_type joinTable;
+ set_type feature_rows; /* the set of all selected features according to expression */
+ int current_tileid; /* usefull to know when to reset the primitive tables: only when a new tile is encountered */
+
+ VRFIndex *index;
+
+ char *coverage; /* the result of the sel.Request parsing */
+ char *fclass;
+ char *expression;
+
+ vpf_table_type fcsTable;
+
+ char *featureTableName;
+ char *featureTablePrimIdName;
+ char *joinTableName;
+ char *joinTableForeignKeyName;
+ char *joinTableFeatureIdName;
+ char *primitiveTableName;
+ int isTiled; /* is this a tiled layer ? */
+ int mergeFeatures; /* merge primitives into features based on join table*/
+
+ union { /* specifics to each feature type */
+
+ VRFArea area;
+ VRFLine line;
+ VRFPoint point;
+ VRFText text;
+
+ } l;
+
+} LayerPrivateData;
+
+
+typedef struct {
+
+ char database[256]; /* fullpath to database and library are usefull when opening table */
+ char library[256];
+ char libname[32]; /* the short name of the library (last part of the path) */
+ char metadatastring[250000]; /*transfert to updatedictionnary of the metadata strings*/
+ vpf_table_type catTable; /* support files are opened at client creation and remain opened until client destruction */
+ vpf_table_type latTable;
+ vpf_table_type dhtTable;
+ vpf_table_type lhtTable;
+ vpf_table_type grtTable;
+ vpf_table_type dqtTable;
+ vpf_table_type fcsTable;
+ vpf_table_type fcaTable;
+
+ int isTiled; /* is this a tiled library ? */
+ VRFTile *tile; /* tile info, if any, for this library */
+ int nbTile; /* number of tile, if tiled */
+ int isDCW; /* Is it a DCW database? */
+
+ int isMetaLoad; /* Indicate if the metainfo is load */
+
+} ServerPrivateData;
+
+ /* layer oriented method are keeped into a single data structure to simplify the code */
+
+typedef void layerfunc();
+typedef void layerobfunc();
+typedef void layercoordfunc();
+
+
+typedef struct {
+ layerfunc *getNextObject;
+ layerobfunc *getObject;
+ layercoordfunc *getObjectIdFromCoord;
+ layerfunc *selectTile;
+} LayerMethod;
+
+
+
+/* VPF feature types used */
+
+#define MAGIC_VEC2_DATA 120000002L
+
+
+typedef struct
+{
+ float x;
+ float y;
+} COORDINATE;
+
+
+typedef struct
+{
+ int32 id;
+ int32 nr_coords;
+ COORDINATE *coords;
+} SEGMENT;
+
+
+typedef struct
+{
+ int32 id;
+ int32 nr_segs;
+ SEGMENT **segs;
+} RING;
+
+
+typedef struct
+{
+ int32 id;
+ int32 nr_rings;
+ RING **rings;
+} AREA_FEATURE;
+
+
+/* private functions prototype */
+
+/* vrf.c */
+
+void vrf_releaseAllLayers _ANSI_ARGS_((ecs_Server *s));
+
+/* utils.c */
+
+void vrf_freePathRegex();
+int vrf_parsePath _ANSI_ARGS_((ecs_Server *s,LayerPrivateData *lpriv,ecs_LayerSelection *sel));
+int vrf_parsePathValue _ANSI_ARGS_((ecs_Server *s,char *request,char **fclass, char **coverage,char **expression));
+int vrf_getFileNameFromFcs _ANSI_ARGS_((ecs_Server *s, LayerPrivateData *lpriv));
+int vrf_verifyCATFile _ANSI_ARGS_((ecs_Server *s));
+int vrf_initRegionWithDefault _ANSI_ARGS_((ecs_Server *s));
+int vrf_GetMetadata _ANSI_ARGS_((ecs_Server *s));
+int vrf_initTiling _ANSI_ARGS_((ecs_Server *s));
+int vrf_IsOutsideRegion _ANSI_ARGS_((double n, double s, double e,double w, ecs_Region *region));
+void vrf_AllFClass _ANSI_ARGS_((ecs_Server *s, char *coverage));
+int vrf_feature_class_dictionary _ANSI_ARGS_((ecs_Server *s,char *request));
+int vrf_build_capabilities( ecs_Server *s, const char *request );
+
+/* feature.c */
+
+int vrf_get_xy _ANSI_ARGS_((vpf_table_type table, row_type row,int32 pos, double *x,double *y));
+int vrf_get_point_feature _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, int prim_id));
+int vrf_get_line_feature _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer,
+ int prim_id, ecs_Result *result ));
+int vrf_get_merged_line_feature _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer,
+ int primCount, int32 *primList));
+int vrf_get_text_feature _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, int prim_id));
+int vrf_get_area_feature _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, int prim_id));
+int vrf_get_line_mbr _ANSI_ARGS_((ecs_Layer *layer,int32 prim_id,double *xmin,double *ymin,double *xmax,double *ymax));
+int vrf_get_lines_mbr _ANSI_ARGS_((ecs_Layer *layer,
+ int32 primCount, int32 *primList,
+ double *xmin,double *ymin,
+ double *xmax,double *ymax));
+int vrf_get_area_mbr _ANSI_ARGS_((ecs_Layer *layer,int32 prim_id,double *xmin,double *ymin,double *xmax,double *ymax));
+int vrf_get_ring_coords _ANSI_ARGS_((ecs_Server *s, RING *ring, int32 face_id,
+ int32 start_edge,vpf_table_type edgetable));
+int32 vrf_next_face_edge _ANSI_ARGS_((edge_rec_type *edge_rec,int32 *prevnode, int32 face_id));
+char *vrf_get_ObjAttributes _ANSI_ARGS_((vpf_table_type table,int32 row_pos));
+void vrf_free_ObjAttributeBuffer();
+int vrf_checkLayerTables _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l));
+
+/* vrfswq.c */
+
+set_type query_table2( char *expression, vpf_table_type table );
+
+/* layer oriented method definition */
+
+/* open.c */
+
+void _openLineLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _openAreaLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _openPointLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _openTextLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+
+void _closeLineLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _closeAreaLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _closePointLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _closeTextLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+
+void _rewindLineLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _rewindAreaLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _rewindPointLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _rewindTextLayer _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+
+
+/* object.c */
+
+void _getTileAndPrimId _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,
+ int32 object_id,int32 *feature_id,
+ short *tile_id,int32 *prim_id));
+void _getPrimList _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,
+ int32 object_id,
+ int32 *feature_id, short *tile_id,
+ int32 *primCount, int32 **primList,
+ int32 *next_object_id));
+
+void _getNextObjectLine _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _getNextObjectArea _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _getNextObjectPoint _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+void _getNextObjectText _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer));
+
+void _getObjectLine _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, char *objectId));
+void _getObjectArea _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, char *objectId));
+void _getObjectPoint _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, char *objectId));
+void _getObjectText _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, char *objectId));
+
+void _getObjectIdLine _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, ecs_Coordinate *coord));
+void _getObjectIdArea _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, ecs_Coordinate *coord));
+void _getObjectIdPoint _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, ecs_Coordinate *coord));
+void _getObjectIdText _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, ecs_Coordinate *coord));
+
+void _selectTileLine _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, int tile_id));
+void _selectTileArea _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, int tile_id));
+void _selectTilePoint _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, int tile_id));
+void _selectTileText _ANSI_ARGS_((ecs_Server *s,ecs_Layer *layer, int tile_id));
+
+void _closeLayerTable _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l));
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrfswq.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrfswq.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/driver/vrf/vrfswq.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,285 @@
+/******************************************************************************
+ *
+ * Component: OGDI VRF Driver
+ * Purpose: Implements VPF query capability based on SWQ in a manner similar
+ * to the vpfquery.c code distributed with vpflib.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: vrfswq.c,v $
+ * Revision 1.6 2007/02/12 15:52:57 cbalint
+ *
+ * Preliminary cleanup.
+ * Get rif of unitialized variables, and unused ones.
+ *
+ * Revision 1.5 2004/10/25 21:24:43 warmerda
+ * Fixed case of 1 character wide fields as per Stephane's submission
+ * in bug 809737.
+ *
+ * Revision 1.4 2004/10/25 19:09:06 warmerda
+ * Fixed so that string comparisons on fields long than 1 character
+ * work. Also fixed so that trailing spaces are trimmed off string
+ * values before comparing.
+ *
+ * Revision 1.3 2001/06/26 00:57:34 warmerda
+ * fixed strcasecmp on WIN32
+ *
+ * Revision 1.2 2001/06/21 20:30:15 warmerda
+ * added ECS_CVSID
+ *
+ * Revision 1.1 2001/06/20 21:49:16 warmerda
+ * New
+ *
+ */
+
+#include "ecs.h"
+#include "vrf.h"
+#include "swq.h"
+
+ECS_CVSID("$Id: vrfswq.c,v 1.6 2007/02/12 15:52:57 cbalint Exp $");
+
+#ifndef __LINKLIST_H__
+#include "linklist.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __SET_H__
+#include "set.h"
+#endif
+#ifndef __STRFUNC_H__
+#include "strfunc.h"
+#endif
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+#ifdef WIN32
+# define strcasecmp stricmp
+#endif
+
+typedef struct {
+ row_type row;
+ vpf_table_type table;
+} evaluator_info;
+
+/************************************************************************/
+/* vrf_swq_evaluator() */
+/* */
+/* Evaluate a single operation from the WHERE expression on a */
+/* row from the VRF table. */
+/************************************************************************/
+
+int vrf_swq_evaluator( swq_field_op *op, void *raw_info )
+
+{
+ int32 lval, count;
+ short sval;
+ float fval;
+ char *tptr;
+
+ evaluator_info *info = (evaluator_info *) raw_info;
+ row_type row = info->row;
+ vpf_table_type table = info->table;
+
+/* -------------------------------------------------------------------- */
+/* String field comparison. */
+/* -------------------------------------------------------------------- */
+ if( table.header[op->field_index].type == 'T' )
+ {
+ int ret_result, i;
+
+ /* count=1 is a special case because the value is returned into
+ a char instead of returning an allocated string */
+ if (table.header[op->field_index].count == 1) {
+
+ char cval;
+ get_table_element( op->field_index, row, table, &cval, &count );
+
+ if( op->operation == SWQ_EQ )
+ ret_result = (cval == op->string_value[0]);
+ else
+ ret_result = (cval != op->string_value[0]);
+
+ } else {
+ tptr = (char *)get_table_element( op->field_index, row, table,
+ NULL, &count );
+
+ /* trim whitepsace */
+ for( i = strlen(tptr)-1; i >= 0 && tptr[i] == ' '; i-- )
+ tptr[i] = '\0';
+
+ if( op->operation == SWQ_EQ )
+ ret_result = (strcasecmp(tptr,op->string_value) == 0);
+ else
+ ret_result = (strcasecmp(tptr,op->string_value) != 0);
+
+ xvt_free(tptr);
+ }
+
+ return ret_result;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Numeric field comparison. */
+/* -------------------------------------------------------------------- */
+ else
+ {
+ if (table.header[op->field_index].count != 1)
+ return FALSE;
+
+ if( table.header[op->field_index].type == 'S' )
+ {
+ get_table_element( op->field_index, row, table, &sval, &count );
+ fval = sval;
+ }
+ else if( table.header[op->field_index].type == 'I' )
+ {
+ get_table_element( op->field_index, row, table, &lval, &count );
+ fval = lval;
+ }
+ else
+ {
+ get_table_element( op->field_index, row, table, &fval, &count );
+ }
+
+ switch( op->operation )
+ {
+ case SWQ_EQ:
+ return fval == op->float_value;
+
+ case SWQ_NE:
+ return fval != op->float_value;
+
+ case SWQ_GT:
+ return fval > op->float_value;
+
+ case SWQ_LT:
+ return fval < op->float_value;
+
+ case SWQ_GE:
+ return fval >= op->float_value;
+
+ case SWQ_LE:
+ return fval <= op->float_value;
+
+ default:
+ return FALSE;
+ }
+ }
+}
+
+
+/************************************************************************
+ * query_table2()
+ *
+ * This function returns the set of selected rows of a VPF table
+ * based upon the evaluation of the given selection expression string.
+ *
+ * see swq.h/swq.c for details on the expression syntax.
+ *
+ * Parameters:
+ *
+ * expression <input>==(char *) selection expression string.
+ * table <input>==(vpf_table_type) VPF table structure.
+ * return <output>==(set_type) set of selected rows.
+ ************************************************************************/
+
+set_type query_table2( char *expression, vpf_table_type table )
+{
+ register int32 i, ipos;
+ set_type select_set;
+
+ swq_expr *expr;
+ const char *error;
+ int nfields;
+ char **fieldname;
+ swq_field_type *fieldtype;
+ evaluator_info ev_info;
+
+ select_set = set_init (table.nrows);
+
+/* -------------------------------------------------------------------- */
+/* If the expression is "*" then just turn on all members of */
+/* select_set and return. */
+/* -------------------------------------------------------------------- */
+ if (strcmp (expression, "*") == 0)
+ {
+ set_on(select_set);
+ return select_set;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Prepare the field list. */
+/* -------------------------------------------------------------------- */
+ nfields = (int32)table.nfields;
+
+ fieldname = (char**) malloc(nfields * sizeof(char *));
+ fieldtype = (swq_field_type *) malloc(nfields * sizeof(swq_field_type));
+
+ for (i=0; i < nfields; i++)
+ {
+ fieldname[i] = (char *) table.header[i].name;
+ if( table.header[i].type == 'T' )
+ fieldtype[i] = SWQ_STRING;
+ else if( table.header[i].type == 'F' )
+ fieldtype[i] = SWQ_FLOAT;
+ else if( table.header[i].type == 'I' || table.header[i].type == 'S' )
+ fieldtype[i] = SWQ_INTEGER;
+ else
+ fieldtype[i] = SWQ_OTHER;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Compile the WHERE expression. */
+/* -------------------------------------------------------------------- */
+ error = swq_expr_compile( expression, nfields, fieldname, fieldtype,
+ &expr );
+
+ if ( error != NULL || expr == NULL )
+ return select_set;
+
+/* -------------------------------------------------------------------- */
+/* Process the table, one record at a time. */
+/* -------------------------------------------------------------------- */
+ if (table.storage == DISK)
+ {
+ ipos = index_pos (1L, table);
+ fseek( table.fp, ipos, SEEK_SET );
+ }
+
+ ev_info.table = table;
+
+ for (i=1;i<=table.nrows;i++) {
+
+ if (table.storage == DISK)
+ ev_info.row = read_next_row(table);
+ else
+ ev_info.row = get_row( i, table );
+
+ if( swq_expr_evaluate( expr, vrf_swq_evaluator, (void *) &ev_info ) )
+ set_insert( i, select_set );
+
+ free_row(ev_info.row, table);
+ }
+
+/* -------------------------------------------------------------------- */
+/* Cleanup */
+/* -------------------------------------------------------------------- */
+ free( fieldtype );
+ free( fieldname );
+ swq_expr_free( expr );
+
+ return select_set;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example1/example1.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example1/example1.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example1/example1.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,44 @@
+#include "ecs.h"
+
+char url[] = "gltp:/grass/c:/demo/spearfish/PERMANENT";
+char layer[] = "roads at PERMANENT(*)";
+
+int main()
+{
+ int ClientID;
+ ecs_Result *result;
+ ecs_Region selectionRegion;
+ ecs_LayerSelection selectionLayer;
+
+ /* Create a client with ClientID as a reference */
+
+ result = cln_CreateClient(&ClientID,url);
+
+ /* The user must set a region value in the client geographic projection */
+
+ selectionRegion.north = 4928000.0;
+ selectionRegion.south = 4914000.0;
+ selectionRegion.east = 609000.0;
+ selectionRegion.west = 590000.0;
+ selectionRegion.ns_res = 50.0;
+ selectionRegion.ew_res = 50.0;
+ result = cln_SelectRegion(ClientID,&selectionRegion);
+
+ /* Define the layer to select */
+
+ selectionLayer.Select = (char *) layer;
+ selectionLayer.F = Line;
+ result = cln_SelectLayer(ClientID,&selectionLayer);
+
+ /* The application process the result of cln_SelectLayer. */
+
+ result = cln_GetNextObject(ClientID);
+ while (ECSSUCCESS(result)) {
+ result = cln_GetNextObject(ClientID);
+ }
+
+ result = cln_ReleaseLayer(ClientID,&selectionLayer);
+ result = cln_DestroyClient(ClientID);
+
+ return 0;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example1/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example1/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example1/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,20 @@
+TOBEGEN = example1
+TARGETGEN=$(PROGGEN)
+
+SOURCES = example1.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(PROJ_STATICLINKLIB)
+
+
+include $(TOPDIR)/config/common.mak
+
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+ $(COPY_LOCAL)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example2/example2.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example2/example2.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example2/example2.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,157 @@
+#include <stdio.h>
+#include "ecs.h"
+
+int PrintResult();
+
+/*
+ This example will print all the lines objects from a database
+ defined by user. The user will give the url and the layer
+ selection to the program and, immediately, he will see the
+ lines print on screen.
+ */
+
+int main()
+{
+ int ClientID;
+ char url[100];
+ char layerSelection[100];
+ ecs_Result *result;
+ ecs_Region selectionRegion;
+ ecs_LayerSelection selectionLayer;
+ int code;
+ int errin;
+ code = TRUE;
+
+ printf("Enter the URL: ");
+ errin = scanf("%s",url);
+ if (errin == 0) {
+ printf("URL Input error.\n");
+ exit(1);
+ }
+ printf("Enter the layer: ");
+ errin = scanf("%s",layerSelection);
+ if (errin == 0) {
+ printf("Layer Input error.\n");
+ exit (1);
+ }
+
+ PrintResult("cln_CreateClient", cln_CreateClient(&ClientID,url));
+ PrintResult("cln_GetGlobalBound", (result=cln_GetGlobalBound(ClientID)));
+
+ /* It's better to allocate locally all the data structure to be sent
+ to the API. In this case, ECSREGION(result) is not used directly in
+ argument of cln_SelectRegion. The SelectRegion destroy the old
+ ecs_Result and it's argument at the same time. */
+
+ selectionRegion.north = ECSREGION(result).north;
+ selectionRegion.south = ECSREGION(result).south;
+ selectionRegion.east = ECSREGION(result).east;
+ selectionRegion.west = ECSREGION(result).west;
+ selectionRegion.ns_res = ECSREGION(result).ns_res;
+ selectionRegion.ew_res = ECSREGION(result).ew_res;
+
+ PrintResult("cln_SelectRegion",cln_SelectRegion(ClientID,&selectionRegion));
+
+ selectionLayer.Select = (char *) layerSelection;
+ selectionLayer.F = Line;
+ PrintResult("cln_SelectLayer",cln_SelectLayer(ClientID,&selectionLayer));
+
+ while (code) {
+ code = PrintResult("cln_GetNextObject",cln_GetNextObject(ClientID));
+ }
+
+ PrintResult("cln_ReleaseLayer",cln_ReleaseLayer(ClientID,&selectionLayer));
+
+ PrintResult("cln_DestroyClient",cln_DestroyClient(ClientID));
+
+ return 1;
+}
+
+/*
+ The following function will make the analysis of the
+ structure ecs_Result return by all API functions.
+ He will print information of the contain of the
+ structure. Of course, this function is incomplete,
+ only error messages, region informations, text and
+ line info will be print. If an error occur, the function
+ will call exit() after the printing the message.
+ */
+
+int PrintResult(command,result)
+ char *command;
+ ecs_Result *result;
+{
+ unsigned int i;
+ int code;
+
+ code = TRUE;
+
+ /* Print the command string */
+
+ printf("\n%s\n\n",command);
+
+ /* Check is a result is pass as an argument */
+
+ if (result == NULL)
+ printf("No structure returned\n");
+
+ /* Check is the request is successful */
+
+ if (ECSSUCCESS(result)) {
+
+ /* Check the contain type of result */
+
+ switch(ECSRESULTTYPE(result)) {
+ case Object:
+ /* result contain an geographical object. Now check
+ the contain if it's a line and print the line
+ geographical object.
+ */
+ if (ECSGEOMTYPE(result) == Line) {
+ printf("Object ID:%s\n",ECSOBJECTID(result));
+ printf("Object Attributes:%s\n",ECSOBJECTATTR(result));
+ for(i=0;i<ECSGEOM(result).line.c.c_len;i++) {
+ printf("%d: (%f , %f)\n",i,
+ ECSGEOM(result).line.c.c_val[i].x,
+ ECSGEOM(result).line.c.c_val[i].y);
+ }
+ }
+ break;
+
+ case GeoRegion:
+ printf("Region: north=%f south=%f east=%f west=%f\n",
+ ECSREGION(result).north,ECSREGION(result).south,
+ ECSREGION(result).east,ECSREGION(result).west);
+ printf("Resolution: ns_resolution=%f ew_resolution=%f\n",
+ ECSREGION(result).ns_res,ECSREGION(result).ew_res);
+ break;
+
+ case AText:
+ printf("AText: %s\n",ECSTEXT(result));
+ break;
+
+ case objAttributeFormat:
+ case RasterInfo:
+ printf("Unsupported feature...\n");
+ break;
+
+ default:
+ break;
+ };
+
+ } else {
+ /* The ecs_Result contain a error message */
+
+ printf("%s\n",result->message);
+
+ if (!ECSEOF(result)) {
+ /* The error message is not an eof. Call exit() */
+ exit(0);
+ }
+ code = FALSE;
+ }
+
+ printf("***************************************************\n");
+ return code;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example2/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example2/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/example2/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,20 @@
+TOBEGEN = example2
+TARGETGEN=$(PROGGEN)
+
+SOURCES = example2.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(PROJ_STATICLINKLIB)
+
+
+include $(TOPDIR)/config/common.mak
+
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+ $(COPY_LOCAL)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/examples/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,42 @@
+# Copyright (C) 2001 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+include $(TOPDIR)/config/common.mak
+
+#
+# Sub-directories that need to be built
+#
+subdirs = example1 example2
+
+#
+# Default target to build everything in all sub-directories
+#
+all: $(subdirs)
+
+#
+# Target to allow individual sub-directories to be built
+# (e.g. make cgmmod)
+#
+.PHONY: $(subdirs)
+$(subdirs):
+ cd $@; $(MAKE)
+
+#
+# Pass specialized targets into the sub-directories
+#
+.PHONY: $(STANDARD_TARGETS)
+$(STANDARD_TARGETS):
+ @for i in $(subdirs); do \
+ $(MAKE) --directory $$i $@; \
+ done
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/asyncsvr.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/asyncsvr.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/asyncsvr.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,578 @@
+/******************************************************************************
+ *
+ * Component: OGDI gltpd Server
+ * Purpose: GLTPD Mainline.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: asyncsvr.c,v $
+ * Revision 1.6 2007/02/12 21:01:48 cbalint
+ * Fix win32 target. It build and works now. (tested with VC6)
+ *
+ * Revision 1.5 2007/02/12 16:09:06 cbalint
+ * * Add hook macros for all GNU systems, hook fread,fwrite,read,fgets.
+ * * Handle errors in those macro, if there are any.
+ * * Fix some includes for GNU systems.
+ * * Reduce remaining warnings, now we got zero warnings with GCC.
+ *
+ * Modified Files:
+ * config/unix.mak contrib/ogdi_import/dbfopen.c
+ * contrib/ogdi_import/shapefil.h contrib/ogdi_import/shpopen.c
+ * ogdi/c-api/ecs_xdr.c ogdi/c-api/ecsinfo.c ogdi/c-api/server.c
+ * ogdi/datum_driver/canada/nadconv.c ogdi/driver/adrg/adrg.c
+ * ogdi/driver/adrg/adrg.h ogdi/driver/adrg/object.c
+ * ogdi/driver/adrg/utils.c ogdi/driver/rpf/rpf.h
+ * ogdi/driver/rpf/utils.c ogdi/gltpd/asyncsvr.c
+ * ogdi/glutil/iofile.c vpflib/vpfprim.c vpflib/vpfspx.c
+ * vpflib/vpftable.c vpflib/vpftidx.c vpflib/xvt.h
+ *
+ * Revision 1.4 2002/02/21 16:38:19 warmerda
+ * undefine svc_fdset if defined - helps avoid odd library requirements on linux
+ *
+ * Revision 1.3 2001/04/09 15:04:35 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+
+#include <ogdi_macro.h>
+
+ECS_CVSID("$Id: asyncsvr.c,v 1.6 2007/02/12 21:01:48 cbalint Exp $");
+
+#ifdef _WINDOWS
+# include "rpc/pmap_cln.h"
+# include "time.h"
+#else
+# include <sys/wait.h>
+# include "time.h"
+#endif
+
+#include <unistd.h>
+
+#ifdef _WINDOWS
+# include <errno.h>
+#else
+# include <sys/errno.h>
+#endif
+
+#ifdef HAVE_STD_RPC_INCLUDES
+# include <rpc/pmap_clnt.h>
+#endif
+
+#ifdef svc_fdset
+#undef svc_fdset
+#endif
+
+#define COMTIMEOUT 900
+
+long timecount;
+
+static void dispatchno_1();
+extern void ecsprog_1();
+u_long newprogramno;
+static char str1[255];
+static char *argv0;
+static void gltpd_svc_run();
+
+
+
+FILE *gltpdstate = NULL;
+
+int main(argc,argv)
+ int argc;
+ char **argv;
+{
+ SVCXPRT *transp;
+ int num;
+ int isDispatch = TRUE;
+ char *debug;
+
+#ifdef _WINDOWS
+ rpc_nt_init();
+#endif
+
+ debug = getenv("GLTPDLOGFILE");
+
+ if (debug) {
+ gltpdstate = (FILE *) ".";
+ if (gltpdstate) {
+ printf("%d: Start in the main\n",getpid());
+ for(num=0;num<argc;num++) {
+ printf("%s ",argv[num]);
+ }
+ printf("\n");
+ }
+ }
+
+ argv0 = argv[0];
+
+ /* Analyser la requete */
+
+ switch(argc) {
+ case 2:
+ sscanf(argv[1],"%s",str1);
+ if (strncmp(str1,"-d",2) == 0) {
+ isDispatch = TRUE;
+ } else {
+ isDispatch = FALSE;
+ sscanf(argv[1],"%d",&num);
+ }
+ break;
+ case 1:
+ isDispatch = TRUE;
+ strcpy(str1,"");
+ break;
+ default:
+ printf("Wrong number of arguments\n");
+ exit(0);
+ break;
+ };
+
+
+ /* Si un argument existe pour ce serveur, creer directement
+ ce serveur sans passer par le dispatcher */
+
+ /* Creer le serveur directement */
+
+ if (isDispatch) {
+ /* Passer par le dispatcher normalement */
+
+ if (debug && gltpdstate) {
+ printf("%d: Start dispatcher: Call pmap_unset\n",getpid());
+ }
+
+ (void)pmap_unset(ECSPROG, ECSVERS);
+
+ if (debug && gltpdstate) {
+ printf("%d: Start dispatcher: Call svctcp_create\n",getpid());
+ }
+
+ transp = svctcp_create(RPC_ANYSOCK, 0, 0);
+ if (transp == NULL) {
+ (void)fprintf(stderr, "cannot create tcp service.\n");
+ if (debug && gltpdstate) {
+ printf("%d: Start dispatcher: cannot create tcp service.\n",getpid());
+ }
+ return 0;
+ }
+
+ if (debug && gltpdstate) {
+ printf("%d: Start dispatcher: Call svc_register\n",getpid());
+ }
+
+ if (!svc_register(transp, ECSPROG, ECSVERS,
+ dispatchno_1, IPPROTO_TCP)) {
+ (void)fprintf(stderr, "unable to register (DISPATCHNO, DISPATCHVERS, tcp).\n");
+ if (debug && gltpdstate) {
+ printf("%d: Start dispatcher: unable to register the dispatcher.\n",
+ getpid());
+ }
+ return 0;
+ }
+ if (debug && gltpdstate) {
+ printf("%d: Start dispatcher: Call svc_run.\n",getpid());
+ }
+ svc_run();
+ (void)fprintf(stderr, "svc_run returned\n");
+ } else {
+ if (debug && gltpdstate) {
+ printf("%d: Start server: Call pmap_unset at rpcaddress %d version %d\n",getpid(),num,(int) ECSVERS);
+ }
+
+ (void)pmap_unset(num, ECSVERS);
+
+ /* Enregistrer le nouveau serveur */
+ if (debug && gltpdstate) {
+ printf("%d: Start server: Call svctcp_create\n",getpid());
+ }
+
+ transp = svctcp_create(RPC_ANYSOCK, 0, 0);
+ if (transp == NULL) {
+ (void)fprintf(stderr, "cannot create tcp service.\n");
+ return 0;
+ }
+
+ if (debug && gltpdstate) {
+ printf("%d: Start server: Call svc_register\n",getpid());
+ }
+
+ if (!svc_register(transp, num, ECSVERS, ecsprog_1, IPPROTO_TCP)) {
+ (void)fprintf(stderr, "unable to register (ECSPROG, ECSVERS, tcp).\n");
+ if (debug && gltpdstate) {
+ printf("%d: Start server: unable to register the dispatcher.\n",getpid());
+ }
+ exit(1);
+ }
+ if (debug && gltpdstate) {
+ printf("%d: Start server: Call svc_run.\n",getpid());
+ }
+
+ gltpd_svc_run();
+
+
+ }
+
+#ifdef _WINDOWS
+ rpc_nt_exit();
+#endif
+
+ return 1;
+}
+
+static void
+dispatchno_1(rqstp, transp)
+ struct svc_req *rqstp;
+ SVCXPRT *transp;
+{
+#ifdef _WINDOWS
+ STARTUPINFO si;
+ SECURITY_ATTRIBUTES saProcess, saThread;
+ PROCESS_INFORMATION piProcessB;
+ bool_t result;
+#endif
+ char temp[256];
+ char *debug;
+ union {
+ int fill;
+ } argument;
+ SVCXPRT *newtransp = NULL;
+
+ debug = getenv("GLTPDLOGFILE");
+
+ if (debug) {
+ gltpdstate = (FILE *) (void *) 1;
+ if (gltpdstate) {
+ printf("%d: Start in the dispatcher function\n",getpid());
+ }
+ }
+
+ switch (rqstp->rq_proc) {
+ case NULLPROC:
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: NULLPROC case\n",getpid());
+ }
+
+ (void)svc_sendreply(transp, (xdrproc_t) xdr_void, (char *)NULL);
+ return;
+
+ case 1:
+ /* Dispatcher de service */
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call the dispatcher request\n",getpid());
+ }
+
+ memset((char *)&argument,0, sizeof(argument));
+ if (!svc_getargs(transp, (xdrproc_t) xdr_void, (char *) &argument)) {
+ svcerr_decode(transp);
+ return;
+ }
+
+#ifndef _WINDOWS
+ /* Reap zombie children */
+ /* while (waitpid(-1, NULL, WNOHANG) > 0);
+ if (fork()) {
+ return;
+ }*/
+#endif
+
+ /* Trouver le numero du nouveau serveur
+ * Note: On Windows NT, this really should not be created here because
+ * the child creates its own socket and registers it. Leave it for now.
+ */
+
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call the svctcp_create function\n",getpid());
+ }
+
+ newtransp = svctcp_create(RPC_ANYSOCK, 0, 0);
+
+ /* Trouver dynamiquement un numero d'identifiant */
+
+ newprogramno = ECS_TRANSIENT_MIN;
+ while( !pmap_set(newprogramno, ECSVERS, IPPROTO_TCP, newtransp->xp_port)) {
+ newprogramno++;
+ if (newprogramno == ECS_TRANSIENT_MAX) {
+ newprogramno = ECS_TRANSIENT_MIN;
+ }
+ }
+
+ svc_destroy(newtransp);
+
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: RPC number: %ld\n",
+ getpid(), newprogramno);
+ }
+
+#ifdef _WINDOWS
+ /* Cas Windows avec CreateProcess */
+
+ ZeroMemory(&si,sizeof(si));
+ si.cb = sizeof(si);
+
+ saProcess.nLength = sizeof(saProcess);
+ saProcess.lpSecurityDescriptor =NULL;
+ saProcess.bInheritHandle=TRUE;
+
+ saThread.nLength = sizeof(saThread);
+ saThread.lpSecurityDescriptor =NULL;
+ saThread.bInheritHandle=FALSE;
+
+ /* spawn process */
+
+ if (strncmp(str1,"-d",2) == 0) {
+
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call the svc_sendreply function\n",getpid());
+ }
+
+ if (!svc_sendreply(transp, (xdrproc_t) xdr_u_long, (char *) &newprogramno)) {
+ svcerr_systemerr(transp);
+ printf("erreur reply\n");
+ }
+ if (!svc_freeargs(transp, xdr_void, &argument)) {
+ (void)fprintf(stderr, "unable to free arguments\n");
+ exit(1);
+ }
+
+ /* Enregistrer le nouveau serveur */
+
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call svc_register\n",getpid());
+ }
+
+ if (!svc_register(newtransp, newprogramno, ECSVERS, ecsprog_1, 0)) {
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: unable to register the server\n",getpid());
+ }
+
+ (void)fprintf(stderr, "unable to register (ECSPROG, ECSVERS, tcp).\n");
+ exit(1);
+ }
+
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: unable to register the server\n",getpid());
+ }
+
+ gltpd_svc_run();
+
+ exit(1);
+ }
+
+ sprintf(temp,"%s %d",argv0, newprogramno);
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call CreateProcess\n",getpid());
+ }
+
+ result = CreateProcess (argv0,
+ temp, /* command line */
+ &saProcess, &saThread,
+ FALSE,
+ DETACHED_PROCESS,
+ NULL, NULL,&si,
+ &piProcessB);
+ if (result) {
+ CloseHandle(piProcessB.hProcess);
+ CloseHandle(piProcessB.hThread);
+ } else {
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Error occur during CreateProcess %s\n",getpid(),temp);
+ }
+ return;
+ }
+ /* Rtourner le resultat au client, mais auparavent on laisse le
+ temps au serveur de s'intialiser */
+ Sleep(3000);
+
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call sendreply\n",getpid());
+ }
+
+ if (!svc_sendreply(transp, (xdrproc_t) xdr_u_long, (char *) &newprogramno)) {
+ svcerr_systemerr(transp);
+ printf("erreur reply\n");
+ }
+ if (!svc_freeargs(transp, xdr_void, &argument)) {
+ (void)fprintf(stderr, "unable to free arguments\n");
+ exit(1);
+ }
+
+
+
+#else
+
+ /*
+
+ Cas UNIX avec fork
+
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call sendreply\n",getpid());
+ fclose(gltpdstate);
+ }
+
+ if (!svc_sendreply(transp, (xdrproc_t) xdr_u_long, (char *) &newprogramno)) {
+ svcerr_systemerr(transp);
+ printf("erreur reply\n");
+ }
+ if (!svc_freeargs(transp, xdr_void, &argument)) {
+ (void)fprintf(stderr, "unable to free arguments\n");
+ exit(1);
+ }
+
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call svc_register\n",getpid());
+ fclose(gltpdstate);
+ }
+
+ if (!svc_register(newtransp, newprogramno, ECSVERS, ecsprog_1, 0)) {
+ (void)fprintf(stderr, "unable to register (ECSPROG, ECSVERS, tcp).\n");
+ exit(1);
+ }
+
+ gltpd_svc_run();
+ (void)fprintf(stderr, "svc_run returned\n");
+ exit(1);
+ */
+
+ sprintf(temp,"%s %ld &",argv0, newprogramno);
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call CreateProcess\n",getpid());
+ }
+
+ /* Reap zombie children */
+ while (waitpid(-1, NULL, WNOHANG) > 0);
+ ogdi_system(temp);
+
+ /* Rtourner le resultat au client, mais auparavent on laisse le
+ temps au serveur de s'intialiser */
+ sleep(1);
+
+ if (debug && gltpdstate) {
+ printf("%d: Dispatcher function: Call sendreply\n",getpid());
+ }
+
+ if (!svc_sendreply(transp, (xdrproc_t) xdr_u_long, (char *) &newprogramno)) {
+ svcerr_systemerr(transp);
+ printf("erreur reply\n");
+ }
+ if (!svc_freeargs(transp, (xdrproc_t) xdr_void, (char *) &argument)) {
+ (void)fprintf(stderr, "unable to free arguments\n");
+ exit(1);
+ }
+
+
+#endif
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ return;
+ }
+}
+
+#ifdef _WINDOWS
+
+void gltpd_svc_run()
+{
+ xdrproc_t xdr_argument, xdr_result;
+ struct timeval timeout;
+#ifdef FD_SETSIZE
+ fd_set readfds;
+#else
+ int readfds;
+#endif
+
+ timeout.tv_sec = COMTIMEOUT;
+ timeout.tv_usec = 1;
+
+ for (;;) {
+#ifdef FD_SETSIZE
+ readfds = svc_fdset;
+#else
+ readfds = svc_fds;
+#endif
+ switch (select(0, &readfds, (int *)NULL, (int *)NULL, (struct timeval *)&timeout)) {
+ case -1:
+ if (WSAerrno == EINTR) {
+ continue;
+ }
+ return;
+ case 0:
+ perror("gltpd_svc_run: - timeout");
+ return;
+ default:
+ svc_getreqset(&readfds);
+ }
+ }
+}
+
+#else
+
+void gltpd_svc_run()
+{
+ fd_set readfdset;
+ extern int errno;
+ static int tsize = 0;
+ struct timeval timeout;
+ xdrproc_t xdr_argument, xdr_result;
+ long currenttime;
+
+ timeout.tv_sec = COMTIMEOUT;
+ timeout.tv_usec = 0;
+
+ if (!tsize)
+ tsize = getdtablesize();
+
+ for (;;) {
+ readfdset = svc_fdset;
+ switch (select(tsize, &readfdset, (fd_set*) NULL, (fd_set*) NULL,
+ (struct timeval *) &timeout)) {
+ case -1:
+ if (errno == EBADF) {
+ continue;
+ }
+ if (errno == EINTR) {
+ time(¤ttime);
+ if (currenttime - timecount > COMTIMEOUT) {
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ destroyserver_1_svc(xdr_argument,NULL);
+ perror("gltpd_svc_run: - timeout");
+ return;
+ }
+ continue;
+ }
+
+ perror("gltpd_svc_run: - select failed");
+ return;
+ case 0:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ destroyserver_1_svc(xdr_argument,NULL);
+ perror("gltpd_svc_run: - timeout");
+ return;
+ default:
+ svc_getreqset(&readfdset);
+ time(&timecount);
+ }
+ }
+
+}
+
+
+
+#endif
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/ecs_sif.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/ecs_sif.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/ecs_sif.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,265 @@
+/******************************************************************************
+ *
+ * Component: OGDI gltpd Server
+ * Purpose: Server function wrappers.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecs_sif.c,v $
+ * Revision 1.3 2001/04/09 15:04:35 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+
+ECS_CVSID("$Id: ecs_sif.c,v 1.3 2001/04/09 15:04:35 warmerda Exp $");
+
+ecs_Server *svr_handle;
+
+ecs_Result ecs_dummy_sif;
+
+/* In this real gltpd server, this is a stub function */
+ecs_Result *
+createproxyserver_1_svc(args,rqstp)
+ ecs_ProxyCreateServer *args;
+ struct svc_req *rqstp;
+{
+ (void) args;
+ (void) rqstp;
+
+ return NULL;
+}
+
+ecs_Result *
+createserver_1_svc(args,rqstp)
+ char **args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ svr_handle = (ecs_Server *) malloc(sizeof(ecs_Server));
+ if (svr_handle == NULL) {
+ ecs_ResultInit(&ecs_dummy_sif);
+ ecs_SetError(&ecs_dummy_sif,1,"no more memory");
+ return &ecs_dummy_sif;
+ }
+ return svr_CreateServer (svr_handle, *args, 0);
+}
+
+ecs_Result *
+destroyserver_1_svc(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ ecs_Result *msg;
+
+ (void) args;
+ (void) rqstp;
+
+ msg = svr_DestroyServer(svr_handle);
+ return msg;
+}
+
+ecs_Result *selectlayer_1_svc(args,rqstp)
+ ecs_LayerSelection *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ return svr_SelectLayer(svr_handle, args);
+}
+
+ecs_Result *releaselayer_1_svc(args,rqstp)
+ ecs_LayerSelection *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ return svr_ReleaseLayer(svr_handle, args);
+}
+
+ecs_Result *selectregion_1_svc(args,rqstp)
+ ecs_Region *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ return svr_SelectRegion(svr_handle, args);
+}
+
+ecs_Result *getdictionnary_1_svc(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+ (void) args;
+
+ return svr_GetDictionary(svr_handle);
+}
+
+ecs_Result *getattributeformat_1_svc(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+ (void) args;
+
+ return svr_GetAttributesFormat(svr_handle);
+}
+
+ecs_Result *getnextobject_1_svc(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+ (void) args;
+
+ return svr_GetNextObject(svr_handle);
+}
+
+ecs_Result *getrasterinfo_1_svc(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+ (void) args;
+
+ return svr_GetRasterInfo(svr_handle);
+}
+
+ecs_Result *getobject_1_svc(args,rqstp)
+ char **args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ return svr_GetObject(svr_handle, *args);
+}
+
+ecs_Result *getobjectidfromcoord_1_svc(args,rqstp)
+ ecs_Coordinate *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ return svr_GetObjectIdFromCoord(svr_handle, args);
+}
+
+ecs_Result *updatedictionary_1_svc(args,rqstp)
+ char **args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ return svr_UpdateDictionary(svr_handle,*args);
+}
+
+ecs_Result *getserverprojection_1_svc(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+ (void) args;
+
+ return svr_GetServerProjection(svr_handle);
+}
+
+ecs_Result *getglobalbound_1_svc(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+ (void) args;
+
+ return svr_GetGlobalBound(svr_handle);
+}
+
+ecs_Result *setserverlanguage_1_svc(args,rqstp)
+ u_int *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ return svr_SetServerLanguage(svr_handle, *args);
+}
+
+ecs_Result * setserverprojection_1_svc(args,rqstp)
+ char **args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ return svr_SetServerProjection(svr_handle, *args);
+}
+
+ecs_Result * setrasterconversion_1_svc(args,rqstp)
+ ecs_RasterConversion *args;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ return svr_SetRasterConversion(svr_handle,args);
+}
+
+ecs_Result *setcompression_1_svc(compression,rqstp)
+ ecs_Compression *compression;
+ struct svc_req *rqstp;
+{
+ (void) rqstp;
+
+ if ((compression->ctype != ECS_COMPRESS_NONE) &&
+ (compression->ctype != ECS_COMPRESS_ZLIB)) {
+ ecs_SetError(&ecs_dummy_sif,1,"Compression format not supported");
+ return &ecs_dummy_sif;
+ }
+ if (compression->cversion != 0) {
+ ecs_SetError(&ecs_dummy_sif,1,"Compression version not supported");
+ return &ecs_dummy_sif;
+ }
+ svr_handle->compression.ctype = compression->ctype;
+ svr_handle->compression.cversion = compression->cversion;
+
+ if (compression->cachesize == 0) {
+ svr_handle->compression.cachesize = ECS_CACHE_DEFAULT;
+ } else if (compression->cachesize > ECS_CACHE_MAX) {
+ svr_handle->compression.cachesize = ECS_CACHE_MAX;
+ } else {
+ svr_handle->compression.cachesize = compression->cachesize;
+ }
+
+ if (compression->ctype == ECS_COMPRESS_ZLIB) {
+ if (compression->clevel == 0) {
+ svr_handle->compression.clevel = ECS_ZLIB_LEVEL_DEFAULT;
+ } else if (compression->clevel > 9) {
+ svr_handle->compression.clevel = 9;
+ } else {
+ svr_handle->compression.clevel = compression->clevel;
+ }
+ if (compression->cblksize > ECS_ZLIB_BLKSIZE_MAX) {
+ svr_handle->compression.cblksize = ECS_ZLIB_BLKSIZE_MAX;
+ } else if (compression->cblksize == 0) {
+ svr_handle->compression.cblksize = ECS_ZLIB_BLKSIZE_DEFAULT;
+ } else {
+ svr_handle->compression.cblksize = compression->cblksize;
+ }
+ } else {
+ svr_handle->compression.clevel = 0;
+ svr_handle->compression.cblksize = 0;
+ }
+ svr_handle->compression.cfullsize = 0;
+
+ ecs_SetSuccess(&ecs_dummy_sif);
+ return &ecs_dummy_sif;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/ecs_svc.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/ecs_svc.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/ecs_svc.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,278 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "ecs.h"
+#ifndef _WINDOWS
+#include <stdio.h>
+#include <stdlib.h>/* getenv, exit */
+#include <rpc/pmap_clnt.h> /* for pmap_unset */
+#include <string.h> /* strcmp */
+#include <signal.h>
+#include <sys/ioctl.h> /* ioctl, TIOCNOTTY */
+#include <sys/types.h> /* open */
+#include <sys/stat.h> /* open */
+#include <fcntl.h> /* open */
+#include <unistd.h> /* getdtablesize */
+#include <memory.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#endif /* ifndef _WINDOWS */
+
+extern unsigned long newprogramno;
+#include <syslog.h>
+
+#ifndef SIG_PF
+#define SIG_PF void(*)(int)
+#endif
+
+#define _RPCSVC_CLOSEDOWN 120
+#define main dummy
+#define RPC_SVC_FG
+
+#ifdef svc_fdset
+#undef svc_fdset
+#endif
+
+extern ecs_Server *svr_handle;
+
+static void closedown(int sig);
+
+void start_closedown_check(void)
+{
+#ifndef _WINDOWS
+ (void) signal(SIGALRM, (SIG_PF) closedown);
+ (void) alarm(_RPCSVC_CLOSEDOWN);
+#endif /* ifndef _WINDOWS */
+}
+
+ int _rpcpmstart; /* Started by a port monitor ? */
+ int _rpcfdtype; /* Whether Stream or Datagram ? */
+ int _rpcsvcdirty; /* Still serving ? */
+
+static
+void _msgout(char* msg)
+{
+#ifdef RPC_SVC_FG
+ if (_rpcpmstart)
+ (void) fprintf(stderr, "%s\n", msg);
+ else
+ (void) fprintf(stderr, "%s\n", msg);
+#else
+ (void) fprintf(stderr, "%s\n", msg);
+#endif
+}
+
+static void
+closedown(int sig)
+{
+ (void) signal(sig, (SIG_PF) closedown);
+ if (_rpcsvcdirty == 0) {
+ extern fd_set svc_fdset;
+ static int size;
+ int i, openfd;
+
+ if (_rpcfdtype == SOCK_DGRAM)
+ exit(0);
+ if (size == 0) {
+ size = getdtablesize();
+ }
+ for (i = 0, openfd = 0; i < size && openfd < 2; i++)
+ if (FD_ISSET(i, &svc_fdset))
+ openfd++;
+ if (openfd <= 1)
+ exit(0);
+ }
+ (void) alarm(_RPCSVC_CLOSEDOWN);
+}
+
+void
+ecsprog_1(struct svc_req *rqstp, register SVCXPRT *transp)
+{
+ union {
+ char *createserver_1_arg;
+ ecs_LayerSelection selectlayer_1_arg;
+ ecs_LayerSelection releaselayer_1_arg;
+ ecs_Region selectregion_1_arg;
+ char *getobject_1_arg;
+ ecs_Coordinate getobjectidfromcoord_1_arg;
+ char *updatedictionary_1_arg;
+ u_int setserverlanguage_1_arg;
+ char *setserverprojection_1_arg;
+ ecs_RasterConversion setrasterconversion_1_arg;
+ ecs_ProxyCreateServer createproxyserver_1_arg;
+ ecs_Compression setcompression_1_arg;
+ } argument;
+ char *result;
+ xdrproc_t xdr_argument, xdr_result;
+ char *(*local)(char *, struct svc_req *);
+
+ _rpcsvcdirty = 1;
+ switch (rqstp->rq_proc) {
+ case NULLPROC:
+ (void) svc_sendreply(transp, (xdrproc_t) xdr_void, (char *)NULL);
+ _rpcsvcdirty = 0;
+ return;
+
+ case CREATESERVER:
+ xdr_argument = (xdrproc_t) xdr_wrapstring;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) createserver_1_svc;
+ break;
+
+ case DESTROYSERVER:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) destroyserver_1_svc;
+ break;
+
+ case SELECTLAYER:
+ xdr_argument = (xdrproc_t) xdr_ecs_LayerSelection;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) selectlayer_1_svc;
+ break;
+
+ case RELEASELAYER:
+ xdr_argument = (xdrproc_t) xdr_ecs_LayerSelection;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) releaselayer_1_svc;
+ break;
+
+ case SELECTREGION:
+ xdr_argument = (xdrproc_t) xdr_ecs_Region;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) selectregion_1_svc;
+ break;
+
+ case GETDICTIONNARY:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) getdictionnary_1_svc;
+ break;
+
+ case GETATTRIBUTEFORMAT:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) getattributeformat_1_svc;
+ break;
+
+ case GETNEXTOBJECT:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) getnextobject_1_svc;
+ break;
+
+ case GETRASTERINFO:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) getrasterinfo_1_svc;
+ break;
+
+ case GETOBJECT:
+ xdr_argument = (xdrproc_t) xdr_wrapstring;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) getobject_1_svc;
+ break;
+
+ case GETOBJECTIDFROMCOORD:
+ xdr_argument = (xdrproc_t) xdr_ecs_Coordinate;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) getobjectidfromcoord_1_svc;
+ break;
+
+ case UPDATEDICTIONARY:
+ xdr_argument = (xdrproc_t) xdr_wrapstring;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) updatedictionary_1_svc;
+ break;
+
+ case GETSERVERPROJECTION:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) getserverprojection_1_svc;
+ break;
+
+ case GETGLOBALBOUND:
+ xdr_argument = (xdrproc_t) xdr_void;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) getglobalbound_1_svc;
+ break;
+
+ case SETSERVERLANGUAGE:
+ xdr_argument = (xdrproc_t) xdr_u_int;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) setserverlanguage_1_svc;
+ break;
+
+ case SETSERVERPROJECTION:
+ xdr_argument = (xdrproc_t) xdr_wrapstring;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) setserverprojection_1_svc;
+ break;
+
+ case SETRASTERCONVERSION:
+ xdr_argument = (xdrproc_t) xdr_ecs_RasterConversion;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) setrasterconversion_1_svc;
+ break;
+
+ case CREATEPROXYSERVER:
+ xdr_argument = (xdrproc_t) xdr_ecs_ProxyCreateServer;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) createproxyserver_1_svc;
+ break;
+
+ case SETCOMPRESSION:
+ xdr_argument = (xdrproc_t) xdr_ecs_Compression;
+ xdr_result = (xdrproc_t) xdr_ecs_Result;
+ local = (char *(*)(char *, struct svc_req *)) setcompression_1_svc;
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ _rpcsvcdirty = 0;
+ return;
+ }
+ (void) memset((char *)&argument, 0, sizeof (argument));
+ if (!svc_getargs(transp, xdr_argument, (caddr_t) &argument)) {
+ svcerr_decode(transp);
+ _rpcsvcdirty = 0;
+ return;
+ }
+ result = (*local)((char *)&argument, rqstp);
+ if (result) {
+ ecs_Result *tmp = (ecs_Result *) result;
+ /* The CreateServer call must be always uncompressed */
+ if (svr_handle && rqstp->rq_proc != CREATESERVER) {
+ tmp->compression = svr_handle->compression;
+ } else {
+ /* This will occur after a DESTROYSERVER call */
+ tmp->compression.ctype = ECS_COMPRESS_NONE;
+ tmp->compression.cversion = 0;
+ tmp->compression.clevel = 0;
+ tmp->compression.cblksize = 0;
+ tmp->compression.cfullsize = 0;
+ tmp->compression.cachesize = 0;
+ }
+ }
+ if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
+ svcerr_systemerr(transp);
+ }
+ if (!svc_freeargs(transp, xdr_argument, (caddr_t) &argument)) {
+ _msgout("unable to free arguments");
+ exit(1);
+ }
+
+ if (rqstp->rq_proc == DESTROYSERVER) {
+#ifdef _WINDOWS
+ rpc_nt_exit();
+#endif
+ pmap_unset(newprogramno, ECSVERS);
+ exit(0);
+ }
+
+ _rpcsvcdirty = 0;
+ return;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = gltpd
+TARGETGEN=$(PROGGEN)
+
+SOURCES = asyncsvr.c ecs_sif.c ecs_svc.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)\
+ $(ZLIB_INCLUDE) $(GENERAL_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS) $(FLAGS_X86DEF) $(RPC_INCLUDES)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(ZLIB_LINKLIB) $(RPC_LINKLIB) \
+ $(PROJ_STATICLIB) $(MATH_LINKLIB) \
+ $(LIBC_LINKLIB) $(UCB_STATICLIB) $(DL_LINKLIB) \
+ $(WIN_LINKLIB) $(X11_LINKLIB) $(LXLIB_LINKLIB) \
+ $(TK_LINKLIB) $(TCL_LINKLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR ecs_svc.c
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+#
+# Because the RPCGEN process doesn't work too well on many
+# platforms we disable it by default, and make people do a "make rpcgen"
+# to regenerate ecs_xdr.c explicitly.
+#
+
+#ecs_svc.c: ../include/ecs.x
+
+rpcgen:
+ -$(RM) -f ecs.x
+ $(FILECOPY) ../include/ecs.x ecs.x
+ $(RM) -f $(OBJDIR)/ecs_svc.c.raw
+ rpcgen -K 120 -I -b -C -s tcp -o $(OBJDIR)/ecs_svc.c.raw ecs.x
+ perl ../scripts/svc_clean.pl \
+ -o ecs_svc.c $(OBJDIR)/ecs_svc.c.raw
+ $(RM) -f ecs.x
+
+clean: default-clean
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/asyncsvr.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/asyncsvr.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/asyncsvr.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,333 @@
+
+#include "ecs.h"
+#ifdef _WINDOWS
+#include "rpc/pmap_cln.h"
+#endif
+#include <unistd.h>
+#include <errno.h>
+
+#define COMTIMEOUT 900
+
+static void dispatchno_1();
+extern void ecsprog_1();
+u_long newprogramno;
+static char str1[255];
+
+void per_svc_run();
+
+int main(argc,argv)
+ int argc;
+ char **argv;
+{
+ SVCXPRT *transp;
+ int num;
+ int isDispatch = TRUE;
+
+#ifdef _WINDOWS
+ rpc_nt_init();
+#endif
+
+ /* Analyser la requete */
+
+ switch(argc) {
+ case 2:
+ sscanf(argv[1],"%s",str1);
+ if (strncmp(str1,"-d",2) == 0) {
+ isDispatch = TRUE;
+ } else {
+ isDispatch = FALSE;
+ sscanf(argv[1],"%d",&num);
+ }
+ break;
+ case 1:
+ isDispatch == TRUE;
+ strcpy(str1,"");
+ break;
+ default:
+ printf("Wrong number of arguments\n");
+ exit(0);
+ break;
+ };
+
+
+ /* Si un argument existe pour ce serveur, creer directement
+ ce serveur sans passer par le dispatcher */
+
+ /* Creer le serveur directement */
+
+ if (isDispatch) {
+ /* Passer par le dispatcher normalement */
+
+ (void)pmap_unset(ECSPROG, ECSVERS);
+
+ transp = svctcp_create(RPC_ANYSOCK, 0, 0);
+ if (transp == NULL) {
+ (void)fprintf(stderr, "cannot create tcp service.\n");
+ return 0;
+ }
+ if (!svc_register(transp, ECSPROG, ECSVERS,
+ dispatchno_1, IPPROTO_TCP)) {
+ (void)fprintf(stderr,
+ "unable to register (DISPATCHNO, DISPATCHVERS, tcp).\n");
+ return 0;
+ }
+ svc_run();
+ (void)fprintf(stderr, "svc_run returned\n");
+ } else {
+
+ (void)pmap_unset(num, ECSVERS);
+
+ /* Enregistrer le nouveau serveur */
+ transp = svctcp_create(RPC_ANYSOCK, 0, 0);
+ if (transp == NULL) {
+ (void)fprintf(stderr, "cannot create tcp service.\n");
+ return 0;
+ }
+
+ if (!svc_register(transp, num, ECSVERS, ecsprog_1, IPPROTO_TCP)) {
+ (void)fprintf(stderr, "unable to register (ECSPROG, ECSVERS, tcp).\n");
+ exit(1);
+ }
+
+ per_svc_run();
+ }
+
+#ifdef _WINDOWS
+ rpc_nt_exit();
+#endif
+
+ return 1;
+}
+
+static void
+dispatchno_1(rqstp, transp)
+ struct svc_req *rqstp;
+ SVCXPRT *transp;
+{
+#ifdef _WINDOWS
+ STARTUPINFO si;
+ SECURITY_ATTRIBUTES saProcess, saThread;
+ PROCESS_INFORMATION piProcessB;
+#endif
+ char temp[256];
+ bool_t result;
+ union {
+ int fill;
+ } argument;
+ SVCXPRT *newtransp;
+
+ switch (rqstp->rq_proc) {
+ case NULLPROC:
+ (void)svc_sendreply(transp, (xdrproc_t) xdr_void, (char *)NULL);
+ return;
+
+ case 1:
+ /* Dispatcher de service */
+
+ memset((char *)&argument,0, sizeof(argument));
+ if (!svc_getargs(transp, xdr_void, &argument)) {
+ svcerr_decode(transp);
+ return;
+ }
+
+#ifndef _WINDOWS
+ if(fork()) return;
+#endif
+
+ /* Trouver le numero du nouveau serveur */
+
+ newtransp = svctcp_create(RPC_ANYSOCK, 0, 0);
+ /* Trouver dynamiquement un numero d'identifiant */
+
+ newprogramno = ECS_TRANSIENT_MIN;
+ while( !pmap_set( newprogramno, ECSVERS, IPPROTO_TCP, newtransp->xp_port)) {
+ newprogramno = ECS_TRANSIENT_MIN + ( newprogramno + 1 )
+ % (ECS_TRANSIENT_MAX - ECS_TRANSIENT_MIN + 1);
+ }
+
+
+#ifdef _WINDOWS
+ /* Cas Windows avec CreateProcess */
+
+ ZeroMemory(&si,sizeof(si));
+ si.cb = sizeof(si);
+
+ saProcess.nLength = sizeof(saProcess);
+ saProcess.lpSecurityDescriptor =NULL;
+ saProcess.bInheritHandle=TRUE;
+
+ saThread.nLength = sizeof(saThread);
+ saThread.lpSecurityDescriptor =NULL;
+ saThread.bInheritHandle=FALSE;
+
+ /* spawn process */
+
+ if (strncmp(str1,"-d",2) != 0) {
+ sprintf(temp,"gltpd %d",newprogramno);
+ result = CreateProcess ("gltpd.exe",
+ temp, /* command line */
+ &saProcess, &saThread,
+ FALSE,
+ DETACHED_PROCESS,
+ NULL, NULL,&si,
+ &piProcessB);
+ } else {
+ if (!svc_sendreply(transp, (xdrproc_t) xdr_u_long, (char *) &newprogramno)) {
+ svcerr_systemerr(transp);
+ printf("erreur reply\n");
+ }
+ if (!svc_freeargs(transp, xdr_void, &argument)) {
+ (void)fprintf(stderr, "unable to free arguments\n");
+ exit(1);
+ }
+
+ /* Enregistrer le nouveau serveur */
+
+ if (!svc_register(newtransp, newprogramno, ECSVERS, ecsprog_1, 0)) {
+ (void)fprintf(stderr, "unable to register (ECSPROG, ECSVERS, tcp).\n");
+ exit(1);
+ }
+
+ per_svc_run();
+
+ exit(1);
+
+ }
+
+ if (result) {
+ CloseHandle(piProcessB.hProcess);
+ CloseHandle(piProcessB.hThread);
+ } else {
+ return;
+ }
+
+ /* Retourner le resultat au client, mais auparavent on laisse le
+ temps au serveur de s'intialiser */
+
+ Sleep(1000);
+
+ if (!svc_sendreply(transp, (xdrproc_t) xdr_u_long, (char *) &newprogramno)) {
+ svcerr_systemerr(transp);
+ printf("erreur reply\n");
+ }
+ if (!svc_freeargs(transp, xdr_void, &argument)) {
+ (void)fprintf(stderr, "unable to free arguments\n");
+ exit(1);
+ }
+
+#else
+ /* Cas UNIX avec fork */
+
+ /* Retourner le resultat au client */
+
+ if (!svc_sendreply(transp, (xdrproc_t) xdr_u_long, (char *) &newprogramno)) {
+ svcerr_systemerr(transp);
+ printf("erreur reply\n");
+ }
+ if (!svc_freeargs(transp, xdr_void, &argument)) {
+ (void)fprintf(stderr, "unable to free arguments\n");
+ exit(1);
+ }
+
+ /* Enregistrer le nouveau serveur */
+
+ if (!svc_register(newtransp, newprogramno, ECSVERS, ecsprog_1, 0)) {
+ (void)fprintf(stderr, "unable to register (ECSPROG, ECSVERS, tcp).\n");
+ exit(1);
+ }
+
+ per_svc_run();
+ (void)fprintf(stderr, "svc_run returned\n");
+ exit(1);
+#endif
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ return;
+ }
+}
+
+
+
+#ifdef _WINDOWS
+
+void per_svc_run()
+{
+ svc_run();
+/* struct timeval timeout;
+ fd_set readfds;
+ Message *retour;
+
+ timeout.tv_sec = COMTIMEOUT;
+ timeout.tv_usec = 0;
+
+ for (;;) {
+
+ readfds = svc_fdset;
+
+ switch (select(0, &readfds,
+ (struct fd_set *) 0, (struct fd_set *)0,
+ (struct timeval *) &timeout)) {
+ case -1:
+ if (WSAerrno == EINTR) {
+ continue;
+ }
+ perror("svc_run: - select failed");
+ return;
+ case 0:
+ retour = disconnecthost_1();
+ perror("per_svc_run: - timeout");
+ return;
+ default:
+ svc_getreqset(&readfds);
+ }
+ }
+*/
+}
+
+#else
+
+void per_svc_run()
+{
+ svc_run();
+
+/* fd_set readfdset;
+ extern int errno;
+ static int tsize = 0;
+ struct timeval timeout;
+ Message *retour;
+
+ timeout.tv_sec = COMTIMEOUT;
+ timeout.tv_usec = 0;
+
+ if (!tsize)
+ tsize = getdtablesize();
+
+ for (;;) {
+ readfdset = svc_fdset;
+ switch (select(tsize, &readfdset, (fd_set*) NULL, (fd_set*) NULL,
+ (struct timeval *) &timeout)) {
+ case -1:
+ if (errno == EBADF) {
+ continue;
+ }
+ perror("svc_run: - select failed");
+ return;
+ case 0:
+ retour = disconnecthost_1();
+ perror("per_svc_run: - timeout");
+ return;
+ default:
+ svc_getreqset(&readfdset);
+ }
+ }
+*/
+}
+
+
+
+#endif
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/ecs_sif.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/ecs_sif.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/ecs_sif.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,150 @@
+#include "ecs.h"
+
+ecs_Server *mptr;
+
+ecs_Result ecs_dummy_sif;
+
+ecs_Result *createserver_1(args,rqstp)
+ char **args;
+ struct svc_req *rqstp;
+{
+ mptr = (ecs_Server *) malloc(sizeof(ecs_Server));
+ if (mptr == NULL) {
+ ecs_ResultInit(&ecs_dummy_sif);
+ ecs_SetError(&ecs_dummy_sif,1,"no more memory");
+ return &ecs_dummy_sif;
+ }
+
+ return svr_CreateServer (mptr, *args, 0);
+}
+
+ecs_Result *destroyserver_1(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ ecs_Result *msg;
+
+ msg = svr_DestroyServer(mptr);
+ free(mptr);
+ mptr = NULL;
+ return msg;
+}
+
+ecs_Result *selectlayer_1(args,rqstp)
+ ecs_LayerSelection *args;
+ struct svc_req *rqstp;
+{
+ return svr_SelectLayer(mptr, args);
+}
+
+ecs_Result *releaselayer_1(args,rqstp)
+ ecs_LayerSelection *args;
+ struct svc_req *rqstp;
+{
+ return svr_ReleaseLayer(mptr, args);
+}
+
+ecs_Result *selectregion_1(args,rqstp)
+ ecs_Region *args;
+ struct svc_req *rqstp;
+{
+ return svr_SelectRegion(mptr, args);
+}
+
+ecs_Result *getdictionnary_1(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ return svr_GetDictionary(mptr);
+}
+
+ecs_Result *getattributeformat_1(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ return svr_GetAttributesFormat(mptr);
+}
+
+ecs_Result *getnextobject_1(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ return svr_GetNextObject(mptr);
+}
+
+ecs_Result *getrasterinfo_1(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ return svr_GetRasterInfo(mptr);
+}
+
+ecs_Result *getobject_1(args,rqstp)
+ char **args;
+ struct svc_req *rqstp;
+{
+ return svr_GetObject(mptr, *args);
+}
+
+ecs_Result *getobjectidfromcoord_1(args,rqstp)
+ ecs_Coordinate *args;
+ struct svc_req *rqstp;
+{
+ return svr_GetObjectIdFromCoord(mptr, args);
+}
+
+ecs_Result *updatedictionary_1(args,rqstp)
+ char **args;
+ struct svc_req *rqstp;
+{
+ return svr_UpdateDictionary(mptr,*args);
+}
+
+ecs_Result *getserverprojection_1(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ return svr_GetServerProjection(mptr);
+}
+
+ecs_Result *getglobalbound_1(args,rqstp)
+ void *args;
+ struct svc_req *rqstp;
+{
+ return svr_GetGlobalBound(mptr);
+}
+
+ecs_Result *setserverlanguage_1(args,rqstp)
+ u_int *args;
+ struct svc_req *rqstp;
+{
+ return svr_SetServerLanguage(mptr, *args);
+}
+
+ecs_Result * setserverprojection_1(args,rqstp)
+ char **args;
+ struct svc_req *rqstp;
+{
+ return svr_SetServerProjection(mptr, *args);
+}
+
+ecs_Result * setrasterconversion_1(args,rqstp)
+ ecs_RasterConversion *args;
+ struct svc_req *rqstp;
+{
+ return svr_SetRasterConversion(mptr,args);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/ecs_svc.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/ecs_svc.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/gltpd/sun/ecs_svc.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,315 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "ecs.h"
+#include <stdio.h>
+#include <stdlib.h> /* getenv, exit */
+#include <signal.h>
+#include <sys/types.h>
+#include <memory.h>
+#include <stropts.h>
+#include <netconfig.h>
+#include <sys/resource.h> /* rlimit */
+#include <syslog.h>
+
+#ifdef DEBUG
+#define RPC_SVC_FG
+#endif
+
+#define _RPCSVC_CLOSEDOWN 120
+#define main dummy
+static int _rpcpmstart; /* Started by a port monitor ? */
+ /* States a server can be in wrt request */
+
+#define _IDLE 0
+#define _SERVED 1
+#define _SERVING 2
+
+static int _rpcsvcstate = _IDLE; /* Set when a request is serviced */
+
+static
+void _msgout(msg)
+ char *msg;
+{
+#ifdef RPC_SVC_FG
+ if (_rpcpmstart)
+ syslog(LOG_ERR, msg);
+ else
+ (void) fprintf(stderr, "%s\n", msg);
+#else
+ syslog(LOG_ERR, msg);
+#endif
+}
+
+static void
+closedown(sig)
+ int sig;
+{
+ if (_rpcsvcstate == _IDLE) {
+ extern fd_set svc_fdset;
+ static int size;
+ int i, openfd;
+ struct t_info tinfo;
+
+ if (!t_getinfo(0, &tinfo) && (tinfo.servtype == T_CLTS))
+ exit(0);
+ if (size == 0) {
+ struct rlimit rl;
+
+ rl.rlim_max = 0;
+ getrlimit(RLIMIT_NOFILE, &rl);
+ if ((size = rl.rlim_max) == 0) {
+ return;
+ }
+ }
+ for (i = 0, openfd = 0; i < size && openfd < 2; i++)
+ if (FD_ISSET(i, &svc_fdset))
+ openfd++;
+ if (openfd <= 1)
+ exit(0);
+ }
+ if (_rpcsvcstate == _SERVED)
+ _rpcsvcstate = _IDLE;
+
+ (void) signal(SIGALRM, (void(*)()) closedown);
+ (void) alarm(_RPCSVC_CLOSEDOWN/2);
+}
+
+void
+ecsprog_1(rqstp, transp)
+ struct svc_req *rqstp;
+ register SVCXPRT *transp;
+{
+ union {
+ char *createserver_1_arg;
+ ecs_LayerSelection selectlayer_1_arg;
+ ecs_LayerSelection releaselayer_1_arg;
+ ecs_Region selectregion_1_arg;
+ char *getobject_1_arg;
+ ecs_Coordinate getobjectidfromcoord_1_arg;
+ char *updatedictionary_1_arg;
+ u_int setserverlanguage_1_arg;
+ char *setserverprojection_1_arg;
+ ecs_RasterConversion setrasterconversion_1_arg;
+ } argument;
+ char *result;
+ bool_t (*xdr_argument)(), (*xdr_result)();
+ char *(*local)();
+
+ _rpcsvcstate = _SERVING;
+ switch (rqstp->rq_proc) {
+ case NULLPROC:
+ (void) svc_sendreply(transp, xdr_void,
+ (char *)NULL);
+ _rpcsvcstate = _SERVED;
+ return;
+
+ case CREATESERVER:
+ xdr_argument = xdr_wrapstring;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) createserver_1;
+ break;
+
+ case DESTROYSERVER:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) destroyserver_1;
+ break;
+
+ case SELECTLAYER:
+ xdr_argument = xdr_ecs_LayerSelection;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) selectlayer_1;
+ break;
+
+ case RELEASELAYER:
+ xdr_argument = xdr_ecs_LayerSelection;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) releaselayer_1;
+ break;
+
+ case SELECTREGION:
+ xdr_argument = xdr_ecs_Region;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) selectregion_1;
+ break;
+
+ case GETDICTIONNARY:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getdictionnary_1;
+ break;
+
+ case GETATTRIBUTEFORMAT:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getattributeformat_1;
+ break;
+
+ case GETNEXTOBJECT:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getnextobject_1;
+ break;
+
+ case GETRASTERINFO:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getrasterinfo_1;
+ break;
+
+ case GETOBJECT:
+ xdr_argument = xdr_wrapstring;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getobject_1;
+ break;
+
+ case GETOBJECTIDFROMCOORD:
+ xdr_argument = xdr_ecs_Coordinate;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getobjectidfromcoord_1;
+ break;
+
+ case UPDATEDICTIONARY:
+ xdr_argument = xdr_wrapstring;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) updatedictionary_1;
+ break;
+
+ case GETSERVERPROJECTION:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getserverprojection_1;
+ break;
+
+ case GETGLOBALBOUND:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getglobalbound_1;
+ break;
+
+ case SETSERVERLANGUAGE:
+ xdr_argument = xdr_u_int;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) setserverlanguage_1;
+ break;
+
+ case SETSERVERPROJECTION:
+ xdr_argument = xdr_wrapstring;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) setserverprojection_1;
+ break;
+
+ case SETRASTERCONVERSION:
+ xdr_argument = xdr_ecs_RasterConversion;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) setrasterconversion_1;
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ _rpcsvcstate = _SERVED;
+ return;
+ }
+ (void) memset((char *)&argument, 0, sizeof (argument));
+ if (!svc_getargs(transp, xdr_argument, &argument)) {
+ svcerr_decode(transp);
+ _rpcsvcstate = _SERVED;
+ return;
+ }
+ result = (*local)(&argument, rqstp);
+ if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
+ svcerr_systemerr(transp);
+ }
+ if (!svc_freeargs(transp, xdr_argument, &argument)) {
+ _msgout("unable to free arguments");
+ exit(1);
+ }
+ _rpcsvcstate = _SERVED;
+ return;
+}
+
+main()
+{
+ pid_t pid;
+ int i;
+ char mname[FMNAMESZ + 1];
+
+ if (!ioctl(0, I_LOOK, mname) &&
+ (!strcmp(mname, "sockmod") || !strcmp(mname, "timod"))) {
+ char *netid;
+ struct netconfig *nconf = NULL;
+ SVCXPRT *transp;
+ int pmclose;
+
+ _rpcpmstart = 1;
+ openlog("ecs", LOG_PID, LOG_DAEMON);
+
+ if ((netid = getenv("NLSPROVIDER")) == NULL) {
+ /* started from inetd */
+ pmclose = 1;
+ } else {
+ if ((nconf = getnetconfigent(netid)) == NULL)
+ _msgout("cannot get transport info");
+
+ pmclose = (t_getstate(0) != T_DATAXFER);
+ }
+ if (strcmp(mname, "sockmod") == 0) {
+ if (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, "timod")) {
+ _msgout("could not get the right module");
+ exit(1);
+ }
+ }
+ if ((transp = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {
+ _msgout("cannot create server handle");
+ exit(1);
+ }
+ if (nconf)
+ freenetconfigent(nconf);
+ if (!svc_reg(transp, ECSPROG, ECSVERS, ecsprog_1, 0)) {
+ _msgout("unable to register (ECSPROG, ECSVERS).");
+ exit(1);
+ }
+ if (pmclose) {
+ (void) signal(SIGALRM, (void(*)()) closedown);
+ (void) alarm(_RPCSVC_CLOSEDOWN/2);
+ }
+ svc_run();
+ exit(1);
+ /* NOTREACHED */
+ } else {
+#ifndef RPC_SVC_FG
+ int size;
+ struct rlimit rl;
+ pid = fork();
+ if (pid < 0) {
+ perror("cannot fork");
+ exit(1);
+ }
+ if (pid)
+ exit(0);
+ rl.rlim_max = 0;
+ getrlimit(RLIMIT_NOFILE, &rl);
+ if ((size = rl.rlim_max) == 0)
+ exit(1);
+ for (i = 0; i < size; i++)
+ (void) close(i);
+ i = open("/dev/console", 2);
+ (void) dup2(i, 1);
+ (void) dup2(i, 2);
+ setsid();
+ openlog("ecs", LOG_PID, LOG_DAEMON);
+#endif
+ }
+ if (!svc_create(ecsprog_1, ECSPROG, ECSVERS, "netpath")) {
+ _msgout("unable to create (ECSPROG, ECSVERS) for netpath.");
+ exit(1);
+ }
+
+ svc_run();
+ _msgout("svc_run returned");
+ exit(1);
+ /* NOTREACHED */
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/dirent.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/dirent.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/dirent.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,288 @@
+#ifdef _WINDOWS
+/*
+ dir.c for MS-DOS by Samuel Lam <skl at van-bc.UUCP>, June/87
+*/
+
+/*
+ * @(#)dir.c 1.4 87/11/06 Public Domain.
+ *
+ * A public domain implementation of BSD directory routines for
+ * MS-DOS. Written by Michael Rendell ({uunet,utai}michael at garfield),
+ * August 1897
+ * Ported to OS/2 by Kai Uwe Rommel
+ * December 1989, February 1990
+ * Ported to Windows NT 22 May 91
+ * other mods Summer '92 brianmo at microsoft.com
+ * opendirx() was horribly written, very inefficient, and did not take care
+ * of all cases. It is still not too clean, but it is far more efficient.
+ * Changes made by Gordon Chaffee (chaffee at bugs-bunny.cs.berkeley.edu)
+ */
+
+
+/*Includes:
+ * crt
+ */
+#include <windows.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys\types.h>
+#include <sys\stat.h>
+#include "dirent.h"
+
+#define stat _stat
+
+/*
+ * NT specific
+ */
+#include <stdio.h>
+
+/*
+ * random typedefs
+ */
+#define HDIR HANDLE
+#define HFILE HANDLE
+#define PHFILE PHANDLE
+
+/*
+ * local functions
+ */
+static char *getdirent(char *);
+static void free_dircontents(struct _dircontents *);
+
+static HDIR FindHandle;
+static WIN32_FIND_DATA FileFindData;
+
+static struct dirent dp;
+
+DIR *opendirx(char *name, char *pattern)
+{
+ struct stat statb;
+ DIR *dirp;
+ char c;
+ char *s;
+ struct _dircontents *dp;
+ int len;
+ int unc;
+ char path[ OFS_MAXPATHNAME ];
+ register char *ip, *op;
+
+ for (ip = name, op = path; ; op++, ip++) {
+ *op = *ip;
+ if (*ip == '\0') {
+ break;
+ }
+ }
+ len = ip - name;
+ if (len > 0) {
+ unc = ((path[0] == '\\' || path[0] == '/') &&
+ (path[1] == '\\' || path[1] == '/'));
+ c = path[len - 1];
+ if (unc) {
+ if (c != '\\' && c != '/') {
+ path[len] = '/';
+ len++;
+ path[len] ='\0';
+ }
+ } else {
+ if ((c == '\\' || c == '/') && (len > 1)) {
+ len--;
+ path[len] = '\0';
+
+ if (path[len - 1] == ':' ) {
+ path[len] = '/'; len++;
+ path[len] = '.'; len++;
+ path[len] = '\0';
+ }
+ } else if (c == ':' ) {
+ path[len] = '.';
+ len++;
+ path[len] ='\0';
+ }
+ }
+ } else {
+ unc = 0;
+ path[0] = '.';
+ path[1] = '\0';
+ len = 1;
+ }
+
+ if (stat(path, &statb) < 0 || (statb.st_mode & S_IFMT) != S_IFDIR) {
+ return NULL;
+ }
+
+ dirp = malloc(sizeof(DIR));
+ if (dirp == NULL) {
+ return dirp;
+ }
+
+ c = path[len - 1];
+ if (c == '.' ) {
+ if (len == 1) {
+ len--;
+ } else {
+ c = path[len - 2];
+ if (c == '\\' || c == ':') {
+ len--;
+ } else {
+ path[len] = '/';
+ len++;
+ }
+ }
+ } else if (!unc && ((len != 1) || (c != '\\' && c != '/'))) {
+ path[len] = '/';
+ len++;
+ }
+ strcpy(path + len, pattern);
+
+ dirp -> dd_loc = 0;
+ dirp -> dd_contents = dirp -> dd_cp = NULL;
+
+ if ((s = getdirent(path)) == NULL) {
+ return dirp;
+ }
+
+ do
+ {
+ if (((dp = malloc(sizeof(struct _dircontents))) == NULL) ||
+ ((dp -> _d_entry = malloc(strlen(s) + 1)) == NULL) )
+ {
+ if (dp)
+ free(dp);
+ free_dircontents(dirp -> dd_contents);
+
+ return NULL;
+ }
+
+ if (dirp -> dd_contents)
+ dirp -> dd_cp = dirp -> dd_cp -> _d_next = dp;
+ else
+ dirp -> dd_contents = dirp -> dd_cp = dp;
+
+ strcpy(dp -> _d_entry, s);
+ dp -> _d_next = NULL;
+
+ }
+ while ((s = getdirent(NULL)) != NULL);
+
+ dirp -> dd_cp = dirp -> dd_contents;
+ return dirp;
+}
+
+DIR *opendir(char *name)
+{
+ return opendirx(name, "*");
+}
+
+void closedir(DIR * dirp)
+{
+ free_dircontents(dirp -> dd_contents);
+ free(dirp);
+}
+
+struct dirent *readdir(DIR * dirp)
+{
+ /* static struct dirent dp; */
+ if (dirp -> dd_cp == NULL)
+ return NULL;
+
+ /*strcpy(dp.d_name,dirp->dd_cp->_d_entry); */
+
+ dp.d_name = dirp->dd_cp->_d_entry;
+
+ dp.d_namlen = dp.d_reclen =
+ strlen(dp.d_name);
+
+ dp.d_ino = dirp->dd_loc+1; /* fake the inode */
+
+ dirp -> dd_cp = dirp -> dd_cp -> _d_next;
+ dirp -> dd_loc++;
+
+
+ return &dp;
+}
+
+void seekdir(DIR * dirp, long off)
+{
+ long i = off;
+ struct _dircontents *dp;
+
+ if (off >= 0)
+ {
+ for (dp = dirp -> dd_contents; --i >= 0 && dp; dp = dp -> _d_next);
+
+ dirp -> dd_loc = off - (i + 1);
+ dirp -> dd_cp = dp;
+ }
+}
+
+
+long telldir(DIR * dirp)
+{
+ return dirp -> dd_loc;
+}
+
+static void free_dircontents(struct _dircontents * dp)
+{
+ struct _dircontents *odp;
+
+ while (dp)
+ {
+ if (dp -> _d_entry)
+ free(dp -> _d_entry);
+
+ dp = (odp = dp) -> _d_next;
+ free(odp);
+ }
+}
+/* end of "free_dircontents" */
+
+static char *getdirent(char *dir)
+{
+ int got_dirent;
+
+ if (dir != NULL)
+ { /* get first entry */
+ if ((FindHandle = FindFirstFile( dir, &FileFindData ))
+ == (HDIR)0xffffffff)
+ {
+ return NULL;
+ }
+ got_dirent = 1;
+ }
+ else /* get next entry */
+ got_dirent = FindNextFile( FindHandle, &FileFindData );
+
+ if (got_dirent)
+ return FileFindData.cFileName;
+ else
+ {
+ FindClose(FindHandle);
+ return NULL;
+ }
+}
+/* end of getdirent() */
+
+struct passwd * _cdecl
+getpwnam(char *name)
+{
+ return NULL;
+}
+
+struct passwd * _cdecl
+getpwuid(int uid)
+{
+ return NULL;
+}
+
+int
+getuid()
+{
+ return 0;
+}
+
+void _cdecl
+endpwent(void)
+{
+}
+
+#endif /* _WINDOWS */
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/getglenv.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/getglenv.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/getglenv.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,196 @@
+#ifdef _WINDOWS
+#include <windows.h>
+#endif
+#include <stdlib.h>
+#include "glutil.h"
+#include <string.h>
+
+/* prototype */
+char *gl_GetRegistryString(char *regPath, char *keyname);
+int gl_SetRegistryString(char *regPath, char *keyname, char *keyinfo);
+
+/*************************************************************************
+* Retreive the information related to where is the bin path of GRASSLAND
+*
+* Results:
+* A string
+*
+**************************************************************************/
+char *getGLenv()
+{
+static char *gl = NULL;
+
+ if (gl != NULL)
+ return gl;
+
+#ifdef _WINDOWS
+
+ gl = gl_GetRegistryString(GLHOME, APPLICATION_NAME);
+ if (gl == NULL)
+ return NULL;
+#else
+ gl = getenv("GRASSLAND");
+ if (gl == NULL)
+ return NULL;
+#endif
+ return gl;
+
+}
+
+/****************************************************************************
+ * Retreive the information related to where is the home user path of GRASSLAND
+ *
+ * Results:
+ * A string
+ *
+ ****************************************************************************/
+char *getUSRHOMEenv()
+{
+static char *gl = NULL;
+
+ if (gl != NULL)
+ return gl;
+
+#ifdef _WINDOWS
+
+ gl = gl_GetRegistryString(GLHOME, APPLICATION_USER_HOME);
+ if (gl == NULL)
+ return NULL;
+#else
+ gl = getenv("HOME");
+ if (gl == NULL)
+ return NULL;
+#endif
+ return gl;
+
+}
+
+/*************************************************************************
+* Retreive the information related to where is the GISRC file
+*
+* Results:
+* A string
+*
+**************************************************************************/
+char *getGISRCenv()
+{
+static char *gl = NULL;
+
+ if (gl != NULL)
+ return gl;
+
+#ifdef _WINDOWS
+
+ gl = gl_GetRegistryString(GLHOME, APPLICATION_USER_GISRC);
+ if (gl == NULL)
+ return NULL;
+#else
+ gl = getenv("GISRC");
+ if (gl == NULL)
+ return NULL;
+#endif
+ return gl;
+
+}
+
+/*************************************************************************
+* Retreive the information related to where is the GISBASE path
+*
+* Results:
+* A string
+*
+**************************************************************************/
+char *getGISBASEenv()
+{
+static char *gl = NULL;
+
+ if (gl != NULL)
+ return gl;
+
+#ifdef _WINDOWS
+
+ gl = gl_GetRegistryString(GLHOME, APPLICATION_USER_GISBASE);
+ if (gl == NULL)
+ return NULL;
+#else
+ gl = getenv("GISBASE");
+ if (gl == NULL)
+ return NULL;
+#endif
+ return gl;
+
+}
+#ifdef _WINDOWS
+/*************************************************************************
+* Retreive the key information from HKEY_LOCAL_MACHINE in the registry
+*
+* Results:
+* A string
+*
+**************************************************************************/
+char *gl_GetRegistryString(char *regPath, char *keyname)
+{
+ HKEY hkey;
+ DWORD dwSize;
+ DWORD dwType;
+ int ret;
+ char *value = NULL;
+
+ ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regPath, 0, KEY_READ, &hkey);
+ if (ret == ERROR_SUCCESS) {
+ ret = RegQueryValueEx(hkey, keyname, NULL, &dwType, NULL, &dwSize);
+ if (ret == ERROR_SUCCESS) {
+ if (dwType != REG_SZ) {
+ RegCloseKey(hkey);
+ return NULL;
+ }
+ value = (char *) malloc(dwSize);
+ if (value) {
+ ret = RegQueryValueEx(hkey, keyname, NULL, &dwType, value,
+ &dwSize);
+ if (ret != ERROR_SUCCESS) {
+ free((char *) value);
+ value = NULL;
+ }
+ }
+ }
+ RegCloseKey(hkey);
+ }
+ return value;
+}
+
+/*************************************************************************
+* Sets the key information from HKEY_LOCAL_MACHINE in the registry
+*
+* Results:
+* 1 if success
+* 0 if fail
+*
+**************************************************************************/
+int gl_SetRegistryString(char *regPath, char *keyname, char *keyinfo)
+{
+ HKEY hkey;
+ DWORD dwDispose;
+ int ret;
+ int size;
+ char *classer;
+
+ ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, regPath, 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hkey, &dwDispose);
+ if (ret == ERROR_SUCCESS) {
+ size = strlen(keyinfo);
+ ret = RegSetValueEx(hkey, keyname, 0, REG_SZ, keyinfo, size);
+ if (ret != ERROR_SUCCESS) {
+ RegCloseKey(hkey);
+ return 0;
+ }
+ else {
+ RegCloseKey(hkey);
+ return 1;
+ }
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/glutil.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/glutil.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/glutil.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,23 @@
+#define GLHOME "SOFTWARE\\GRASSLAND\\HOME"
+#define GLINFO "SOFTWARE\\GRASSLAND\\INFO"
+#define APPLICATION_NAME "GRASSLAND"
+#define APPLICATION_USER_HOME "USRHOME"
+#define APPLICATION_USER_GISRC "GISRC"
+#define APPLICATION_USER_GISBASE "GISBASE"
+
+
+
+/* PROTOTYPE */
+char *getGLenv(void);
+char *getUSRHOMEenv(void);
+char *getGISRCenv();
+char *getGISBASEenv();
+int remove_dir(char *path);
+char *ConvertFStoBSString(char *in);
+char *ConvertBStoFSString(char *in);
+
+int bCreate_status_d_text(char *text1,char *text2);
+int bUpdate_status_d_text(char *text1,char *text2);
+int bIs_status_d_Cancel_checked();
+void close_status_d();
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/iofile.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/iofile.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/iofile.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,207 @@
+#ifdef _WINDOWS
+#include <string.h>
+#include <windows.h>
+#include <io.h>
+#include <direct.h>
+#include <stdio.h>
+#else
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#endif
+
+#include "glutil.h"
+#include <ogdi_macro.h>
+/*
+ *----------------------------------------------------------------------
+ * remove_dir
+ *
+ * Empty a directory (delete all *.* files) and remove the directory
+ *
+ * Results:
+ * A int (1 = done, 0 = error
+ *
+ *----------------------------------------------------------------------
+ */
+int remove_dir(path)
+ char *path;
+{
+#ifdef _WINDOWS
+ struct _finddata_t c_file;
+ long hfile;
+ char current_dir[_MAX_PATH];
+
+ if (_getcwd(current_dir,_MAX_PATH) == NULL) {
+ return 0;
+ }
+
+ if (_chdir(path)) {
+ return 0;
+ }
+
+ if ((hfile = _findfirst("*.*", &c_file)) == -1L) {
+ return 0;
+ } else {
+ do {
+ unlink(c_file.name);
+ }
+ while(_findnext(hfile, &c_file) == 0);
+ _findclose(hfile);
+ }
+
+
+ _chdir(current_dir);
+
+ return (int) RemoveDirectory(path);
+#else
+ char buffer[256];
+
+ sprintf(buffer,"rm -r %s",path);
+ ogdi_system(buffer);
+ return 0;
+#endif
+}
+
+/*
+ *----------------------------------------------------------------------
+ * ConvertFStoBSString --
+ *
+ * Convert a string with forward slashes to a string with backslashes
+ * The returned string must be freed with ckfree.
+ *
+ * Results:
+ * A string
+ *
+ * Side effects:
+ * Memory is allocated.
+ *----------------------------------------------------------------------
+ */
+char *ConvertFStoBSString(char *in)
+{
+ char *out;
+ char *ip, *op;
+ int len;
+
+ len = strlen(in) + 1;
+ out = malloc(len);
+ if (out == NULL) return in;
+
+ op = out; ip = in;
+ while (*ip != '\0') {
+ if (*ip == '/') {
+ *op = '\\';
+ } else {
+ *op = *ip;
+ }
+ ip++; op++;
+ }
+ *op = '\0';
+ return out;
+}
+
+/*
+ *----------------------------------------------------------------------
+ * ConvertBStoFSString --
+ *
+ * Convert a string with backslashes to a string with Forward slashes
+ * The returned string must be freed with ckfree.
+ *
+ * Results:
+ * A string
+ *
+ * Side effects:
+ * Memory is allocated.
+ *----------------------------------------------------------------------
+ */
+char *ConvertBStoFSString(char *in)
+{
+ char *out;
+ char *ip, *op;
+ int len;
+
+ len = strlen(in) + 1;
+ out = malloc(len);
+ if (out == NULL) return in;
+
+ op = out; ip = in;
+ while (*ip != '\0') {
+ if (*ip == '\\') {
+ *op = '/';
+ } else {
+ *op = *ip;
+ }
+ ip++; op++;
+ }
+ *op = '\0';
+ return out;
+}
+
+#ifdef _WINDOWS
+int list_element (out, element, desc, mapset, lister)
+ FILE *out;
+ char *element;
+ char *desc;
+ char *mapset;
+ int (*lister)();
+{
+ char path[1000];
+ char buf[400];
+ int count,j;
+ struct _finddata_t c_file;
+ long hfile;
+ char current_dir[_MAX_PATH];
+
+ count = 0;
+/*
+ * convert . to current mapset
+ */
+ if (strcmp (mapset,".") == 0)
+ mapset = G_mapset();
+
+/*
+ * get the full name of the GIS directory within the mapset
+ * and list its contents (if it exists)
+ *
+ * if lister() routine is given, the ls command must give 1 name
+ */
+ G__file_name (path, element, "", mapset);
+ if(access(path, 0) != 0)
+ return 0;
+
+/*
+ * if a title so that we can call lister() with the names
+ * otherwise the ls must be forced into columnar form.
+ */
+
+ if (_getcwd(current_dir,_MAX_PATH) == NULL)
+ return 0;
+
+
+ if (_chdir(path))
+ return 0;
+
+ fprintf(out,"in mapset %s:\n\n",mapset);
+
+ if ((hfile = _findfirst("*.*", &c_file)) == -1L) {
+ _chdir(current_dir);
+ return 0;
+ }
+
+ count = 0;
+ do {
+ if ( (c_file.attrib & (_A_HIDDEN | _A_SYSTEM)) == 0 && c_file.name[0] != '.') {
+ fprintf(out," %s\n", c_file.name);
+ count++;
+ }
+ } while(_findnext(hfile, &c_file) == 0);
+
+ fprintf(out,"\n");
+
+ _findclose(hfile);
+
+ _chdir(current_dir);
+
+ return count;
+}
+#endif
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,30 @@
+#
+# Grassland utility functions
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = glutil
+TARGETGEN=$(ARCHGEN)
+
+SOURCES = getglenv.c iofile.c dirent.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/status_d.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/status_d.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/glutil/status_d.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,201 @@
+//================================================================================
+//
+// status_d.c Francois Levert LAS inc.
+// Create a Dialog with a cancel button. This dialog will be used to send status
+// messages to the user. Two strings messages are provided by the status dialog.
+//================================================================================
+
+#include <windows.h>
+#include "status_d.h"
+#include "glutil.h"
+
+/* Prototype */
+void ThreadProc (LPVOID arg);
+int CreateStatus_D_Thread(HANDLE outHandle);
+void CloseStatus_D_Thread();
+
+/*** global variables ***/
+static BOOL bCancelChecked = TRUE; /* Is Cancel Button pressed */
+LPTSTR lpszText1; /* String message 1 */
+LPTSTR lpszText2; /* String message 2 */
+BOOL bDialog_created = FALSE; /* Is The status Dialog created */
+HWND global_hDlg = NULL; /* Handle of the main dialog */
+HANDLE myThread; /* Thread created for the display event of the status dislog */
+int bStatus; /* Status of the creation of the Status Dialog */
+
+BOOL CALLBACK status_dDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+
+ switch(msg)
+ {
+ case WM_COMMAND:
+ Handle_WM_COMMAND(hDlg, wParam, lParam);
+ return TRUE;
+ case WM_INITDIALOG:
+ Handle_WM_INITDIALOG(hDlg);
+ return TRUE;
+ /* case WM_MY_PAINT:
+ Handle_WM_PAINT(hDlg);
+ return TRUE; */
+ case WM_CLOSE:
+/* SetCursor(LoadCursor(NULL, IDC_ARROW)); */
+ EndDialog(hDlg, 0);
+ CloseStatus_D_Thread();
+ }
+ return FALSE;
+}
+
+void Handle_WM_COMMAND(HWND hDlg, WPARAM wParam, LPARAM lParam)
+{
+ if (HIWORD(wParam) != BN_CLICKED)
+ return;
+
+ switch(LOWORD(wParam) )
+ {
+ case ID_CANCEL:
+ bCancelChecked = TRUE;
+ SendMessage(hDlg, WM_CLOSE, 0, 0);
+ break;
+ }
+ return;
+}
+
+void Handle_WM_INITDIALOG(HWND hDlg)
+{
+ RECT rect;
+ int cx,cy;
+
+ GetWindowRect(hDlg, &rect);
+ cx = rect.right - rect.left;
+ cy = rect.top - rect.bottom;
+
+ lpszText1= "Status 1";
+ lpszText2= "Status 2";
+
+
+ bDialog_created = TRUE;
+ bCancelChecked = FALSE;
+ SetWindowPos(hDlg, HWND_TOP, 5 ,5, cx, cy, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
+ SetFocus((HWND) ID_CANCEL);
+
+/* SetCursor(LoadCursor(NULL, IDC_APPSTARTING)); */
+}
+
+void Handle_WM_PAINT(HWND hDlg)
+{
+ SetDlgItemText(hDlg, ID_TEXT1, lpszText1);
+ SetDlgItemText(hDlg, ID_TEXT2, lpszText2);
+ SendMessage(hDlg, WM_PAINT, 0, 0);
+}
+
+//================================================================================
+// Tell if the cancel has been pressed
+//================================================================================
+int bIs_status_d_Cancel_checked()
+{
+ return (int) bCancelChecked;
+}
+
+//================================================================================
+// Update the status dialog messages
+//================================================================================
+int bUpdate_status_d_text(char *text1,char *text2)
+{
+ if(bDialog_created)
+ {
+ lpszText1 = (LPTSTR) text1;
+ lpszText2 = (LPTSTR) text2;
+ SetFocus((HWND) global_hDlg);
+ if (global_hDlg != NULL) Handle_WM_PAINT(global_hDlg);
+ return 1;
+ }
+ return 0;
+}
+
+//================================================================================
+// Create a status message dialog
+//================================================================================
+int bCreate_status_d_text(char *text1,char *text2)
+{
+ int bResult;
+ lpszText1 = (LPTSTR) text1;
+ lpszText2 = (LPTSTR) text2;
+
+ bResult = CreateStatus_D_Thread(NULL);
+
+ if (bResult == 0) return 0; /* Not able to create a thread == not able to create a dialog */
+
+ return bStatus; /* Return the Create Dialog Status (see ThreadProc) */
+}
+
+//================================================================================
+// Close the status message dialog
+//================================================================================
+void close_status_d()
+{
+ if (global_hDlg != NULL) SendMessage(global_hDlg, WM_CLOSE, 0, 0);
+}
+
+//================================================================================
+// Create a thread for the status Dialog
+//================================================================================
+int CreateStatus_D_Thread(HANDLE outHandle)
+{
+ DWORD threadId;
+ CHAR Buf[80];
+ HANDLE sem;
+
+ sem = CreateSemaphore(NULL, 0, 1, NULL);
+ myThread = CreateThread(NULL, 0,
+ (LPTHREAD_START_ROUTINE)ThreadProc,
+ (LPVOID)sem, 0,
+ (LPDWORD)&threadId);
+ if (!myThread)
+ {
+ wsprintf(Buf, "Error in creating the Status Dialog thread: %d",
+ GetLastError());
+ MessageBox (GetFocus(), Buf, "WM_CREATE", MB_OK);
+ return 0;
+ }
+ WaitForSingleObject(sem, INFINITE);
+
+ return 1;
+
+}
+
+//================================================================================
+// Create a thread for the status Dialog
+//================================================================================
+void CloseStatus_D_Thread()
+{
+ TerminateThread(myThread, 0);
+}
+
+//================================================================================
+// A thread procedure which only send messages to be taken
+// by the Satus Dialog Procedure.
+//================================================================================
+
+VOID ThreadProc ( LPVOID arg)
+{
+ MSG msg;
+ HANDLE sem = (HANDLE) arg;
+
+
+ global_hDlg = CreateDialog( NULL, MAKEINTRESOURCE(STATUS_D), GetFocus(), (DLGPROC)status_dDlgProc);
+
+ if ( global_hDlg == (HWND) NULL) bStatus = 0;
+ else bStatus = 1;
+ ReleaseSemaphore(sem, 1, NULL); /* this will resumed the main thread permetting
+ bCreate_status_d_text() to return bStatus */
+
+ do { // do forever ...
+ GetMessage(&msg, NULL, 0, 0);
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ SendMessage(global_hDlg, msg.message, 0, 0);
+ /* PostThreadMessage((DWORD) arg, msg.message, 0, 0); */
+
+ }while(1);
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,678 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#ifndef _ECSH_H_RPCGEN
+#define _ECSH_H_RPCGEN
+
+#include <rpc/rpc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * fichier genere par RPCGEN a partir de ecs.x
+ *
+ * Declaration des structures & prototypes de l'extension client/serveur.
+ * Ce fichier est recu par rpcgen et ce dernier generera 4 fichiers pour
+ * pour l'extension client/serveur. Le "header" suivant doit ce retrouver
+ * dans tout les fichiers
+ */
+
+/*
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ */
+
+extern u_int ecs_compression_type;
+extern u_int ecs_compression_version;
+extern u_int ecs_compression_blksize;
+extern u_int ecs_compression_level;
+extern u_int ecs_compression_fullsize;
+
+#define ECS_SUCCESS 0
+#define ECS_FAILURE 1
+#define ECS_RASTERSIZE 1000
+#define ECS_MTEXT 1024
+#define ECS_TRANSIENT_MIN 1073741824
+#define ECS_TRANSIENT_MAX 1610612735
+#define ECS_COMPRESS_NONE 0
+#define ECS_COMPRESS_ZLIB 1
+#define ECS_ZLIB_VERSION 0
+#define ECS_ZLIB_LEVEL_DEFAULT 1
+#define ECS_ZLIB_BLKSIZE_DEFAULT 512
+#define ECS_ZLIB_BLKSIZE_MAX 131072
+#define ECS_CACHE_DEFAULT 25
+#define ECS_CACHE_MIN 1
+#define ECS_CACHE_MAX 10000
+
+enum ecs_Family {
+ Area = 1,
+ Line = 2,
+ Point = 3,
+ Matrix = 4,
+ Image = 5,
+ Text = 6,
+ Edge = 7,
+ Face = 8,
+ Node = 9,
+ Ring = 10
+};
+typedef enum ecs_Family ecs_Family;
+
+struct ecs_Region {
+ double north;
+ double south;
+ double east;
+ double west;
+ double ns_res;
+ double ew_res;
+};
+typedef struct ecs_Region ecs_Region;
+
+enum ecs_Resampling {
+ nn = 1
+};
+typedef enum ecs_Resampling ecs_Resampling;
+
+enum ecs_Transformation {
+ projective = 1,
+ affine = 2,
+ similarity = 3
+};
+typedef enum ecs_Transformation ecs_Transformation;
+
+struct ecs_RasterConversion {
+ struct {
+ u_int coef_len;
+ double *coef_val;
+ } coef;
+ int isProjEqual;
+ ecs_Resampling r_method;
+ ecs_Transformation t_method;
+};
+typedef struct ecs_RasterConversion ecs_RasterConversion;
+
+struct ecs_Coordinate {
+ double x;
+ double y;
+};
+typedef struct ecs_Coordinate ecs_Coordinate;
+
+struct ecs_FeatureRing {
+ ecs_Coordinate centroid;
+ struct {
+ u_int c_len;
+ ecs_Coordinate *c_val;
+ } c;
+};
+typedef struct ecs_FeatureRing ecs_FeatureRing;
+
+struct ecs_Area {
+ struct {
+ u_int ring_len;
+ ecs_FeatureRing *ring_val;
+ } ring;
+};
+typedef struct ecs_Area ecs_Area;
+
+struct ecs_Line {
+ struct {
+ u_int c_len;
+ ecs_Coordinate *c_val;
+ } c;
+};
+typedef struct ecs_Line ecs_Line;
+
+struct ecs_Point {
+ ecs_Coordinate c;
+};
+typedef struct ecs_Point ecs_Point;
+
+struct ecs_Matrix {
+ struct {
+ u_int x_len;
+ u_int *x_val;
+ } x;
+};
+typedef struct ecs_Matrix ecs_Matrix;
+
+struct ecs_Image {
+ struct {
+ u_int x_len;
+ u_int *x_val;
+ } x;
+};
+typedef struct ecs_Image ecs_Image;
+
+struct ecs_Text {
+ char *desc;
+ ecs_Coordinate c;
+};
+typedef struct ecs_Text ecs_Text;
+
+struct ecs_Node {
+ int id;
+ int containfaceid;
+ ecs_Coordinate c;
+};
+typedef struct ecs_Node ecs_Node;
+
+struct ecs_Edge {
+ int id;
+ int startnodeid;
+ int endnodeid;
+ int rightfaceid;
+ int leftfaceid;
+ int rightfedgeid;
+ int leftfedgeid;
+ struct {
+ u_int c_len;
+ ecs_Coordinate *c_val;
+ } c;
+};
+typedef struct ecs_Edge ecs_Edge;
+
+enum ecs_TopoLevel {
+ Level012 = 1,
+ Level3 = 2
+};
+typedef enum ecs_TopoLevel ecs_TopoLevel;
+
+struct ecs_Face {
+ int id;
+ struct {
+ u_int edgeid_len;
+ int *edgeid_val;
+ } edgeid;
+};
+typedef struct ecs_Face ecs_Face;
+
+struct ecs_AreaPrim {
+ ecs_TopoLevel level;
+ union {
+ struct {
+ u_int edgeid_len;
+ int *edgeid_val;
+ } edgeid;
+ struct {
+ u_int fedgeid_len;
+ ecs_Face *fedgeid_val;
+ } fedgeid;
+ } ecs_AreaPrim_u;
+};
+typedef struct ecs_AreaPrim ecs_AreaPrim;
+
+struct ecs_Geometry {
+ ecs_Family family;
+ union {
+ ecs_Area area;
+ ecs_Line line;
+ ecs_Point point;
+ ecs_Matrix matrix;
+ ecs_Image image;
+ ecs_Text text;
+ ecs_Node node;
+ ecs_Edge edge;
+ ecs_AreaPrim ring;
+ } ecs_Geometry_u;
+};
+typedef struct ecs_Geometry ecs_Geometry;
+
+struct ecs_Object {
+ char *Id;
+ ecs_Geometry geom;
+ char *attr;
+ double xmin;
+ double ymin;
+ double xmax;
+ double ymax;
+};
+typedef struct ecs_Object ecs_Object;
+
+enum ecs_AttributeFormat {
+ Char = 1,
+ Varchar = 2,
+ Longvarchar = 3,
+ Decimal = 4,
+ Numeric = 5,
+ Smallint = 6,
+ Integer = 7,
+ Real = 8,
+ Float = 9,
+ Double = 10
+};
+typedef enum ecs_AttributeFormat ecs_AttributeFormat;
+
+struct ecs_ObjAttribute {
+ char *name;
+ ecs_AttributeFormat type;
+ int lenght;
+ int precision;
+ int nullable;
+};
+typedef struct ecs_ObjAttribute ecs_ObjAttribute;
+
+struct ecs_ObjAttributeFormat {
+ struct {
+ u_int oa_len;
+ ecs_ObjAttribute *oa_val;
+ } oa;
+};
+typedef struct ecs_ObjAttributeFormat ecs_ObjAttributeFormat;
+
+struct ecs_Category {
+ long no_cat;
+ u_int r;
+ u_int g;
+ u_int b;
+ char *label;
+ u_long qty;
+};
+typedef struct ecs_Category ecs_Category;
+
+struct ecs_RasterInfo {
+ long mincat;
+ long maxcat;
+ int width;
+ int height;
+ struct {
+ u_int cat_len;
+ ecs_Category *cat_val;
+ } cat;
+};
+typedef struct ecs_RasterInfo ecs_RasterInfo;
+
+struct ecs_Compression {
+ u_int cachesize;
+ u_int ctype;
+ u_int cversion;
+ u_int clevel;
+ u_int cblksize;
+ u_int cfullsize;
+};
+typedef struct ecs_Compression ecs_Compression;
+
+enum ecs_ResultType {
+ SimpleError = 0,
+ Object = 1,
+ GeoRegion = 2,
+ objAttributeFormat = 3,
+ RasterInfo = 4,
+ AText = 5,
+ MultiResult = 6
+};
+typedef enum ecs_ResultType ecs_ResultType;
+typedef struct ecs_ResultUnion ecs_ResultUnion;
+
+struct ecs_ResultUnion {
+ ecs_ResultType type;
+ union {
+ ecs_Object dob;
+ ecs_Region gr;
+ ecs_ObjAttributeFormat oaf;
+ ecs_RasterInfo ri;
+ char *s;
+ struct {
+ u_int results_len;
+ ecs_ResultUnion *results_val;
+ } results;
+ } ecs_ResultUnion_u;
+};
+
+struct ecs_Result {
+ ecs_Compression compression;
+ int error;
+ char *message;
+ ecs_ResultUnion res;
+};
+typedef struct ecs_Result ecs_Result;
+
+struct ecs_LayerSelection {
+ char *Select;
+ ecs_Family F;
+};
+typedef struct ecs_LayerSelection ecs_LayerSelection;
+
+struct ecs_ProxyCreateServer {
+ char *server_name;
+ char *server_url;
+};
+typedef struct ecs_ProxyCreateServer ecs_ProxyCreateServer;
+
+#include <ecs_util.h> /* Outils pour l'aide a ecs */
+
+
+#define ECSPROG ((unsigned long)(0x20000001))
+#define ECSVERS ((unsigned long)(1))
+
+#if defined(__STDC__) || defined(__cplusplus)
+#define CREATESERVER ((unsigned long)(1))
+extern ecs_Result * createserver_1(char **, CLIENT *);
+extern ecs_Result * createserver_1_svc(char **, struct svc_req *);
+#define DESTROYSERVER ((unsigned long)(2))
+extern ecs_Result * destroyserver_1(void *, CLIENT *);
+extern ecs_Result * destroyserver_1_svc(void *, struct svc_req *);
+#define SELECTLAYER ((unsigned long)(3))
+extern ecs_Result * selectlayer_1(ecs_LayerSelection *, CLIENT *);
+extern ecs_Result * selectlayer_1_svc(ecs_LayerSelection *, struct svc_req *);
+#define RELEASELAYER ((unsigned long)(4))
+extern ecs_Result * releaselayer_1(ecs_LayerSelection *, CLIENT *);
+extern ecs_Result * releaselayer_1_svc(ecs_LayerSelection *, struct svc_req *);
+#define SELECTREGION ((unsigned long)(5))
+extern ecs_Result * selectregion_1(ecs_Region *, CLIENT *);
+extern ecs_Result * selectregion_1_svc(ecs_Region *, struct svc_req *);
+#define GETDICTIONNARY ((unsigned long)(6))
+extern ecs_Result * getdictionnary_1(void *, CLIENT *);
+extern ecs_Result * getdictionnary_1_svc(void *, struct svc_req *);
+#define GETATTRIBUTEFORMAT ((unsigned long)(7))
+extern ecs_Result * getattributeformat_1(void *, CLIENT *);
+extern ecs_Result * getattributeformat_1_svc(void *, struct svc_req *);
+#define GETNEXTOBJECT ((unsigned long)(8))
+extern ecs_Result * getnextobject_1(void *, CLIENT *);
+extern ecs_Result * getnextobject_1_svc(void *, struct svc_req *);
+#define GETRASTERINFO ((unsigned long)(9))
+extern ecs_Result * getrasterinfo_1(void *, CLIENT *);
+extern ecs_Result * getrasterinfo_1_svc(void *, struct svc_req *);
+#define GETOBJECT ((unsigned long)(10))
+extern ecs_Result * getobject_1(char **, CLIENT *);
+extern ecs_Result * getobject_1_svc(char **, struct svc_req *);
+#define GETOBJECTIDFROMCOORD ((unsigned long)(11))
+extern ecs_Result * getobjectidfromcoord_1(ecs_Coordinate *, CLIENT *);
+extern ecs_Result * getobjectidfromcoord_1_svc(ecs_Coordinate *, struct svc_req *);
+#define UPDATEDICTIONARY ((unsigned long)(12))
+extern ecs_Result * updatedictionary_1(char **, CLIENT *);
+extern ecs_Result * updatedictionary_1_svc(char **, struct svc_req *);
+#define GETSERVERPROJECTION ((unsigned long)(13))
+extern ecs_Result * getserverprojection_1(void *, CLIENT *);
+extern ecs_Result * getserverprojection_1_svc(void *, struct svc_req *);
+#define GETGLOBALBOUND ((unsigned long)(14))
+extern ecs_Result * getglobalbound_1(void *, CLIENT *);
+extern ecs_Result * getglobalbound_1_svc(void *, struct svc_req *);
+#define SETSERVERLANGUAGE ((unsigned long)(15))
+extern ecs_Result * setserverlanguage_1(u_int *, CLIENT *);
+extern ecs_Result * setserverlanguage_1_svc(u_int *, struct svc_req *);
+#define SETSERVERPROJECTION ((unsigned long)(16))
+extern ecs_Result * setserverprojection_1(char **, CLIENT *);
+extern ecs_Result * setserverprojection_1_svc(char **, struct svc_req *);
+#define SETRASTERCONVERSION ((unsigned long)(17))
+extern ecs_Result * setrasterconversion_1(ecs_RasterConversion *, CLIENT *);
+extern ecs_Result * setrasterconversion_1_svc(ecs_RasterConversion *, struct svc_req *);
+#define CREATEPROXYSERVER ((unsigned long)(100))
+extern ecs_Result * createproxyserver_1(ecs_ProxyCreateServer *, CLIENT *);
+extern ecs_Result * createproxyserver_1_svc(ecs_ProxyCreateServer *, struct svc_req *);
+#define SETCOMPRESSION ((unsigned long)(101))
+extern ecs_Result * setcompression_1(ecs_Compression *, CLIENT *);
+extern ecs_Result * setcompression_1_svc(ecs_Compression *, struct svc_req *);
+extern int ecsprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t);
+
+#else /* K&R C */
+#define CREATESERVER ((unsigned long)(1))
+extern ecs_Result * createserver_1();
+extern ecs_Result * createserver_1_svc();
+#define DESTROYSERVER ((unsigned long)(2))
+extern ecs_Result * destroyserver_1();
+extern ecs_Result * destroyserver_1_svc();
+#define SELECTLAYER ((unsigned long)(3))
+extern ecs_Result * selectlayer_1();
+extern ecs_Result * selectlayer_1_svc();
+#define RELEASELAYER ((unsigned long)(4))
+extern ecs_Result * releaselayer_1();
+extern ecs_Result * releaselayer_1_svc();
+#define SELECTREGION ((unsigned long)(5))
+extern ecs_Result * selectregion_1();
+extern ecs_Result * selectregion_1_svc();
+#define GETDICTIONNARY ((unsigned long)(6))
+extern ecs_Result * getdictionnary_1();
+extern ecs_Result * getdictionnary_1_svc();
+#define GETATTRIBUTEFORMAT ((unsigned long)(7))
+extern ecs_Result * getattributeformat_1();
+extern ecs_Result * getattributeformat_1_svc();
+#define GETNEXTOBJECT ((unsigned long)(8))
+extern ecs_Result * getnextobject_1();
+extern ecs_Result * getnextobject_1_svc();
+#define GETRASTERINFO ((unsigned long)(9))
+extern ecs_Result * getrasterinfo_1();
+extern ecs_Result * getrasterinfo_1_svc();
+#define GETOBJECT ((unsigned long)(10))
+extern ecs_Result * getobject_1();
+extern ecs_Result * getobject_1_svc();
+#define GETOBJECTIDFROMCOORD ((unsigned long)(11))
+extern ecs_Result * getobjectidfromcoord_1();
+extern ecs_Result * getobjectidfromcoord_1_svc();
+#define UPDATEDICTIONARY ((unsigned long)(12))
+extern ecs_Result * updatedictionary_1();
+extern ecs_Result * updatedictionary_1_svc();
+#define GETSERVERPROJECTION ((unsigned long)(13))
+extern ecs_Result * getserverprojection_1();
+extern ecs_Result * getserverprojection_1_svc();
+#define GETGLOBALBOUND ((unsigned long)(14))
+extern ecs_Result * getglobalbound_1();
+extern ecs_Result * getglobalbound_1_svc();
+#define SETSERVERLANGUAGE ((unsigned long)(15))
+extern ecs_Result * setserverlanguage_1();
+extern ecs_Result * setserverlanguage_1_svc();
+#define SETSERVERPROJECTION ((unsigned long)(16))
+extern ecs_Result * setserverprojection_1();
+extern ecs_Result * setserverprojection_1_svc();
+#define SETRASTERCONVERSION ((unsigned long)(17))
+extern ecs_Result * setrasterconversion_1();
+extern ecs_Result * setrasterconversion_1_svc();
+#define CREATEPROXYSERVER ((unsigned long)(100))
+extern ecs_Result * createproxyserver_1();
+extern ecs_Result * createproxyserver_1_svc();
+#define SETCOMPRESSION ((unsigned long)(101))
+extern ecs_Result * setcompression_1();
+extern ecs_Result * setcompression_1_svc();
+extern int ecsprog_1_freeresult();
+#endif /* K&R C */
+
+#define ECSPROXYPROG ((unsigned long)(0x20000002))
+#define ECSPROXYVERS ((unsigned long)(1))
+
+#if defined(__STDC__) || defined(__cplusplus)
+#define PROXY_CREATEREMOTESERVER ((unsigned long)(1))
+extern ecs_Result * proxy_createremoteserver_1(char **, CLIENT *);
+extern ecs_Result * proxy_createremoteserver_1_svc(char **, struct svc_req *);
+#define PROXY_DESTROYSERVER ((unsigned long)(2))
+extern ecs_Result * proxy_destroyserver_1(void *, CLIENT *);
+extern ecs_Result * proxy_destroyserver_1_svc(void *, struct svc_req *);
+#define PROXY_SELECTLAYER ((unsigned long)(3))
+extern ecs_Result * proxy_selectlayer_1(ecs_LayerSelection *, CLIENT *);
+extern ecs_Result * proxy_selectlayer_1_svc(ecs_LayerSelection *, struct svc_req *);
+#define PROXY_RELEASELAYER ((unsigned long)(4))
+extern ecs_Result * proxy_releaselayer_1(ecs_LayerSelection *, CLIENT *);
+extern ecs_Result * proxy_releaselayer_1_svc(ecs_LayerSelection *, struct svc_req *);
+#define PROXY_SELECTREGION ((unsigned long)(5))
+extern ecs_Result * proxy_selectregion_1(ecs_Region *, CLIENT *);
+extern ecs_Result * proxy_selectregion_1_svc(ecs_Region *, struct svc_req *);
+#define PROXY_GETDICTIONNARY ((unsigned long)(6))
+extern ecs_Result * proxy_getdictionnary_1(void *, CLIENT *);
+extern ecs_Result * proxy_getdictionnary_1_svc(void *, struct svc_req *);
+#define PROXY_GETATTRIBUTEFORMAT ((unsigned long)(7))
+extern ecs_Result * proxy_getattributeformat_1(void *, CLIENT *);
+extern ecs_Result * proxy_getattributeformat_1_svc(void *, struct svc_req *);
+#define PROXY_GETNEXTOBJECT ((unsigned long)(8))
+extern ecs_Result * proxy_getnextobject_1(void *, CLIENT *);
+extern ecs_Result * proxy_getnextobject_1_svc(void *, struct svc_req *);
+#define PROXY_GETRASTERINFO ((unsigned long)(9))
+extern ecs_Result * proxy_getrasterinfo_1(void *, CLIENT *);
+extern ecs_Result * proxy_getrasterinfo_1_svc(void *, struct svc_req *);
+#define PROXY_GETOBJECT ((unsigned long)(10))
+extern ecs_Result * proxy_getobject_1(char **, CLIENT *);
+extern ecs_Result * proxy_getobject_1_svc(char **, struct svc_req *);
+#define PROXY_GETOBJECTIDFROMCOORD ((unsigned long)(11))
+extern ecs_Result * proxy_getobjectidfromcoord_1(ecs_Coordinate *, CLIENT *);
+extern ecs_Result * proxy_getobjectidfromcoord_1_svc(ecs_Coordinate *, struct svc_req *);
+#define PROXY_UPDATEDICTIONARY ((unsigned long)(12))
+extern ecs_Result * proxy_updatedictionary_1(char **, CLIENT *);
+extern ecs_Result * proxy_updatedictionary_1_svc(char **, struct svc_req *);
+#define PROXY_GETSERVERPROJECTION ((unsigned long)(13))
+extern ecs_Result * proxy_getserverprojection_1(void *, CLIENT *);
+extern ecs_Result * proxy_getserverprojection_1_svc(void *, struct svc_req *);
+#define PROXY_GETGLOBALBOUND ((unsigned long)(14))
+extern ecs_Result * proxy_getglobalbound_1(void *, CLIENT *);
+extern ecs_Result * proxy_getglobalbound_1_svc(void *, struct svc_req *);
+#define PROXY_SETSERVERLANGUAGE ((unsigned long)(15))
+extern ecs_Result * proxy_setserverlanguage_1(u_int *, CLIENT *);
+extern ecs_Result * proxy_setserverlanguage_1_svc(u_int *, struct svc_req *);
+#define PROXY_SETSERVERPROJECTION ((unsigned long)(16))
+extern ecs_Result * proxy_setserverprojection_1(char **, CLIENT *);
+extern ecs_Result * proxy_setserverprojection_1_svc(char **, struct svc_req *);
+#define PROXY_SETRASTERCONVERSION ((unsigned long)(17))
+extern ecs_Result * proxy_setrasterconversion_1(ecs_RasterConversion *, CLIENT *);
+extern ecs_Result * proxy_setrasterconversion_1_svc(ecs_RasterConversion *, struct svc_req *);
+#define PROXY_CREATESERVER ((unsigned long)(100))
+extern ecs_Result * proxy_createserver_1(ecs_ProxyCreateServer *, CLIENT *);
+extern ecs_Result * proxy_createserver_1_svc(ecs_ProxyCreateServer *, struct svc_req *);
+#define PROXY_SETCOMPRESSION ((unsigned long)(101))
+extern ecs_Result * proxy_setcompression_1(ecs_Compression *, CLIENT *);
+extern ecs_Result * proxy_setcompression_1_svc(ecs_Compression *, struct svc_req *);
+extern int ecsproxyprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t);
+
+#else /* K&R C */
+#define PROXY_CREATEREMOTESERVER ((unsigned long)(1))
+extern ecs_Result * proxy_createremoteserver_1();
+extern ecs_Result * proxy_createremoteserver_1_svc();
+#define PROXY_DESTROYSERVER ((unsigned long)(2))
+extern ecs_Result * proxy_destroyserver_1();
+extern ecs_Result * proxy_destroyserver_1_svc();
+#define PROXY_SELECTLAYER ((unsigned long)(3))
+extern ecs_Result * proxy_selectlayer_1();
+extern ecs_Result * proxy_selectlayer_1_svc();
+#define PROXY_RELEASELAYER ((unsigned long)(4))
+extern ecs_Result * proxy_releaselayer_1();
+extern ecs_Result * proxy_releaselayer_1_svc();
+#define PROXY_SELECTREGION ((unsigned long)(5))
+extern ecs_Result * proxy_selectregion_1();
+extern ecs_Result * proxy_selectregion_1_svc();
+#define PROXY_GETDICTIONNARY ((unsigned long)(6))
+extern ecs_Result * proxy_getdictionnary_1();
+extern ecs_Result * proxy_getdictionnary_1_svc();
+#define PROXY_GETATTRIBUTEFORMAT ((unsigned long)(7))
+extern ecs_Result * proxy_getattributeformat_1();
+extern ecs_Result * proxy_getattributeformat_1_svc();
+#define PROXY_GETNEXTOBJECT ((unsigned long)(8))
+extern ecs_Result * proxy_getnextobject_1();
+extern ecs_Result * proxy_getnextobject_1_svc();
+#define PROXY_GETRASTERINFO ((unsigned long)(9))
+extern ecs_Result * proxy_getrasterinfo_1();
+extern ecs_Result * proxy_getrasterinfo_1_svc();
+#define PROXY_GETOBJECT ((unsigned long)(10))
+extern ecs_Result * proxy_getobject_1();
+extern ecs_Result * proxy_getobject_1_svc();
+#define PROXY_GETOBJECTIDFROMCOORD ((unsigned long)(11))
+extern ecs_Result * proxy_getobjectidfromcoord_1();
+extern ecs_Result * proxy_getobjectidfromcoord_1_svc();
+#define PROXY_UPDATEDICTIONARY ((unsigned long)(12))
+extern ecs_Result * proxy_updatedictionary_1();
+extern ecs_Result * proxy_updatedictionary_1_svc();
+#define PROXY_GETSERVERPROJECTION ((unsigned long)(13))
+extern ecs_Result * proxy_getserverprojection_1();
+extern ecs_Result * proxy_getserverprojection_1_svc();
+#define PROXY_GETGLOBALBOUND ((unsigned long)(14))
+extern ecs_Result * proxy_getglobalbound_1();
+extern ecs_Result * proxy_getglobalbound_1_svc();
+#define PROXY_SETSERVERLANGUAGE ((unsigned long)(15))
+extern ecs_Result * proxy_setserverlanguage_1();
+extern ecs_Result * proxy_setserverlanguage_1_svc();
+#define PROXY_SETSERVERPROJECTION ((unsigned long)(16))
+extern ecs_Result * proxy_setserverprojection_1();
+extern ecs_Result * proxy_setserverprojection_1_svc();
+#define PROXY_SETRASTERCONVERSION ((unsigned long)(17))
+extern ecs_Result * proxy_setrasterconversion_1();
+extern ecs_Result * proxy_setrasterconversion_1_svc();
+#define PROXY_CREATESERVER ((unsigned long)(100))
+extern ecs_Result * proxy_createserver_1();
+extern ecs_Result * proxy_createserver_1_svc();
+#define PROXY_SETCOMPRESSION ((unsigned long)(101))
+extern ecs_Result * proxy_setcompression_1();
+extern ecs_Result * proxy_setcompression_1_svc();
+extern int ecsproxyprog_1_freeresult();
+#endif /* K&R C */
+
+/* the xdr functions */
+
+#if defined(__STDC__) || defined(__cplusplus)
+extern bool_t xdr_ecs_Family(XDR *, ecs_Family*);
+extern bool_t xdr_ecs_Region(XDR *, ecs_Region*);
+extern bool_t xdr_ecs_Resampling(XDR *, ecs_Resampling*);
+extern bool_t xdr_ecs_Transformation(XDR *, ecs_Transformation*);
+extern bool_t xdr_ecs_RasterConversion(XDR *, ecs_RasterConversion*);
+extern bool_t xdr_ecs_Coordinate(XDR *, ecs_Coordinate*);
+extern bool_t xdr_ecs_FeatureRing(XDR *, ecs_FeatureRing*);
+extern bool_t xdr_ecs_Area(XDR *, ecs_Area*);
+extern bool_t xdr_ecs_Line(XDR *, ecs_Line*);
+extern bool_t xdr_ecs_Point(XDR *, ecs_Point*);
+extern bool_t xdr_ecs_Matrix(XDR *, ecs_Matrix*);
+extern bool_t xdr_ecs_Image(XDR *, ecs_Image*);
+extern bool_t xdr_ecs_Text(XDR *, ecs_Text*);
+extern bool_t xdr_ecs_Node(XDR *, ecs_Node*);
+extern bool_t xdr_ecs_Edge(XDR *, ecs_Edge*);
+extern bool_t xdr_ecs_TopoLevel(XDR *, ecs_TopoLevel*);
+extern bool_t xdr_ecs_Face(XDR *, ecs_Face*);
+extern bool_t xdr_ecs_AreaPrim(XDR *, ecs_AreaPrim*);
+extern bool_t xdr_ecs_Geometry(XDR *, ecs_Geometry*);
+extern bool_t xdr_ecs_Object(XDR *, ecs_Object*);
+extern bool_t xdr_ecs_AttributeFormat(XDR *, ecs_AttributeFormat*);
+extern bool_t xdr_ecs_ObjAttribute(XDR *, ecs_ObjAttribute*);
+extern bool_t xdr_ecs_ObjAttributeFormat(XDR *, ecs_ObjAttributeFormat*);
+extern bool_t xdr_ecs_Category(XDR *, ecs_Category*);
+extern bool_t xdr_ecs_RasterInfo(XDR *, ecs_RasterInfo*);
+extern bool_t xdr_ecs_Compression(XDR *, ecs_Compression*);
+extern bool_t xdr_ecs_ResultType(XDR *, ecs_ResultType*);
+extern bool_t xdr_ecs_ResultUnion(XDR *, ecs_ResultUnion*);
+extern bool_t xdr_ecs_Result(XDR *, ecs_Result*);
+extern bool_t xdr_ecs_LayerSelection(XDR *, ecs_LayerSelection*);
+extern bool_t xdr_ecs_ProxyCreateServer(XDR *, ecs_ProxyCreateServer*);
+
+#else /* K&R C */
+extern bool_t xdr_ecs_Family();
+extern bool_t xdr_ecs_Region();
+extern bool_t xdr_ecs_Resampling();
+extern bool_t xdr_ecs_Transformation();
+extern bool_t xdr_ecs_RasterConversion();
+extern bool_t xdr_ecs_Coordinate();
+extern bool_t xdr_ecs_FeatureRing();
+extern bool_t xdr_ecs_Area();
+extern bool_t xdr_ecs_Line();
+extern bool_t xdr_ecs_Point();
+extern bool_t xdr_ecs_Matrix();
+extern bool_t xdr_ecs_Image();
+extern bool_t xdr_ecs_Text();
+extern bool_t xdr_ecs_Node();
+extern bool_t xdr_ecs_Edge();
+extern bool_t xdr_ecs_TopoLevel();
+extern bool_t xdr_ecs_Face();
+extern bool_t xdr_ecs_AreaPrim();
+extern bool_t xdr_ecs_Geometry();
+extern bool_t xdr_ecs_Object();
+extern bool_t xdr_ecs_AttributeFormat();
+extern bool_t xdr_ecs_ObjAttribute();
+extern bool_t xdr_ecs_ObjAttributeFormat();
+extern bool_t xdr_ecs_Category();
+extern bool_t xdr_ecs_RasterInfo();
+extern bool_t xdr_ecs_Compression();
+extern bool_t xdr_ecs_ResultType();
+extern bool_t xdr_ecs_ResultUnion();
+extern bool_t xdr_ecs_Result();
+extern bool_t xdr_ecs_LayerSelection();
+extern bool_t xdr_ecs_ProxyCreateServer();
+
+#endif /* K&R C */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_ECS.H_H_RPCGEN */
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs.x
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs.x 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs.x 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,433 @@
+#ifdef RPC_HDR
+%/*
+% * fichier genere par RPCGEN a partir de ecs.x
+% *
+% * Declaration des structures & prototypes de l'extension client/serveur.
+% * Ce fichier est recu par rpcgen et ce dernier generera 4 fichiers pour
+% * pour l'extension client/serveur. Le "header" suivant doit ce retrouver
+% * dans tout les fichiers
+% */
+%
+%
+% /* Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc*/
+% /* Permission to use, copy, modify and distribute this software and */
+% /* its documentation for any purpose and without fee is hereby granted, */
+% /* provided that the above copyright notice appear in all copies, that */
+% /* both the copyright notice and this permission notice appear in */
+% /* supporting documentation, and that the name of L.A.S. Inc not be used */
+% /* in advertising or publicity pertaining to distribution of the software */
+% /* without specific, written prior permission. L.A.S. Inc. makes no */
+% /* representations about the suitability of this software for any purpose.*/
+% /* It is provided "as is" without express or implied warranty. */
+%
+%extern u_int ecs_compression_type;
+%extern u_int ecs_compression_version;
+%extern u_int ecs_compression_blksize;
+%extern u_int ecs_compression_level;
+%extern u_int ecs_compression_fullsize;
+%
+#endif
+
+#ifdef RPC_SVC
+%#define main dummy
+%#define RPC_SVC_FG
+%
+%extern ecs_Server *svr_handle;
+%
+%void start_closedown_check(void)
+%{
+% extern int _rpcpmstart;
+% static void closedown(int sig);
+%
+% _rpcpmstart = 1;
+% (void) signal(SIGALRM, (SIG_PF) closedown);
+% (void) alarm(_RPCSVC_CLOSEDOWN);
+%}
+%
+#endif
+
+const ECS_SUCCESS = 0;
+const ECS_FAILURE = 1;
+
+const ECS_RASTERSIZE = 1000;
+const ECS_MTEXT = 1024;
+const ECS_TRANSIENT_MIN = 1073741824;
+const ECS_TRANSIENT_MAX = 1610612735;
+
+const ECS_COMPRESS_NONE = 0;
+const ECS_COMPRESS_ZLIB = 1;
+
+const ECS_ZLIB_VERSION = 0;
+const ECS_ZLIB_LEVEL_DEFAULT = 1;
+const ECS_ZLIB_BLKSIZE_DEFAULT = 512;
+const ECS_ZLIB_BLKSIZE_MAX = 131072;
+
+const ECS_CACHE_DEFAULT = 25;
+const ECS_CACHE_MIN = 1;
+const ECS_CACHE_MAX = 10000;
+
+enum ecs_Family {
+ Area = 1,
+ Line = 2,
+ Point = 3,
+ Matrix = 4,
+ Image = 5,
+ Text = 6,
+ Edge = 7,
+ Face = 8,
+ Node = 9,
+ Ring =10
+};
+
+/*
+ * Structure contenant la description d'une region geographique.
+ */
+
+struct ecs_Region {
+ double north;
+ double south;
+ double east;
+ double west;
+ double ns_res;
+ double ew_res;
+};
+
+/*
+ * Structure contenant les informations relatif a la conversion
+ * de projection de raster
+ */
+
+enum ecs_Resampling {
+ nn = 1
+};
+
+enum ecs_Transformation {
+ projective = 1,
+ affine = 2,
+ similarity = 3
+};
+
+struct ecs_RasterConversion {
+ double coef<>;
+ int isProjEqual;
+ ecs_Resampling r_method;
+ ecs_Transformation t_method;
+};
+
+/*
+ * Description d'une coordonnee geographique.
+ */
+
+struct ecs_Coordinate {
+ double x;
+ double y;
+};
+
+/*
+ * Description d'un objet geographique de type Area.
+ */
+
+struct ecs_FeatureRing {
+ ecs_Coordinate centroid;
+ ecs_Coordinate c<>;
+};
+
+struct ecs_Area {
+ ecs_FeatureRing ring<>;
+};
+
+/*
+ * Description d'un objet geographique de type Line.
+ */
+
+struct ecs_Line {
+ ecs_Coordinate c<>;
+ };
+
+/*
+ * Description d'un objet geographique de type Point.
+ */
+
+struct ecs_Point {
+ ecs_Coordinate c;
+};
+
+/*
+ * Description d'un objet geographique de type Matrix.
+ */
+
+struct ecs_Matrix {
+ unsigned int x<>;
+};
+
+
+/*
+ * Description d'un objet geographique de type Image.
+ */
+
+struct ecs_Image {
+ unsigned int x<>;
+};
+
+/*
+ * Description d'un objet geographique de type Text.
+ */
+
+struct ecs_Text {
+ string desc<>;
+ ecs_Coordinate c;
+};
+
+/*
+ * Description de la primitive NODE
+ */
+
+struct ecs_Node {
+ int id;
+ int containfaceid;
+ ecs_Coordinate c;
+};
+
+/*
+ * Description de la primitive EDGE
+ */
+
+struct ecs_Edge {
+ int id;
+ int startnodeid;
+ int endnodeid;
+ int rightfaceid;
+ int leftfaceid;
+ int rightfedgeid;
+ int leftfedgeid;
+ ecs_Coordinate c<>;
+};
+
+/*
+ * Description de la primitive RING. Si topology level 0,1 ou 2 une liste de "edges"
+ * si topology level 3 une face (ecs_Face) avec une liste de "edges"
+ */
+
+enum ecs_TopoLevel {
+ Level012 = 1,
+ Level3 = 2
+};
+
+/*
+ * Descrition de la primitive FACE
+ */
+
+struct ecs_Face {
+ int id;
+ int edgeid<>;
+};
+
+union ecs_AreaPrim switch (ecs_TopoLevel level) {
+ case Level012 : int edgeid<>;
+ case Level3 : ecs_Face fedgeid<>;
+ default : void;
+};
+
+
+/*
+ * Description de la geometrie d'un object ecs
+ */
+
+union ecs_Geometry switch (ecs_Family family) {
+ case Area: ecs_Area area;
+ case Line: ecs_Line line;
+ case Point: ecs_Point point;
+ case Matrix: ecs_Matrix matrix;
+ case Image: ecs_Image image;
+ case Text: ecs_Text text;
+ case Node: ecs_Node node;
+ case Edge: ecs_Edge edge;
+ case Ring: ecs_AreaPrim ring;
+ default : void;
+};
+
+struct ecs_Object {
+ string Id<>;
+ ecs_Geometry geom;
+ string attr<>;
+ double xmin; /* "bounding box" de l'objet */
+ double ymin;
+ double xmax;
+ double ymax;
+};
+
+/*
+ * Format des types disponible dans SQL
+ */
+
+enum ecs_AttributeFormat {
+ Char = 1,
+ Varchar = 2,
+ Longvarchar = 3,
+ Decimal = 4,
+ Numeric = 5,
+ Smallint = 6,
+ Integer = 7,
+ Real = 8,
+ Float = 9,
+ Double = 10
+};
+
+/*
+ * Description d'un type d'attribut.
+ */
+
+struct ecs_ObjAttribute {
+ string name<>;
+ ecs_AttributeFormat type;
+ int lenght;
+ int precision;
+ int nullable;
+};
+
+struct ecs_ObjAttributeFormat {
+ ecs_ObjAttribute oa<>;
+};
+
+struct ecs_Category {
+ long no_cat;
+ unsigned int r;
+ unsigned int g;
+ unsigned int b;
+ string label<>;
+ unsigned long qty; /* nbre de cellules ayant cette categorie dans la matrice */
+};
+
+struct ecs_RasterInfo {
+ long mincat;
+ long maxcat;
+ int width;
+ int height;
+ ecs_Category cat<>;
+};
+
+/*
+ * Structure for compression parameters
+ */
+
+struct ecs_Compression {
+ unsigned int cachesize; /* Number of items to get with getnextobject */
+ unsigned int ctype; /* Compression type i.e. ECS_COMPRESS_ZLIB */
+ unsigned int cversion; /* Which version of this compression */
+ unsigned int clevel; /* How agressively to compress min 1 - 9 max */
+ unsigned int cblksize; /* Number of bytes to compress at a time */
+ unsigned int cfullsize; /* Used by server */
+};
+
+/*
+ * Description du resultat retourne par ECS
+ */
+
+enum ecs_ResultType {
+ SimpleError = 0,
+ Object = 1,
+ GeoRegion = 2,
+ objAttributeFormat = 3,
+ RasterInfo = 4,
+ AText = 5,
+ MultiResult = 6
+};
+
+
+union ecs_ResultUnion switch(ecs_ResultType type) {
+ case Object: ecs_Object dob;
+ case GeoRegion: ecs_Region gr;
+ case objAttributeFormat: ecs_ObjAttributeFormat oaf;
+ case RasterInfo: ecs_RasterInfo ri;
+ case AText : string s<>;
+ case MultiResult : ecs_ResultUnion results<>;
+ default : void;
+};
+
+struct ecs_Result {
+ ecs_Compression compression;
+ int error;
+ string message<>;
+ ecs_ResultUnion res;
+};
+
+
+/*
+ * Structure pour le parametre compose de SELECTLAYER
+ */
+
+struct ecs_LayerSelection {
+ string Select<>;
+ ecs_Family F;
+};
+
+/*
+ * Structure for proxy server connect
+ */
+
+struct ecs_ProxyCreateServer {
+ string server_name<>;
+ string server_url<>;
+};
+
+#ifdef RPC_HDR
+%
+%#include <ecs_util.h> /* Outils pour l'aide a ecs */
+%
+#endif
+
+#if (!defined(RPC_SVC) && !defined(RPC_CLNT)) || \
+ ((defined(RPC_SVC) || defined(RPC_CLNT)) && !defined(PROXY))
+/* Definition des programmes */
+program ECSPROG {
+ version ECSVERS {
+ ecs_Result CREATESERVER(string) = 1;
+ ecs_Result DESTROYSERVER(void) = 2;
+ ecs_Result SELECTLAYER(ecs_LayerSelection) = 3;
+ ecs_Result RELEASELAYER(ecs_LayerSelection) = 4;
+ ecs_Result SELECTREGION(ecs_Region) = 5;
+ ecs_Result GETDICTIONNARY(void) = 6;
+ ecs_Result GETATTRIBUTEFORMAT(void) = 7;
+ ecs_Result GETNEXTOBJECT(void) = 8;
+ ecs_Result GETRASTERINFO(void) = 9;
+ ecs_Result GETOBJECT(string) = 10;
+ ecs_Result GETOBJECTIDFROMCOORD(ecs_Coordinate) = 11;
+ ecs_Result UPDATEDICTIONARY(string) = 12;
+ ecs_Result GETSERVERPROJECTION(void) = 13;
+ ecs_Result GETGLOBALBOUND(void) = 14;
+ ecs_Result SETSERVERLANGUAGE(unsigned int) = 15;
+ ecs_Result SETSERVERPROJECTION(string) = 16;
+ ecs_Result SETRASTERCONVERSION(ecs_RasterConversion) = 17;
+ ecs_Result CREATEPROXYSERVER(ecs_ProxyCreateServer) = 100;
+ ecs_Result SETCOMPRESSION(ecs_Compression) = 101;
+ } = 1;
+} = 0x20000001;
+#endif
+
+#if (!defined(RPC_SVC) && !defined(RPC_CLNT)) || \
+ ((defined(RPC_SVC) || defined(RPC_CLNT)) && defined(PROXY))
+program ECSPROXYPROG {
+ version ECSPROXYVERS {
+ ecs_Result PROXY_CREATEREMOTESERVER(string) = 1;
+ ecs_Result PROXY_DESTROYSERVER(void) = 2;
+ ecs_Result PROXY_SELECTLAYER(ecs_LayerSelection) = 3;
+ ecs_Result PROXY_RELEASELAYER(ecs_LayerSelection) = 4;
+ ecs_Result PROXY_SELECTREGION(ecs_Region) = 5;
+ ecs_Result PROXY_GETDICTIONNARY(void) = 6;
+ ecs_Result PROXY_GETATTRIBUTEFORMAT(void) = 7;
+ ecs_Result PROXY_GETNEXTOBJECT(void) = 8;
+ ecs_Result PROXY_GETRASTERINFO(void) = 9;
+ ecs_Result PROXY_GETOBJECT(string) = 10;
+ ecs_Result PROXY_GETOBJECTIDFROMCOORD(ecs_Coordinate) = 11;
+ ecs_Result PROXY_UPDATEDICTIONARY(string) = 12;
+ ecs_Result PROXY_GETSERVERPROJECTION(void) = 13;
+ ecs_Result PROXY_GETGLOBALBOUND(void) = 14;
+ ecs_Result PROXY_SETSERVERLANGUAGE(unsigned int) = 15;
+ ecs_Result PROXY_SETSERVERPROJECTION(string) = 16;
+ ecs_Result PROXY_SETRASTERCONVERSION(ecs_RasterConversion) = 17;
+ ecs_Result PROXY_CREATESERVER(ecs_ProxyCreateServer) = 100;
+ ecs_Result PROXY_SETCOMPRESSION(ecs_Compression) = 101;
+ } = 1;
+} = 0x20000002;
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs_util.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs_util.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/include/ecs_util.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1528 @@
+/******************************************************************************
+ *
+ * Component: OGDI Core C API
+ * Purpose: Include file for all the OGDI (included by ecs.h).
+ * Contains most macros, and function prototypes, and structures
+ * that aren't transmitted over RPC (the rest are in ecs.h).
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecs_util.h,v $
+ * Revision 1.22 2007/02/24 17:12:33 cbalint
+ * 3.2.0beta1 pre-release
+ * Modified Files:
+ * ChangeLog HOWTO-RELEASE NEWS configure configure.in
+ * mkogdidist.sh ogdi/include/ecs_util.h
+ *
+ * Revision 1.21 2007/02/13 20:24:28 cbalint
+ * fix 64bit platforms.
+ *
+ * Revision 1.20 2007/02/13 02:11:18 cbalint
+ * 3.1.6 release.
+ *
+ * Revision 1.19 2005/03/01 00:49:27 warmerda
+ * Updated to 3.1.5.
+ *
+ * Revision 1.18 2004/10/26 20:45:52 warmerda
+ * Uupdated to 3.1.4.
+ *
+ * Revision 1.17 2004/10/04 15:53:12 warmerda
+ * Updated to version 3.1.3.
+ *
+ * Revision 1.16 2003/12/15 18:11:21 warmerda
+ * Updated version to 3.1.2.
+ *
+ * Revision 1.15 2003/01/29 15:46:45 warmerda
+ * fixed spelling of length
+ *
+ * Revision 1.14 2002/12/18 14:31:47 warmerda
+ * provide more precision for PI and use M_PI if available
+ *
+ * Revision 1.13 2002/03/28 16:09:07 warmerda
+ * updated version/release info
+ *
+ * Revision 1.12 2001/09/28 18:56:20 warmerda
+ * added OGDI_VERSION and OGDI_RELEASEDATE
+ *
+ * Revision 1.11 2001/07/18 03:55:09 warmerda
+ * Fixed case where DISABLE_CVSID is defined.
+ *
+ * Revision 1.10 2001/06/22 16:28:24 warmerda
+ * fixed typo in ECS_SETGEOMIMAGEVALUE
+ *
+ * Revision 1.9 2001/04/12 19:25:39 warmerda
+ * added RGB<->Pixel functions
+ *
+ * Revision 1.8 2001/04/12 18:15:25 warmerda
+ * added/finished capabilities support
+ *
+ * Revision 1.7 2001/04/12 05:29:47 warmerda
+ * added ecs_LayerCapabilities structure, and additions to ecs_Client
+ *
+ * Revision 1.6 2001/04/09 15:04:35 warmerda
+ * applied new source headers
+ *
+ */
+
+#ifndef ECS_UTIL
+#define ECS_UTIL 1
+
+#define OGDI_VERSION 320
+#define OGDI_RELEASEDATE 20070224
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rpc/rpc.h>
+#include <math.h>
+#include <memory.h>
+#include <ctype.h>
+
+#ifdef _WINDOWS
+#include <windows.h>
+#include <winsock.h>
+#else
+#include <dlfcn.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "projects.h"
+
+/* Ensure we are compatible with PROJ.4.4.x and PROJ.4.3.x */
+#ifndef USE_PROJUV
+# define projUV UV
+#endif
+
+#include "ecs.h"
+
+#ifdef _SCO
+#include <sys/fs/nfs/time.h>
+#endif
+
+#ifdef _WINDOWS
+#include <signal.h>
+#define alarm(a) printf("")
+#endif
+
+
+#ifndef __INT32DEF__
+#define __INT32DEF__
+#ifdef _ALPHA
+typedef int32_t int32;
+typedef uint32_t uint32;
+#else
+typedef int32_t int32;
+typedef uint32_t uint32;
+#endif
+#endif
+
+/***********************************************************************/
+
+/* Global definitions */
+
+#undef _ANSI_ARGS_
+#undef CONST
+#if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus)
+# define _USING_PROTOTYPES_ 1
+# define _ANSI_ARGS_(x) x
+# define CONST const
+# ifdef __cplusplus
+# define VARARGS(first) (first, ...)
+# else
+# define VARARGS(first) ()
+# endif
+#else
+# define _ANSI_ARGS_(x) ()
+# define CONST
+#endif
+
+#ifdef __cplusplus
+# define EXTERN extern "C"
+#else
+# define EXTERN extern
+#endif
+
+/*
+ * Macro to use instead of "void" for arguments that must have
+ * type "void *" in ANSI C; maps them to type "char *" in
+ * non-ANSI systems.
+ */
+
+#ifndef VOID
+# ifdef __STDC__
+# define VOID void
+# else
+# define VOID char
+# endif
+#endif
+
+/*
+ * Miscellaneous declarations (to allow Tcl to be used stand-alone,
+ * without the rest of Sprite).
+ */
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define ECSTOLERANCE 0.05
+
+#define PROJ_UNKNOWN "unknown"
+#define PROJ_LONGLAT "+proj=longlat"
+
+#define ECSGETJ(s,i1,j1) (int)(((s->rasterconversion.coef.coef_val[0]*j1 + s->rasterconversion.coef.coef_val[1]*i1 + s->rasterconversion.coef.coef_val[6]) / (s->rasterconversion.coef.coef_val[4]*j1 + s->rasterconversion.coef.coef_val[5]*i1 + 1)) + 0.5)
+#define ECSGETI(s,i1,j1) (int)(((s->rasterconversion.coef.coef_val[2]*j1 + s->rasterconversion.coef.coef_val[3]*i1 + s->rasterconversion.coef.coef_val[7]) / (s->rasterconversion.coef.coef_val[4]*j1 + s->rasterconversion.coef.coef_val[5]*i1 + 1)) + 0.5)
+
+#ifndef PI
+# ifdef M_PI
+# define PI M_PI
+# else
+# define PI 3.1415926535897932384626433832795029
+# endif
+#endif
+
+/***********************************************************************
+ * Define ECS_CVSID() macro. It can be disabled during a build by
+ * defining DISABLE_CVSID in the compiler options.
+ *
+ * The cvsid_aw() function is just there to prevent reports of ecs_cvsid()
+ * being unused.
+ */
+
+#ifndef DISABLE_CVSID
+# define ECS_CVSID(string) static char ecs_cvsid[] = string; \
+static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : ecs_cvsid ); }
+#else
+# define ECS_CVSID(string)
+#endif
+
+/***********************************************************************/
+
+/* defines for defaults file */
+
+#define MAX_DEF_LINE_LENGTH 1024
+#define DEFAULTS_INDEX_FILE "ogdidef.idx"
+
+
+/***********************************************************************/
+
+/* server.c declarations */
+
+#define OGDIID -1
+#define OGDICAT -2
+#define OGDIDESC -3
+#define OGDILAYERINC 32
+
+typedef ecs_Result *dynfunc();
+typedef int attrfunc();
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ecs_AttributeLink
+
+ DESCRIPTION
+ Description of a possible link between a geographic layer and a attribute driver
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ char *url: URL of the geographic layer
+ char *layer: Geographic layer selection string
+ ecs_Family family: Family of the geographic objects selected by this layer
+ char *DriverType: The kind of attribute driver to be link
+ char *InformationSource: Information source of the link
+ char *UserDescription: User description
+ char *AutorizationDescription: Autorization description
+ char *SelectionRequest: The request to construct the link.
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+typedef struct {
+ char *url;
+ char *layer;
+ ecs_Family family;
+ char *DriverType;
+ char *InformationSource;
+ char *UserDescription;
+ char *AutorizationDescription;
+ char *SelectionRequest;
+} ecs_AttributeLink;
+
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ecs_Layer
+
+ DESCRIPTION
+ Contain all the layer selection information.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ ecs_LayerSelection sel: Layer Selection Information
+ int index: For GetNextObject, the current object extracted
+ int nbfeature: The number of features in a layer. Optionnal.
+ void *priv: The private geographic information of the geographic driver for a geographic layer.
+ ecs_AttributeLink *AttributeDriverLinkPtr: The item in the list of possible odbc link that's in use. If null, no ODBC link
+ void *attribute_priv: The private geographic information of the geographic driver.
+ attrfunc *InitializeDBLinkFuncPtr: The pointer to the function dyn_InitializeDBLink in the attribute driver
+ attrfunc *DeinitializeDBLinkFuncPtr: The pointer to the function dyn_DeinitializeDBLink in the attribute driver
+ attrfunc *GetColumnsInfoFuncPtr: The pointer to the function dyn_GetColumnsInfo in the attribute driver
+ attrfunc *SelectAttributes: The pointer to the function dyn_SelectAttributes in the attribute driver
+ attrfunc *IsSelectedFuncPtr: The pointer to the function dyn_IsSelected in the attribute driver
+ attrfunc *GetSelectedAttributesFuncPtr: The pointer to the function GetSelectedAttributes in the attribute driver
+ void *AttributeDriverHandle: The dynamic library handle for the attribute driver
+ int SelectionAttributeListQty: The quantity of elements in the SelectionAttributeList
+ int *SelectionAttributeList: The list of positions of the objects attributes in use in the IsValueIsSelected of the attribute driver
+ char *AttrRequest: The attribute request with the "?code?" replaced with "?"
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+typedef struct {
+ ecs_LayerSelection sel;
+ int index;
+ int nbfeature;
+ void *priv;
+ ecs_AttributeLink *AttributeDriverLinkPtr;
+ void *attribute_priv;
+ attrfunc *InitializeDBLinkFuncPtr;
+ attrfunc *DeinitializeDBLinkFuncPtr;
+ attrfunc *GetColumnsInfoFuncPtr;
+ attrfunc *SelectAttributesFuncPtr;
+ attrfunc *IsSelectedFuncPtr;
+ attrfunc *GetSelectedAttributesFuncPtr;
+ void *AttributeDriverHandle;
+ int SelectionAttributeListQty;
+ int *SelectionAttributeList;
+ char *AttrRequest;
+} ecs_Layer;
+
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ecs_Server
+
+ DESCRIPTION
+ Contain all the geographic driver information
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ void *priv: The private geographic information of the geographic driver
+ ecs_Layer *layer: The table of the layer in use in the driver
+ int nblayer: Quantity of layer in layer.
+ int layer_tablesize: The table size of the layer table
+ int currentLayer: The current layer in use in the driver
+ void *handle: The dynamic library handle of the geographic driver
+ ecs_Region currentRegion: The current region of the geographic driver
+ ecs_Region globalRegion: The global region of the geographic driver
+ char *projection: The projection string of the contain of the geographic driver
+ char *hostname: The hostname extracted from the URL
+ char *server_type: The server type extracted from the URL
+ char *pathname: The path name extracted from the URL
+ int isRemote: Indicate if the server is a remote server or not
+ ecs_RasterConversion rasterconversion: Used to convert rasters in the driver
+ ecs_Result result: Returned structure to the client
+ int AttributeListQty: Quantity of links in AttributeList
+ ecs_AttributeList *AttributeList: The list of attribute links available
+ dynfunc *createserver: Pointer to the function dyn_CreateServer
+ dynfunc *destroyserver: Pointer to the function dyn_DestroyServer
+ dynfunc *selectlayer: Pointer to the function dyn_SelectLayer
+ dynfunc *releaselayer: Pointer to the function dyn_ReleaseLayer
+ dynfunc *closelayer: Pointer to the function dyn_ReleaseLayer
+ dynfunc *selectregion: Pointer to the function dyn_SelectRegion
+ dynfunc *getdictionary: Pointer to the function dyn_GetDictionary
+ dynfunc *getattrformat: Pointer to the function dyn_GetAttributesFormat
+ dynfunc *getnextobject: Pointer to the function dyn_GetNextObject
+ dynfunc *getrasterinfo: Pointer to the function dyn_GetRasterInfo
+ dynfunc *getobject: Pointer to the function dyn_GetObject
+ dynfunc *getobjectid: Pointer to the function dyn_GetObjectIdFromCoord
+ dynfunc *updatedictionary: Pointer to the function dyn_UpdateDictionary
+ dynfunc *getserverprojection: Pointer to the function dyn_GetServerProjection
+ dynfunc *getglobalbound: Pointer to the function dyn_GetGlobalBound
+ dynfunc *setserverlanguage: Pointer to the function dyn_SetServerLanguage
+ dynfunc *setserverprojection: Pointer to the function dyn_SetServerProjection
+ dynfunc *setrasterconversion: Pointer to the function dyn_SetRasterConversion
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+typedef struct {
+ /* Specific information for dynamic part of the server */
+
+ void *priv;
+
+ ecs_Layer *layer;
+ int nblayer;
+ int currentLayer;
+ int layer_tablesize;
+
+ /* dynamic library handle */
+
+ void *handle;
+
+ /* Regions of the server */
+
+ ecs_Region currentRegion;
+ ecs_Region globalRegion;
+
+ /* Server projection */
+
+ char *projection;
+
+ /* Extracted information from URL */
+
+ char *url;
+ char *hostname;
+ char *server_type;
+ char *pathname;
+
+ /* Indicate if the server is a remote server or not */
+
+ int isRemote;
+
+ /* Indicate if the client is local or not */
+
+ int localClient;
+
+ /* RasterConversion structure */
+
+ ecs_RasterConversion rasterconversion;
+
+ /* Structure returned to client */
+
+ ecs_Result result;
+
+ /* Compression parameters */
+
+ ecs_Compression compression;
+
+ /* pointers to functions */
+
+ dynfunc *createserver;
+ dynfunc *destroyserver;
+ dynfunc *selectlayer;
+ dynfunc *releaselayer;
+ dynfunc *closelayer;
+ dynfunc *selectregion;
+ dynfunc *getdictionary;
+ dynfunc *getattrformat;
+ dynfunc *getnextobject;
+ dynfunc *getrasterinfo;
+ dynfunc *getobject;
+ dynfunc *getobjectid;
+ dynfunc *updatedictionary;
+ dynfunc *getserverprojection;
+ dynfunc *getglobalbound;
+ dynfunc *setserverlanguage;
+ dynfunc *setserverprojection;
+ dynfunc *setrasterconversion;
+ dynfunc *setcompression;
+
+ int AttributeListQty;
+ ecs_AttributeLink *AttributeList;
+} ecs_Server;
+
+
+ecs_Result *svr_CreateServer _ANSI_ARGS_((ecs_Server *s, char *Request, int isLocal));
+ecs_Result *svr_DestroyServer _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_SelectLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *ls));
+ecs_Result *svr_ReleaseLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *ls));
+void svr_BroadCloseLayers _ANSI_ARGS_((ecs_Server *s));
+void svr_CloseLayer _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_SelectRegion _ANSI_ARGS_((ecs_Server *s, ecs_Region *gr));
+ecs_Result *svr_GetDictionary _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetAttributesFormat _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetNextObject _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetRasterInfo _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetObject _ANSI_ARGS_((ecs_Server *s, char *Id));
+ecs_Result *svr_GetObjectIdFromCoord _ANSI_ARGS_((ecs_Server *s, ecs_Coordinate *coord));
+ecs_Result *svr_UpdateDictionary _ANSI_ARGS_((ecs_Server *s, char *info));
+ecs_Result *svr_GetServerProjection _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetGlobalBound _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_SetServerLanguage _ANSI_ARGS_((ecs_Server *s, u_int language));
+ecs_Result *svr_SetCompression _ANSI_ARGS_((ecs_Server *s, ecs_Compression *compression));
+ecs_Result *svr_SetServerProjection _ANSI_ARGS_((ecs_Server *s, char *projection));
+ecs_Result *svr_SetRasterConversion _ANSI_ARGS_((ecs_Server *s,
+ ecs_RasterConversion *rc));
+
+/* These functions will be called by dynamic servers */
+
+int ecs_SetLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *sel));
+int ecs_GetLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *sel));
+void ecs_FreeLayer _ANSI_ARGS_((ecs_Server *s, int layer));
+int ecs_RemoveDir _ANSI_ARGS_((char *path));
+
+/* These functions are internally used in server.c */
+
+int ecs_GetLateralDBConnectionCtrlFile _ANSI_ARGS_((ecs_Server *s));
+int ecs_SetAttributeLinkWithRequest _ANSI_ARGS_((ecs_Server *s, char *request, ecs_Family family));
+int ecs_RemoveAttributeLinkWithRequest _ANSI_ARGS_((ecs_Server *s, char *request, ecs_Family family));
+int ecs_SetAttributeQuery _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char **error));
+int ecs_ReleaseAttributeQuery _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char **error));
+int ecs_UnstackRequest _ANSI_ARGS_((ecs_Server *s, char **request));
+int AddAttributeLink _ANSI_ARGS_((ecs_Server *s, char *url, char *layer, char *family, char *drivertype, char *infosource, char *userdesc, char *autorization, char *request));
+int ecs_SetBindListForVector _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, ecs_Result *msg, char ***BindList, char **error));
+int ecs_SetBindListForMatrix _ANSI_ARGS_((ecs_Server *s,ecs_Layer *l,ecs_Category *ptr,char ***BindList,char **error));
+int ecs_AddAttributeLink _ANSI_ARGS_((ecs_Server *s,char *url,char *layer,ecs_Family family,char *drivertype,char *infosource,
+ char *userdesc,char *autorization,char *request));
+int ecs_ExtractRequestInformation _ANSI_ARGS_((char *request,char **ExtractRequest,char **DriverType,char **InformationSource,
+ char **UserDescription,char **AutorizationDescription, char **SelectionRequest));
+
+/***********************************************************************/
+
+/* ecs_dyna.c declarations */
+
+void *ecs_OpenDynamicLib _ANSI_ARGS_((char *libname));
+void *ecs_GetDynamicLibFunction _ANSI_ARGS_((void *handle,char *functionname));
+void ecs_CloseDynamicLib _ANSI_ARGS_((void *handle));
+
+/***********************************************************************/
+
+/* ecsregex.c declarations */
+
+#define NSUBEXP 50
+typedef struct ecs_regexp {
+ char *startp[NSUBEXP];
+ char *endp[NSUBEXP];
+ char regstart; /* Internal use only. */
+ char reganch; /* Internal use only. */
+ char *regmust; /* Internal use only. */
+ int regmlen; /* Internal use only. */
+ char program[1]; /* Unwarranted chumminess with compiler. */
+} ecs_regexp;
+
+ecs_regexp *EcsRegComp _ANSI_ARGS_((char *exp));
+int EcsRegExec _ANSI_ARGS_((ecs_regexp *prog, char *string, char *start));
+void EcsRegError _ANSI_ARGS_((char *msg));
+char *EcsGetRegError _ANSI_ARGS_((void));
+
+/***********************************************************************/
+
+/* ecsdist.c declarations */
+
+
+double ecs_DistanceObject _ANSI_ARGS_((ecs_Object *obj, double X, double Y));
+double ecs_DistanceObjectWithTolerance _ANSI_ARGS_((ecs_Object *obj, double X, double Y));
+double ecs_SetTolerance _ANSI_ARGS_((ecs_Region *reg));
+double ecs_DistanceMBR _ANSI_ARGS_((double xl, double yl, double xu, double yu, double dx, double dy));
+double ecs_DistanceSegment _ANSI_ARGS_((double xl, double yl, double xu, double yu, double dx, double dy));
+int ecs_IsPointInPolygon _ANSI_ARGS_((int npoints, ecs_Coordinate *poly,double x,double y));
+
+/***********************************************************************/
+/* ecsinfo.c declaration */
+
+int ecs_GetDefaultInfo _ANSI_ARGS_((char* url, char* key, char** result));
+
+/***********************************************************************/
+
+/* ecsassoc.c declarations */
+
+/* WARNING: These define do more than one operation.
+ Please, don't consider these as functions.
+ */
+
+
+/*
+ ----------------------------------------------------------------
+ ECSRESULTTYPE: This macro indicate the object type of ecs_Result
+ ----------------------------------------------------------------
+ */
+
+#define ECSRESULTTYPE(result) ((result)->res.type)
+
+/*
+ ----------------------------------------------------------------
+ ECSRESULTTYPE: This macro access the union in ecs_Result and
+ facilitate ecs_Result structures access.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRESULT(result) ((result)->res.ecs_ResultUnion_u)
+
+/*
+ ----------------------------------------------------------------
+ ECSRESULTTYPE: This macro indicate the geographical object type
+ contain in ecs_Result
+ ----------------------------------------------------------------
+ */
+
+#define ECSGEOMTYPE(result) ((result)->res.ecs_ResultUnion_u.dob.geom.family)
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOM: This macro access the union contain in the geographical
+ object in ecs_Result.
+ ----------------------------------------------------------------
+ */
+
+#define ECSGEOM(result) ((result)->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u)
+
+/*
+ ----------------------------------------------------------------
+ ECSAREARING: This macro access the area ring in the geographic
+ object of type Area
+ ----------------------------------------------------------------
+ */
+
+#define ECSAREARING(result,pos) ((result)->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.area.ring.ring_val[(pos)])
+
+/*
+ ----------------------------------------------------------------
+ ECSERROR: Indicate if ecs_Result contain an error code
+ ----------------------------------------------------------------
+ */
+
+#define ECSERROR(r) ((r)->error != 0)
+
+/*
+ ----------------------------------------------------------------
+ ECSSUCCESS: Indicate if ecs_Result contain an success code
+ ----------------------------------------------------------------
+ */
+
+#define ECSSUCCESS(r) ((r)->error == 0)
+
+/*
+ ----------------------------------------------------------------
+ ECSEOF: Indicate if ecs_Result contain EOF message. Mainly
+ use in cln_GetNextObject function.
+ ----------------------------------------------------------------
+ */
+
+#define ECSEOF(r) ((r)->error == 2)
+
+/*
+ ----------------------------------------------------------------
+ ECSPROJ: Indicate if ecs_Result contain PROJ error message. Mainly
+ use in cln_GetNextObject function.
+ ----------------------------------------------------------------
+ */
+
+#define ECSPROJ(r) ((r)->error == 3)
+
+/*
+ ----------------------------------------------------------------
+ ECSMESSAGE: Return the error message contain in ecs_Result (an
+ string).
+ ----------------------------------------------------------------
+ */
+
+#define ECSMESSAGE(r) ((r)->message)
+
+/*
+ ----------------------------------------------------------------
+ ECSREGION: Return the geographical region contain in ecs_Result
+ (if it's the case). The structure returned is a ecs_Region.
+ ----------------------------------------------------------------
+ */
+
+#define ECSREGION(r) (ECSRESULT(r).gr)
+
+/*
+ ----------------------------------------------------------------
+ ECSTEXT: Return the text string contain in ecs_Result (if
+ it's the case). The structure returned is a string.
+ ----------------------------------------------------------------
+ */
+
+#define ECSTEXT(r) (ECSRESULT(r).s)
+
+/*
+ ----------------------------------------------------------------
+ ECSRASTERINFO: Return the raster information contain in ecs_Result
+ (if it's the case). The structure return is a ecs_RasterInfo.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRASTERINFO(r) (ECSRESULT(r).ri)
+
+/*
+ ----------------------------------------------------------------
+ ECSRASTERINFONB: Return the number of categories in the
+ ecs_RasterInfo structure contain in ecs_Result.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRASTERINFONB(r) (ECSRASTERINFO(r).cat.cat_len)
+
+/*
+ ----------------------------------------------------------------
+ ECSRASTERINFOCAT: Return the category number "c" contain in
+ ecs_RasterInfo in ecs_Result. The structure returned is a
+ ecs_Category.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRASTERINFOCAT(r,c) (ECSRASTERINFO(r).cat.cat_val[(c)])
+
+/*
+ ----------------------------------------------------------------
+ ECSOBJECT: Return the geographic object contain in ecs_Result
+ (if it's the case). The structure return is a ecs_Object.
+ ----------------------------------------------------------------
+ */
+
+#define ECSOBJECT(r) (ECSRESULT(r).dob)
+
+/*
+ ----------------------------------------------------------------
+ ECSOBJECTID: Return the "Id" attribute contain the ecs_Object structure
+ contain in ecs_Result.
+ ----------------------------------------------------------------
+ */
+
+#define ECSOBJECTID(r) (ECSOBJECT(r).Id)
+
+/*
+ ----------------------------------------------------------------
+ ECSOBJECTATTR: Return the "attr" attribute contain the ecs_Object structure
+ contain in ecs_Result.
+ ----------------------------------------------------------------
+ */
+
+#define ECSOBJECTATTR(r) (ECSOBJECT(r).attr)
+
+/*
+ ----------------------------------------------------------------
+ ECSRASTER: Return the raster line table contain in ecs_Object.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRASTER(r) (ECSOBJECT(r).geom.ecs_Geometry_u.matrix.x.x_val)
+
+/*
+ ----------------------------------------------------------------
+ ECS_SETGEOMBOUNDINGBOX: This macro will put in the geographical
+ object contain in "result" the bounding rectangle (lxmin, lymin,
+ lxmax, lymax).
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMBOUNDINGBOX(result,lxmin,lymin,lxmax,lymax) { \
+ {if ((result)->res.type==Object) { \
+ (result)->res.ecs_ResultUnion_u.dob.xmin=(lxmin); \
+ (result)->res.ecs_ResultUnion_u.dob.ymin=(lymin); \
+ (result)->res.ecs_ResultUnion_u.dob.xmax=(lxmax); \
+ (result)->res.ecs_ResultUnion_u.dob.ymax=(lymax); \
+ }} \
+}
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOMLINECOORD: This macro put a point (lx,ly) at the position
+ "position" in a line geographical object. To entirely set the
+ line object, ecs_SetGeomLine must be call first and for each point,
+ ECS_SETGEOMLINECOORD must be call.
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMLINECOORD(result,position,lx,ly) \
+{ \
+ (result)->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.line.c.c_val[position].x = (lx); \
+ (result)->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.line.c.c_val[position].y = (ly); \
+}
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOMAREACOORD: This macro put a point (lx,ly) at the position
+ "position" of the ring "ringpos" in a area geographical object. To
+ entirely set the area object, ecs_SetGeomArea must be call first
+ and for each ring, ecs_SetGeomAreaRing must be call. In each of
+ this ring, ECS_SETGEOMAREACOORD must be call define the polygons
+ points.
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMAREACOORD(result,ringpos,position,lx,ly) \
+{ \
+(result)->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.area.ring.ring_val[ringpos].c.c_val[position].x = lx; \
+(result)->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.area.ring.ring_val[ringpos].c.c_val[position].y = ly; \
+}
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOMMATRIXCOORD: This macro put a value at the position
+ "position" in a matrix geographical object. To entirely set the
+ matrix object, ecs_SetGeomMatrix must be call first and for each
+ column, ECS_SETGEOMMATRIXCOORD must be call.
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMMATRIXVALUE(result,lpos,lval) \
+{(result)->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.matrix.x.x_val[lpos] = (lval);}
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOMIMAGECOORD: This macro put a value at the position
+ "position" in a image geographical object. To entirely set the
+ image object, ecs_SetGeomImage must be call first and for each
+ column, ECS_SETGEOMIMAGECOORD must be call.
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMIMAGEVALUE(result,lpos,lval) \
+{(result)->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.image.x.x_val[lpos] = (lval);}
+
+/********************************/
+
+int ecs_SetError _ANSI_ARGS_((ecs_Result *r,
+ int errorcode, char *error_message));
+int ecs_SetSuccess _ANSI_ARGS_((ecs_Result *r));
+int ecs_AdjustResult _ANSI_ARGS_((ecs_Result *r));
+int ecs_SetGeoRegion _ANSI_ARGS_((ecs_Result *r,
+ double north, double south, double east,
+ double west, double nsres, double ewres));
+int ecs_SetText _ANSI_ARGS_((ecs_Result *r,char *text));
+int ecs_AddText _ANSI_ARGS_((ecs_Result *r,char *text));
+int ecs_SetRasterInfo _ANSI_ARGS_((ecs_Result *r, int width, int height));
+int ecs_AddRasterInfoCategory _ANSI_ARGS_((ecs_Result *r, long no_cat,
+ unsigned int red,
+ unsigned int green,
+ unsigned int blue, char *label,
+ unsigned long qty));
+int ecs_SetObjAttributeFormat _ANSI_ARGS_((ecs_Result *r));
+int ecs_AddAttributeFormat _ANSI_ARGS_((ecs_Result *r, char *name,
+ ecs_AttributeFormat type,
+ int length, int precision,
+ int nullable));
+int ecs_SetGeomPoint _ANSI_ARGS_((ecs_Result *r, double x, double y));
+int ecs_SetGeomText _ANSI_ARGS_((ecs_Result *r, double x,
+ double y, char *desc));
+int ecs_SetGeomLine _ANSI_ARGS_((ecs_Result *r, unsigned int length));
+int ecs_SetGeomArea _ANSI_ARGS_((ecs_Result *r, unsigned int length));
+int ecs_SetGeomAreaRing _ANSI_ARGS_((ecs_Result *r, int position,
+ unsigned int length,
+ double centroid_x, double centroid_y));
+int ecs_SetGeomMatrix _ANSI_ARGS_((ecs_Result *r, int size));
+int ecs_SetGeomMatrixWithArray _ANSI_ARGS_((ecs_Result *r, int size, unsigned int *array));
+int ecs_SetGeomImage _ANSI_ARGS_((ecs_Result *r, int size));
+int ecs_SetGeomImageWithArray _ANSI_ARGS_((ecs_Result *r, int size, unsigned int *array));
+int ecs_SetObjectId _ANSI_ARGS_((ecs_Result *r,char *id));
+int ecs_SetObjectAttr _ANSI_ARGS_((ecs_Result *r,char *attr));
+int ecs_CleanUp _ANSI_ARGS_((ecs_Result *r));
+int ecs_CleanUpObject _ANSI_ARGS_((ecs_Object *r));
+int ecs_CleanUpResultUnion _ANSI_ARGS_((ecs_ResultUnion *r));
+int ecs_ResultInit _ANSI_ARGS_((ecs_Result *r));
+int ecs_CalcObjectMBR _ANSI_ARGS_((ecs_Server *s, ecs_Object *obj));
+int ecs_CopyResult _ANSI_ARGS_((ecs_Result *source, ecs_Result **copy));
+int ecs_CopyResultFromUnion _ANSI_ARGS_((ecs_ResultUnion *source, ecs_Result **copy));
+int ecs_CopyResultUnion _ANSI_ARGS_((ecs_ResultUnion *source, ecs_ResultUnion **copy));
+int ecs_CopyResultUnionWork _ANSI_ARGS_((ecs_ResultUnion *source, ecs_ResultUnion *copy));
+int ecs_CopyObject _ANSI_ARGS_((ecs_Object *source, ecs_Object *copy));
+int ecs_CopyGeometry _ANSI_ARGS_((ecs_Object *source, ecs_Object *copy));
+int ecs_CopyArea _ANSI_ARGS_((ecs_Area *source, ecs_Area *copy));
+int ecs_CopyLine _ANSI_ARGS_((ecs_Line *source, ecs_Line *copy));
+int ecs_CopyPoint _ANSI_ARGS_((ecs_Point *source, ecs_Point *copy));
+int ecs_CopyText _ANSI_ARGS_((ecs_Text *source, ecs_Text *copy));
+int ecs_CopyMatrix _ANSI_ARGS_((ecs_Matrix *source, ecs_Matrix *copy));
+int ecs_CopyImage _ANSI_ARGS_((ecs_Image *source, ecs_Image *copy));
+void ecs_FreeObject _ANSI_ARGS_((ecs_Object *obj));
+
+
+/***********************************************************************/
+
+/* ecs_split.c declarations */
+
+void ecs_freeSplitURL _ANSI_ARGS_((char **type,char **machine,char **path));
+int ecs_GetRegex _ANSI_ARGS_((ecs_regexp *reg,int index,char **chaine));
+int ecs_SplitURL _ANSI_ARGS_((char *url,char **machine,char **server,char **path));
+
+
+/***********************************************************************/
+
+/* ecs_list.c declarations */
+
+char ecs_Backslash _ANSI_ARGS_((char *src, int *readPtr));
+int ecs_FindElement _ANSI_ARGS_((register char *list,char **elementPtr, char **nextPtr, int *sizePtr, int *bracePtr));
+void ecs_CopyAndCollapse _ANSI_ARGS_((int count,register char *src,register char *dst));
+int ecs_SplitList _ANSI_ARGS_((char *list,int *argcPtr,char ***argvPtr));
+
+/***********************************************************************/
+
+/* dynamic library server declarations */
+
+ecs_Result *dyn_CreateServer _ANSI_ARGS_((ecs_Server *s, char *Request));
+ecs_Result *dyn_DestroyServer _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_SelectLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *ls));
+ecs_Result *dyn_ReleaseLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *ls));
+ecs_Result *dyn_SelectRegion _ANSI_ARGS_((ecs_Server *s, ecs_Region *gr));
+ecs_Result *dyn_GetDictionary _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetAttributesFormat _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetNextObject _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetRasterInfo _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetObject _ANSI_ARGS_((ecs_Server *s, char *Id));
+ecs_Result *dyn_GetObjectIdFromCoord _ANSI_ARGS_((ecs_Server *s, ecs_Coordinate *coord));
+ecs_Result *dyn_UpdateDictionary _ANSI_ARGS_((ecs_Server *s, char *info));
+ecs_Result *dyn_GetServerProjection _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetGlobalBound _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_SetServerLanguage _ANSI_ARGS_((ecs_Server *s, u_int language));
+ecs_Result *dyn_SetServerProjection _ANSI_ARGS_((ecs_Server *s, char *projection));
+ecs_Result *dyn_SetRasterConversion _ANSI_ARGS_((ecs_Server *s,
+ ecs_RasterConversion *rc));
+ecs_Result *dyn_SetCompression _ANSI_ARGS_((ecs_Server *s, ecs_Compression *compression));
+
+/***********************************************************************/
+
+/* dynamic library attribute driver declarations */
+
+int dyn_InitializeDBLink _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char **error));
+int dyn_DeinitializeDBLink _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char **error));
+int dyn_GetColumnsInfo _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, int *columns_qty, ecs_ObjAttribute **attr, char **error));
+int dyn_SelectAttributes _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, int attribute_qty, char **attribute_list, char **error));
+int dyn_IsSelected _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, short *isSelected, char **error));
+int dyn_GetSelectedAttributes _ANSI_ARGS_((ecs_Server *s, ecs_Layer *l, char **attributes, char **error));
+
+/***********************************************************************/
+
+/* dynamic library attribute driver declarations */
+
+int dyn_nad_init _ANSI_ARGS_((void **privtableinfo, char *table));
+int dyn_nad_close _ANSI_ARGS_((void *privtableinfo));
+int dyn_nad_forward _ANSI_ARGS_((void *privtableinfo, double *x, double *y));
+int dyn_nad_reverse _ANSI_ARGS_((void *privtableinfo, double *x, double *y));
+
+/***********************************************************************/
+
+
+/*
+ * client.h --
+ *
+ * Control dispatch of locals client. Also control cache management and
+ * projection changes.
+ *
+ * Copyright (c) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc.
+ * Il est strictement interdit de publier ou de devoiler le contenu de ce
+ * programme sans avoir prealablement obtenu la permission de L.A.S. Inc.
+ */
+
+#define CACHEINITSIZE 100
+#define COMPARETOLERANCE 0.000000001 /* For projection conversion, tolerance factor during projection compare */
+
+#define ECS_TTOS 0 /* define the conversion direction (target to source) or (source to target) */
+#define ECS_STOT 1
+
+
+typedef struct ecs_CtlPoint {
+ double e1,n1,e2,n2;
+ double errorx,errory;
+} ecs_CtlPoint;
+
+
+typedef struct ecs_CtlPoints {
+ int nbpts;
+ ecs_CtlPoint *pts;
+} ecs_CtlPoints;
+
+
+typedef struct ecs_Cache {
+ ecs_LayerSelection coverage; /* coverage descriptor */
+
+ int size; /* logical cache size */
+ int startpos; /* beginning position of cache */
+ int currentpos; /* current position in cache for getnextobject */
+ int allocatedSize; /* physical size of cache */
+ ecs_Result **o; /* the cache itself */
+
+ struct ecs_Cache *next; /* linked list successor, NULL if end of list */
+ struct ecs_Cache *previous; /* linked list predecessor */
+} ecs_Cache;
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ecs_Datum
+
+ DESCRIPTION
+ Description of all the possible states of a projection about datum.
+ END_DESCRIPTION
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+enum ecs_Datum {
+ nodatum = 1,
+ nad27 = 2,
+ nad83 = 3
+};
+typedef enum ecs_Datum ecs_Datum;
+
+typedef int dtfunc();
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ecs_LayerCapabilities
+
+ DESCRIPTION
+ Information about a layer gleaned from OGDI_Capabilities document.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ char *name: The default layer name, as per the <Name> element.
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+#define MAX_FAMILIES 20
+
+typedef struct {
+ char *name;
+ char *title;
+ char *srs;
+ int families[MAX_FAMILIES];
+ char **parents;
+ char **extensions;
+
+ int ll_bounds_set;
+ double ll_north;
+ double ll_south;
+ double ll_east;
+ double ll_west;
+
+ double srs_north;
+ double srs_south;
+ double srs_east;
+ double srs_west;
+ double srs_nsres;
+ double srs_ewres;
+
+ int query_expression_set;
+ char *qe_prefix;
+ char *qe_suffix;
+ char *qe_format;
+ char *qe_description;
+} ecs_LayerCapabilities;
+
+/*********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ecs_Client
+
+ DESCRIPTION
+ Description of the attributes of the c interface object (client.c).
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ char *url: Client URL, mostly used to see if a client already exist
+ ecs_Cache *cache: linked list of all cached coverage
+ ecs_Cache *selectCache: A pointer to the cache selected by SelectLayer
+ ecs_Region cacheRegion: mbr region of cache
+ ecs_Region currentRegion: mbr of current region
+ ecs_Family currentSelectionFamily: Current layer selection type
+ char *tclprocname: attribute callback procedure for tcl
+ char *target_proj: Projection descriptor
+ PJ *target: target (c interface) projection descriptors
+ PJ *source: source (driver) projection descriptors
+ ecs_Datum targetdatum: target datum information
+ ecs_Datum sourcedatum: source datum information
+ void *dthandle: Handle to the datum driver
+ void *privdatuminfo: The private datum information pointer. Used to specify the object.
+ dtfunc *nad_init: Pointer to the nad_init function in the datum driver
+ dtfunc *nad_forward: Pointer to the nad_forward function in the datum driver
+ dtfunc *nad_reverse: Pointer to the nad_reverse function in the datum driver
+ dtfunc *nad_close: Pointer to the nad_close function in the datum driver
+ char datumtable[10]: Datum table name
+ int isSourceLL: Indicate if the source is a longlat projection
+ int isTargetLL: Indicate if the target is a longlat projection
+ int isProjEqual: Indicate if the projections are the same
+ int isCurrentRegionSet: Indicate if the current region is set
+ double target_azimuth: The azimuth angle to apply to the target projection
+ double sinazimuth: The azimuth sinus
+ double cosazimuth: The azimuth cosinus
+ ecs_Server s: The ecs_Server structure is hold here.
+ ecs_FeatureRing *mask: Polygon mask
+ int isMaskInclusive: Indicate if the mask is inclusive (all the objects are completelly inside) or not.
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************/
+
+typedef struct {
+ char *url; /* Client URL, mostly used to see if a client already exist */
+
+ ecs_Cache *cache; /* linked list of all cached coverage */
+ ecs_Cache *selectCache; /* A pointer to the cache selected by SelectLayer */
+ ecs_Cache *autoCache; /* Automatic cache when using with remote servers */
+ ecs_Region cacheRegion; /* mbr region of cache */
+ ecs_Region currentRegion; /* mbr of current region */
+ ecs_Family currentSelectionFamily; /* Current layer selection type */
+ char *tclprocname; /* attribute callback procedure for tcl */
+ char *target_proj;
+ PJ *target; /* source and target projection descriptors */
+ PJ *source;
+ int isSourceLL; /* flags to avoid unnecessary computation */
+ int isTargetLL;
+ int isProjEqual;
+ int isCurrentRegionSet;
+ double target_azimuth;
+ double sinazimuth;
+ double cosazimuth;
+ ecs_Datum targetdatum;
+ ecs_Datum sourcedatum;
+ char datumtable[10];
+ void *privdatuminfo;
+ void *dthandle;
+ dtfunc *nad_init;
+ dtfunc *nad_forward;
+ dtfunc *nad_reverse;
+ dtfunc *nad_close;
+
+ ecs_Server s;
+
+ ecs_FeatureRing *mask;
+ ecs_Region maskregion;
+ int isMaskInclusive;
+
+ int have_server_capabilities;
+ char server_version_str[32];
+ int server_version; /* version times 1000, ie. 3100 for 3.1 */
+
+ char **global_extensions;
+
+ int have_capabilities;
+ int layer_cap_count;
+ ecs_LayerCapabilities **layer_cap;
+
+} ecs_Client;
+
+#define MAXCLIENT 32
+
+/* Functions used for allocation and deallocation. */
+
+void cln_FreeClient _ANSI_ARGS_((ecs_Client **c));
+int cln_AllocClient _ANSI_ARGS_((char *URL,int *error));
+
+/* API functions */
+
+ecs_Result *cln_CreateClient _ANSI_ARGS_((int *ClientID,char *url));
+ecs_Result *cln_DestroyClient _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_SelectLayer _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls));
+ecs_Result *cln_ReleaseLayer _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls));
+void cln_BroadCloseLayers();
+ecs_Result *cln_SelectMask _ANSI_ARGS_((int ClientID,ecs_FeatureRing *mask,int isInclusive));
+ecs_Result *cln_UnSelectMask _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_SelectRegion _ANSI_ARGS_((int ClientID, ecs_Region *gr));
+ecs_Result *cln_GetDictionary _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_GetAttributesFormat _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_GetNextObject _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_GetRasterInfo _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_GetObject _ANSI_ARGS_((int ClientID, char *Id));
+ecs_Result *cln_GetObjectIdFromCoord _ANSI_ARGS_((int ClientID, ecs_Coordinate *coord));
+ecs_Result *cln_UpdateDictionary _ANSI_ARGS_((int ClientID, char *info));
+ecs_Result *cln_GetGlobalBound _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_SetServerLanguage _ANSI_ARGS_((int ClientID, u_int language));
+ecs_Result *cln_SetCompression _ANSI_ARGS_((int ClientID, ecs_Compression *compression));
+ecs_Result *cln_GetServerProjection _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_SetServerProjection _ANSI_ARGS_((int ClientID, char *projection));
+ecs_Result *cln_SetClientProjection _ANSI_ARGS_((int ClientID, char *projection));
+void cln_SetTclProc _ANSI_ARGS_((int ClientID, char *tclproc));
+char *cln_GetTclProc _ANSI_ARGS_((int ClientID));
+
+
+/* Projection conversion functions */
+
+PJ *cln_ProjInit _ANSI_ARGS_((char *d));
+int cln_CompareProjections _ANSI_ARGS_((int ClientID));
+int cln_UpdateMaxRegion _ANSI_ARGS_((int ClientID, double x, double y, ecs_Region *gr, int sens, int first));
+int cln_ConvRegion _ANSI_ARGS_((int ClientID, ecs_Region *gr, int sens));
+int cln_ConvTtoS _ANSI_ARGS_((int ClientID, double *X, double *Y));
+int cln_ConvStoT _ANSI_ARGS_((int ClientID, double *X, double *Y));
+int cln_ChangeProjection _ANSI_ARGS_((int ClientID, ecs_Object *obj));
+int cln_ChangeProjectionArea _ANSI_ARGS_((int ClientID, ecs_Area *obj));
+int cln_ChangeProjectionLine _ANSI_ARGS_((int ClientID, ecs_Line *obj));
+int cln_ChangeProjectionPoint _ANSI_ARGS_((int ClientID, ecs_Point *obj));
+int cln_ChangeProjectionMatrix _ANSI_ARGS_((int ClientID, ecs_Matrix *obj));
+int cln_ChangeProjectionImage _ANSI_ARGS_((int ClientID, ecs_Image *obj));
+int cln_ChangeProjectionText _ANSI_ARGS_((int ClientID, ecs_Text *obj));
+int cln_PointValid _ANSI_ARGS_((int ClientID, double x, double y));
+ecs_Datum cln_GetDatumInfo _ANSI_ARGS_((char *projection));
+
+/* Matrix conversion functions */
+
+int cln_CalcCtlPoint _ANSI_ARGS_((int ClientID, ecs_Region *server_region,
+ int SI, int SJ, ecs_CtlPoint *pt));
+int cln_CalcCtlPoints _ANSI_ARGS_((int ClientID, ecs_CtlPoints **pts,
+ char **error_message));
+int cln_SetRasterConversion _ANSI_ARGS_((int ClientID,
+ ecs_CtlPoints **pts,
+ ecs_Resampling resampling,
+ ecs_Transformation trans,
+ char **error_message));
+
+
+/* URL manipulation */
+
+int cln_GetClientIdFromURL _ANSI_ARGS_((char *url));
+int cln_GetURLList _ANSI_ARGS_((char **urllist));
+
+/* Cache functions */
+
+int cln_SetRegionCaches _ANSI_ARGS_((int ClientID, ecs_Region *GR, char **error_message));
+int cln_LoadCache _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls, char **error_message));
+int cln_ReleaseCache _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls, char **error_message));
+void cln_FreeCache _ANSI_ARGS_((ecs_Cache *cache));
+ecs_Cache *cln_NewCache _ANSI_ARGS_((int size));
+ecs_Cache *cln_FoundCache _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls));
+
+/* The rest */
+
+void cln_BlockOGDI();
+void cln_UnBlockOGDI();
+int cln_IsGeoObjectInsideMask _ANSI_ARGS_((int ClientID,ecs_Result *obj));
+int cln_ConvMBR _ANSI_ARGS_((int ClientID,double *xl,double *yl,double *xu,double *yu,int direction));
+
+/* capabilities */
+
+ecs_Result *cln_GetVersion( int ClientID );
+int cln_CheckExtension( int ClientID, const char *extension,
+ const char *layer_name );
+const ecs_LayerCapabilities *
+ cln_GetLayerCapabilities( int ClientID, int layer_index );
+
+ecs_Result *cln_LoadCapabilities( int ClientID, const char *arg, int err );
+void ecs_ParseCapabilities( ecs_Client *cln, const char *cap_doc,
+ ecs_Result *result );
+
+/***********************************************************************/
+
+
+/*
+ * ecsgeo --
+ *
+ * Make geometric calculations
+ *
+ * Copyright (c) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc.
+ * Il est strictement interdit de publier ou de devoiler le contenu de ce
+ * programme sans avoir prealablement obtenu la permission de L.A.S. Inc.
+ */
+
+void ecs_begin_ellipsoid_polygon_area _ANSI_ARGS_((double a, double e2));
+double ecs_Q _ANSI_ARGS_((double x));
+double ecs_Qbar _ANSI_ARGS_((double x));
+double ecs_planimetric_polygon_area _ANSI_ARGS_((int n,ecs_Coordinate *coord));
+double ecs_ellipsoid_polygon_area _ANSI_ARGS_((int n,ecs_Coordinate *coord));
+double ecs_geodesic_distance _ANSI_ARGS_((double lon1, double lat1, double lon2, double lat2));
+double ecs_distance_meters _ANSI_ARGS_((char *projection, double X1, double Y1, double X2, double Y2));
+int ecs_CalculateCentroid _ANSI_ARGS_((int nb_segment, ecs_Coordinate *coord,ecs_Coordinate *centroid));
+
+
+/***********************************************************************/
+
+/*
+ * Structure definition for an entry in a hash table. No-one outside
+ * ecs should access any of these fields directly; use the macros
+ * defined below.
+ */
+
+typedef struct ecs_HashEntry {
+ struct ecs_HashEntry *nextPtr; /* Pointer to next entry in this
+ * hash bucket, or NULL for end of
+ * chain. */
+ struct ecs_HashTable *tablePtr; /* Pointer to table containing entry. */
+ struct ecs_HashEntry **bucketPtr; /* Pointer to bucket that points to
+ * first entry in this entry's chain:
+ * used for deleting the entry. */
+ int clientData; /* Application stores something here
+ * with ecs_SetHashValue. */
+ union { /* Key has one of these forms: */
+ char *oneWordValue; /* One-word value for key. */
+ int words[1]; /* Multiple integer words for key.
+ * The actual size will be as large
+ * as necessary for this table's
+ * keys. */
+ char string[4]; /* String for key. The actual size
+ * will be as large as needed to hold
+ * the key. */
+ } key; /* MUST BE LAST FIELD IN RECORD!! */
+} ecs_HashEntry;
+
+/*
+ * Structure definition for a hash table. Must be in ecs.h so clients
+ * can allocate space for these structures, but clients should never
+ * access any fields in this structure.
+ */
+
+#define ECS_SMALL_HASH_TABLE 4
+typedef struct ecs_HashTable {
+ ecs_HashEntry **buckets; /* Pointer to bucket array. Each
+ * element points to first entry in
+ * bucket's hash chain, or NULL. */
+ ecs_HashEntry *staticBuckets[ECS_SMALL_HASH_TABLE];
+ /* Bucket array used for small tables
+ * (to avoid mallocs and frees). */
+ int numBuckets; /* Total number of buckets allocated
+ * at **bucketPtr. */
+ int numEntries; /* Total number of entries present
+ * in table. */
+ int rebuildSize; /* Enlarge table when numEntries gets
+ * to be this large. */
+ int downShift; /* Shift count used in hashing
+ * function. Designed to use high-
+ * order bits of randomized keys. */
+ int mask; /* Mask value used in hashing
+ * function. */
+ int keyType; /* Type of keys used in this table.
+ * It's either ECS_STRING_KEYS,
+ * ECS_ONE_WORD_KEYS, or an integer
+ * giving the number of ints in a
+ */
+ ecs_HashEntry *(*findProc) _ANSI_ARGS_((struct ecs_HashTable *tablePtr,
+ char *key));
+ ecs_HashEntry *(*createProc) _ANSI_ARGS_((struct ecs_HashTable *tablePtr,
+ char *key, int *newPtr));
+} ecs_HashTable;
+
+/*
+ * Structure definition for information used to keep track of searches
+ * through hash tables:
+ */
+
+typedef struct ecs_HashSearch {
+ ecs_HashTable *tablePtr; /* Table being searched. */
+ int nextIndex; /* Index of next bucket to be
+ * enumerated after present one. */
+ ecs_HashEntry *nextEntryPtr; /* Next entry to be enumerated in the
+ * the current bucket. */
+} ecs_HashSearch;
+
+/*
+ * Acceptable key types for hash tables:
+ */
+
+#define ECS_STRING_KEYS 0
+#define ECS_ONE_WORD_KEYS 1
+
+/*
+ * Macros for clients to use to access fields of hash entries:
+ */
+
+#define ecs_GetHashValue(h) ((h)->clientData)
+#define ecs_SetHashValue(h, value) ((h)->clientData = (ClientData) (value))
+#define ecs_GetHashKey(tablePtr, h) \
+ ((char *) (((tablePtr)->keyType == ECS_ONE_WORD_KEYS) ? (h)->key.oneWordValue \
+ : (h)->key.string))
+
+/*
+ * Macros to use for clients to use to invoke find and create procedures
+ * for hash tables:
+ */
+
+#define ecs_FindHashEntry(tablePtr, key) \
+ (*((tablePtr)->findProc))(tablePtr, key)
+#define ecs_CreateHashEntry(tablePtr, key, newPtr) \
+ (*((tablePtr)->createProc))(tablePtr, key, newPtr)
+
+void ecs_InitHashTable _ANSI_ARGS_((ecs_HashTable *tablePtr, int keyType));
+void ecs_DeleteHashEntry _ANSI_ARGS_((ecs_HashEntry *entryPtr));
+void ecs_DeleteHashTable _ANSI_ARGS_((ecs_HashTable *tablePtr));
+ecs_HashEntry * ecs_FirstHashEntry _ANSI_ARGS_((ecs_HashTable *tablePtr,
+ ecs_HashSearch *searchPtr));
+ecs_HashEntry * ecs_NextHashEntry _ANSI_ARGS_((ecs_HashSearch *searchPtr));
+char *ecs_HashStats _ANSI_ARGS_((ecs_HashTable *tablePtr));
+
+
+/***********************************************************************/
+
+typedef int tile_func();
+
+/*
+ ********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ecs_TileID
+ DESCRIPTION
+ Identifier for a tile
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ int x: the horizontal tile number
+ int y: the vertical tile number
+ short none: 0 if invalid tile
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************
+*/
+
+typedef struct ecs_TileID {
+ int x;
+ int y;
+ short none; /* 1 if valid, 0 if uninitialized */
+} ecs_TileID;
+
+/*
+ ********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ecs_TileBufferLine
+ DESCRIPTION
+ A line in the tile buffer. Stores categories
+ that have been retrieved from the file.
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ int *linebuffer: ptr to array of values
+ (length is stored in ecs_Tile).
+ int index: the y-matrix position of this line.
+ int last: the last filled point.
+ ecs_TileBufferLinePtr *next: pointer to next line.
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************
+*/
+
+typedef struct ecs_TileBufferLine {
+ int *linebuffer;
+ int index;
+ int last;
+ struct ecs_TileBufferLine *next;
+} ecs_TileBufferLine;
+
+/*
+ ********************************************************************
+
+ STRUCTURE_INFORMATION
+
+ NAME
+ ecs_Tile
+ DESCRIPTION
+ structure for storing information about tiling
+ END_DESCRIPTION
+
+ ATTRIBUTES
+ int x: the number of horizontal tiles
+
+ int y: the number of vertical tiles
+
+ ecs_Region region: the "global" region of the tile
+
+ ecs_Result *callback(); the callback to get the i,j
+ value
+
+ int offValue; the value for a "no data" raster value
+
+ int uninitializedValue the value for an uninitialized
+ matrix value
+
+ ecs_TileBufferLine *linebuffer; a pointer to a linked
+ list of buffered lines
+
+ int index; index of the top line in the buffer (y
+ matrix value)
+
+ int nb_lines the number of lines
+
+ int linelength; the length of a line
+
+ ecs_TileID currentTile; the current tile: -1 if none
+
+ void *priv; private data for tile.
+ END_ATTRIBUTES
+
+ END_STRUCTURE_INFORMATION
+
+ ********************************************************************
+*/
+
+typedef struct ecs_TileStructure {
+ int xtiles; /* the number of horizontal tiles */
+ int ytiles; /* the number of vertical tiles */
+ tile_func *callback; /* the callback to get the i,j value */
+ tile_func *tileDimCallback; /* a callback to get the tile dimensions */
+ int offValue; /* the value for a "no data" raster value */
+ int uninitializedValue; /* the value for an uninitialized matrix value */
+
+ ecs_Region region;
+ int regionwidth;
+ int regionheight;
+
+ ecs_TileBufferLine *linebuffer; /* a pointer to a linked list of buffered lines */
+ int index; /* the index of the top line in the buffer */
+ int nb_lines; /* the number of lines */
+ int linelength; /* the length of a line */
+
+ int width; /* the width of a tile */
+ int height; /* the height of a tile */
+
+ ecs_TileID currentTile; /* the current tile: -1 if none */
+ void *priv;
+} ecs_TileStructure;
+
+/* public commands */
+int ecs_TileInitialize _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, ecs_Region *region, int xtiles, int ytiles, int tilewidth, int tileheight, tile_func *callbackFunc, tile_func *globalRegionFunc));
+int ecs_TileGetLine _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, ecs_Coordinate *start, ecs_Coordinate *end));
+void ecs_TileClearBuffer _ANSI_ARGS_((ecs_TileStructure *t));
+
+/* private commands */
+int ecs_TileFind _ANSI_ARGS_((ecs_Server *s, ecs_TileID *id, ecs_Coordinate *coord));
+int ecs_TileFindBuffer _ANSI_ARGS_((ecs_TileStructure *t, int bufptr, ecs_TileBufferLine **tbuf));
+int ecs_TileGetCurPos _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, int i, int j, int *cat));
+
+
+int ecs_TileFill _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, int index, ecs_TileID *tile_id));
+int ecs_TileAddLine _ANSI_ARGS_((ecs_TileStructure *tile, int length, int index, ecs_TileBufferLine **tbuf));
+int ecs_TileDeleteLine _ANSI_ARGS_((ecs_TileStructure *tile));
+void ecs_TileDeleteAllLines _ANSI_ARGS_((ecs_TileStructure *tile));
+int ecs_GetTileId _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, ecs_Coordinate *coord, ecs_TileID *tile_id));
+int ecs_GetTileIdFromPos _ANSI_ARGS_((ecs_Server *s, ecs_TileStructure *t, int x, int y, ecs_TileID *tile_id));
+int ecs_TileCompare _ANSI_ARGS_((ecs_TileID *id1, ecs_TileID *id2));
+int ecs_SetTile _ANSI_ARGS_((ecs_TileID *destination, ecs_TileID *source));
+
+/* RGB Image functions */
+
+void ecs_GetRGBFromPixel( unsigned int pixel,
+ unsigned char *transparent,
+ unsigned char *r,
+ unsigned char *g,
+ unsigned char *b );
+
+unsigned int ecs_GetPixelFromRGB( int trans, int r, int g, int b );
+
+#endif /* ECS_UTIL */
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/include/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/include/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/include/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,31 @@
+#
+# RPCGEN to generate the OGDI header file.
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+EXTRA_INSTALL_TARGETS = install-includes
+
+include $(TOPDIR)/config/common.mak
+
+all:
+
+rpcgen:
+ -$(RM) -f $@ $@.raw
+ rpcgen -h -C -o $@.raw ecs.x
+ perl ../scripts/h_clean.pl -o $@ $@.raw
+
+clean:
+ @echo Nothing to clean in ogdi/include
+
+install-includes:
+ cp *.h $(INST_INCLUDE)
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,384 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#ifndef _ECS_H_RPCGEN
+#define _ECS_H_RPCGEN
+
+#include <rpc/rpc.h>
+/*
+ * fichier genere par RPCGEN a partir de ecs.x
+ *
+ * Declaration des structures & prototypes de l'extension client/serveur.
+ * Ce fichier est recu par rpcgen et ce dernier generera 4 fichiers pour
+ * pour l'extension client/serveur. Le "header" suivant doit ce retrouver
+ * dans tout les fichiers
+ */
+
+
+/*
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ */
+
+
+#define ECS_SUCCESS 0
+#define ECS_FAILURE 1
+#define ECS_RASTERSIZE 1000
+#define ECS_MTEXT 1024
+#define ECS_TRANSIENT_MIN 1073741824
+#define ECS_TRANSIENT_MAX 1610612735
+
+enum ecs_Family {
+ Area = 1,
+ Line = 2,
+ Point = 3,
+ Matrix = 4,
+ Image = 5,
+ Text = 6,
+ Edge = 7,
+ Face = 8,
+ Node = 9,
+ Ring = 10
+};
+typedef enum ecs_Family ecs_Family;
+
+struct ecs_Region {
+ double north;
+ double south;
+ double east;
+ double west;
+ double ns_res;
+ double ew_res;
+};
+typedef struct ecs_Region ecs_Region;
+
+enum ecs_Resampling {
+ nn = 1
+};
+typedef enum ecs_Resampling ecs_Resampling;
+
+enum ecs_Transformation {
+ projective = 1,
+ affine = 2,
+ similarity = 3
+};
+typedef enum ecs_Transformation ecs_Transformation;
+
+struct ecs_RasterConversion {
+ struct {
+ u_int coef_len;
+ double *coef_val;
+ } coef;
+ int isProjEqual;
+ ecs_Resampling r_method;
+ ecs_Transformation t_method;
+};
+typedef struct ecs_RasterConversion ecs_RasterConversion;
+
+struct ecs_Coordinate {
+ double x;
+ double y;
+};
+typedef struct ecs_Coordinate ecs_Coordinate;
+
+struct ecs_FeatureRing {
+ ecs_Coordinate centroid;
+ struct {
+ u_int c_len;
+ ecs_Coordinate *c_val;
+ } c;
+};
+typedef struct ecs_FeatureRing ecs_FeatureRing;
+
+struct ecs_Area {
+ struct {
+ u_int ring_len;
+ ecs_FeatureRing *ring_val;
+ } ring;
+};
+typedef struct ecs_Area ecs_Area;
+
+struct ecs_Line {
+ struct {
+ u_int c_len;
+ ecs_Coordinate *c_val;
+ } c;
+};
+typedef struct ecs_Line ecs_Line;
+
+struct ecs_Point {
+ ecs_Coordinate c;
+};
+typedef struct ecs_Point ecs_Point;
+
+struct ecs_Matrix {
+ struct {
+ u_int x_len;
+ u_int *x_val;
+ } x;
+};
+typedef struct ecs_Matrix ecs_Matrix;
+
+struct ecs_Image {
+ struct {
+ u_int x_len;
+ u_int *x_val;
+ } x;
+};
+typedef struct ecs_Image ecs_Image;
+
+struct ecs_Text {
+ char *desc;
+ ecs_Coordinate c;
+};
+typedef struct ecs_Text ecs_Text;
+
+struct ecs_Node {
+ int id;
+ int containfaceid;
+ ecs_Coordinate c;
+};
+typedef struct ecs_Node ecs_Node;
+
+struct ecs_Edge {
+ int id;
+ int startnodeid;
+ int endnodeid;
+ int rightfaceid;
+ int leftfaceid;
+ int rightfedgeid;
+ int leftfedgeid;
+ struct {
+ u_int c_len;
+ ecs_Coordinate *c_val;
+ } c;
+};
+typedef struct ecs_Edge ecs_Edge;
+
+enum ecs_TopoLevel {
+ Level012 = 1,
+ Level3 = 2
+};
+typedef enum ecs_TopoLevel ecs_TopoLevel;
+
+struct ecs_Face {
+ int id;
+ struct {
+ u_int edgeid_len;
+ int *edgeid_val;
+ } edgeid;
+};
+typedef struct ecs_Face ecs_Face;
+
+struct ecs_AreaPrim {
+ ecs_TopoLevel level;
+ union {
+ struct {
+ u_int edgeid_len;
+ int *edgeid_val;
+ } edgeid;
+ struct {
+ u_int fedgeid_len;
+ ecs_Face *fedgeid_val;
+ } fedgeid;
+ } ecs_AreaPrim_u;
+};
+typedef struct ecs_AreaPrim ecs_AreaPrim;
+
+struct ecs_Geometry {
+ ecs_Family family;
+ union {
+ ecs_Area area;
+ ecs_Line line;
+ ecs_Point point;
+ ecs_Matrix matrix;
+ ecs_Image image;
+ ecs_Text text;
+ ecs_Node node;
+ ecs_Edge edge;
+ ecs_AreaPrim ring;
+ } ecs_Geometry_u;
+};
+typedef struct ecs_Geometry ecs_Geometry;
+
+struct ecs_Object {
+ char *Id;
+ ecs_Geometry geom;
+ char *attr;
+ double xmin;
+ double ymin;
+ double xmax;
+ double ymax;
+};
+typedef struct ecs_Object ecs_Object;
+
+enum ecs_AttributeFormat {
+ Char = 1,
+ Varchar = 2,
+ Longvarchar = 3,
+ Decimal = 4,
+ Numeric = 5,
+ Smallint = 6,
+ Integer = 7,
+ Real = 8,
+ Float = 9,
+ Double = 10
+};
+typedef enum ecs_AttributeFormat ecs_AttributeFormat;
+
+struct ecs_ObjAttribute {
+ char *name;
+ ecs_AttributeFormat type;
+ int lenght;
+ int precision;
+ int nullable;
+};
+typedef struct ecs_ObjAttribute ecs_ObjAttribute;
+
+struct ecs_ObjAttributeFormat {
+ struct {
+ u_int oa_len;
+ ecs_ObjAttribute *oa_val;
+ } oa;
+};
+typedef struct ecs_ObjAttributeFormat ecs_ObjAttributeFormat;
+
+struct ecs_Category {
+ long no_cat;
+ u_int r;
+ u_int g;
+ u_int b;
+ char *label;
+ u_long qty;
+};
+typedef struct ecs_Category ecs_Category;
+
+struct ecs_RasterInfo {
+ long mincat;
+ long maxcat;
+ int width;
+ int height;
+ struct {
+ u_int cat_len;
+ ecs_Category *cat_val;
+ } cat;
+};
+typedef struct ecs_RasterInfo ecs_RasterInfo;
+
+enum ecs_ResultType {
+ Object = 1,
+ GeoRegion = 2,
+ objAttributeFormat = 3,
+ RasterInfo = 4,
+ AText = 5
+};
+typedef enum ecs_ResultType ecs_ResultType;
+
+struct ecs_ResultUnion {
+ ecs_ResultType type;
+ union {
+ ecs_Object dob;
+ ecs_Region gr;
+ ecs_ObjAttributeFormat oaf;
+ ecs_RasterInfo ri;
+ char *s;
+ } ecs_ResultUnion_u;
+};
+typedef struct ecs_ResultUnion ecs_ResultUnion;
+
+struct ecs_Result {
+ int error;
+ char *message;
+ ecs_ResultUnion res;
+};
+typedef struct ecs_Result ecs_Result;
+
+struct ecs_LayerSelection {
+ char *Select;
+ ecs_Family F;
+};
+typedef struct ecs_LayerSelection ecs_LayerSelection;
+
+#include <ecs_util.h> /* Outils pour l'aide a ecs */
+
+
+#define ECSPROG ((unsigned long)(0x20000001))
+#define ECSVERS ((unsigned long)(1))
+#define CREATESERVER ((unsigned long)(1))
+extern ecs_Result * createserver_1();
+#define DESTROYSERVER ((unsigned long)(2))
+extern ecs_Result * destroyserver_1();
+#define SELECTLAYER ((unsigned long)(3))
+extern ecs_Result * selectlayer_1();
+#define RELEASELAYER ((unsigned long)(4))
+extern ecs_Result * releaselayer_1();
+#define SELECTREGION ((unsigned long)(5))
+extern ecs_Result * selectregion_1();
+#define GETDICTIONNARY ((unsigned long)(6))
+extern ecs_Result * getdictionnary_1();
+#define GETATTRIBUTEFORMAT ((unsigned long)(7))
+extern ecs_Result * getattributeformat_1();
+#define GETNEXTOBJECT ((unsigned long)(8))
+extern ecs_Result * getnextobject_1();
+#define GETRASTERINFO ((unsigned long)(9))
+extern ecs_Result * getrasterinfo_1();
+#define GETOBJECT ((unsigned long)(10))
+extern ecs_Result * getobject_1();
+#define GETOBJECTIDFROMCOORD ((unsigned long)(11))
+extern ecs_Result * getobjectidfromcoord_1();
+#define UPDATEDICTIONARY ((unsigned long)(12))
+extern ecs_Result * updatedictionary_1();
+#define GETSERVERPROJECTION ((unsigned long)(13))
+extern ecs_Result * getserverprojection_1();
+#define GETGLOBALBOUND ((unsigned long)(14))
+extern ecs_Result * getglobalbound_1();
+#define SETSERVERLANGUAGE ((unsigned long)(15))
+extern ecs_Result * setserverlanguage_1();
+#define SETSERVERPROJECTION ((unsigned long)(16))
+extern ecs_Result * setserverprojection_1();
+#define SETRASTERCONVERSION ((unsigned long)(17))
+extern ecs_Result * setrasterconversion_1();
+extern int ecsprog_1_freeresult();
+
+/* the xdr functions */
+extern bool_t xdr_ecs_Family();
+extern bool_t xdr_ecs_Region();
+extern bool_t xdr_ecs_Resampling();
+extern bool_t xdr_ecs_Transformation();
+extern bool_t xdr_ecs_RasterConversion();
+extern bool_t xdr_ecs_Coordinate();
+extern bool_t xdr_ecs_FeatureRing();
+extern bool_t xdr_ecs_Area();
+extern bool_t xdr_ecs_Line();
+extern bool_t xdr_ecs_Point();
+extern bool_t xdr_ecs_Matrix();
+extern bool_t xdr_ecs_Image();
+extern bool_t xdr_ecs_Text();
+extern bool_t xdr_ecs_Node();
+extern bool_t xdr_ecs_Edge();
+extern bool_t xdr_ecs_TopoLevel();
+extern bool_t xdr_ecs_Face();
+extern bool_t xdr_ecs_AreaPrim();
+extern bool_t xdr_ecs_Geometry();
+extern bool_t xdr_ecs_Object();
+extern bool_t xdr_ecs_AttributeFormat();
+extern bool_t xdr_ecs_ObjAttribute();
+extern bool_t xdr_ecs_ObjAttributeFormat();
+extern bool_t xdr_ecs_Category();
+extern bool_t xdr_ecs_RasterInfo();
+extern bool_t xdr_ecs_ResultType();
+extern bool_t xdr_ecs_ResultUnion();
+extern bool_t xdr_ecs_Result();
+extern bool_t xdr_ecs_LayerSelection();
+
+#endif /* !_ECS_H_RPCGEN */
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_clnt.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_clnt.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_clnt.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,298 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "ecs.h"
+
+/* Default timeout can be changed using clnt_control() */
+static struct timeval TIMEOUT = { 25, 0 };
+
+ecs_Result *
+createserver_1(argp, clnt)
+ char **argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, CREATESERVER,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+destroyserver_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, DESTROYSERVER,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+selectlayer_1(argp, clnt)
+ ecs_LayerSelection *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SELECTLAYER,
+ (xdrproc_t) xdr_ecs_LayerSelection, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+releaselayer_1(argp, clnt)
+ ecs_LayerSelection *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, RELEASELAYER,
+ (xdrproc_t) xdr_ecs_LayerSelection, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+selectregion_1(argp, clnt)
+ ecs_Region *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SELECTREGION,
+ (xdrproc_t) xdr_ecs_Region, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getdictionnary_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETDICTIONNARY,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getattributeformat_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETATTRIBUTEFORMAT,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getnextobject_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETNEXTOBJECT,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getrasterinfo_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETRASTERINFO,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getobject_1(argp, clnt)
+ char **argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETOBJECT,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getobjectidfromcoord_1(argp, clnt)
+ ecs_Coordinate *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETOBJECTIDFROMCOORD,
+ (xdrproc_t) xdr_ecs_Coordinate, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+updatedictionary_1(argp, clnt)
+ char **argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, UPDATEDICTIONARY,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getserverprojection_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETSERVERPROJECTION,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+getglobalbound_1(argp, clnt)
+ void *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, GETGLOBALBOUND,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setserverlanguage_1(argp, clnt)
+ u_int *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETSERVERLANGUAGE,
+ (xdrproc_t) xdr_u_int, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setserverprojection_1(argp, clnt)
+ char **argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETSERVERPROJECTION,
+ (xdrproc_t) xdr_wrapstring, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+ecs_Result *
+setrasterconversion_1(argp, clnt)
+ ecs_RasterConversion *argp;
+ CLIENT *clnt;
+{
+ static ecs_Result clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof (clnt_res));
+ if (clnt_call(clnt, SETRASTERCONVERSION,
+ (xdrproc_t) xdr_ecs_RasterConversion, (caddr_t) argp,
+ (xdrproc_t) xdr_ecs_Result, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_svc.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_svc.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_svc.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,315 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "ecs.h"
+#include <stdio.h>
+#include <stdlib.h> /* getenv, exit */
+#include <signal.h>
+#include <sys/types.h>
+#include <memory.h>
+#include <stropts.h>
+#include <netconfig.h>
+#include <sys/resource.h> /* rlimit */
+#include <syslog.h>
+
+#ifdef DEBUG
+#define RPC_SVC_FG
+#endif
+
+#define _RPCSVC_CLOSEDOWN 120
+#define main dummy
+static int _rpcpmstart; /* Started by a port monitor ? */
+ /* States a server can be in wrt request */
+
+#define _IDLE 0
+#define _SERVED 1
+#define _SERVING 2
+
+static int _rpcsvcstate = _IDLE; /* Set when a request is serviced */
+
+static
+void _msgout(msg)
+ char *msg;
+{
+#ifdef RPC_SVC_FG
+ if (_rpcpmstart)
+ syslog(LOG_ERR, msg);
+ else
+ (void) fprintf(stderr, "%s\n", msg);
+#else
+ syslog(LOG_ERR, msg);
+#endif
+}
+
+static void
+closedown(sig)
+ int sig;
+{
+ if (_rpcsvcstate == _IDLE) {
+ extern fd_set svc_fdset;
+ static int size;
+ int i, openfd;
+ struct t_info tinfo;
+
+ if (!t_getinfo(0, &tinfo) && (tinfo.servtype == T_CLTS))
+ exit(0);
+ if (size == 0) {
+ struct rlimit rl;
+
+ rl.rlim_max = 0;
+ getrlimit(RLIMIT_NOFILE, &rl);
+ if ((size = rl.rlim_max) == 0) {
+ return;
+ }
+ }
+ for (i = 0, openfd = 0; i < size && openfd < 2; i++)
+ if (FD_ISSET(i, &svc_fdset))
+ openfd++;
+ if (openfd <= 1)
+ exit(0);
+ }
+ if (_rpcsvcstate == _SERVED)
+ _rpcsvcstate = _IDLE;
+
+ (void) signal(SIGALRM, (void(*)()) closedown);
+ (void) alarm(_RPCSVC_CLOSEDOWN/2);
+}
+
+void
+ecsprog_1(rqstp, transp)
+ struct svc_req *rqstp;
+ register SVCXPRT *transp;
+{
+ union {
+ char *createserver_1_arg;
+ ecs_LayerSelection selectlayer_1_arg;
+ ecs_LayerSelection releaselayer_1_arg;
+ ecs_Region selectregion_1_arg;
+ char *getobject_1_arg;
+ ecs_Coordinate getobjectidfromcoord_1_arg;
+ char *updatedictionary_1_arg;
+ u_int setserverlanguage_1_arg;
+ char *setserverprojection_1_arg;
+ ecs_RasterConversion setrasterconversion_1_arg;
+ } argument;
+ char *result;
+ bool_t (*xdr_argument)(), (*xdr_result)();
+ char *(*local)();
+
+ _rpcsvcstate = _SERVING;
+ switch (rqstp->rq_proc) {
+ case NULLPROC:
+ (void) svc_sendreply(transp, xdr_void,
+ (char *)NULL);
+ _rpcsvcstate = _SERVED;
+ return;
+
+ case CREATESERVER:
+ xdr_argument = xdr_wrapstring;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) createserver_1;
+ break;
+
+ case DESTROYSERVER:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) destroyserver_1;
+ break;
+
+ case SELECTLAYER:
+ xdr_argument = xdr_ecs_LayerSelection;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) selectlayer_1;
+ break;
+
+ case RELEASELAYER:
+ xdr_argument = xdr_ecs_LayerSelection;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) releaselayer_1;
+ break;
+
+ case SELECTREGION:
+ xdr_argument = xdr_ecs_Region;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) selectregion_1;
+ break;
+
+ case GETDICTIONNARY:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getdictionnary_1;
+ break;
+
+ case GETATTRIBUTEFORMAT:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getattributeformat_1;
+ break;
+
+ case GETNEXTOBJECT:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getnextobject_1;
+ break;
+
+ case GETRASTERINFO:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getrasterinfo_1;
+ break;
+
+ case GETOBJECT:
+ xdr_argument = xdr_wrapstring;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getobject_1;
+ break;
+
+ case GETOBJECTIDFROMCOORD:
+ xdr_argument = xdr_ecs_Coordinate;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getobjectidfromcoord_1;
+ break;
+
+ case UPDATEDICTIONARY:
+ xdr_argument = xdr_wrapstring;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) updatedictionary_1;
+ break;
+
+ case GETSERVERPROJECTION:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getserverprojection_1;
+ break;
+
+ case GETGLOBALBOUND:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) getglobalbound_1;
+ break;
+
+ case SETSERVERLANGUAGE:
+ xdr_argument = xdr_u_int;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) setserverlanguage_1;
+ break;
+
+ case SETSERVERPROJECTION:
+ xdr_argument = xdr_wrapstring;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) setserverprojection_1;
+ break;
+
+ case SETRASTERCONVERSION:
+ xdr_argument = xdr_ecs_RasterConversion;
+ xdr_result = xdr_ecs_Result;
+ local = (char *(*)()) setrasterconversion_1;
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ _rpcsvcstate = _SERVED;
+ return;
+ }
+ (void) memset((char *)&argument, 0, sizeof (argument));
+ if (!svc_getargs(transp, xdr_argument, &argument)) {
+ svcerr_decode(transp);
+ _rpcsvcstate = _SERVED;
+ return;
+ }
+ result = (*local)(&argument, rqstp);
+ if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
+ svcerr_systemerr(transp);
+ }
+ if (!svc_freeargs(transp, xdr_argument, &argument)) {
+ _msgout("unable to free arguments");
+ exit(1);
+ }
+ _rpcsvcstate = _SERVED;
+ return;
+}
+
+main()
+{
+ pid_t pid;
+ int i;
+ char mname[FMNAMESZ + 1];
+
+ if (!ioctl(0, I_LOOK, mname) &&
+ (!strcmp(mname, "sockmod") || !strcmp(mname, "timod"))) {
+ char *netid;
+ struct netconfig *nconf = NULL;
+ SVCXPRT *transp;
+ int pmclose;
+
+ _rpcpmstart = 1;
+ openlog("ecs", LOG_PID, LOG_DAEMON);
+
+ if ((netid = getenv("NLSPROVIDER")) == NULL) {
+ /* started from inetd */
+ pmclose = 1;
+ } else {
+ if ((nconf = getnetconfigent(netid)) == NULL)
+ _msgout("cannot get transport info");
+
+ pmclose = (t_getstate(0) != T_DATAXFER);
+ }
+ if (strcmp(mname, "sockmod") == 0) {
+ if (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, "timod")) {
+ _msgout("could not get the right module");
+ exit(1);
+ }
+ }
+ if ((transp = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {
+ _msgout("cannot create server handle");
+ exit(1);
+ }
+ if (nconf)
+ freenetconfigent(nconf);
+ if (!svc_reg(transp, ECSPROG, ECSVERS, ecsprog_1, 0)) {
+ _msgout("unable to register (ECSPROG, ECSVERS).");
+ exit(1);
+ }
+ if (pmclose) {
+ (void) signal(SIGALRM, (void(*)()) closedown);
+ (void) alarm(_RPCSVC_CLOSEDOWN/2);
+ }
+ svc_run();
+ exit(1);
+ /* NOTREACHED */
+ } else {
+#ifndef RPC_SVC_FG
+ int size;
+ struct rlimit rl;
+ pid = fork();
+ if (pid < 0) {
+ perror("cannot fork");
+ exit(1);
+ }
+ if (pid)
+ exit(0);
+ rl.rlim_max = 0;
+ getrlimit(RLIMIT_NOFILE, &rl);
+ if ((size = rl.rlim_max) == 0)
+ exit(1);
+ for (i = 0; i < size; i++)
+ (void) close(i);
+ i = open("/dev/console", 2);
+ (void) dup2(i, 1);
+ (void) dup2(i, 2);
+ setsid();
+ openlog("ecs", LOG_PID, LOG_DAEMON);
+#endif
+ }
+ if (!svc_create(ecsprog_1, ECSPROG, ECSVERS, "netpath")) {
+ _msgout("unable to create (ECSPROG, ECSVERS) for netpath.");
+ exit(1);
+ }
+
+ svc_run();
+ _msgout("svc_run returned");
+ exit(1);
+ /* NOTREACHED */
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_util.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_util.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_util.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,735 @@
+#ifndef ECS_UTIL
+#define ECS_UTIL 1
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rpc/rpc.h>
+#include <math.h>
+#include <memory.h>
+#include <ctype.h>
+
+#ifdef _WINDOWS
+#include <windows.h>
+#include <winsock.h>
+#else
+#include <dlfcn.h>
+#endif
+
+#include "projects.h"
+#include "ecs.h"
+
+#ifdef _SCO
+#include <sys/fs/nfs/time.h>
+#endif
+
+/***********************************************************************/
+
+/* Global definitions */
+
+#undef _ANSI_ARGS_
+#undef CONST
+#if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus)
+# define _USING_PROTOTYPES_ 1
+# define _ANSI_ARGS_(x) x
+# define CONST const
+# ifdef __cplusplus
+# define VARARGS(first) (first, ...)
+# else
+# define VARARGS(first) ()
+# endif
+#else
+# define _ANSI_ARGS_(x) ()
+# define CONST
+#endif
+
+#ifdef __cplusplus
+# define EXTERN extern "C"
+#else
+# define EXTERN extern
+#endif
+
+/*
+ * Macro to use instead of "void" for arguments that must have
+ * type "void *" in ANSI C; maps them to type "char *" in
+ * non-ANSI systems.
+ */
+
+#ifndef VOID
+# ifdef __STDC__
+# define VOID void
+# else
+# define VOID char
+# endif
+#endif
+
+/*
+ * Miscellaneous declarations (to allow Tcl to be used stand-alone,
+ * without the rest of Sprite).
+ */
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define PROJ_UNKNOWN "unknown"
+#define PROJ_LONGLAT "+proj=longlat"
+
+#define ECSGETJ(s,i1,j1) (int)(((s->rasterconversion.coef.coef_val[0]*j1 + s->rasterconversion.coef.coef_val[1]*i1 + s->rasterconversion.coef.coef_val[6]) / (s->rasterconversion.coef.coef_val[4]*j1 + s->rasterconversion.coef.coef_val[5]*i1 + 1)) + 0.5)
+#define ECSGETI(s,i1,j1) (int)(((s->rasterconversion.coef.coef_val[2]*j1 + s->rasterconversion.coef.coef_val[3]*i1 + s->rasterconversion.coef.coef_val[7]) / (s->rasterconversion.coef.coef_val[4]*j1 + s->rasterconversion.coef.coef_val[5]*i1 + 1)) + 0.5)
+
+#ifndef PI
+#define PI 3.14159265359
+#endif
+
+/***********************************************************************/
+
+/* server.c declarations */
+
+#define ECSMAXLAYER 64
+
+typedef ecs_Result *dynfunc();
+
+typedef struct {
+ ecs_LayerSelection sel;
+ int index;
+ int nbfeature;
+ void *priv;
+} ecs_Layer;
+
+typedef struct {
+ /* Specific information for dynamic part of the server */
+
+ void *priv;
+
+ ecs_Layer layer[ECSMAXLAYER];
+ int nblayer;
+ int currentLayer;
+
+ /* dynamic library handle */
+
+ void *handle;
+
+ /* Regions of the server */
+
+ ecs_Region currentRegion;
+ ecs_Region globalRegion;
+
+ /* Server projection */
+
+ char *projection;
+
+ /* Extracted information from URL */
+
+ char *hostname;
+ char *server_type;
+ char *pathname;
+
+ /* Indicate if the server is a remote server or not */
+
+ int isRemote;
+
+ /* RasterConversion structure */
+
+ ecs_RasterConversion rasterconversion;
+
+ /* Structure returned to client */
+
+ ecs_Result result;
+
+ /* pointers to functions */
+
+ dynfunc *createserver;
+ dynfunc *destroyserver;
+ dynfunc *selectlayer;
+ dynfunc *releaselayer;
+
+ dynfunc *closelayer;
+
+ dynfunc *selectregion;
+ dynfunc *getdictionary;
+ dynfunc *getattrformat;
+ dynfunc *getnextobject;
+ dynfunc *getrasterinfo;
+ dynfunc *getobject;
+ dynfunc *getobjectid;
+ dynfunc *updatedictionary;
+ dynfunc *getserverprojection;
+ dynfunc *getglobalbound;
+ dynfunc *setserverlanguage;
+ dynfunc *setserverprojection;
+ dynfunc *setrasterconversion;
+} ecs_Server;
+
+
+ecs_Result *svr_CreateServer _ANSI_ARGS_((ecs_Server *s, char *Request, int isLocal));
+ecs_Result *svr_DestroyServer _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_SelectLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *ls));
+ecs_Result *svr_ReleaseLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *ls));
+void svr_BroadCloseLayers _ANSI_ARGS_((ecs_Server *s));
+void svr_CloseLayer _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_SelectRegion _ANSI_ARGS_((ecs_Server *s, ecs_Region *gr));
+ecs_Result *svr_GetDictionary _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetAttributesFormat _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetNextObject _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetRasterInfo _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetObject _ANSI_ARGS_((ecs_Server *s, char *Id));
+ecs_Result *svr_GetObjectIdFromCoord _ANSI_ARGS_((ecs_Server *s, ecs_Coordinate *coord));
+ecs_Result *svr_UpdateDictionary _ANSI_ARGS_((ecs_Server *s, char *info));
+ecs_Result *svr_GetServerProjection _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_GetGlobalBound _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *svr_SetServerLanguage _ANSI_ARGS_((ecs_Server *s, u_int language));
+ecs_Result *svr_SetServerProjection _ANSI_ARGS_((ecs_Server *s, char *projection));
+ecs_Result *svr_SetRasterConversion _ANSI_ARGS_((ecs_Server *s,
+ ecs_RasterConversion *rc));
+
+/* These functions will be called by dynamic servers */
+
+int ecs_SetLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *sel));
+int ecs_GetLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *sel));
+void ecs_FreeLayer _ANSI_ARGS_((ecs_Server *s, int layer));
+int ecs_RemoveDir _ANSI_ARGS_((char *path));
+
+/***********************************************************************/
+
+/* ecs_dyna.c declarations */
+
+void *ecs_OpenDynamicLib _ANSI_ARGS_((char *libname));
+void *ecs_GetDynamicLibFunction _ANSI_ARGS_((void *handle,char *functionname));
+void ecs_CloseDynamicLib _ANSI_ARGS_((void *handle));
+
+/***********************************************************************/
+
+/* ecsregex.c declarations */
+
+#define NSUBEXP 50
+typedef struct ecs_regexp {
+ char *startp[NSUBEXP];
+ char *endp[NSUBEXP];
+ char regstart; /* Internal use only. */
+ char reganch; /* Internal use only. */
+ char *regmust; /* Internal use only. */
+ int regmlen; /* Internal use only. */
+ char program[1]; /* Unwarranted chumminess with compiler. */
+} ecs_regexp;
+
+ecs_regexp *EcsRegComp _ANSI_ARGS_((char *exp));
+int EcsRegExec _ANSI_ARGS_((ecs_regexp *prog, char *string, char *start));
+void EcsRegError _ANSI_ARGS_((char *msg));
+char *EcsGetRegError _ANSI_ARGS_((void));
+
+/***********************************************************************/
+
+/* ecsdist.c declarations */
+
+
+double ecs_DistanceObject _ANSI_ARGS_((ecs_Object *obj, double X, double Y));
+double ecs_DistanceMBR _ANSI_ARGS_((double xl, double yl, double xu, double yu, double dx, double dy));
+double ecs_DistanceSegment _ANSI_ARGS_((double xl, double yl, double xu, double yu, double dx, double dy));
+
+/***********************************************************************/
+
+/* ecsassoc.c declarations */
+
+/* WARNING: These define do more than one operation.
+ Please, don't consider these as functions.
+ */
+
+
+/*
+ ----------------------------------------------------------------
+ ECSRESULTTYPE: This macro indicate the object type of ecs_Result
+ ----------------------------------------------------------------
+ */
+
+#define ECSRESULTTYPE(result) result->res.type
+
+/*
+ ----------------------------------------------------------------
+ ECSRESULTTYPE: This macro access the union in ecs_Result and
+ facilitate ecs_Result structures access.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRESULT(result) result->res.ecs_ResultUnion_u
+
+/*
+ ----------------------------------------------------------------
+ ECSRESULTTYPE: This macro indicate the geographical object type
+ contain in ecs_Result
+ ----------------------------------------------------------------
+ */
+
+#define ECSGEOMTYPE(result) result->res.ecs_ResultUnion_u.dob.geom.family
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOM: This macro access the union contain in the geographical
+ object in ecs_Result.
+ ----------------------------------------------------------------
+ */
+
+#define ECSGEOM(result) result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u
+
+/*
+ ----------------------------------------------------------------
+ ECSAREARING: This macro access the area ring in the geographic
+ object of type Area
+ ----------------------------------------------------------------
+ */
+
+#define ECSAREARING(result,pos) result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.area.ring.ring_val[pos]
+
+/*
+ ----------------------------------------------------------------
+ ECSERROR: Indicate if ecs_Result contain an error code
+ ----------------------------------------------------------------
+ */
+
+#define ECSERROR(r) (r->error != 0)
+
+/*
+ ----------------------------------------------------------------
+ ECSSUCCESS: Indicate if ecs_Result contain an success code
+ ----------------------------------------------------------------
+ */
+
+#define ECSSUCCESS(r) (r->error == 0)
+
+/*
+ ----------------------------------------------------------------
+ ECSEOF: Indicate if ecs_Result contain EOF message. Mainly
+ use in cln_GetNextObject function.
+ ----------------------------------------------------------------
+ */
+
+#define ECSEOF(r) (r->error == 2)
+
+/*
+ ----------------------------------------------------------------
+ ECSPROJ: Indicate if ecs_Result contain PROJ error message. Mainly
+ use in cln_GetNextObject function.
+ ----------------------------------------------------------------
+ */
+
+#define ECSPROJ(r) (r->error == 3)
+
+/*
+ ----------------------------------------------------------------
+ ECSMESSAGE: Return the error message contain in ecs_Result (an
+ string).
+ ----------------------------------------------------------------
+ */
+
+#define ECSMESSAGE(r) r->message
+
+/*
+ ----------------------------------------------------------------
+ ECSREGION: Return the geographical region contain in ecs_Result
+ (if it's the case). The structure returned is a ecs_Region.
+ ----------------------------------------------------------------
+ */
+
+#define ECSREGION(r) ECSRESULT(r).gr
+
+/*
+ ----------------------------------------------------------------
+ ECSTEXT: Return the text string contain in ecs_Result (if
+ it's the case). The structure returned is a string.
+ ----------------------------------------------------------------
+ */
+
+#define ECSTEXT(r) ECSRESULT(r).s
+
+/*
+ ----------------------------------------------------------------
+ ECSRASTERINFO: Return the raster information contain in ecs_Result
+ (if it's the case). The structure return is a ecs_RasterInfo.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRASTERINFO(r) ECSRESULT(r).ri
+
+/*
+ ----------------------------------------------------------------
+ ECSRASTERINFONB: Return the number of categories in the
+ ecs_RasterInfo structure contain in ecs_Result.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRASTERINFONB(r) ECSRASTERINFO(r).cat.cat_len
+
+/*
+ ----------------------------------------------------------------
+ ECSRASTERINFOCAT: Return the category number "c" contain in
+ ecs_RasterInfo in ecs_Result. The structure returned is a
+ ecs_Category.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRASTERINFOCAT(r,c) ECSRASTERINFO(r).cat.cat_val[c]
+
+/*
+ ----------------------------------------------------------------
+ ECSOBJECT: Return the geographic object contain in ecs_Result
+ (if it's the case). The structure return is a ecs_Object.
+ ----------------------------------------------------------------
+ */
+
+#define ECSOBJECT(r) ECSRESULT(r).dob
+
+/*
+ ----------------------------------------------------------------
+ ECSOBJECTID: Return the "Id" attribute contain the ecs_Object structure
+ contain in ecs_Result.
+ ----------------------------------------------------------------
+ */
+
+#define ECSOBJECTID(r) ECSOBJECT(r).Id
+
+/*
+ ----------------------------------------------------------------
+ ECSOBJECTATTR: Return the "attr" attribute contain the ecs_Object structure
+ contain in ecs_Result.
+ ----------------------------------------------------------------
+ */
+
+#define ECSOBJECTATTR(r) ECSOBJECT(r).attr
+
+/*
+ ----------------------------------------------------------------
+ ECSRASTER: Return the raster line table contain in ecs_Object.
+ ----------------------------------------------------------------
+ */
+
+#define ECSRASTER(r) ECSOBJECT(r).geom.ecs_Geometry_u.matrix.x.x_val
+
+/*
+ ----------------------------------------------------------------
+ ECS_SETGEOMBOUNDINGBOX: This macro will put in the geographical
+ object contain in "result" the bounding rectangle (lxmin, lymin,
+ lxmax, lymax).
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMBOUNDINGBOX(result,lxmin,lymin,lxmax,lymax) { \
+ if (result->res.type==Object) { \
+ result->res.ecs_ResultUnion_u.dob.xmin=lxmin; \
+ result->res.ecs_ResultUnion_u.dob.ymin=lymin; \
+ result->res.ecs_ResultUnion_u.dob.xmax=lxmax; \
+ result->res.ecs_ResultUnion_u.dob.ymax=lymax; \
+ } \
+}
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOMLINECOORD: This macro put a point (lx,ly) at the position
+ "position" in a line geographical object. To entirely set the
+ line object, ecs_SetGeomLine must be call first and for each point,
+ ECS_SETGEOMLINECOORD must be call.
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMLINECOORD(result,position,lx,ly) \
+result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.line.c.c_val[position].x = lx; \
+result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.line.c.c_val[position].y = ly;
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOMAREACOORD: This macro put a point (lx,ly) at the position
+ "position" of the ring "ringpos" in a area geographical object. To
+ entirely set the area object, ecs_SetGeomArea must be call first
+ and for each ring, ecs_SetGeomAreaRing must be call. In each of
+ this ring, ECS_SETGEOMAREACOORD must be call define the polygons
+ points.
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMAREACOORD(result,ringpos,position,lx,ly) \
+result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.area.ring.ring_val[ringpos].c.c_val[position].x = lx; \
+result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.area.ring.ring_val[ringpos].c.c_val[position].y = ly;
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOMMATRIXCOORD: This macro put a value at the position
+ "position" in a matrix geographical object. To entirely set the
+ matrix object, ecs_SetGeomMatrix must be call first and for each
+ column, ECS_SETGEOMMATRIXCOORD must be call.
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMMATRIXVALUE(result,lpos,lval) \
+result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.matrix.x.x_val[lpos] = lval
+
+/*
+ ----------------------------------------------------------------
+ ECSGEOMIMAGECOORD: This macro put a value at the position
+ "position" in a image geographical object. To entirely set the
+ image object, ecs_SetGeomImage must be call first and for each
+ column, ECS_SETGEOMIMAGECOORD must be call.
+ ----------------------------------------------------------------
+ */
+
+#define ECS_SETGEOMIMAGEVALUE(result,lpos,lval) \
+result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.image.x.x_val[lpos] = lval
+
+/********************************/
+
+int ecs_SetError _ANSI_ARGS_((ecs_Result *r,
+ int errorcode, char *error_message));
+int ecs_SetSuccess _ANSI_ARGS_((ecs_Result *r));
+int ecs_AdjustResult _ANSI_ARGS_((ecs_Result *r));
+int ecs_SetGeoRegion _ANSI_ARGS_((ecs_Result *r,
+ double north, double south, double east,
+ double west, double nsres, double ewres));
+int ecs_SetText _ANSI_ARGS_((ecs_Result *r,char *text));
+int ecs_AddText _ANSI_ARGS_((ecs_Result *r,char *text));
+int ecs_SetRasterInfo _ANSI_ARGS_((ecs_Result *r, int width, int height));
+int ecs_AddRasterInfoCategory _ANSI_ARGS_((ecs_Result *r, long no_cat,
+ unsigned int red,
+ unsigned int green,
+ unsigned int blue, char *label,
+ unsigned long qty));
+int ecs_SetObjAttributeFormat _ANSI_ARGS_((ecs_Result *r));
+int ecs_AddAttributeFormat _ANSI_ARGS_((ecs_Result *r, char *name,
+ ecs_AttributeFormat type,
+ int lenght, int precision,
+ int nullable));
+int ecs_SetGeomPoint _ANSI_ARGS_((ecs_Result *r, double x, double y));
+int ecs_SetGeomText _ANSI_ARGS_((ecs_Result *r, double x,
+ double y, char *desc));
+int ecs_SetGeomLine _ANSI_ARGS_((ecs_Result *r, unsigned int lenght));
+int ecs_SetGeomArea _ANSI_ARGS_((ecs_Result *r, unsigned int lenght));
+int ecs_SetGeomAreaRing _ANSI_ARGS_((ecs_Result *r, int position,
+ unsigned int length,
+ double centroid_x, double centroid_y));
+int ecs_SetGeomMatrix _ANSI_ARGS_((ecs_Result *r, int size));
+int ecs_SetGeomMatrixWithArray _ANSI_ARGS_((ecs_Result *r, int size, unsigned int *array));
+int ecs_SetGeomImage _ANSI_ARGS_((ecs_Result *r, int size));
+int ecs_SetGeomImageWithArray _ANSI_ARGS_((ecs_Result *r, int size, unsigned int *array));
+int ecs_SetObjectId _ANSI_ARGS_((ecs_Result *r,char *id));
+int ecs_SetObjectAttr _ANSI_ARGS_((ecs_Result *r,char *attr));
+int ecs_CleanUp _ANSI_ARGS_((ecs_Result *r));
+int ecs_CleanUpObject _ANSI_ARGS_((ecs_Result *r));
+int ecs_ResultInit _ANSI_ARGS_((ecs_Result *r));
+int ecs_CalcObjectMBR _ANSI_ARGS_((ecs_Server *r, ecs_Result *e));
+
+/***********************************************************************/
+
+/* ecs_split.c declarations */
+
+void ecs_freeSplitURL _ANSI_ARGS_((char **type,char **machine,char **path));
+int ecs_GetRegex _ANSI_ARGS_((ecs_regexp *reg,int index,char **chaine));
+int ecs_SplitURL _ANSI_ARGS_((char *url,char **machine,char **server,char **path));
+
+
+/***********************************************************************/
+
+/* ecs_list.c declarations */
+
+char ecs_Backslash _ANSI_ARGS_((char *src, int *readPtr));
+int ecs_FindElement _ANSI_ARGS_((register char *list,char **elementPtr, char **nextPtr, int *sizePtr, int *bracePtr));
+void ecs_CopyAndCollapse _ANSI_ARGS_((int count,register char *src,register char *dst));
+int ecs_SplitList _ANSI_ARGS_((char *list,int *argcPtr,char ***argvPtr));
+
+/***********************************************************************/
+
+
+
+/* dynamic library server declarations */
+
+ecs_Result *dyn_CreateServer _ANSI_ARGS_((ecs_Server *s, char *Request));
+ecs_Result *dyn_DestroyServer _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_SelectLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *ls));
+ecs_Result *dyn_ReleaseLayer _ANSI_ARGS_((ecs_Server *s, ecs_LayerSelection *ls));
+ecs_Result *dyn_SelectRegion _ANSI_ARGS_((ecs_Server *s, ecs_Region *gr));
+ecs_Result *dyn_GetDictionary _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetAttributesFormat _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetNextObject _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetRasterInfo _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetObject _ANSI_ARGS_((ecs_Server *s, char *Id));
+ecs_Result *dyn_GetObjectIdFromCoord _ANSI_ARGS_((ecs_Server *s, ecs_Coordinate *coord));
+ecs_Result *dyn_UpdateDictionary _ANSI_ARGS_((ecs_Server *s, char *info));
+ecs_Result *dyn_GetServerProjection _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_GetGlobalBound _ANSI_ARGS_((ecs_Server *s));
+ecs_Result *dyn_SetServerLanguage _ANSI_ARGS_((ecs_Server *s, u_int language));
+ecs_Result *dyn_SetServerProjection _ANSI_ARGS_((ecs_Server *s, char *projection));
+ecs_Result *dyn_SetRasterConversion _ANSI_ARGS_((ecs_Server *s,
+ ecs_RasterConversion *rc));
+
+
+/***********************************************************************/
+
+
+/*
+ * client.h --
+ *
+ * Control dispatch of locals client. Also control cache management and
+ * projection changes.
+ *
+ * Copyright (c) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc.
+ * Il est strictement interdit de publier ou de devoiler le contenu de ce
+ * programme sans avoir prealablement obtenu la permission de L.A.S. Inc.
+ */
+
+#define CACHEINITSIZE 100
+#define COMPARETOLERANCE 0.005 /* For projection conversion, tolerance factor during projection compare */
+
+#define ECS_TTOS 0 /* define the conversion direction (target to source) or (source to target) */
+#define ECS_STOT 1
+
+
+typedef struct ecs_CtlPoint {
+ double e1,n1,e2,n2;
+ double errorx,errory;
+} ecs_CtlPoint;
+
+
+typedef struct ecs_CtlPoints {
+ int nbpts;
+ ecs_CtlPoint *pts;
+} ecs_CtlPoints;
+
+
+typedef struct ecs_Cache {
+ ecs_LayerSelection coverage; /* coverage descriptor */
+
+ int size; /* logical cache size */
+ int currentpos; /* current position in cache for getnextobject */
+ int allocatedSize; /* physical size of cache */
+ ecs_Result **o; /* the cache itself */
+
+ struct ecs_Cache *next; /* linked list successor, NULL if end of list */
+ struct ecs_Cache *previous; /* linked list predecessor */
+} ecs_Cache;
+
+
+typedef struct {
+ char *url; /* Client URL, mostly used to see if a client already exist */
+
+ ecs_Cache *cache; /* linked list of all cached coverage */
+ ecs_Cache *selectCache; /* A pointer to the cache selected by SelectLayer */
+ ecs_Region cacheRegion; /* mbr region of cache */
+ ecs_Region currentRegion; /* mbr of current region */
+ ecs_Family currentSelectionFamily; /* Current layer selection type */
+
+ char *tclprocname; /* attribute callback procedure for tcl */
+
+ PJ *target; /* source and target projection descriptors */
+ PJ *source;
+ int isSourceLL; /* flags to avoid unnecessary computation */
+ int isTargetLL;
+ int isProjEqual;
+ int isCurrentRegionSet;
+
+ ecs_Server s;
+
+} ecs_Client;
+
+#define MAXCLIENT 8
+
+/* Functions used for allocation and deallocation. */
+
+void cln_FreeClient _ANSI_ARGS_((ecs_Client **c));
+int cln_AllocClient _ANSI_ARGS_((char *URL,int *error));
+
+/* API functions */
+
+ecs_Result *cln_CreateClient _ANSI_ARGS_((int *ClientID,char *url));
+ecs_Result *cln_DestroyClient _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_SelectLayer _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls));
+ecs_Result *cln_ReleaseLayer _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls));
+void cln_BroadCloseLayers();
+ecs_Result *cln_SelectRegion _ANSI_ARGS_((int ClientID, ecs_Region *gr));
+ecs_Result *cln_GetDictionary _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_GetAttributesFormat _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_GetNextObject _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_GetRasterInfo _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_GetObject _ANSI_ARGS_((int ClientID, char *Id));
+ecs_Result *cln_GetObjectIdFromCoord _ANSI_ARGS_((int ClientID, ecs_Coordinate *coord));
+ecs_Result *cln_UpdateDictionary _ANSI_ARGS_((int ClientID, char *info));
+ecs_Result *cln_GetGlobalBound _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_SetServerLanguage _ANSI_ARGS_((int ClientID, u_int language));
+ecs_Result *cln_GetServerProjection _ANSI_ARGS_((int ClientID));
+ecs_Result *cln_SetServerProjection _ANSI_ARGS_((int ClientID, char *projection));
+ecs_Result *cln_SetClientProjection _ANSI_ARGS_((int ClientID, char *projection));
+void cln_SetTclProc _ANSI_ARGS_((int ClientID, char *tclproc));
+char *cln_GetTclProc _ANSI_ARGS_((int ClientID));
+
+/* Projection conversion functions */
+
+PJ *cln_ProjInit _ANSI_ARGS_((char *d));
+int cln_CompareProjections _ANSI_ARGS_((int ClientID));
+int cln_UpdateMaxRegion _ANSI_ARGS_((int ClientID, double x, double y, ecs_Region *gr, int sens, int first));
+int cln_ConvRegion _ANSI_ARGS_((int ClientID, ecs_Region *gr, int sens));
+int cln_ConvTtoS _ANSI_ARGS_((int ClientID, double *X, double *Y));
+int cln_ConvStoT _ANSI_ARGS_((int ClientID, double *X, double *Y));
+int cln_ChangeProjection _ANSI_ARGS_((int ClientID, ecs_Object *obj));
+int cln_ChangeProjectionArea _ANSI_ARGS_((int ClientID, ecs_Area *obj));
+int cln_ChangeProjectionLine _ANSI_ARGS_((int ClientID, ecs_Line *obj));
+int cln_ChangeProjectionPoint _ANSI_ARGS_((int ClientID, ecs_Point *obj));
+int cln_ChangeProjectionMatrix _ANSI_ARGS_((int ClientID, ecs_Matrix *obj));
+int cln_ChangeProjectionImage _ANSI_ARGS_((int ClientID, ecs_Image *obj));
+int cln_ChangeProjectionText _ANSI_ARGS_((int ClientID, ecs_Text *obj));
+int cln_PointValid _ANSI_ARGS_((int ClientID, double x, double y));
+
+/* Matrix conversion functions */
+
+int cln_CalcCtlPoint _ANSI_ARGS_((int ClientID, ecs_Region *server_region,
+ int SI, int SJ, ecs_CtlPoint *pt));
+int cln_CalcCtlPoints _ANSI_ARGS_((int ClientID, ecs_CtlPoints **pts,
+ char **error_message));
+int cln_SetRasterConversion _ANSI_ARGS_((int ClientID,
+ ecs_CtlPoints **pts,
+ ecs_Resampling resampling,
+ ecs_Transformation trans,
+ char **error_message));
+
+
+/* URL manipulation */
+
+int cln_GetClientIdFromURL _ANSI_ARGS_((char *url));
+int cln_GetURLList _ANSI_ARGS_((char **urllist));
+
+/* Cache functions */
+
+int cln_SetRegionCaches _ANSI_ARGS_((int ClientID, ecs_Region *GR, char **error_message));
+int cln_LoadCache _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls, char **error_message));
+int cln_ReleaseCache _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls, char **error_message));
+void cln_FreeCache _ANSI_ARGS_((ecs_Cache *cache));
+ecs_Cache *cln_FoundCache _ANSI_ARGS_((int ClientID, ecs_LayerSelection *ls));
+int cln_CopyObject _ANSI_ARGS_((ecs_Result *source, ecs_Result **copy, char **error_message));
+int cln_CopyGeometry _ANSI_ARGS_((ecs_Object *source, ecs_Object *copy, char **error_message));
+int cln_CopyArea _ANSI_ARGS_((ecs_Area *source, ecs_Area *copy, char **error_message));
+int cln_CopyLine _ANSI_ARGS_((ecs_Line *source, ecs_Line *copy, char **error_message));
+int cln_CopyPoint _ANSI_ARGS_((ecs_Point *source, ecs_Point *copy, char **error_message));
+int cln_CopyText _ANSI_ARGS_((ecs_Text *source, ecs_Text *copy, char **error_message));
+int cln_CopyMatrix _ANSI_ARGS_((ecs_Matrix *source, ecs_Matrix *copy, char **error_message));
+int cln_CopyImage _ANSI_ARGS_((ecs_Image *source, ecs_Image *copy, char **error_message));
+void cln_FreeObject _ANSI_ARGS_((ecs_Object *obj));
+
+#endif /* ECS_UTIL */
+
+
+/***********************************************************************/
+
+
+/*
+ * ecsgeo --
+ *
+ * Make geometric calculations
+ *
+ * Copyright (c) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc.
+ * Il est strictement interdit de publier ou de devoiler le contenu de ce
+ * programme sans avoir prealablement obtenu la permission de L.A.S. Inc.
+ */
+
+void ecs_begin_ellipsoid_polygon_area _ANSI_ARGS_((double a, double e2));
+double ecs_Q _ANSI_ARGS_((double x));
+double ecs_Qbar _ANSI_ARGS_((double x));
+double ecs_planimetric_polygon_area _ANSI_ARGS_((int n,ecs_Coordinate *coord));
+double ecs_ellipsoid_polygon_area _ANSI_ARGS_((int n,ecs_Coordinate *coord));
+double ecs_geodesic_distance _ANSI_ARGS_((double lon1, double lat1, double lon2, double lat2));
+double ecs_distance_meters _ANSI_ARGS_((char *projection, double X1, double Y1, double X2, double Y2));
+int ecs_CalculateCentroid _ANSI_ARGS_((int nb_segment, ecs_Coordinate *coord,ecs_Coordinate *centroid));
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_xdr.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_xdr.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/include/sun/ecs_xdr.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,616 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "ecs.h"
+
+bool_t
+xdr_ecs_Family(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Family *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Region(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Region *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_double(xdrs, &objp->north))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->south))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->east))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->west))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->ns_res))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->ew_res))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Resampling(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Resampling *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Transformation(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Transformation *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_RasterConversion(xdrs, objp)
+ register XDR *xdrs;
+ ecs_RasterConversion *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->coef.coef_val, (u_int *) &objp->coef.coef_len, ~0,
+ sizeof (double), (xdrproc_t) xdr_double))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->isProjEqual))
+ return (FALSE);
+ if (!xdr_ecs_Resampling(xdrs, &objp->r_method))
+ return (FALSE);
+ if (!xdr_ecs_Transformation(xdrs, &objp->t_method))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Coordinate(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Coordinate *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_double(xdrs, &objp->x))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->y))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_FeatureRing(xdrs, objp)
+ register XDR *xdrs;
+ ecs_FeatureRing *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_ecs_Coordinate(xdrs, &objp->centroid))
+ return (FALSE);
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Area(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Area *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->ring.ring_val, (u_int *) &objp->ring.ring_len, ~0,
+ sizeof (ecs_FeatureRing), (xdrproc_t) xdr_ecs_FeatureRing))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Line(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Line *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Point(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Point *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_ecs_Coordinate(xdrs, &objp->c))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Matrix(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Matrix *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->x.x_val, (u_int *) &objp->x.x_len, ~0,
+ sizeof (u_int), (xdrproc_t) xdr_u_int))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Image(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Image *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->x.x_val, (u_int *) &objp->x.x_len, ~0,
+ sizeof (u_int), (xdrproc_t) xdr_u_int))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Text(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Text *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_string(xdrs, &objp->desc, ~0))
+ return (FALSE);
+ if (!xdr_ecs_Coordinate(xdrs, &objp->c))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Node(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Node *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->containfaceid))
+ return (FALSE);
+ if (!xdr_ecs_Coordinate(xdrs, &objp->c))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Edge(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Edge *objp;
+{
+
+ register long *buf;
+
+
+ if (xdrs->x_op == XDR_ENCODE) {
+ buf = XDR_INLINE(xdrs, 7 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->startnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->endnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfedgeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfedgeid))
+ return (FALSE);
+
+ } else {
+ IXDR_PUT_LONG(buf, objp->id);
+ IXDR_PUT_LONG(buf, objp->startnodeid);
+ IXDR_PUT_LONG(buf, objp->endnodeid);
+ IXDR_PUT_LONG(buf, objp->rightfaceid);
+ IXDR_PUT_LONG(buf, objp->leftfaceid);
+ IXDR_PUT_LONG(buf, objp->rightfedgeid);
+ IXDR_PUT_LONG(buf, objp->leftfedgeid);
+ }
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+ } else if (xdrs->x_op == XDR_DECODE) {
+ buf = XDR_INLINE(xdrs, 7 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->startnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->endnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfedgeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfedgeid))
+ return (FALSE);
+
+ } else {
+ objp->id = IXDR_GET_LONG(buf);
+ objp->startnodeid = IXDR_GET_LONG(buf);
+ objp->endnodeid = IXDR_GET_LONG(buf);
+ objp->rightfaceid = IXDR_GET_LONG(buf);
+ objp->leftfaceid = IXDR_GET_LONG(buf);
+ objp->rightfedgeid = IXDR_GET_LONG(buf);
+ objp->leftfedgeid = IXDR_GET_LONG(buf);
+ }
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+ }
+
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->startnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->endnodeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfaceid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rightfedgeid))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->leftfedgeid))
+ return (FALSE);
+ if (!xdr_array(xdrs, (char **)&objp->c.c_val, (u_int *) &objp->c.c_len, ~0,
+ sizeof (ecs_Coordinate), (xdrproc_t) xdr_ecs_Coordinate))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_TopoLevel(xdrs, objp)
+ register XDR *xdrs;
+ ecs_TopoLevel *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Face(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Face *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_int(xdrs, &objp->id))
+ return (FALSE);
+ if (!xdr_array(xdrs, (char **)&objp->edgeid.edgeid_val, (u_int *) &objp->edgeid.edgeid_len, ~0,
+ sizeof (int), (xdrproc_t) xdr_int))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_AreaPrim(xdrs, objp)
+ register XDR *xdrs;
+ ecs_AreaPrim *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_ecs_TopoLevel(xdrs, &objp->level))
+ return (FALSE);
+ switch (objp->level) {
+ case Level012:
+ if (!xdr_array(xdrs, (char **)&objp->ecs_AreaPrim_u.edgeid.edgeid_val, (u_int *) &objp->ecs_AreaPrim_u.edgeid.edgeid_len, ~0,
+ sizeof (int), (xdrproc_t) xdr_int))
+ return (FALSE);
+ break;
+ case Level3:
+ if (!xdr_array(xdrs, (char **)&objp->ecs_AreaPrim_u.fedgeid.fedgeid_val, (u_int *) &objp->ecs_AreaPrim_u.fedgeid.fedgeid_len, ~0,
+ sizeof (ecs_Face), (xdrproc_t) xdr_ecs_Face))
+ return (FALSE);
+ break;
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Geometry(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Geometry *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_ecs_Family(xdrs, &objp->family))
+ return (FALSE);
+ switch (objp->family) {
+ case Area:
+ if (!xdr_ecs_Area(xdrs, &objp->ecs_Geometry_u.area))
+ return (FALSE);
+ break;
+ case Line:
+ if (!xdr_ecs_Line(xdrs, &objp->ecs_Geometry_u.line))
+ return (FALSE);
+ break;
+ case Point:
+ if (!xdr_ecs_Point(xdrs, &objp->ecs_Geometry_u.point))
+ return (FALSE);
+ break;
+ case Matrix:
+ if (!xdr_ecs_Matrix(xdrs, &objp->ecs_Geometry_u.matrix))
+ return (FALSE);
+ break;
+ case Image:
+ if (!xdr_ecs_Image(xdrs, &objp->ecs_Geometry_u.image))
+ return (FALSE);
+ break;
+ case Text:
+ if (!xdr_ecs_Text(xdrs, &objp->ecs_Geometry_u.text))
+ return (FALSE);
+ break;
+ case Node:
+ if (!xdr_ecs_Node(xdrs, &objp->ecs_Geometry_u.node))
+ return (FALSE);
+ break;
+ case Edge:
+ if (!xdr_ecs_Edge(xdrs, &objp->ecs_Geometry_u.edge))
+ return (FALSE);
+ break;
+ case Ring:
+ if (!xdr_ecs_AreaPrim(xdrs, &objp->ecs_Geometry_u.ring))
+ return (FALSE);
+ break;
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Object(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Object *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_string(xdrs, &objp->Id, ~0))
+ return (FALSE);
+ if (!xdr_ecs_Geometry(xdrs, &objp->geom))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->attr, ~0))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->xmin))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->ymin))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->xmax))
+ return (FALSE);
+ if (!xdr_double(xdrs, &objp->ymax))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_AttributeFormat(xdrs, objp)
+ register XDR *xdrs;
+ ecs_AttributeFormat *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_ObjAttribute(xdrs, objp)
+ register XDR *xdrs;
+ ecs_ObjAttribute *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_string(xdrs, &objp->name, ~0))
+ return (FALSE);
+ if (!xdr_ecs_AttributeFormat(xdrs, &objp->type))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->lenght))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->precision))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->nullable))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_ObjAttributeFormat(xdrs, objp)
+ register XDR *xdrs;
+ ecs_ObjAttributeFormat *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_array(xdrs, (char **)&objp->oa.oa_val, (u_int *) &objp->oa.oa_len, ~0,
+ sizeof (ecs_ObjAttribute), (xdrproc_t) xdr_ecs_ObjAttribute))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Category(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Category *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_long(xdrs, &objp->no_cat))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->r))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->g))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, &objp->b))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->label, ~0))
+ return (FALSE);
+ if (!xdr_u_long(xdrs, &objp->qty))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_RasterInfo(xdrs, objp)
+ register XDR *xdrs;
+ ecs_RasterInfo *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_long(xdrs, &objp->mincat))
+ return (FALSE);
+ if (!xdr_long(xdrs, &objp->maxcat))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->width))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->height))
+ return (FALSE);
+ if (!xdr_array(xdrs, (char **)&objp->cat.cat_val, (u_int *) &objp->cat.cat_len, ~0,
+ sizeof (ecs_Category), (xdrproc_t) xdr_ecs_Category))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_ResultType(xdrs, objp)
+ register XDR *xdrs;
+ ecs_ResultType *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_ResultUnion(xdrs, objp)
+ register XDR *xdrs;
+ ecs_ResultUnion *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_ecs_ResultType(xdrs, &objp->type))
+ return (FALSE);
+ switch (objp->type) {
+ case Object:
+ if (!xdr_ecs_Object(xdrs, &objp->ecs_ResultUnion_u.dob))
+ return (FALSE);
+ break;
+ case GeoRegion:
+ if (!xdr_ecs_Region(xdrs, &objp->ecs_ResultUnion_u.gr))
+ return (FALSE);
+ break;
+ case objAttributeFormat:
+ if (!xdr_ecs_ObjAttributeFormat(xdrs, &objp->ecs_ResultUnion_u.oaf))
+ return (FALSE);
+ break;
+ case RasterInfo:
+ if (!xdr_ecs_RasterInfo(xdrs, &objp->ecs_ResultUnion_u.ri))
+ return (FALSE);
+ break;
+ case AText:
+ if (!xdr_string(xdrs, &objp->ecs_ResultUnion_u.s, ~0))
+ return (FALSE);
+ break;
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_Result(xdrs, objp)
+ register XDR *xdrs;
+ ecs_Result *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_int(xdrs, &objp->error))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->message, ~0))
+ return (FALSE);
+ if (!xdr_ecs_ResultUnion(xdrs, &objp->res))
+ return (FALSE);
+ return (TRUE);
+}
+
+bool_t
+xdr_ecs_LayerSelection(xdrs, objp)
+ register XDR *xdrs;
+ ecs_LayerSelection *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_string(xdrs, &objp->Select, ~0))
+ return (FALSE);
+ if (!xdr_ecs_Family(xdrs, &objp->F))
+ return (FALSE);
+ return (TRUE);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,41 @@
+# Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Her Majesty the Queen
+# in Right of Canada not be used in advertising or publicity pertaining
+# to distribution of the software without specific, written prior
+# permission. Her Majesty the Queen in Right of Canada makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+
+include $(TOPDIR)/config/common.mak
+
+#
+# Sub-directories that need to be built
+#
+subdirs = include c-api glutil attr_driver datum_driver driver gltpd examples
+
+#
+# Default target to build everything in all sub-directories
+#
+all: $(subdirs)
+
+#
+# Target to allow individual sub-directories to be built
+# (e.g. make driver)
+#
+.PHONY: $(subdirs)
+$(subdirs):
+ cd $@; $(MAKE)
+
+#
+# Pass specialized targets into the sub-directories
+#
+.PHONY: $(STANDARD_TARGETS)
+$(STANDARD_TARGETS):
+ @for i in $(subdirs); do \
+ $(MAKE) --directory $$i $@; \
+ done
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/h_clean.pl
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/h_clean.pl 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/h_clean.pl 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,37 @@
+#! /usr/bin/perl
+
+require "getopts.pl";
+
+&Getopts('o:');
+
+if ($#ARGV != 0) {
+ die "Usage: $0 [-o outfile] infile\n";
+}
+
+if ($opt_o) {
+ $outfname = ">$opt_o";
+} else {
+ $outfname = '>&STDOUT';
+}
+
+$infname = $ARGV[0];
+
+open(OUTFILE, $outfname) || die "Unable to open $opt_o for writing: $!\n";
+open(INFILE, $ARGV[0]) || die "Unable to open $infname for reading: $!\n";
+
+binmode(OUTFILE);
+while (<INFILE>) {
+ push(@OUTLINES, $_);
+ if (/^struct ecs_ResultUnion \{/) {
+ splice(@OUTLINES, $#OUTLINES-1, 0,
+ "typedef struct ecs_ResultUnion ecs_ResultUnion;\n");
+ } elsif (/^typedef struct ecs_ResultUnion ecs_ResultUnion/) {
+ splice(@OUTLINES, $#OUTLINES, 1);
+ } elsif (/^(.*)struct struct(.*)$/) {
+ splice(@OUTLINES, $#OUTLINES, 1, "$1struct$2\n");
+ }
+}
+
+print OUTFILE @OUTLINES;
+close(OUTFILE);
+close(INFILE);
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/svc_clean.pl
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/svc_clean.pl 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/svc_clean.pl 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,112 @@
+#! /usr/bin/perl
+
+require "getopts.pl";
+
+&Getopts('o:');
+
+if ($#ARGV != 0) {
+ die "Usage: $0 [-o outfile] infile\n";
+}
+
+if ($opt_o) {
+ $outfname = ">$opt_o";
+} else {
+ $outfname = '>&STDOUT';
+}
+
+$infname = $ARGV[0];
+
+open(OUTFILE, $outfname) || die "Unable to open $opt_o for writing: $!\n";
+open(INFILE, $ARGV[0]) || die "Unable to open $infname for reading: $!\n";
+
+binmode(OUTFILE);
+while (<INFILE>) {
+ s/extern int _rpcpmstart/static int _rpcpmstart/;
+ push(@OUTLINES, $_);
+ if (/svc_freeargs/) {
+ while (<INFILE>) {
+ s/extern int _rpcpmstart/static int _rpcpmstart/;
+ push(@OUTLINES, $_);
+ if (/^\s*\}\s*$/) {
+ push(@OUTLINES, "\n");
+ push(@OUTLINES, "\tif (rqstp->rq_proc == DESTROYSERVER) {\n");
+ push(@OUTLINES, "#ifdef _WINDOWS\n");
+ push(@OUTLINES, "\t rpc_nt_exit();\n");
+ push(@OUTLINES, "#endif\n");
+ push(@OUTLINES, "\t pmap_unset(newprogramno, ECSVERS);\n");
+ push(@OUTLINES, "\t exit(0);\n");
+ push(@OUTLINES, "\t}\n\n");
+ last;
+ }
+ }
+ } elsif (/^void start_closedown_check/) {
+ while (<INFILE>) {
+ last if (/signal/);
+ }
+ push(@OUTLINES,$_);
+ push(@OUTLINES, "#ifndef _WINDOWS\n");
+ while (<INFILE>) {
+ push(@OUTLINES,$_);
+ last if (/^\}/);
+ }
+ push(@OUTLINES, "#endif /* ifndef _WINDOWS */\n");
+
+ } elsif (/^#include "ecs.h"/) {
+ push(@OUTLINES, "#ifndef _WINDOWS\n");
+ } elsif (/^#include <netinet\/in.h>/) {
+ push(@OUTLINES, "#endif /* ifndef _WINDOWS */\n");
+ push(@OUTLINES, "\nextern unsigned long newprogramno;\n");
+ } elsif (/^#include <signal.h>/) {
+ push(@OUTLINES, "#if 0\n");
+ } elsif (/^#include <sys\/ttycom.h>/) {
+ push(@OUTLINES, "#endif /* if 0 */\n");
+ } elsif (/^#include <memory.h>/) {
+ push(@OUTLINES, "#if 0\n");
+ } elsif (/^#include <stropts.h>/) {
+ push(@OUTLINES, "#endif /* if 0 */\n");
+ } elsif (/(.*)syslog\s*\(.*,(.*)\)(.*)/) {
+ splice(@OUTLINES, $#OUTLINES, 1);
+ push(@OUTLINES, "$1(void) fprintf(stderr, \"%s\\n\", $2)$3\n");
+ } elsif (/^main\(.*\)/) {
+ splice(@OUTLINES, $#OUTLINES-1, 2);
+ while (<INFILE>) {
+ ;
+ }
+ } elsif (/^ecsprog_1\(/) {
+ splice(@OUTLINES, $#OUTLINES-1, 1, "void\n");
+ } elsif (/^ecsproxyprog_1\(/) {
+ splice(@OUTLINES, $#OUTLINES-1, 1, "void\n");
+ } elsif (/^\s*(\S*)\s*=\s*\(\*local\)/) {
+ # Append after the line: result = (*local)(&argument, rqstp);
+ # In the proxy, decompression occurs, but no recompression occurs
+ push(@OUTLINES, "\tif ($1) {\n");
+ push(@OUTLINES, "\t\tecs_Result *tmp = (ecs_Result *) $1;\n");
+ if ($infname =~ /proxy/) {
+ push(@OUTLINES, "\t\t/* Proxy to client communication is uncompressed */\n");
+ push(@OUTLINES, "\t\ttmp->compression.ctype = 0;\n");
+ push(@OUTLINES, "\t\ttmp->compression.cversion = 0;\n");
+ push(@OUTLINES, "\t\ttmp->compression.clevel = 0;\n");
+ push(@OUTLINES, "\t\ttmp->compression.cblksize = 0;\n");
+ push(@OUTLINES, "\t\ttmp->compression.cfullsize = 0;\n");
+ } else {
+# Is this wrong????
+# push(@OUTLINES, "\t\ttmp->compression = svr_handle->compression;\n");
+ push(@OUTLINES, "\t\tif (svr_handle) {\n");
+ push(@OUTLINES, "\t\t\ttmp->compression = svr_handle->compression;\n");
+ push(@OUTLINES, "\t\t} else {\n");
+ push(@OUTLINES, "\t\t\t/* This will occur after a DESTROYSERVER call */\n");
+ push(@OUTLINES, "\t\t\ttmp->compression.ctype = ECS_COMPRESS_NONE;\n");
+ push(@OUTLINES, "\t\t\ttmp->compression.cversion = 0;\n");
+ push(@OUTLINES, "\t\t\ttmp->compression.clevel = 0;\n");
+ push(@OUTLINES, "\t\t\ttmp->compression.cblksize = 0;\n");
+ push(@OUTLINES, "\t\t\ttmp->compression.cfullsize = 0;\n");
+ push(@OUTLINES, "\t\t\ttmp->compression.cachesize = 0;\n");
+ push(@OUTLINES, "}\t\t\n");
+ }
+ push(@OUTLINES, "\t}\n");
+ }
+}
+
+print OUTFILE @OUTLINES;
+close(OUTFILE);
+close(INFILE);
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/xdr_clean.pl
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/xdr_clean.pl 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/scripts/xdr_clean.pl 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,45 @@
+#! /usr/bin/perl
+
+require "getopts.pl";
+
+&Getopts('o:');
+
+if ($#ARGV != 0) {
+ die "Usage: $0 [-o outfile] infile\n";
+}
+
+if ($opt_o) {
+ $outfname = ">$opt_o";
+} else {
+ $outfname = '>&STDOUT';
+}
+
+$infname = $ARGV[0];
+
+open(OUTFILE, $outfname) || die "Unable to open $opt_o for writing: $!\n";
+open(INFILE, $ARGV[0]) || die "Unable to open $infname for reading: $!\n";
+
+binmode(OUTFILE);
+while (<INFILE>) {
+ push(@OUTLINES, $_);
+ if (/^xdr_ecs_Result\s*\((.*)\)\s*$/) {
+ splice(@OUTLINES, $#OUTLINES, 1, "xdr_ecs_Result_Work($1)\n");
+ while (<INFILE>) {
+ if (! /xdr_ecs_Compression/) {
+ push(@OUTLINES, $_);
+ } else {
+ while (<INFILE>) {
+ if (/xdr_int/) {
+ push(@OUTLINES, $_);
+ last;
+ }
+ }
+ last;
+ }
+ }
+ }
+}
+
+print OUTFILE @OUTLINES;
+close(OUTFILE);
+close(INFILE);
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/ecs_tcl.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/ecs_tcl.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/ecs_tcl.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1988 @@
+/******************************************************************************
+ *
+ * Component: OGDI Tcl Binding
+ * Purpose: Contains all function bindings.
+ *
+ ******************************************************************************
+ * Copyright (C) 1995 Logiciels et Applications Scientifiques (L.A.S.) Inc
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies, that
+ * both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of L.A.S. Inc not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. L.A.S. Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ ******************************************************************************
+ *
+ * $Log: ecs_tcl.c,v $
+ * Revision 1.6 2007/02/12 16:04:21 cbalint
+ * More warrning fixes in tcl and odbc plugins.
+ *
+ * Revision 1.5 2001/04/09 15:04:35 warmerda
+ * applied new source headers
+ *
+ */
+
+#include "ecs.h"
+#include "tcl.h"
+
+char *ecstcl_message[] = {
+ /* 0 */ "wrong number of args: should be ",
+ /* 1 */ "URLdescriptor",
+ /* 2 */ "URL unknown:",
+ /* 3 */ "Family",
+ /* 4 */ "Request",
+ /* 5 */ "Error: The family appears to be invalid. Must be one of \"Area, Line, Point, Matrix, Image, Text, Edge, Face, Node, Ring\".",
+ /* 6 */ "TclArrayVariable",
+ /* 7 */ "Region",
+ /* 8 */ "Error: The region is invalid. It should be in the form {N S E W NS_resolution EW_resolution} where N>S and E>W.",
+ /* 9 */ "Error: This doesn't appear to be a valid itcl_class dictionary",
+ /* 10 */ "ID",
+ /* 11 */ "Projection",
+ /* 12 */ "Error: unable to get list of URLs",
+ /* 13 */ "TclCallbackProc",
+ /* 14 */ "Callback procedure removed.",
+ /* 15 */ "LanguageNumber",
+ /* 16 */ "This was an unknown return type",
+ /* 17 */ "Cannot set the tcl array variable",
+ /* 18 */ "DictionaryString",
+ /* 19 */ "CompressType",
+ /* 20 */ "CompressVersion",
+ /* 21 */ "CompressLevel",
+ /* 22 */ "CompressBlksize",
+ /* 23 */ "CacheSize",
+};
+
+struct ecs_UserData {
+ int ClientID;
+ char *ObjID;
+ char *proc;
+ char *tclvar;
+};
+
+typedef struct ecs_UserData ecs_UserData;
+
+int ecs_SetClientProjectionList _ANSI_ARGS_((Tcl_Interp *interp,int ClientID, char *list));
+int ecs_SetGeoRegionList _ANSI_ARGS_((Tcl_Interp *interp,ecs_Region *gr,char *list));
+int ecs_CreateClientCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp,int argc, const char **argv));
+int ecs_DestroyClientCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_SelectLayerCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_ReleaseLayerCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_SelectRegionCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_SelectMaskCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_UnSelectMaskCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_GetDictionaryCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_GetAttributesFormatCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_GetNextObjectCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_GetRasterInfoCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_GetObjectCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_GetObjectIdFromCoordCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_UpdateDictionaryCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_GetServerProjectionCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_GetGlobalBoundCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_SetClientProjectionCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_SetServerProjectionCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_GetURLListCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_AssignTclFunctionCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_SetCacheCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_LoadCacheCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_ReleaseCacheCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_SetServerLanguageCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+int ecs_SetCompressionCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, const char **argv));
+static int _interpEcsResult _ANSI_ARGS_((Tcl_Interp *interp, ecs_Result *result, ecs_UserData *userdata));
+static int _interpObject _ANSI_ARGS_((Tcl_Interp *interp, ecs_Result *result, char *buffer, ecs_UserData *userdata));
+static int _interpArea _ANSI_ARGS_((Tcl_Interp *interp, ecs_Area *area, char *buffer));
+static int _interpMatrix _ANSI_ARGS_((Tcl_Interp *interp, ecs_Matrix *matrix, char *buffer));
+static int _interpImage _ANSI_ARGS_((Tcl_Interp *interp, ecs_Image *image, char *buffer));
+static int _interpRegion _ANSI_ARGS_((Tcl_Interp *interp, ecs_Region *region, char *buffer));
+static int _interpRasterInfo _ANSI_ARGS_((Tcl_Interp *interp, ecs_RasterInfo *raster, char *buffer));
+static int _interpCoord _ANSI_ARGS_((Tcl_Interp *interp, ecs_Coordinate *coord, char *buffer));
+static int _interpCategory _ANSI_ARGS_((Tcl_Interp *interp, ecs_Category *category, char *buffer));
+static int _interpObjAttribute _ANSI_ARGS_((Tcl_Interp *interp, ecs_ObjAttribute *oa, char *buffer));
+static int _interpObjAttributeFormat _ANSI_ARGS_((Tcl_Interp *interp, ecs_ObjAttributeFormat *oaf, char *buffer, ecs_UserData *userdata));
+static int _GetLayer _ANSI_ARGS_((Tcl_Interp *interp, char *family, char *request, ecs_LayerSelection *layer));
+static int _getObjectFromTclProc _ANSI_ARGS_((Tcl_Interp *interp, char *proc, char *ObjID, char *tclvar, int ClientID));
+int _getAttributesFromTCLProc _ANSI_ARGS_((Tcl_Interp *interp, char *proc, char *tclvar, int ClientID));
+
+int
+Ecs_Init(interp)
+Tcl_Interp *interp; /* Interpreter to add extra commands */
+{
+ Tcl_CreateCommand(interp, "ecs_CreateClient",
+ ecs_CreateClientCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_DestroyClient",
+ ecs_DestroyClientCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_SelectLayer",
+ ecs_SelectLayerCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_ReleaseLayer",
+ ecs_ReleaseLayerCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_SelectRegion",
+ ecs_SelectRegionCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_SelectMask",
+ ecs_SelectMaskCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_UnSelectMask",
+ ecs_UnSelectMaskCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_GetDictionary",
+ ecs_GetDictionaryCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_GetNextObject",
+ ecs_GetNextObjectCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_GetAttributesFormat",
+ ecs_GetAttributesFormatCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_GetRasterInfo",
+ ecs_GetRasterInfoCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_GetObject",
+ ecs_GetObjectCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_GetObjectIdFromCoord",
+ ecs_GetObjectIdFromCoordCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_SetClientProjection",
+ ecs_SetClientProjectionCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_SetServerProjection",
+ ecs_SetServerProjectionCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_UpdateDictionary",
+ ecs_UpdateDictionaryCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_GetServerProjection",
+ ecs_GetServerProjectionCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_GetURLList",
+ ecs_GetURLListCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_GetGlobalBound",
+ ecs_GetGlobalBoundCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_AssignTclAttributeCallback",
+ ecs_AssignTclFunctionCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_LoadCache",
+ ecs_LoadCacheCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_ReleaseCache",
+ ecs_ReleaseCacheCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_SetCache",
+ ecs_SetCacheCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_SetServerLanguage",
+ ecs_SetServerLanguageCmd, (ClientData) 0, NULL);
+ Tcl_CreateCommand(interp, "ecs_SetCompression",
+ ecs_SetCompressionCmd, (ClientData) 0, NULL);
+
+/* globalinterp = interp; */
+
+ return TCL_OK;
+}
+
+int Ecs_tcl_Init(Tcl_Interp *interp )
+{
+ return Ecs_Init( interp );
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ecs_Init --
+ *
+ * Basically an alias for Ecs_Init. The load command in the
+ * Sun Tcl distribution wants the initialization routine to
+ * begin with a capital letter. Oblige it without breaking
+ * the old initialization routine.
+ *
+ * Results:
+ * A standard TCL result
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+ecs_Init(interp)
+Tcl_Interp *interp; /* Interpreter to add extra commands */
+{
+ return Ecs_Init(interp);
+}
+
+/********************/
+
+/*
+ ecs_CreateClientCmd
+ arg1: URL
+
+ Cette fonction cree le client et etablit une connection entre ce client
+ et un serveur identifie par URL. Cette fonction s'occupe de la creation
+ du client et lui assigne une projection geographique.
+ */
+
+int ecs_CreateClientCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+ ecs_Result *result;
+
+ if (argc != 2) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], "\"", (char *) NULL);
+ return(TCL_ERROR);
+ }
+
+ /* Creation du client */
+
+ result = cln_CreateClient(&ClientID,(char *)argv[1]);
+ if (result->error > 0) {
+ _interpEcsResult(interp,result,NULL);
+ return TCL_ERROR;
+ }
+
+ Tcl_AppendResult(interp, argv[1], (char *) NULL);
+ return TCL_OK;
+}
+
+
+/********************/
+
+/*
+ ecs_DestroyClientCmd
+ arg1: URL
+
+ Detruit un client et disconnecte le disconnecte du serveur correspondant
+ */
+
+int ecs_DestroyClientCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+
+ if (argc != 2) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], "\"", (char *) NULL);
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp,cln_DestroyClient(ClientID), NULL);
+
+}
+
+/*
+ _GetLayer
+ arg1: interp
+ arg2: Family
+ arg3: Request
+ arg4: Layer
+
+ creates an ecs_Layer from the arguments
+*/
+
+static int _GetLayer(interp,family,request,layer)
+ Tcl_Interp *interp;
+ char *family;
+ char *request;
+ ecs_LayerSelection *layer;
+{
+ char c;
+ size_t length;
+
+ c = family[0];
+ length = strlen(family);
+
+ layer->Select=request;
+/* if ((c == 'M') && (strncmp(family, "Meta", length) == 0)) {
+ layer->F = Meta;
+ return TCL_OK;
+ }*/
+ if ((c == 'L') && (strncmp(family, "Line", length) == 0)) {
+ layer->F = Line;
+ return TCL_OK;
+ }
+ if ((c == 'P') && (strncmp(family, "Point", length) == 0)) {
+ layer->F = Point;
+ return TCL_OK;
+ }
+ if ((c == 'A') && (strncmp(family, "Area", length) == 0)) {
+ layer->F = Area;
+ return TCL_OK;
+ }
+ if ((c == 'T') && (strncmp(family, "Text", length) == 0)) {
+ layer->F = Text;
+ return TCL_OK;
+ }
+ if ((c == 'M') && (strncmp(family, "Matrix", length) == 0)) {
+ layer->F = Matrix;
+ return TCL_OK;
+ }
+ if ((c == 'I') && (strncmp(family, "Image", length) == 0)) {
+ layer->F = Image;
+ return TCL_OK;
+ }
+ if ((c == 'E') && (strncmp(family, "Edge", length) == 0)) {
+ layer->F = Edge;
+ return TCL_OK;
+ }
+ if ((c == 'F') && (strncmp(family, "Face", length) == 0)) {
+ layer->F = Face;
+ return TCL_OK;
+ }
+ if ((c == 'N') && (strncmp(family, "Node", length) == 0)) {
+ layer->F = Node;
+ return TCL_OK;
+ }
+ if ((c == 'R') && (strncmp(family, "Ring", length) == 0)) {
+ layer->F = Ring;
+ return TCL_OK;
+ }
+ Tcl_AppendResult(interp, ecstcl_message[5],(char *) NULL);
+ layer= NULL;
+ return TCL_ERROR;
+}
+
+/********************/
+
+
+
+
+/*
+ ecs_SelectLayerCmd
+ arg 1: URL
+ arg 2: Family
+ arg 3-fin: Request
+
+ Defini le coverage actuel pour un client donne. Ce coverage
+ sera considere par toutes les autres fonctions.
+ */
+
+int ecs_SelectLayerCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ ecs_LayerSelection layer;
+ int ClientID;
+
+ if (argc != 4) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1]," ", ecstcl_message[3], " ",
+ ecstcl_message[4], "\"", (char *) NULL);
+/* Tcl_AppendResult(interp, ""wrong # args: should be \"",
+ argv[0], " URLdescriptor Family Request\"", 0);*/
+ return(TCL_ERROR);
+ }
+
+ ClientID = cln_GetClientIdFromURL((char *)argv[1]);
+ if (ClientID < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if ((_GetLayer(interp, (char *)argv[2],(char *)argv[3],&layer)) != TCL_OK) {
+ /* GetLayer appends its own error message */
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp,cln_SelectLayer(ClientID,&layer), NULL);
+
+}
+
+/********************/
+
+
+/*
+ ecs_ReleaseLayerCmd
+ arg 1: URL
+ arg 2: Family
+ arg 3-fin: Request
+
+ */
+
+int ecs_ReleaseLayerCmd(clientData,interp,argc,argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ const char **argv;
+{
+ int ClientID;
+ ecs_LayerSelection layer;
+
+ if (argc != 4) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1]," ", ecstcl_message[3], " ",
+ ecstcl_message[4], "\"", (char *) NULL);
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor Family Request ...\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if ((_GetLayer(interp, (char *)argv[2],(char *)argv[3], &layer)) != TCL_OK) {
+ /* GetLayer returns its own error msg to the interp */
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp,cln_ReleaseLayer(ClientID,&layer), NULL);
+
+}
+
+/********************/
+
+/*
+ ecs_SelectRegionCmd
+ arg 1: URL
+ arg 2: {Region}
+
+ Met a jour la region geographique courante. Tous les objects geographiques
+ seront contenu dans cette region.
+ */
+
+int ecs_SelectRegionCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int j;
+ int ClientID;
+ ecs_Region GR;
+
+ if (argc != 3) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ",
+ ecstcl_message[7], "\"", (char *) NULL);
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor Region\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((j=ecs_SetGeoRegionList(interp,&GR,(char *)argv[2])) == ECS_FAILURE) {
+ /* region is invalid */
+ Tcl_AppendResult(interp,ecstcl_message[8], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp,cln_SelectRegion(ClientID,&GR), NULL);
+
+/* Tcl_AppendResult(interp, argv[2]," is selected for ", argv[1], (char *) NULL); */
+}
+
+/********************/
+
+int ecs_SelectMaskCmd(clientData,interp,argc,argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ const char **argv;
+{
+ int largc;
+ const char **largv;
+ int pargc;
+ const char **pargv;
+ ecs_FeatureRing poly;
+ int i;
+ int isInclusive;
+ int ClientID;
+
+ if (argc != 4) {
+ Tcl_AppendResult(interp,
+ "ecs_SelectMask url {isMaskInclusive (0 or 1)} {list of points {X Y} } ",
+ (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if (Tcl_GetInt(interp, argv[2], &isInclusive) != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ /*
+ Convert the points into a ecs_FeatureRing
+ */
+
+ Tcl_ResetResult(interp);
+ if ((Tcl_SplitList(interp,argv[3],&largc,&largv) != TCL_OK) ||
+ (largc < 0)) {
+ return TCL_ERROR;
+ }
+
+ poly.c.c_len = largc;
+ poly.c.c_val = malloc(sizeof(ecs_Coordinate)*largc);
+ if (poly.c.c_val == NULL) {
+ ckfree((char *)largv);
+ return TCL_ERROR;
+ }
+
+ for (i=0;i<largc;i++) {
+ Tcl_ResetResult(interp);
+ if ((Tcl_SplitList(interp,largv[i],&pargc,&pargv) != TCL_OK) ||
+ (pargc < 0)) {
+ ckfree((char *)largv);
+ free(poly.c.c_val);
+ return TCL_ERROR;
+ }
+
+ if (Tcl_GetDouble(interp,pargv[0], &(poly.c.c_val[i].x)) != TCL_OK) {
+ ckfree((char *)largv);
+ ckfree((char *)pargv);
+ free(poly.c.c_val);
+ return TCL_ERROR;
+ }
+
+ if (Tcl_GetDouble(interp,pargv[1], &(poly.c.c_val[i].y)) != TCL_OK) {
+ ckfree((char *)largv);
+ ckfree((char *)pargv);
+ free(poly.c.c_val);
+ return TCL_ERROR;
+ }
+
+ ckfree((char *)pargv);
+ }
+
+ ckfree((char *)largv);
+
+ return _interpEcsResult(interp,cln_SelectMask(ClientID,&poly,isInclusive), NULL);
+}
+
+
+/********************/
+
+int ecs_UnSelectMaskCmd(clientData,interp,argc,argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ const char **argv;
+{
+ int ClientID;
+
+ if (argc != 2) {
+ Tcl_AppendResult(interp,
+ "ecs_UnSelectMask url",
+ (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp,cln_UnSelectMask(ClientID), NULL);
+}
+
+
+/********************/
+
+/*
+ ecs_GetDictionaryCmd
+ arg 1: URL
+
+ Retourne un objet ITCL qui decrit le contenu de la base de donnees
+ du serveur.
+ */
+
+
+int ecs_GetDictionaryCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ ecs_Result *result;
+ int ClientID;
+ char *dictionary;
+ char class[129];
+ int class_len;
+ Tcl_RegExp itclclass;
+ const char *startp, *endp;
+
+ /* if (!compiled) {
+ itclclass = TclRegComp("itcl_class ([A-Za-z_]+)"); */
+ itclclass = Tcl_RegExpCompile(interp,"itcl_class ([A-Za-z_]+)");
+ /* compiled = 1;
+ }*/
+
+ if (argc != 2) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], "\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ result = cln_GetDictionary(ClientID);
+ if (result->error > 0) {
+ _interpEcsResult(interp,result,NULL);
+ return TCL_ERROR;
+ }
+
+/* if (TclRegExec(itclclass,dictionary,NULL) == 0) { */
+ dictionary=result->res.ecs_ResultUnion_u.s;
+ if (Tcl_RegExpExec(interp,itclclass,dictionary,NULL) <= 0) {
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp,ecstcl_message[9], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ Tcl_RegExpRange(itclclass,0,&startp,&endp);
+ class_len = endp - startp;
+ if (class_len > 127) {class_len=127;}
+/* strncpy(class,itclclass->startp[1],class_len); */
+ strncpy(class,startp,class_len);
+ class[class_len] = '\0';
+
+ Tcl_AppendElement(interp,class);
+ Tcl_AppendElement(interp,dictionary);
+ return TCL_OK;
+}
+
+
+/********************/
+
+/*
+ ecs_GetAttributesFormatCmd
+ arg 1: URL
+
+ Retourne le format des attributs d'un coverage quelconque.
+ */
+
+int ecs_GetAttributesFormatCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ ecs_Result *result;
+ ecs_UserData userdata;
+ int ClientID;
+
+ if (argc != 2) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], "\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+ userdata.ClientID=ClientID;
+ userdata.ObjID=NULL;
+ userdata.proc=cln_GetTclProc(ClientID);
+ userdata.tclvar=NULL;
+
+ result=cln_GetAttributesFormat(ClientID);
+ /* todo: move this to ecsResult */
+
+ return(_interpEcsResult(interp,result,&userdata));
+}
+
+/********************/
+
+/*
+ ecs_GetNextObjectCmd
+ arg 1: URL
+ arg 2: tclArrayVariable
+ */
+
+int ecs_GetNextObjectCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+ ecs_Result *result;
+ ecs_UserData userdata;
+
+ if (argc != 3) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ", ecstcl_message[6],
+ "\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor tclArrayVariable\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+ userdata.ClientID=ClientID;
+ userdata.tclvar=(char *)argv[2];
+ result = cln_GetNextObject(ClientID);
+ return (_interpEcsResult(interp, result, &userdata));
+
+}
+
+/********************/
+/*
+ ecs_GetRasterInfoCmd
+ arg 1: URL
+
+ */
+
+int ecs_GetRasterInfoCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+ ecs_Result *result;
+
+ if (argc != 2) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], "\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ result= cln_GetRasterInfo(ClientID);
+
+ return(_interpEcsResult(interp,result,NULL));
+
+}
+
+/*******************/
+
+static int _getObjectFromTclProc(interp, proc, ObjID, tclvar, ClientID)
+ Tcl_Interp *interp;
+ char *proc;
+ char *ObjID;
+ char *tclvar;
+ int ClientID;
+{
+ char buffer[256];
+ sprintf(buffer,"%s %d %s %s", proc, ClientID, ObjID, tclvar);
+ return (Tcl_Eval(interp, buffer));
+}
+
+/*******************/
+
+static int _getAttributesFromTclProc(interp, proc, tclvar, ClientID)
+ Tcl_Interp *interp;
+ char *proc;
+ char *tclvar;
+ int ClientID;
+{
+ char buffer[256];
+ sprintf(buffer,"%s %d %s{} {}", proc, ClientID, tclvar);
+ return (Tcl_Eval(interp, buffer));
+}
+
+
+/********************/
+
+/*
+ ecs_GetObjectCmd
+ arg 1: URL
+ arg 2:
+ */
+
+int ecs_GetObjectCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+ ecs_Result *result;
+ ecs_UserData userdata;
+
+ if (argc != 4) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ", ecstcl_message[10], " ",
+ ecstcl_message[6], "\"", (char *) NULL);
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor ID tclArrayVariable\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ result = cln_GetObject(ClientID,(char *)argv[2]);
+ /* if there is an error in GetObject, return */
+
+ userdata.tclvar=(char *)argv[3];
+ userdata.ClientID=ClientID;
+ userdata.ObjID=(char *)argv[2];
+
+ return (_interpEcsResult(interp, result, &userdata));
+
+
+}
+
+/********************/
+
+/*
+ ecs_GetObjectIdFromCoordCmd
+ arg 1: URL
+ arg 2: X
+ arg 3: Y
+
+ Retourne l'identifiant de l'objet se trouve le plus pres
+ du point X,Y dans le coverage courant, peu importe le
+ type de l'objet.
+ */
+
+int ecs_GetObjectIdFromCoordCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+ ecs_Coordinate coordinate;
+
+ if (argc != 4) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " X Y\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor X Y\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ coordinate.x=atof(argv[2]);
+ coordinate.y=atof(argv[3]);
+
+ return _interpEcsResult(interp, cln_GetObjectIdFromCoord(ClientID,&coordinate),NULL);
+
+}
+
+/********************/
+
+/*
+ ecs_UpdateDictionaryCmd
+ arg 1: URL
+ arg 2: ?dictionary String?
+ Retourne une liste de toutes les coverages geographiques
+ disponibles du cote du serveur. Le dictionnaire de donnees
+ retourne par GetDictionary est en mesure de lire ces
+ informations.
+ */
+
+int ecs_UpdateDictionaryCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+
+ if (argc < 2 || argc > 3) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ?",
+ ecstcl_message[18], "?\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor dictionaryString\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+ if (argc == 2) {
+ return _interpEcsResult(interp,cln_UpdateDictionary(ClientID,NULL),NULL);
+ } else {
+ return _interpEcsResult(interp,cln_UpdateDictionary(ClientID,(char *)argv[2]),NULL);
+ }
+}
+
+
+/********************/
+
+/*
+ ecs_GetServerProjectionCmd
+ arg 1: URL
+
+ Retourne la projection geographique d'un serveur donne.
+ */
+
+int ecs_GetServerProjectionCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+
+ if (argc != 2) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], "\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor\"", 0); */
+ return(TCL_ERROR);
+ }
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp, cln_GetServerProjection(ClientID),NULL);
+
+}
+
+/********************/
+
+/*
+ ecs_GetGlobalBoundCmd
+ arg 1: URL
+
+ Retourne la region geographique globale des donnees contenu par
+ le serveur.
+ */
+
+int ecs_GetGlobalBoundCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+
+ if (argc != 2) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], "\"", (char *) NULL);
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp,cln_GetGlobalBound(ClientID),NULL);
+ return TCL_OK;
+}
+
+/********************/
+
+/*
+ ecs_SetClientProjectionCmd
+ arg 1: URL
+ arg 2-fin: Projection
+
+ Met a jour la projection geographique du client.
+ */
+
+int ecs_SetClientProjectionCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+ ecs_Result *result;
+
+ if (argc != 3) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ",
+ ecstcl_message[11],"\"", (char *) NULL);
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor Projection\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ result = cln_SetClientProjection(ClientID,(char *)argv[2]);
+ _interpEcsResult(interp,result,NULL);
+ if(result->error > 0) {
+ return TCL_ERROR;
+ }
+
+ return TCL_OK;
+
+}
+
+/********************/
+
+/*
+ ecs_SetServerProjectionCmd
+ arg 1: URL
+ arg 2-fin: Projection
+
+ Met a jour la projection geographique du client.
+ */
+
+int ecs_SetServerProjectionCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+
+ if (argc != 3) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ",
+ ecstcl_message[11],"\"", (char *) NULL);
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor Projection\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp, cln_SetServerProjection(ClientID,(char *)argv[2]),NULL);
+
+ /*
+ Tcl_AppendResult(interp, "projection ",argv[2]," is selected for ", argv[1], (
+char *) NULL);
+ */
+
+}
+
+/********************/
+
+/*
+ ecs_GetURLListCmd
+
+ Retourne la liste des URL valides
+ */
+
+int ecs_GetURLListCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int j;
+ char *Liste;
+
+ j = cln_GetURLList(&Liste);
+
+ if (!j) {
+ Tcl_AppendResult(interp,ecstcl_message[12], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ Tcl_AppendResult(interp,Liste, (char *) NULL);
+
+ return TCL_OK;
+}
+
+/********************/
+
+/*
+ ecs_AssignTclFunctionCmd
+ arg 1: URL
+ arg 2: tcl command
+
+ Assigne une fonction TCL pour gerer les attributs pour un coverage
+ donne.
+ */
+
+int ecs_AssignTclFunctionCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+
+ if (argc < 2) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ?",
+ ecstcl_message[13],"?\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor tclcommand \" or \"",
+ argv[0], " URLdescriptor\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if (argc == 2) {
+ cln_SetTclProc(ClientID, NULL);
+ Tcl_AppendResult(interp,ecstcl_message[14], (char *) NULL);
+ return TCL_OK;
+ } else {
+ cln_SetTclProc(ClientID,(char *)argv[2]);
+ Tcl_AppendResult(interp, argv[2], (char *) NULL);
+ return TCL_OK;
+ }
+
+ return TCL_OK;
+
+}
+
+/********************/
+/*
+ ecs_SetCacheCmd
+ arg 1: URL
+ arg 2: {Region}
+
+ Met a jour la region que seront occupes par les caches.
+ */
+
+int ecs_SetCacheCmd(clientData,interp,argc,argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ const char **argv;
+{
+ int j;
+ int ClientID;
+ ecs_Region GR;
+ char *string;
+
+ if (argc != 3) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ",
+ ecstcl_message[7], "\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0],
+ " URLdescriptor Region\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if ((j = ecs_SetGeoRegionList(interp,&GR,(char *)argv[2])) != ECS_SUCCESS) {
+ Tcl_AppendResult(interp,ecstcl_message[8], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if (!cln_SetRegionCaches(ClientID,&GR,&string)) {
+ Tcl_AppendResult(interp,string, (char *) NULL);
+ /*"Error: ecs_SetCache failed. ", (char *) NULL); */
+ return TCL_ERROR;
+ }
+ Tcl_AppendResult(interp,argv[2], (char *) NULL);
+ return TCL_OK;
+
+ }
+
+/********************/
+
+/*
+ ecs_LoadCacheCmd
+ arg 1: URL
+ arg 2: Family
+ arg 3-fin: Request
+
+ Charge les objets geographiques d'une region quelconque
+ dans une cache pour accelerer l'acces aux objets geographiques.
+ */
+
+int ecs_LoadCacheCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+ int j;
+ ecs_LayerSelection layer;
+ char *errorMsg;
+
+ if (argc != 4) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ", ecstcl_message[3], " ",
+ ecstcl_message[4], "\"", (char *) NULL);
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor Family Request\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if ((_GetLayer(interp,(char *)argv[2],(char *)argv[3],&layer)) != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ j = cln_LoadCache(ClientID,&layer,&errorMsg);
+
+ if (!j) {
+ Tcl_AppendResult(interp,errorMsg, (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ Tcl_AppendResult(interp,argv[3], (char *) NULL);
+
+ return TCL_OK;
+}
+
+/********************/
+/********************/
+
+/*
+ ecs_ReleaseCacheCmd
+ arg 1: URL
+ arg 2: Family
+ arg 3-fin: Request
+
+ Detruit une cache
+ */
+
+int ecs_ReleaseCacheCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+ int j;
+ ecs_LayerSelection layer;
+ char *errorMsg;
+
+ if (argc != 4) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ", ecstcl_message[3], " ",
+ ecstcl_message[4], "\"", (char *) NULL);
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor Family Request\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ if ((_GetLayer(interp,(char *)argv[2],(char *)argv[3],&layer)) != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ j = cln_ReleaseCache(ClientID,&layer,&errorMsg);
+
+ if (!j) {
+ Tcl_AppendResult(interp,errorMsg, (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ return TCL_OK;
+}
+
+int ecs_SetServerLanguageCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID, num;
+
+ if (argc != 3) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ",
+ ecstcl_message[15], "\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor LanguageNumber\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if (Tcl_GetInt(interp, argv[2], &num) != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp, cln_SetServerLanguage(ClientID, num),NULL);
+
+}
+
+/*
+ *----------------------------------------------------------------------
+ * ecs_SetCompressionCmd --
+ *
+ * Sets the compression parameters in the server. Parameters are:
+ * type: 0 = none, 1 = zlib; no others supported right now
+ * version: 0 is only version supported right now
+ * level: 1-9 where 1 is fastest, 9 compresses best. If 0, gets
+ * the server's default compression level.
+ * blksize: Size of the blocks that are compressed at a time. If 0,
+ * gets the server's default compression blocksize
+ *
+ * Results:
+ * Standard Tcl result
+ *----------------------------------------------------------------------
+ */
+
+int ecs_SetCompressionCmd(clientData,interp,argc,argv)
+ClientData clientData;
+Tcl_Interp *interp;
+int argc;
+const char **argv;
+{
+ int ClientID;
+ ecs_Compression c;
+
+ if (argc != 7) {
+ Tcl_AppendResult(interp, ecstcl_message[0],"\"",
+ argv[0], " ",ecstcl_message[1], " ",
+ ecstcl_message[19], " ", ecstcl_message[20], " ",
+ ecstcl_message[21], " ", ecstcl_message[22], " ",
+ ecstcl_message[23], "\"", (char *) NULL);
+
+/* Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " URLdescriptor type version level blksize cachesize\"", 0); */
+ return(TCL_ERROR);
+ }
+
+ if (Tcl_GetInt(interp, argv[2],(int *) &c.ctype) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (Tcl_GetInt(interp, argv[3],(int *) &c.cversion) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (Tcl_GetInt(interp, argv[4],(int *) &c.clevel) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (Tcl_GetInt(interp, argv[5],(int *) &c.cblksize) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (Tcl_GetInt(interp, argv[6],(int *) &c.cachesize) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ c.cfullsize = 0;
+
+ if ((ClientID = cln_GetClientIdFromURL((char *)argv[1])) < 0) {
+ /* url unknown */
+ Tcl_AppendResult(interp,ecstcl_message[2], " ", argv[1], (char *) NULL);
+ return TCL_ERROR;
+ }
+
+ return _interpEcsResult(interp, cln_SetCompression(ClientID, &c),NULL);
+}
+
+
+/********************/
+/********************/
+
+int ecs_SetGeoRegionList(interp,gr,liste)
+ Tcl_Interp *interp;
+ ecs_Region *gr;
+ char *liste;
+{
+ int argc;
+ const char **argv;
+ int code = ECS_FAILURE;
+
+ if (Tcl_SplitList(interp,liste,&argc,&argv) != TCL_OK) {
+ return ECS_FAILURE;
+ }
+
+ if (argc == 6) {
+ gr->north = atof(argv[0]);
+ gr->south = atof(argv[1]);
+ gr->east = atof(argv[2]);
+ gr->west = atof(argv[3]);
+ gr->ns_res = atof(argv[4]);
+ gr->ew_res = atof(argv[5]);
+
+ if ((gr->north>gr->south) && (gr->east>gr->west) &&
+ (gr->ns_res > 0) && (gr->ew_res > 0)) {
+ if (((gr->north-gr->south)> gr->ns_res) &&
+ ((gr->east-gr->west)> gr->ew_res))
+ code = ECS_SUCCESS;
+ }
+ }
+
+ free((char *) argv);
+ return code;
+
+}
+
+
+/********************/
+
+/*
+ _interpEcsResult
+ arg 1: interp
+ arg 2: result
+ arg 3: userdata
+ Convert ecs_Result into a string and give it to the interpreter given
+ by interp. "userdata" is a ptr to a structure of miscellany that can be passed in.
+ (if it is null, then there is no data.)
+*/
+static int _interpEcsResult(interp, result, userdata)
+ Tcl_Interp *interp;
+ ecs_Result *result;
+ ecs_UserData *userdata;
+{
+
+ char buffer[200];
+
+ Tcl_ResetResult(interp);
+ /* check for error */
+ if (result->error > 0) {
+ Tcl_AppendResult(interp,result->message,(char*) NULL);
+ /* also set errorCode here */
+ sprintf(buffer,"%d",result->error);
+ Tcl_SetErrorCode(interp,"ECS",buffer,(char*) NULL);
+ return TCL_ERROR;
+ }
+
+ /* switch on ecs_ResultUnion */
+
+ switch (result->res.type) {
+ case Object:
+ _interpObject(interp,result,buffer,userdata);
+ break;
+ case GeoRegion:
+ _interpRegion(interp, &(result->res.ecs_ResultUnion_u.gr),buffer);
+ break;
+ case objAttributeFormat:
+ _interpObjAttributeFormat(interp, &(result->res.ecs_ResultUnion_u.oaf),buffer,userdata);
+ break;
+ case RasterInfo:
+ _interpRasterInfo(interp, &(result->res.ecs_ResultUnion_u.ri),buffer);
+ break;
+ case AText:
+ Tcl_AppendResult(interp,result->res.ecs_ResultUnion_u.s, (char *) NULL );
+ break;
+ default:
+ Tcl_AppendResult(interp, "OK", (char *) NULL );
+ break;
+ }
+
+/* Tcl_AppendResult(interp, tmp, (char *) NULL ); */
+
+ return TCL_OK;
+}
+
+/********************/
+
+/*
+ _interpObjAttributeFormat
+ arg 1: interp
+ arg 2: oaf
+ arg 3: a pointer to some space
+ arg 4: the user's data
+ given an ecs_ObjAttributeFormat, appends whatever is in
+ it into interp in the form:
+ {<_interpObjAttribute1> <_interpObjAttribute2> ...}
+*/
+
+static int _interpObjAttributeFormat(interp, oaf, buffer, userdata)
+ Tcl_Interp *interp;
+ ecs_ObjAttributeFormat *oaf;
+ char *buffer;
+ ecs_UserData *userdata;
+{
+ u_int i;
+
+ if (userdata != NULL && userdata->proc != NULL) {
+ return(_getAttributesFromTclProc(interp, userdata->proc, userdata->tclvar, userdata->ClientID));
+ }
+
+ for(i=0; i<oaf->oa.oa_len; i++) {
+ _interpObjAttribute(interp, &(oaf->oa.oa_val[i]),buffer);
+ }
+ return TCL_OK;
+}
+
+/********************/
+
+/*
+ _interpObjAttribute
+ arg 1: interp
+ arg 2: oa
+ arg 3: a pointer to some space
+ given an ecs_ObjAttribute, appends whatever is in
+ it into interp in the form:
+ {name type length precision nullable}
+*/
+
+static int _interpObjAttribute(interp, oa, buffer)
+ Tcl_Interp *interp;
+ ecs_ObjAttribute *oa;
+ char* buffer;
+{
+ Tcl_AppendResult(interp,"{ ",(char *) NULL);
+ Tcl_AppendResult(interp, "\"", oa->name, "\"", (char *) NULL);
+ switch (oa->type) {
+ case Char:
+ Tcl_AppendElement(interp, "CHAR");
+ break;
+ case Varchar:
+ Tcl_AppendElement(interp, "VARCHAR");
+ break;
+ case Longvarchar:
+ Tcl_AppendElement(interp, "LONGVARCHAR");
+ break;
+ case Decimal:
+ Tcl_AppendElement(interp, "DECIMAL");
+ break;
+ case Numeric:
+ Tcl_AppendElement(interp, "NUMERIC");
+ break;
+ case Smallint:
+ Tcl_AppendElement(interp, "SMALLINT");
+ break;
+ case Integer:
+ Tcl_AppendElement(interp, "INTEGER");
+ break;
+ case Real:
+ Tcl_AppendElement(interp, "REAL");
+ break;
+ case Float:
+ Tcl_AppendElement(interp, "FLOAT");
+ break;
+ case Double:
+ Tcl_AppendElement(interp, "DOUBLE");
+ break;
+ default:
+ Tcl_AppendElement(interp, "UNKNOWNTYPE");
+ break;
+ }
+ sprintf(buffer," %d %d %d } ",
+ oa->lenght,
+ oa->precision,
+ oa->nullable
+ );
+ Tcl_AppendResult(interp,buffer,(char *) NULL);
+
+ return TCL_OK;
+}
+
+/********************/
+
+/*
+ _interpRasterInfo
+ arg 1: interp
+ arg 2: raster
+ arg 3: a pointer to some space
+ given an ecs_RasterInfo, appends whatever is in
+ it into interp in the form:
+ {mincat maxcat} {<_interpCategory1> <_interpCategory2> ...}
+
+*/
+
+static int _interpRasterInfo (interp, raster, buffer)
+ Tcl_Interp *interp;
+ ecs_RasterInfo *raster;
+ char *buffer;
+{
+ u_int i;
+ sprintf(buffer,"{%ld %ld %d %d}",
+ raster->mincat,
+ raster->maxcat,
+ raster->width,
+ raster->height
+ );
+ Tcl_AppendResult(interp, buffer, " { ", (char *) NULL);
+
+ for (i=0; i< raster->cat.cat_len; i++) {
+ _interpCategory(interp,&(raster->cat.cat_val[i]),buffer);
+ }
+ Tcl_AppendResult(interp, " }", (char *) NULL);
+
+ return TCL_OK;
+ }
+
+/********************/
+
+/*
+ _interpCategory
+ arg 1: interp
+ arg 2: category
+ arg 3: a pointer to some space
+ given an ecs_Category, appends whatever is in
+ it into interp in the form:
+ {no_cat r g b label qty}
+
+*/
+
+static int _interpCategory(interp, category, buffer)
+ Tcl_Interp *interp;
+ ecs_Category *category;
+ char *buffer;
+{
+ Tcl_AppendResult(interp,"{",(char*) NULL);
+ sprintf(buffer, "%ld %u %u %u",
+ category->no_cat,
+ category->r,
+ category->g,
+ category->b
+ );
+ Tcl_AppendResult(interp, buffer, (char *) NULL);
+ Tcl_AppendElement(interp, category->label);
+ sprintf(buffer," %lu",category->qty);
+ Tcl_AppendResult(interp, buffer, (char *) NULL);
+
+ Tcl_AppendResult(interp," } ",(char*) NULL);
+
+ return TCL_OK;
+}
+
+/********************/
+/********************/
+
+/*
+ _interpObject
+ arg 1: interp
+ arg 2: result
+ arg 3: a pointer to some space
+ Convert ecs_Result, into a tcl string of the form:
+ {id attr {xmin ymin xmax ymax} type { <type relative code> }}
+ { type Id {<type relative data>} {xmin ymin xmax ymax} }
+ and adds lines of attributes into a tcl array whose name is in "tclvar"
+*/
+
+static int _interpObject(interp,result,buffer,userdata)
+ Tcl_Interp *interp;
+ ecs_Result *result;
+ char *buffer;
+ ecs_UserData *userdata;
+{
+ u_int i;
+
+ /* switch on the ecs_Geometry family type */
+ switch (result->res.ecs_ResultUnion_u.dob.geom.family) {
+
+ case Area: /* Area */
+ Tcl_AppendResult (interp, "Area ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ _interpArea(interp, &(result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.area), buffer);
+ break;
+
+ case Line: /* Line */
+ Tcl_AppendResult (interp, "Line ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ Tcl_AppendResult (interp, " { ", (char *) NULL);
+ for (i=0; i<result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.line.c.c_len; i++) {
+ _interpCoord (interp,&(result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.line.c.c_val[i]),buffer);
+ }
+ Tcl_AppendResult (interp, " } ", (char *) NULL);
+ break;
+
+ case Point: /* Point */
+ Tcl_AppendResult (interp, "Point ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ _interpCoord(interp, &(result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.point.c), buffer);
+ break;
+
+ case Matrix: /* Matrix */
+ Tcl_AppendResult (interp, "Matrix ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ _interpMatrix(interp, &(result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.matrix), buffer);
+ break;
+
+ case Image: /* Image */
+ Tcl_AppendResult (interp, "Image ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ _interpImage(interp, &(result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.image), buffer);
+ break;
+
+ case Text: /* Text */
+ Tcl_AppendResult (interp, "Text ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ Tcl_AppendElement (interp, result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.text.desc);
+ _interpCoord (interp, &(result->res.ecs_ResultUnion_u.dob.geom.ecs_Geometry_u.text.c), buffer);
+ break;
+
+ case Edge: /* Edge */
+ Tcl_AppendResult (interp, "Edge ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ break;
+
+ case Face: /* Face */
+ Tcl_AppendResult (interp, "Face ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ break;
+
+ case Node: /* Node */
+ Tcl_AppendResult (interp, "Node ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ break;
+
+ case Ring: /* Ring */
+ Tcl_AppendResult (interp, "Ring ", (char *) NULL);
+ Tcl_AppendElement(interp, result->res.ecs_ResultUnion_u.dob.Id);
+ break;
+
+ default:
+ Tcl_AppendResult(interp, ecstcl_message[16], (char *) NULL );
+ break;
+ }
+
+ /* the bounding box */
+ sprintf(buffer,"%lf %lf %lf %lf ",
+ result->res.ecs_ResultUnion_u.dob.xmin,
+ result->res.ecs_ResultUnion_u.dob.ymin,
+ result->res.ecs_ResultUnion_u.dob.xmax,
+ result->res.ecs_ResultUnion_u.dob.ymax
+ );
+ Tcl_AppendElement(interp, buffer);
+
+ /* Set the array - if tcl proc exists for this client, call it, else use returned attributes. */
+
+ if ((userdata->proc=cln_GetTclProc(userdata->ClientID)) != NULL) {
+ return(_getObjectFromTclProc(interp, userdata->proc, userdata->ObjID, userdata->tclvar, userdata->ClientID));
+ } else {
+ Tcl_UnsetVar(interp,userdata->tclvar, TCL_GLOBAL_ONLY);
+ if (Tcl_SetVar2(interp,userdata->tclvar, "0", result->res.ecs_ResultUnion_u.dob.attr,
+ TCL_GLOBAL_ONLY) == NULL) {
+ Tcl_ResetResult(interp);
+/* sprintf(buffer, "Cannot set tcl array variable ""\"%s\".", userdata->tclvar); */
+ Tcl_AppendResult(interp, ecstcl_message[17], " ", userdata->tclvar,".", (char *) NULL);
+ return TCL_ERROR;
+ };
+ }
+
+ return TCL_OK;
+}
+
+/********************/
+
+/*
+ _interpRegion
+ arg 1: interp
+ arg 2: region
+ arg 3: a pointer to some space
+ Convert ecs_Region into a tcl string of the form:
+ {north south east west ns_res ew_res}
+
+*/
+
+static int _interpRegion(interp, region, buffer)
+ Tcl_Interp *interp;
+ ecs_Region *region;
+ char *buffer;
+{
+ sprintf(buffer,"%lf %lf %lf %lf %lf %lf",
+ region->north,
+ region->south,
+ region->east,
+ region->west,
+ region->ns_res,
+ region->ew_res
+ );
+ Tcl_AppendResult(interp, buffer, (char *) NULL);
+ return TCL_OK;
+}
+
+/********************/
+
+/*
+ _interpCoordinate
+ arg 1: interp
+ arg 2: coordinate
+ arg 3: a pointer to some space
+ Convert ecs_Coordinate into a tcl string of the form:
+ {x y} and add to interpreter
+
+*/
+
+static int _interpCoord(interp, coord, buffer)
+ Tcl_Interp *interp;
+ ecs_Coordinate *coord;
+ char *buffer;
+{
+ sprintf(buffer," {%lf %lf} ",
+ coord->x,
+ coord->y
+ );
+ Tcl_AppendResult(interp,buffer, (char *) NULL);
+ return TCL_OK;
+}
+
+/********************/
+
+/*
+ _interpMatrix
+ arg 1: interp
+ arg 2: matrix
+ arg 3: a pointer to some space
+ Convert ecs_matrix into a tcl string of the form:
+ {width height} {<interpRegion>} { x1 x2 ... xn }
+
+*/
+
+static int _interpMatrix(interp, matrix, buffer)
+ Tcl_Interp *interp;
+ ecs_Matrix *matrix;
+ char *buffer;
+{
+ u_int i;
+/* sprintf(buffer,"%d %d"
+ matrix->width,
+ matrix->height
+ );
+ Tcl_AppendElement(interp, buffer);
+ _interpRegion(interp, &(matrix->blockbound), buffer);
+ */
+
+ Tcl_AppendResult(interp," {", (char*) NULL);
+ for (i=0; i<matrix->x.x_len; i++) {
+ sprintf(buffer,"%u ", matrix->x.x_val[i]);
+ Tcl_AppendResult(interp,buffer, (char *) NULL);
+ }
+ Tcl_AppendResult(interp,"} ",(char*) NULL);
+
+ return TCL_OK;
+}
+
+/********************/
+
+/*
+ _interpImage
+ arg 1: interp
+ arg 2: image
+ arg 3: a pointer to some space
+ Convert ecs_image into a tcl string of the form:
+ {width height} {<interpRegion>} { x1 x2 ... xn }
+
+*/
+
+static int _interpImage(interp, image, buffer)
+ Tcl_Interp *interp;
+ ecs_Image *image;
+ char *buffer;
+{
+ u_int i;
+/* sprintf(buffer,"%d %d",
+ image->width,
+ image->height
+ );
+ Tcl_AppendElement(interp, buffer);
+ _interpRegion(interp, &(image->blockbound), buffer);
+*/
+ Tcl_AppendResult(interp," {", (char*) NULL);
+ for (i=0; i<image->x.x_len; i++) {
+ sprintf(buffer,"%u ", image->x.x_val[i]);
+ Tcl_AppendResult(interp,buffer, (char *) NULL);
+ }
+ Tcl_AppendResult(interp,"} ",(char*) NULL);
+
+ return TCL_OK;
+
+}
+
+
+/********************/
+
+/*
+ _interpArea
+ arg 1: interp
+ arg 2: area
+ arg 3: a pointer to some space
+ Convert ecs_Area into a tcl string of the form:
+
+ { {centroid0.x centroid0.y} {{x0 y0} {x1 y1} ...}
+ {centroid1.x centroid1.y} {{x0 y0} {x1 y1} ...}
+ ...
+ }
+
+*/
+
+static int _interpArea(interp, area, buffer)
+ Tcl_Interp *interp;
+ ecs_Area *area;
+ char *buffer;
+{
+ u_int i,j;
+
+ /* FeatureRings */
+ Tcl_AppendResult (interp, " {", (char *) NULL);
+
+ for (i=0; i < area->ring.ring_len; i++) {
+ Tcl_AppendResult (interp, " {", (char *) NULL);
+ sprintf(buffer," {%lf %lf} ",area->ring.ring_val[i].centroid.x, area->ring.ring_val[i].centroid.y);
+ Tcl_AppendResult (interp, buffer, (char *) NULL);
+
+ /* Coordinates */
+ Tcl_AppendResult (interp, " {", (char *) NULL);
+
+ for (j=0; j < area->ring.ring_val[i].c.c_len; j++) {
+ _interpCoord(interp,&(area->ring.ring_val[i].c.c_val[j]),buffer);
+ };
+
+ Tcl_AppendResult (interp, "} } ", (char *) NULL);
+
+ };
+
+ Tcl_AppendResult (interp, "} ", (char *) NULL);
+ return TCL_OK;
+}
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/ecs_tcl.def
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/ecs_tcl.def 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/ecs_tcl.def 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,8 @@
+LIBRARY ECS_TCL
+
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD SINGLE
+
+EXPORTS
+ ecs_Init
+ Ecs_Init
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi/tcl_interface/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc
+# Permission to use, copy, modify and distribute this software and
+# its documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies, that
+# both the copyright notice and this permission notice appear in
+# supporting documentation, and that the name of L.A.S. Inc not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission. L.A.S. Inc. makes no
+# representations about the suitability of this software for any purpose.
+# It is provided "as is" without express or implied warranty.
+#
+
+TOBEGEN = ecs_tcl
+TARGETGEN=$(DYNAGEN)
+
+SOURCES = ecs_tcl.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(TCL_INCLUDE) $(OGDI_INCLUDE) $(PROJ_INCLUDE)
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS)
+
+LINK_LIBS= $(OGDI_LINKLIB) $(TCL_LINKLIB) $(MATH_LINKLIB)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi-config
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi-config 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi-config 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,123 @@
+#! /bin/sh
+
+# ogdi-config
+# provides configuration info for ogdi library.
+
+# Copyright (C) 2007 Balint Cristian <cbalint at redhat.com>
+# This file is released under the terms of GPL v2 license.
+#
+
+version="3.2.0beta1"
+prefix="/usr"
+exec_prefix="${prefix}"
+libdir="${exec_prefix}/lib"
+includedir="${prefix}/include/ogdi"
+libs="-logdi"
+all_libs="-logdi -lproj -lexpat -lz"
+I_opts="-I${includedir}"
+L_opts=""
+R_opts=""
+cppflags=""
+ccopts=""
+ldopts=""
+
+usage()
+{
+ cat <<EOF
+Usage: $0 [OPTION] ...
+
+Known values for OPTION are:
+
+ --prefix print libogdi prefix
+ --libdir print path to directory containing library
+ --libs print library linking information
+ --ccopts print compiler options
+ --cppflags print pre-processor flags
+ --cflags print preprocessor flags, I_opts, and compiler options
+ --I_opts print "-I" include options
+ --L_opts print linker "-L" flags for dynamic linking
+ --R_opts print dynamic linker "-R" or "-rpath" flags
+ --ldopts print linker options
+ --ldflags print linker flags (ldopts, L_opts, R_opts, and libs)
+ --static revise subsequent outputs for static linking
+ --help print this help and exit
+ --version print version information
+EOF
+
+ exit $1
+}
+
+if test $# -eq 0; then
+ usage 1
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+
+ --prefix)
+ echo ${prefix}
+ ;;
+
+ --version)
+ echo ${version}
+ exit 0
+ ;;
+
+ --help)
+ usage 0
+ ;;
+
+ --ccopts)
+ echo ${ccopts}
+ ;;
+
+ --cppflags)
+ echo ${cppflags}
+ ;;
+
+ --cflags)
+ echo ${I_opts} ${cppflags} ${ccopts}
+ ;;
+
+ --libdir)
+ echo ${libdir}
+ ;;
+
+ --libs)
+ echo ${libs}
+ ;;
+
+ --I_opts)
+ echo ${I_opts}
+ ;;
+
+ --L_opts)
+ echo ${L_opts}
+ ;;
+
+ --R_opts)
+ echo ${R_opts}
+ ;;
+
+ --ldopts)
+ echo ${ldopts}
+ ;;
+
+ --ldflags)
+ echo ${ldopts} ${L_opts} ${R_opts} ${libs}
+ ;;
+
+ --static)
+ R_opts=""
+ libs=${all_libs}
+ ;;
+
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+exit 0
Property changes on: packages/ogdi-dfsg/branches/upstream/current/ogdi-config
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi-config.in
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi-config.in 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi-config.in 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,123 @@
+#! /bin/sh
+
+# ogdi-config
+# provides configuration info for ogdi library.
+
+# Copyright (C) 2007 Balint Cristian <cbalint at redhat.com>
+# This file is released under the terms of GPL v2 license.
+#
+
+version="@OGDI_VERSION@"
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+libdir="@libdir@"
+includedir="@includedir@/ogdi"
+libs="-logdi"
+all_libs="-logdi -lproj -lexpat -lz"
+I_opts="-I${includedir}"
+L_opts=""
+R_opts=""
+cppflags=""
+ccopts=""
+ldopts=""
+
+usage()
+{
+ cat <<EOF
+Usage: $0 [OPTION] ...
+
+Known values for OPTION are:
+
+ --prefix print libogdi prefix
+ --libdir print path to directory containing library
+ --libs print library linking information
+ --ccopts print compiler options
+ --cppflags print pre-processor flags
+ --cflags print preprocessor flags, I_opts, and compiler options
+ --I_opts print "-I" include options
+ --L_opts print linker "-L" flags for dynamic linking
+ --R_opts print dynamic linker "-R" or "-rpath" flags
+ --ldopts print linker options
+ --ldflags print linker flags (ldopts, L_opts, R_opts, and libs)
+ --static revise subsequent outputs for static linking
+ --help print this help and exit
+ --version print version information
+EOF
+
+ exit $1
+}
+
+if test $# -eq 0; then
+ usage 1
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+
+ --prefix)
+ echo ${prefix}
+ ;;
+
+ --version)
+ echo ${version}
+ exit 0
+ ;;
+
+ --help)
+ usage 0
+ ;;
+
+ --ccopts)
+ echo ${ccopts}
+ ;;
+
+ --cppflags)
+ echo ${cppflags}
+ ;;
+
+ --cflags)
+ echo ${I_opts} ${cppflags} ${ccopts}
+ ;;
+
+ --libdir)
+ echo ${libdir}
+ ;;
+
+ --libs)
+ echo ${libs}
+ ;;
+
+ --I_opts)
+ echo ${I_opts}
+ ;;
+
+ --L_opts)
+ echo ${L_opts}
+ ;;
+
+ --R_opts)
+ echo ${R_opts}
+ ;;
+
+ --ldopts)
+ echo ${ldopts}
+ ;;
+
+ --ldflags)
+ echo ${ldopts} ${L_opts} ${R_opts} ${libs}
+ ;;
+
+ --static)
+ R_opts=""
+ libs=${all_libs}
+ ;;
+
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+exit 0
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi.pc
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi.pc 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi.pc 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=/usr
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: ogdi
+Description: Open Geographic Datastore Interface
+Version: 3.2.0beta1
+Cflags: -I${includedir}/ogdi
+Libs: -L${libdir} -logdi
+Libs.private: -lproj -lexpat -lz
+
Added: packages/ogdi-dfsg/branches/upstream/current/ogdi.pc.in
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/ogdi.pc.in 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/ogdi.pc.in 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ogdi
+Description: Open Geographic Datastore Interface
+Version: @OGDI_VERSION@
+Cflags: -I${includedir}/ogdi
+Libs: -L${libdir} -logdi
+Libs.private: -lproj -lexpat -lz
+
Added: packages/ogdi-dfsg/branches/upstream/current/readme.w32
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/readme.w32 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/readme.w32 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,100 @@
+
+
+Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+Permission to use, copy, modify and distribute this software and
+its documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies, that
+both the copyright notice and this permission notice appear in
+supporting documentation, and that the name of Her Majesty the Queen
+in Right of Canada not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission. Her Majesty the Queen in Right of Canada makes no
+representations about the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+
+ The configuration was tested on:
+
+ - Windows 95 (standard)
+ - Windows 95B (FAT32)
+ - Windows NT 4.0, Workstation
+
+
+
+
+ This file will guide you in the process of installing all necessary
+ software and components needed to develop and compile new OGDI drivers
+
+-------------------------------------------------------------------------
+-------------------------------------------------------------------------
+
+ Requirements:
+
+ - OGDI sources
+
+ *** Install them in the root directory of your C drive
+ *** (c:\devdir)
+
+ - GNU Tools (development package:
+ ftp.cygnus.com/pub/gnu-win32/latest/cdk.exe, 14 Mb)
+
+ *** Follow InstallShield instructions.
+
+ *** It will be installed under
+ *** 'c:\gnuwin32\b18\H-i386-cygwin32'.
+
+ *** Once it is done, create a directory 'c:\usr\bin'.
+ *** Copy the content of
+ *** 'c:\gnuwin32\b18\H-i386-cygwin3\bin'
+ *** in your newly created directory (c:\usr\bin).
+
+ *** Create another directory 'c:\bin' and copy
+ *** 'bash.exe' and 'sh.exe' into it.
+
+ *** Bash also needs a 'tmp' directory, therefore,
+ *** if it does not exist in the root of your C drive,
+ *** you must create it.
+
+ - Microsoft Visual C++ 5.0 (FULL installation)
+
+ *** We strongly suggest to install it under
+ *** 'c:\msvc5\DevStudio...'
+
+ - 180 Mb of disk space
+
+ *** 10 Mb for sources installation,
+ *** (40 Mb after compiling)
+ *** 15 Mb for the GNU Tools,
+ *** 125 Mb for Visual C++,
+
+
+-------------------------------------------------------------------------
+-------------------------------------------------------------------------
+
+ To enable Windows95 to handle all needed environment variables, you
+ must change the size of 'initial environment' as follows:
+
+ - in the menu bar, click on 'Start'
+ - go to 'Settings' and select 'Taskbar'
+ - click on the 'Start Menu Programs' tab
+ - click on 'Advanced'
+ - in the opened window, double-click on 'Programs' folder
+ - select 'MS-DOS Prompt' with the right button of the mouse
+ - select 'Properties'
+ - click on the 'Memory' tab
+ - change the 'Initial Environment' value to 1024
+
+
+ Upon the completion of the above steps, go to c:\devdir and edit the file
+ 'varwin32.bat' to reflect your environment (if you followed the above
+ instructions, no editing should be required).
+
+
+ To start compiling, open a DOS console, go to 'c:\devdir' and execute
+ "varwin32". Type 'make' and hit the 'enter' key!
+
+
+
+Support: pmorin at host-194.j2geo.ndhq.dnd.ca <Paul Morin>
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/varwin32.bat
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/varwin32.bat 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/varwin32.bat 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,81 @@
+echo off
+rem Copyright (C) 1996 Her Majesty the Queen in Right of Canada.
+rem Permission to use, copy, modify and distribute this software and
+rem its documentation for any purpose and without fee is hereby granted,
+rem provided that the above copyright notice appear in all copies, that
+rem both the copyright notice and this permission notice appear in
+rem supporting documentation, and that the name of Her Majesty the Queen
+rem in Right of Canada not be used in advertising or publicity pertaining
+rem to distribution of the software without specific, written prior
+rem permission. Her Majesty the Queen in Right of Canada makes no
+rem representations about the suitability of this software for any purpose.
+rem It is provided "as is" without express or implied warranty.
+
+
+
+
+rem
+rem Visual Developer Studio files.
+rem
+
+set MSDevDir=C:\msvc5\DevStudio\SharedIDE
+
+
+rem
+rem Visual C++ files.
+rem
+
+set MSVCDir=C:\msvc5\DevStudio\VC
+
+
+rem
+rem Installation disk.
+rem
+
+set INSTALLDISK=C:
+
+
+rem
+rem Path to GNU tools.
+rem
+
+set GNUTOOLS=%INSTALLDISK%\usr\bin
+
+
+rem
+rem The shell.
+rem
+
+set shell=%INSTALLDISK%\bin\sh.exe
+
+
+rem
+rem Root of the sources.
+rem
+
+set TOPDIR=%INSTALLDISK%/devdir
+
+
+rem
+rem Target environment.
+rem
+
+set TARGET=win32
+
+
+rem
+rem Special flag for the b19 version number of the GNUTools.
+rem
+
+set MAKE_MODE=UNIX
+
+
+echo Setting environment variables, then starting BASH.
+
+
+set PATH="%MSDevDir%\BIN;%MSVCDir%\BIN";"%MSVCDir%\BIN\%VcOsDir%";%MSDevDir%\BIN;%MSVCDir%\BIN;%MSVCDir%\BIN\%VcOsDir%;"%GNUTOOLS%";%GNUTOOLS%;"%TOPDIR%"\bin\"%TARGET%";%PATH%
+set INCLUDE=%MSVCDir%\INCLUDE;%MSVCDir%\MFC\INCLUDE;%MSVCDir%\ATL\INCLUDE;%INCLUDE%
+set LIB=%MSVCDir%\LIB;%MSVCDir%\MFC\LIB;%LIB%
+
+
+%GNUTOOLS%\bash.exe
Property changes on: packages/ogdi-dfsg/branches/upstream/current/varwin32.bat
___________________________________________________________________
Name: svn:executable
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/coorgeom.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/coorgeom.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/coorgeom.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,836 @@
+
+/***************************************************************************
+ *
+ *N Module COORGEOM.C
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Coordinate Geometry Module
+ *
+ * Contains functions for performing general purpose coordinate
+ * geometry operations.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Sep 1992
+ * Dan Maddux Jan 1994
+ *E
+ **************************************************************************/
+
+#include <math.h>
+#include <stdlib.h>
+#include <float.h>
+
+#ifdef _MSDOS
+#include <limits.h>
+#define MAXFLOAT FLT_MAX
+#endif
+
+#ifdef _MAC
+#undef MAXFLOAT
+#define MAXFLOAT 3.37E+38
+#endif
+
+#ifndef MISSING_FLOAT_H
+#include <float.h>
+#define MAXFLOAT FLT_MAX
+#endif
+
+#ifndef __COORGEOM_H__
+#include "coorgeom.h"
+#endif
+
+
+
+/*************************************************************************
+ *
+ *N gc_distance
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function computes the distance between two points on the
+ * surface of the (spherical) earth. The points are specified in
+ * geographic coordinates (lat1,lon1) and (lat2,lon2). The algorithm
+ * used here is taken directly from ELEMENTS OF CARTOGRAPHY, 4e. -
+ * Robinson, Sale, Morrison - John Wiley & Sons, Inc. - pp. 44-45.
+ * Geometrically, the function computes the arc distance dtheta on
+ * the sphere between two points A and B by the following formula:
+ *
+ * cos dtheta = (sin a sin b) + (cos a cos b cos p)
+ *
+ * where:
+ *
+ * dtheta = arc distance between A and B
+ * a = latitude of A
+ * b = latitude of B
+ * p = degrees of longitude between A and B
+ *
+ * Once the arc distance is determined, it is converted into miles by
+ * taking the ratio between the circumference of the earth (2*PI*R) and
+ * the number of degrees in a circle (360):
+ *
+ * distance in miles (d) arc distance in degrees (dtheta)
+ * ------------------------------ = --------------------------------
+ * earth's circumference in miles earth's circumference in degrees
+ *
+ * or
+ *
+ * d = (dtheta * (2*PI*R)) / 360 =>
+ * d = (dtheta*PI*R)/180
+ *
+ * The calculated distance is referred to as the Great Circle Distance.
+ *
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * lat1 <input> == (double) latitude of point A.
+ * lon1 <input> == (double) longitude of point A.
+ * lat2 <input> == (double) latitude of point B.
+ * lon2 <input> == (double) longitude of point B.
+ * units <input> == (int32) flag to indicate output distance units.
+ * Must be one of the coord_units_type enumerations.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels November 1990 Original Version DOS Turbo C
+ * September 1992 UNIX Port - Additional Units
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ double gc_distance( double lat1, double lon1, double lat2, double lon2, int32 units)
+#else
+ double gc_distance (lat1, lon1, lat2, lon2, units)
+ double lat1, lon1, lat2, lon2;
+ int32 units;
+#endif
+{
+ double a,b,p,dtheta,d;
+#ifndef PI
+ double PI=3.141592654;
+#endif
+ double DEG2RAD=(PI/180.0), RAD2DEG=(180.0/PI);
+ static double R[] =
+ { 3958.754, 6370997.0, 1.00000, 2090221.12, 250826653.44 , 6370.997 };
+ /* miles meters degrees feet inches kilometers */
+
+ if ((units<Miles)||(units>Kilometers)) units = Miles;
+
+ if (lat1 > 90.0) lat1 -= 180.0;
+ if (lat2 > 90.0) lat2 -= 180.0;
+
+ a = lat1*DEG2RAD; /* Degrees must be converted to radians */
+ b = lat2*DEG2RAD;
+ p = fabs(lon1-lon2)*DEG2RAD;
+ dtheta = (sin(a)*sin(b)) + (cos(a)*cos(b)*cos(p));
+ dtheta = acos(dtheta)*RAD2DEG; /* Compute arc distance in degrees */
+ d = (dtheta*PI*R[units])/180.0; /* Compute distance in miles or km */
+ return d;
+}
+
+
+/*************************************************************************/
+/* geo_intersect */
+/* This function determines if any portion of an input */
+/* rectangular "fextent1' is contained within another rectangular */
+/* 'fextent2'. It returns either TRUE of FALSE */
+/* DGM 21 Jan 94 */
+/*************************************************************************/
+#ifdef PROTO
+ int32 geo_intersect (fextent_type fextent1, fextent_type fextent2)
+#else
+ int32 geo_intersect (fextent1, fextent2)
+ fextent_type fextent1, fextent2;
+#endif
+ {
+ float merid_180;
+
+ /* Check for crossing the 180 meridian */
+ if (fextent1.x1 < -180.0)
+ merid_180 = -1.0;
+ else if (fextent1.x2 > 180.0)
+ merid_180 = 1.0;
+ else
+ merid_180 = 0.0;
+
+ if (fextent2.x1 > 0.0 && fextent2.x2 < 0.0 && fextent1.x1 > 0.0)
+ merid_180 = 1.0;
+ else if (fextent2.x1 > 0.0 && fextent2.x2 < 0.0 && fextent1.x1 < 0.0)
+ merid_180 = -1.0;
+
+ if ((fextent2.x1 >= fextent1.x1 && fextent2.x1 <= fextent1.x2) ||
+ (fextent2.x2 >= fextent1.x1 && fextent2.x2 <= fextent1.x2))
+ merid_180 = 0.0;
+
+ if (merid_180 == -1.0)
+ {
+ if (fextent2.x1 > 0.0)
+ fextent2.x1 = fextent2.x1 + merid_180 * 360.0;
+ if (fextent2.x2 > 0.0)
+ fextent2.x2 = fextent2.x2 + merid_180 * 360.0;
+ }
+ else if (merid_180 == 1.0)
+ {
+ if (fextent2.x1 < 0.0)
+ fextent2.x1 = fextent2.x1 + merid_180 * 360.0;
+ if (fextent2.x2 < 0.0)
+ fextent2.x2 = fextent2.x2 + merid_180 * 360.0;
+ }
+
+ /* 1 intersects 2 from the top */
+ if ((fextent1.y1 >= fextent2.y1) &&
+ (fextent1.y1 < fextent2.y2) &&
+ (fextent1.x1 < fextent2.x2) &&
+ (fextent1.x2 > fextent2.x1))
+ return (TRUE);
+
+ /* 1 intersects 2 from the bottom */
+ if ((fextent1.y2 <= fextent2.y2) &&
+ (fextent1.y2 > fextent2.y1) &&
+ (fextent1.x1 < fextent2.x2) &&
+ (fextent1.x2 > fextent2.x1))
+ return (TRUE);
+
+ /* 1 intersects 2 from the right */
+ if ((fextent1.x1 >= fextent2.x1) &&
+ (fextent1.x1 < fextent2.x2) &&
+ (fextent1.y2 > fextent2.y1) &&
+ (fextent1.y1 < fextent2.y2))
+ return (TRUE);
+
+ /* 1 intersects 2 from the left */
+ if ((fextent1.x2 <= fextent2.x2) &&
+ (fextent1.x2 > fextent2.x1) &&
+ (fextent1.y2 > fextent2.y1) &&
+ (fextent1.y1 < fextent2.y2))
+ return (TRUE);
+
+ /* 1 contains 2 */
+ if ((fextent1.x1 <= fextent2.x1) &&
+ (fextent1.x2 >= fextent2.x2) &&
+ (fextent1.y2 >= fextent2.y2) &&
+ (fextent1.y1 <= fextent2.y1))
+ return (TRUE);
+
+ /* 1 is contained by 2 */
+ if ((fextent1.x1 >= fextent2.x1) &&
+ (fextent1.x2 <= fextent2.x2) &&
+ (fextent1.y2 <= fextent2.y2) &&
+ (fextent1.y1 >= fextent2.y1))
+ return (TRUE);
+
+ return (FALSE);
+ }
+
+
+/*************************************************************************
+ *
+ *N contained
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function determines whether any portion of an input rectangular
+ * 'extent1' is contained within another rectangular 'extent2'. It
+ * returns either TRUE or FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * extent1 <input> == (extent_type) rectangular area to be tested within.
+ * extent2 <input> == (extent_type) rectangular area to be tested against.
+ * contained <output> == (int32) boolean:
+ * TRUE if extent2 contains extent1
+ * FALSE if extent2 does not contain extent1
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1990 Original Version DOS Turbo C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 contained (extent_type extent1, extent_type extent2)
+#else
+ int32 contained (extent1, extent2)
+ extent_type extent1, extent2;
+#endif
+
+ {
+ /* 1 intersects 2 from the top */
+ if ((extent1.y1 >= extent2.y1) &&
+ (extent1.y1 < extent2.y2) &&
+ (extent1.x1 < extent2.x2) &&
+ (extent1.x2 > extent2.x1))
+ return (TRUE);
+
+ /* 1 intersects 2 from the bottom */
+ if ((extent1.y2 <= extent2.y2) &&
+ (extent1.y2 > extent2.y1) &&
+ (extent1.x1 < extent2.x2) &&
+ (extent1.x2 > extent2.x1))
+ return (TRUE);
+
+ /* 1 intersects 2 from the right */
+ if ((extent1.x1 >= extent2.x1) &&
+ (extent1.x1 < extent2.x2) &&
+ (extent1.y2 > extent2.y1) &&
+ (extent1.y1 < extent2.y2))
+ return (TRUE);
+
+ /* 1 intersects 2 from the left */
+ if ((extent1.x2 <= extent2.x2) &&
+ (extent1.x2 > extent2.x1) &&
+ (extent1.y2 > extent2.y1) &&
+ (extent1.y1 < extent2.y2))
+ return (TRUE);
+
+ /* 1 contains 2 */
+ if ((extent1.x1 <= extent2.x1) &&
+ (extent1.x2 >= extent2.x2) &&
+ (extent1.y2 >= extent2.y2) &&
+ (extent1.y1 <= extent2.y1))
+ return (TRUE);
+
+ /* 1 is contained by 2 */
+ if ((extent1.x1 >= extent2.x1) &&
+ (extent1.x2 <= extent2.x2) &&
+ (extent1.y2 <= extent2.y2) &&
+ (extent1.y1 >= extent2.y1))
+ return (TRUE);
+
+ return (FALSE);
+ }
+
+/*************************************************************************
+ *
+ *N completely_within
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function determines whether extent1 is completely within
+ * extent2.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * extent1 <input>==(extent_type) first extent to compare.
+ * extent2 <input>==(extent_type) second extent to compare.
+ * return <output>==(int32) 1 if extent1 is completely within extent2,
+ * 0 if not.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 completely_within (extent_type extent1, extent_type extent2)
+#else
+ int32 completely_within (extent1, extent2)
+ extent_type extent1, extent2;
+#endif
+
+{
+ if (extent1.x1 < extent2.x1) return 0;
+ if (extent1.y1 < extent2.y1) return 0;
+ if (extent1.x2 > extent2.x2) return 0;
+ if (extent1.y2 > extent2.y2) return 0;
+ return 1;
+}
+
+
+
+
+/*************************************************************************
+ *
+ *N fwithin
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function determines whether the given (floating point)
+ * coordinate is contained within the specified extent.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * x <input>==(double) X coordiante.
+ * y <input>==(double) Y coordiante.
+ * extent <input>==(extent_type) extent to compare.
+ * return <output>==(int32) TRUE if the coordinate is contained within
+ * the extent; FALSE if not.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ * Sep 1992 UNIX Port
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 fwithin (double x, double y, extent_type extent)
+#else
+ int32 fwithin (x, y, extent)
+ double x, y;
+ extent_type extent;
+#endif
+
+{
+ if ( x >= extent.x1 && x <= extent.x2 &&
+ y >= extent.y1 && y <= extent.y2 )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+
+/* Check if the value n0 is in between n1 and n2 */
+#define BETWEEN(n0,n1,n2) ((n0>=n1 && n0<=n2) || (n0<=n1 && n0>=n2))
+
+/**************************************************************************
+ *
+ *N intersect
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Test whether line segment l1 intersects line segment l2
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * l1 <input> == (line_segment_type) line segment one.
+ * l2 <input> == (line_segment_type) line segment two.
+ * xint <inout> == (double *) intersection point x coordinate.
+ * yint <inout> == (double *) intersection point y coordinate.
+ * intersect <output> == (int32) boolean:
+ * 1 --> line segments intersect
+ * 0 --> line segments do not intersect
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels DOS Turbo C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 intersect (line_segment_type l1, line_segment_type l2,
+ double *xint, double *yint)
+#else
+ int32 intersect (l1, l2, xint, yint)
+ line_segment_type l1, l2;
+ double *xint, *yint;
+#endif
+
+{
+ double m1,m2,b1=0,b2=0;
+ double tempy1,tempy2;
+
+ if ( (l1.x1==l1.x2) && (l2.y1==l2.y2) ) {
+ /* l1 is vertical and l2 is horizontal */
+
+ if ( ( ((l2.x1 <= l1.x1) && (l1.x1 <= l2.x2)) || /* X coordinate */
+ ((l2.x2 <= l1.x1) && (l1.x1 <= l2.x1)) ) && /* intersects */
+ ( ((l1.y1 <= l2.y1) && (l2.y1 <= l1.y2)) || /* Y coordinate */
+ ((l1.y2 <= l2.y1) && (l2.y1 <= l1.y1)) ) ) /* intersects */
+ {
+ *xint = l1.x1;
+ *yint = l2.y1;
+ return 1;
+ }
+ } else
+ return 0;
+
+ if ( (l2.x1==l2.x2) && (l1.y1==l1.y2) ) {
+ /* l2 is vertical and l1 is horizontal */
+
+ if ( ( ((l1.x1 <= l2.x1) && (l2.x1 <= l1.x2)) || /* X coordinate */
+ ((l1.x2 <= l2.x1) && (l2.x1 <= l1.x1)) ) && /* intersects */
+ ( ((l2.y1 <= l1.y1) && (l1.y1 <= l2.y2)) || /* Y coordinate */
+ ((l2.y2 <= l1.y1) && (l1.y1 <= l2.y1)) ) ) /* intersects */
+ {
+ *xint = l2.x1;
+ *yint = l1.y1;
+ return 1;
+ }
+ } else
+ return 0;
+
+ if ( (l1.x1==l2.x1) && (l1.y1==l2.y1) ) {
+ *xint = l1.x1;
+ *yint = l1.y1;
+ return 1;
+ }
+ if ( (l1.x2==l2.x2) && (l1.y2==l2.y2) ) {
+ *xint = l1.x2;
+ *yint = l1.y2;
+ return 1;
+ }
+ if ( (l1.x1==l2.x2) && (l1.y1==l2.y2) ) {
+ *xint = l1.x1;
+ *yint = l1.y1;
+ return 1;
+ }
+ if ( (l1.x2==l2.x1) && (l1.y2==l2.y1) ) {
+ *xint = l1.x2;
+ *yint = l1.y2;
+ return 1;
+ }
+
+ if (l1.x1 != l1.x2) {
+ m1 = (l1.y2-l1.y1)/(l1.x2-l1.x1);
+ b1 = -1.0*m1*l1.x1 + l1.y1;
+ } else { /* l1 is a vertical line */
+ m1 = MAXFLOAT;
+ }
+
+ if (l2.x1 != l2.x2) {
+ m2 = (l2.y2-l2.y1)/(l2.x2-l2.x1);
+ b2 = -1.0*m2*l2.x1 + l2.y1;
+ } else { /* l2 is a vertical line */
+ m2 = MAXFLOAT;
+ }
+
+
+ /* Find intersection point of lines */
+
+ if ((m1 == m2) && (m1 != MAXFLOAT)) {
+ if (b1 == b2) {
+ /* Slopes are equal (and not vertical). */
+ /* Check end points for overlap. */
+ if (BETWEEN(l1.x1,l2.x1,l2.x2)) {
+ *xint = l1.x1;
+ *yint = l1.y1;
+ return 1;
+ }
+ if (BETWEEN(l1.x2,l2.x1,l2.x2)) {
+ *xint = l1.x2;
+ *yint = l1.y2;
+ return 1;
+ }
+ if (BETWEEN(l2.x1,l1.x1,l1.x2)) {
+ *xint = l2.x1;
+ *yint = l2.y1;
+ return 1;
+ }
+ if (BETWEEN(l2.x2,l1.x1,l1.x2)) {
+ *xint = l2.x2;
+ *yint = l2.y2;
+ return 1;
+ }
+ }
+ /* Endpoints don't overlap - no intersection */
+ return 0;
+ }
+
+ if ( (m1 != MAXFLOAT) && (m2 != MAXFLOAT) ) {
+ /* neither line is a vertical line */
+ *xint = (b2-b1)/(m1-m2);
+ if (m1 == 0) /* if l1 is a horizontal line */
+ *yint = l1.y1;
+ else
+ {
+ if (m2 == 0) /* if l2 is a horizontal line */
+ *yint = l2.y1;
+ else
+ *yint = m1*(*xint)+b1;
+ }
+
+ } else { /* At least one vertical line */
+ if (m1==m2) { /* Both vertical lines */
+ if (l1.x1==l2.x1) { /* Coincident vertical lines */
+ *xint = l1.x1;
+ tempy1 = (double) min( l1.y1, l1.y2 );
+ tempy2 = (double) min( l2.y1, l2.y2 );
+ *yint = (double) max( tempy1, tempy2 );
+ } else { /* Non-coincident vertical lines */
+ return 0;
+ }
+ } else if (m1==MAXFLOAT) { /* l1 is vertical */
+ if ( ((l2.x1 <= l1.x1) && (l2.x2 >= l1.x1)) ||
+ ((l2.x2 <= l1.x1) && (l2.x1 >= l1.x1)) )
+ {
+ *yint = m2*l1.x1 + b2; /* l2 intersects l1 */
+ *xint = l1.x1;
+ }
+ else
+ return 0; /* l2 does not intersect l1 */
+
+ } else { /* l2 is vertical */
+ if ( ((l1.x1 <= l2.x1) && (l1.x2 >= l2.x1)) ||
+ ((l1.x2 <= l2.x1) && (l1.x1 >= l2.x1)) )
+ {
+ *yint = m1*l2.x1 + b1; /* l1 intersects l2 */
+ *xint = l2.x1;
+ }
+ else
+ return 0; /* l1 does not intersect l2 */
+
+ }
+ }
+
+ /* See if intersection point lies on both line segments */
+ return ( (*xint >= (double)min(l1.x1,l1.x2)) &&
+ (*xint <= (double)max(l1.x1,l1.x2)) &&
+ (*yint >= (double)min(l1.y1,l1.y2)) &&
+ (*yint <= (double)max(l1.y1,l1.y2)) &&
+ (*xint >= (double)min(l2.x1,l2.x2)) &&
+ (*xint <= (double)max(l2.x1,l2.x2)) &&
+ (*yint >= (double)min(l2.y1,l2.y2)) &&
+ (*yint <= (double)max(l2.y1,l2.y2)) );
+
+}
+
+
+
+
+/**************************************************************************
+ *
+ *N perpendicular_intersection
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Test whether a perpendicular to a line segment intersects a search
+ * point. lseg must be of a type similar to line_segment_type.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * lseg <input> == (line_segment_type) line segment.
+ * xsearch <input> == (double) search point x coordinate.
+ * ysearch <input> == (double) search point y coordinate.
+ * xint <inout> == (double *) intersection point x coordinate.
+ * yint <inout> == (double *) intersection point y coordinate.
+ * return <output> == (int32) TRUE if a perpendicular to the line
+ * segment intersects the search point;
+ * FALSE if there is no intersection.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels, DOS Turbo C 1991
+ * Ronald Rozensky, vertical and horizontal line handlers.
+ * Barry Michaels Sep 1992 UNIX Port - double precision
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 perpendicular_intersection (line_segment_type lseg,
+ double xsearch, double ysearch,
+ double *xint, double *yint)
+#else
+ int32 perpendicular_intersection (lseg, xsearch, ysearch, xint, yint)
+ line_segment_type lseg;
+ double xsearch, ysearch, *xint, *yint;
+#endif
+
+{
+ double m1,mp,b1=0,bp; /* m's are for slopes, b's are for y intersections */
+ /* for the old y=mx+b point slope formula. */
+
+ if (lseg.y1 == lseg.y2)
+ if (((lseg.x1 <= xsearch) && (xsearch <= lseg.x2)) ||
+ ((lseg.x2 <= xsearch) && (xsearch <= lseg.x1)))
+ {
+ *xint = xsearch;
+ *yint = lseg.y1;
+ return 1;
+ }
+
+ if (lseg.x1 == lseg.x2)
+
+ if (((lseg.y1 <= ysearch) && (ysearch <= lseg.y2)) ||
+ ((lseg.y2 <= ysearch) && (ysearch <= lseg.y1)))
+ {
+ *xint = lseg.x1;
+ *yint = ysearch;
+ return 1;
+ }
+
+ if ( (lseg.x1==xsearch) && (lseg.y1==ysearch) ) {
+ *xint = xsearch;
+ *yint = ysearch;
+ return 1;
+ }
+ if ( (lseg.x2==xsearch) && (lseg.y2==ysearch) ) {
+ *xint = xsearch;
+ *yint = ysearch;
+ return 1;
+ }
+
+ if (lseg.x1 != lseg.x2) {
+ m1 = (lseg.y2-lseg.y1)/(lseg.x2-lseg.x1);
+ b1 = -1*m1*lseg.x1 + lseg.y1;
+ if (m1 != 0.0) {
+ mp = -1.0/m1; /* perpendicular */
+ } else {
+ mp = MAXFLOAT;
+ }
+ } else {
+ m1 = MAXFLOAT;
+ mp = 0.0;
+ }
+
+ if (fabs(mp) < 1000000.0) {
+ bp = ysearch - mp*xsearch;
+ } else {
+ bp = MAXFLOAT;
+ }
+
+ /* Find intersection point of lseg and its perpendicular */
+
+ if ( (m1 != MAXFLOAT) && (mp != MAXFLOAT) ) {
+ *xint = (bp-b1)/(m1-mp);
+ *yint = m1*(*xint)+b1;
+ } else { /* At least one vertical line */
+ if (m1==MAXFLOAT) { /* lseg is vertical */
+ *yint = ysearch;
+ *xint = lseg.x1;
+ } else { /* perp is vertical */
+ *yint = lseg.y1;
+ *xint = xsearch;
+ }
+ }
+
+ /* See if intersection point lies on both line segments */
+ return ( (*xint >= (float)min(lseg.x1,lseg.x2)) &&
+ (*xint <= (float)max(lseg.x1,lseg.x2)) &&
+ (*yint >= (float)min(lseg.y1,lseg.y2)) &&
+ (*yint <= (float)max(lseg.y1,lseg.y2)) );
+}
+
+
+/*************************************************************************
+ *
+ *N float_to_dms
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function converts a floating point lat lon coordinate to
+ * degrees-minutes-seconds format.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * coord <input> == (double) floating point lat lon coordinate.
+ * return <output> == (dms_type) degrees-minutes-seconds coordinate.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1990 Original Version DOS Turbo C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ dms_type float_to_dms (double coord)
+#else
+ dms_type float_to_dms (coord)
+ double coord;
+#endif
+
+{
+ dms_type dms_coord;
+
+ dms_coord.degrees = (int32)coord;
+ dms_coord.minutes = (int32)((double)(coord-(int32)coord)*60.0);
+ dms_coord.seconds = (float)(((double)(coord-(int32)coord)* 60.0) -
+ (double)dms_coord.minutes) * 60.0;
+ dms_coord.minutes = (int32)abs ((short)dms_coord.minutes);
+ dms_coord.seconds = (float)fabs (dms_coord.seconds);
+
+ if (dms_coord.seconds >= 60.0) {
+ dms_coord.minutes++;
+ dms_coord.seconds -= (float)60.0;
+ }
+
+ if (dms_coord.minutes == 60) {
+ if (dms_coord.degrees >= 0)
+ dms_coord.degrees++;
+ else
+ dms_coord.degrees--;
+ dms_coord.minutes = 0;
+ }
+
+ if ((dms_coord.degrees == 0)&&(coord < 0.0)) dms_coord.minutes *= -1;
+
+ return dms_coord;
+}
+
+
+/*************************************************************************
+ *
+ *N dms_to_float
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function converts a coordinate in degrees-minutes-seconds
+ * format to a (double precision) floating point decimal degree value.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * coord <input> == (dms_type) degrees-minutes-seconds coordinate.
+ * return <output> == (double) floating point lat lon coordinate.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1990 Original Version DOS Turbo C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ double dms_to_float (dms_type dms_coord)
+#else
+ double dms_to_float (dms_coord)
+ dms_type dms_coord;
+#endif
+
+{
+ double fcoord;
+
+ if (dms_coord.degrees >= 0)
+ fcoord = (double)dms_coord.degrees +
+ (((double)dms_coord.minutes)/60.0) +
+ (dms_coord.seconds/3600.0);
+ else
+ fcoord = (double)dms_coord.degrees -
+ (((double)dms_coord.minutes)/60.0) -
+ (dms_coord.seconds/3600.0);
+
+ return fcoord;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/coorgeom.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/coorgeom.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/coorgeom.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,92 @@
+
+
+#ifndef __COORGEOM_H__
+#define __COORGEOM_H__ 1
+
+#include "machine.h"
+
+/* Geographic extent or line segment structure of type double */
+typedef struct
+ {
+ double x1, y1, x2, y2;
+} extent_type, line_segment_type;
+
+/* Geographic extent structure of type float */
+typedef struct {
+ float x1, y1, x2, y2;
+} fextent_type;
+
+typedef enum {
+ Miles,
+ Meters,
+ Degrees,
+ Feet,
+ Inches,
+ Kilometers
+} coord_units_type;
+
+/* For latitude-longitude */
+typedef struct {
+ int32 degrees;
+ int32 minutes;
+ float seconds;
+} dms_type;
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+/* Cartesian distance formula. */
+/* All parameters must be float or double. */
+#define DISTANCE( x1, y1, x2, y2 ) \
+ sqrt( ((x2-x1)*(x2-x1)) + ((y2-y1)*(y2-y1)) )
+
+#ifndef _WINDOWS
+#ifndef max
+#define max(a,b) ((a > b) ? a : b)
+#endif
+
+#ifndef min
+#define min(a,b) ((a < b) ? a : b)
+#endif
+#endif
+
+#define MILES_TO_KM(x) (x*1.6093)
+#define MILES_TO_METERS(x) (1000.0*x*1.6093)
+#define MILES_TO_FEET(x) (x*5280.0);
+#define MILES_TO_INCHES(x) (x*5280.0*12.0)
+
+#define KM_TO_MILES(x) (x*0.6214)
+#define METERS_TO_MILES(x) (x*0.0006214)
+#define FEET_TO_MILES(x) (x/5280.0)
+#define INCHES_TO_MILES(x) (x/63360.0)
+
+/* Functions */
+#ifdef PROTO
+ double gc_distance (double lat1, double lon1, double lat2, double lon2, int32 units);
+ int32 contained( extent_type extent1, extent_type extent2 );
+ int32 geo_intersect (fextent_type extent1, fextent_type extent2);
+ int32 completely_within( extent_type extent1, extent_type extent2 );
+ int32 fwithin( double x, double y, extent_type extent );
+ int32 intersect( line_segment_type l1, line_segment_type l2, double *xint, double *yint );
+ int32 perpendicular_intersection( line_segment_type lseg, double xsearch, double ysearch,
+ double *xint, double *yint );
+ dms_type float_to_dms( double coordinate );
+#else
+ double dms_to_float ();
+ double gc_distance ();
+ int32 contained ();
+ int32 geo_intersect ();
+ int32 completely_within ();
+ int32 fwithin ();
+ int32 intersect ();
+ int32 perpendicular_intersection ();
+ dms_type float_to_dms ();
+ double dms_to_float ();
+#endif /* If PROTO */
+
+#endif
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/get_feat.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/get_feat.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/get_feat.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,526 @@
+/**********************************************************************/
+/* GET_FEATURE.C */
+/**********************************************************************/
+
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+#ifndef __COORGEOM_H__
+#include "coorgeom.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __VPFPRIM_H__
+#include "vpfprim.h"
+#endif
+#ifndef GET_FEATURE_H
+#include "get_feat.h"
+#endif
+
+/* Global Variables */
+/*extern vpf_projection_type NOPROJ; */
+vpf_projection_type NOPROJ = {DDS, 0.0, 0.0, 0.0, 0.0, 0, 0.0, 0.0,
+ NULL, NULL, "Decimal Degrees "};
+
+
+
+
+/**********************************************************************/
+/* GET_LINE_FEATURE */
+/**********************************************************************/
+#ifdef PROTO
+ void get_line_feature (LINE_FEATURE *line, row_type row, vpf_table_type table)
+#else
+ void get_line_feature (line, row, table)
+ LINE_FEATURE *line;
+ row_type row;
+ vpf_table_type table;
+#endif
+
+ {
+ int32 pos, id, count;
+
+ /* Go ahead and set up code to handle compound line features */
+ line->nr_segs = 1;
+ line->segs = (SEGMENT**)xvt_zmalloc ((size_t)line->nr_segs * sizeof (SEGMENT*));
+ if (line->segs == NULL)
+ xvt_fatal ("GET_LINE_FEATURE:1 Out of memory!");
+
+ line->segs[0] = (SEGMENT*)xvt_zmalloc (sizeof (SEGMENT));
+ if (line->segs[0] == NULL)
+ xvt_fatal ("GET_LINE_FEATURE:2 Out of memory!");
+
+ pos = table_pos ("ID", table);
+ get_table_element (pos, row, table, &id, &count);
+ line->segs[0]->id = id;
+
+ pos = table_pos ("COORDINATES", table);
+ line->segs[0]->coords = (COORDINATE*)get_xy (table, row, pos, &count);
+ line->segs[0]->nr_coords = count;
+
+ return;
+ }
+
+/**********************************************************************/
+/* GET_TEXT_FEATURE */
+/**********************************************************************/
+#ifdef PROTO
+ void get_text_feature (TEXT_FEATURE *text, row_type row, vpf_table_type table)
+#else
+ void get_text_feature (text, row, table)
+ TEXT_FEATURE *text;
+ row_type row;
+ vpf_table_type table;
+#endif
+
+ {
+ int32 pos, id, count;
+
+ pos = table_pos ("ID", table);
+ get_table_element (pos, row, table, &id, &count);
+ text->id = id;
+
+ pos = table_pos ("STRING", table);
+ text->string = (char*)get_table_element (pos, row, table, NULL, &count);
+
+ pos = table_pos ("SHAPE_LINE", table);
+ text->coords = (COORDINATE*)get_xy (table, row, pos, &count);
+ text->nr_coords = count;
+
+ return;
+ }
+
+/**********************************************************************/
+/* GET_POINT_FEATURE */
+/* Derived from draw_point_row [vpfdraw.c] */
+/**********************************************************************/
+#ifdef PROTO
+ void get_point_feature
+ (POINT_FEATURE *point, row_type row, vpf_table_type table)
+#else
+ void get_point_feature (point, row, table)
+ POINT_FEATURE *point;
+ row_type row;
+ vpf_table_type table;
+#endif
+
+ {
+ int32 pos, id, count;
+
+ pos = table_pos ("ID", table);
+ get_table_element (pos, row, table, &id, &count);
+ point->id = id;
+
+ pos = table_pos ("COORDINATE", table);
+ point->coord = (COORDINATE*)get_xy (table, row, pos, &count);
+
+ return;
+ }
+
+
+/**********************************************************************/
+/* GET_AREA_FEATURE */
+/* Derived from outline_face [vpfdraw.c] */
+/**********************************************************************/
+#ifdef PROTO
+ void get_area_feature (AREA_FEATURE *area, int32 face_id,
+ vpf_table_type facetable,
+ vpf_table_type ringtable,
+ vpf_table_type edgetable)
+#else
+ void get_area_feature (area, face_id, facetable, ringtable, edgetable)
+ AREA_FEATURE *area;
+ int32 face_id;
+ vpf_table_type facetable, ringtable, edgetable;
+#endif
+
+ {
+ int32 n=0;
+ face_rec_type face_rec;
+ ring_rec_type ring_rec;
+ RING **temp;
+
+ face_rec = read_face (face_id, facetable);
+ ring_rec = read_ring (face_rec.ring, ringtable);
+
+ /* Allocate space to store addresses of all the ring structures */
+ area->rings = (RING**)xvt_zmalloc (MAXRINGS * sizeof (RING*));
+ if (area->rings == NULL)
+ xvt_fatal ("GET_AREA_FEATURE: Out of memory!");
+
+ /* Get the outer ring coords */
+ area->rings[n] = (RING*)xvt_zmalloc (sizeof (RING));
+ if (area->rings[n] == NULL)
+ xvt_fatal ("GET_AREA_FEATURE: Out of memory!");
+
+ area->rings[n]->id = n+1;
+
+ get_ring_coords (area->rings[n], face_id, ring_rec.edge, edgetable);
+ n++;
+
+ /* Get the coords for any inner rings that exist */
+ while (ring_rec.face == face_id)
+ {
+ ring_rec = read_next_ring (ringtable);
+
+ if (feof (ringtable.fp))
+ break;
+ if (ring_rec.face == face_id)
+ {
+ area->rings[n] = (RING*)xvt_zmalloc (sizeof (RING));
+ if (area->rings[n] == NULL)
+ xvt_fatal ("GET_AREA_FEATURE: Out of memory!");
+
+ area->rings[n]->id = n+1;
+
+ get_ring_coords (area->rings[n], face_id, ring_rec.edge, edgetable);
+ n++;
+ }
+ }
+ area->nr_rings = n;
+
+ /* Realloc rings array to the required size */
+ temp = (RING**)xvt_zmalloc (area->nr_rings * sizeof (RING*));
+ if (temp == (RING**)NULL)
+ xvt_fatal ("GET_AREA_FEATURE: Out of memory!");
+ else
+ {
+ memcpy (temp, area->rings, (area->nr_rings * sizeof (RING*)));
+ xvt_free ((char*)area->rings);
+ area->rings = temp;
+ }
+
+ return;
+ }
+
+
+
+/**********************************************************************/
+/* GET_RING_COORDS */
+/* Derived from outline_face_ring [vpfdraw.c] */
+/**********************************************************************/
+#ifdef PROTO
+ void get_ring_coords (RING *ring, int32 face_id,int32 start_edge,
+ vpf_table_type edgetable)
+#else
+ void get_ring_coords (ring, face_id, start_edge, edgetable)
+ RING *ring;
+ int32 face_id, start_edge;
+ vpf_table_type edgetable;
+#endif
+
+ {
+ edge_rec_type edge_rec;
+ int32 next_edge, prevnode, i, n=0;
+ boolean done=FALSE;
+ vpf_projection_type proj;
+ double_coordinate_type dcoord;
+ SEGMENT **temp;
+
+ proj = NOPROJ;
+
+ edge_rec = read_edge (start_edge, edgetable, proj.inverse_proj);
+ edge_rec.dir = '+';
+ prevnode = edge_rec.start_node;
+
+ if (edge_rec.start_node == edge_rec.end_node)
+ done = TRUE;
+ next_edge = next_face_edge (&edge_rec, &prevnode, face_id);
+
+ /* Allocate plenty of space for array of segment addresses */
+ ring->segs = (SEGMENT**)xvt_zmalloc (MAXSEGS * sizeof (SEGMENT*));
+ if (ring->segs == NULL)
+ xvt_fatal ("GET_RING_COORDS:1 Out of memory!");
+
+
+ /* Load the first segment of the ring */
+ ring->segs[n] = (SEGMENT*)xvt_zmalloc (sizeof (SEGMENT));
+ if (ring->segs[n] == NULL)
+ xvt_fatal ("GET_RING_COORDS:2 Out of memory!");
+
+ ring->segs[n]->nr_coords = edge_rec.npts;
+ ring->segs[n]->id = n+1;
+
+ /* Allocate space for the coordinates of the first segment */
+ ring->segs[n]->coords = (COORDINATE*)xvt_zmalloc ((size_t)edge_rec.npts *
+ sizeof (COORDINATE));
+ if (ring->segs[n]->coords == NULL)
+ xvt_fatal ("GET_RING_COORDS:3 Out of memory!");
+
+
+ /* If the direction is - load in reverse order */
+ if (edge_rec.dir == '-')
+ {
+ for (i=(edge_rec.npts-1); i>=0; i--)
+ {
+ dcoord = next_edge_coordinate (&edge_rec);
+ ring->segs[n]->coords[i].x = (float)dcoord.x;
+ ring->segs[n]->coords[i].y = (float)dcoord.y;
+ }
+ }
+ else
+ {
+ for (i=0; i<edge_rec.npts; i++)
+ {
+ dcoord = next_edge_coordinate (&edge_rec);
+ ring->segs[n]->coords[i].x = (float)dcoord.x;
+ ring->segs[n]->coords[i].y = (float)dcoord.y;
+ }
+ }
+
+ n++;
+ if (edge_rec.coords)
+ xvt_free ((char*)edge_rec.coords);
+
+ while (!done)
+ {
+ if (next_edge < 0)
+ {
+ xvt_note (
+ "topology error! Edge: %d face: %d left: %d right: %d\n",
+ edge_rec.id,face_id,edge_rec.left_face,edge_rec.right_face);
+ done = TRUE;
+ }
+
+ if (next_edge == 0)
+ {
+ xvt_note ("Next edge(%d) = 0\n",(int)edge_rec.id);
+ done = TRUE;
+ }
+
+ if (next_edge == start_edge)
+ done = TRUE;
+
+ if (!done)
+ {
+ edge_rec = read_edge( next_edge, edgetable, NOPROJ.inverse_proj);
+ next_edge = next_face_edge( &edge_rec, &prevnode, face_id );
+
+ /* Allocate space for the next segment */
+ ring->segs[n] = (SEGMENT*)xvt_zmalloc (sizeof (SEGMENT));
+ if (ring->segs[n] == NULL)
+ xvt_fatal ("GET_RING_COORDS:4 Out of memory!");
+
+
+ /* Allocate space for the segment coordinates */
+ ring->segs[n]->coords = (COORDINATE*)xvt_zmalloc ((size_t)edge_rec.npts *
+ sizeof (COORDINATE));
+ if (ring->segs[n]->coords == NULL)
+ xvt_fatal ("GET_RING_COORDS:5 Out of memory!");
+
+ ring->segs[n]->nr_coords = edge_rec.npts;
+ ring->segs[n]->id = n+1;
+
+
+ /* If the direction is - load in reverse order */
+ if (edge_rec.dir == '-')
+ {
+ for (i=(edge_rec.npts-1); i>=0; i--)
+ {
+ dcoord = next_edge_coordinate (&edge_rec);
+ ring->segs[n]->coords[i].x = (float)dcoord.x;
+ ring->segs[n]->coords[i].y = (float)dcoord.y;
+ }
+ }
+ else
+ {
+ for (i=0; i<edge_rec.npts; i++)
+ {
+ dcoord = next_edge_coordinate (&edge_rec);
+ ring->segs[n]->coords[i].x = (float)dcoord.x;
+ ring->segs[n]->coords[i].y = (float)dcoord.y;
+ }
+ }
+ n++;
+ if (edge_rec.coords)
+ xvt_free ((char*)edge_rec.coords);
+
+ } /* if (!done) */
+ } /* while */
+ ring->nr_segs = n;
+
+ /* Realloc the segs array to free unused memory */
+ temp = (SEGMENT**)xvt_zmalloc (ring->nr_segs * sizeof (SEGMENT*));
+ if (temp == (SEGMENT**)NULL)
+ xvt_fatal ("GET_RING_COORDS:6 Out of memory!");
+ else
+ {
+ memcpy (temp, ring->segs, (ring->nr_segs * sizeof (SEGMENT*)));
+ xvt_free ((char*)ring->segs);
+ ring->segs = temp;
+ }
+
+ return;
+ }
+
+/**********************************************************************/
+/* NEXT_FACE_EDGE */
+/* Derived from next_face_edge [vpfdraw.c] */
+/**********************************************************************/
+#ifdef PROTO
+ int32 next_face_edge (edge_rec_type *edge_rec, int32 *prevnode, int32 face_id)
+#else
+ int32 next_face_edge (edge_rec, prevnode, face_id)
+ edge_rec_type *edge_rec;
+ int32 *prevnode, face_id;
+#endif
+
+ {
+ int32 next;
+
+ if ((edge_rec->right_face == face_id) &&
+ (edge_rec->left_face == face_id))
+ {
+ /* Dangle - go the opposite dir to continue along the boundary */
+ if (*prevnode == edge_rec->start_node)
+ {
+ edge_rec->dir = '-';
+ next = edge_rec->left_edge;
+ *prevnode = edge_rec->start_node;
+ }
+ else if (*prevnode == edge_rec->end_node)
+ {
+ edge_rec->dir = '+';
+ next = edge_rec->right_edge;
+ *prevnode = edge_rec->end_node;
+ }
+ else
+ next = -1;
+ }
+ else if (edge_rec->right_face == face_id)
+ {
+ /* The face is on the right - take the right forward edge */
+ next = edge_rec->right_edge;
+ edge_rec->dir = '+';
+ *prevnode = edge_rec->end_node;
+ }
+ else if (edge_rec->left_face == face_id)
+ {
+ /* The face is on the left - take the left forward edge */
+ next = edge_rec->left_edge;
+ edge_rec->dir = '-';
+ *prevnode = edge_rec->start_node;
+ }
+ else
+ next = -1;
+
+ return next;
+ }
+
+/*****************************************************************************/
+/* GET_XY */
+/*****************************************************************************/
+#ifdef PROTO
+ COORDINATE *get_xy (vpf_table_type table, row_type row, int32 pos, int32 *count)
+#else
+ COORDINATE *get_xy (table, row, pos, count)
+ vpf_table_type table;
+ row_type row;
+ int32 pos;
+ int32 *count;
+#endif
+
+ {
+ int32 i;
+ COORDINATE *coord = NULL;
+
+ switch (table.header[pos].type)
+ {
+ case 'C':
+ {
+ coordinate_type temp, *ptr;
+ ptr = get_table_element (pos, row, table, &temp, count);
+
+ if ((*count == 1) && (ptr == (coordinate_type*)NULL))
+ {
+ coord = (COORDINATE*)xvt_zmalloc (sizeof (COORDINATE));
+ if (coord == (COORDINATE*)NULL)
+ xvt_fatal ("GET_XY:1 Out of memory!");
+ coord->x = temp.x;
+ coord->y = temp.y;
+ }
+ else
+ coord = (COORDINATE*)ptr;
+ break;
+ }
+ case 'Z':
+ {
+ tri_coordinate_type temp, *ptr;
+ ptr = get_table_element (pos, row, table, &temp, count);
+ coord = (COORDINATE*)xvt_zmalloc (sizeof (COORDINATE) * (size_t)*count);
+ if (coord == (COORDINATE*)NULL)
+ xvt_fatal ("GET_XY:2 Out of memory!");
+ if ((*count == 1) && (ptr == (tri_coordinate_type*)NULL))
+ {
+ coord->x = temp.x;
+ coord->y = temp.y;
+ }
+ else
+ {
+ for (i=0; i<*count; i++)
+ {
+ coord[i].x = ptr[i].x;
+ coord[i].y = ptr[i].y;
+ }
+ }
+ if (ptr)
+ xvt_free ((char*)ptr);
+ break;
+ }
+ case 'B':
+ {
+ double_coordinate_type temp, *ptr;
+ ptr = get_table_element (pos, row, table, &temp, count);
+ coord = (COORDINATE*)xvt_zmalloc (sizeof (COORDINATE) * (size_t)*count);
+ if (coord == (COORDINATE*)NULL)
+ xvt_fatal ("GET_XY:3 Out of memory!");
+ if ((*count == 1) && (ptr == (double_coordinate_type*)NULL))
+ {
+ coord->x = (float)temp.x;
+ coord->y = (float)temp.y;
+ }
+ else
+ {
+ for (i=0; i<*count; i++)
+ {
+ coord[i].x = (float)ptr[i].x;
+ coord[i].y = (float)ptr[i].y;
+ }
+ }
+ if (ptr)
+ xvt_free ((char*)ptr);
+ break;
+ }
+
+ case 'Y':
+ {
+ double_tri_coordinate_type temp, *ptr;
+ ptr = get_table_element (pos, row, table, &temp, count);
+ coord = (COORDINATE*)xvt_zmalloc (sizeof (COORDINATE) * (size_t)*count);
+ if (coord == (COORDINATE*)NULL)
+ xvt_fatal ("GET_XY:4 Out of memory!");
+ if ((*count == 1) && (ptr == (double_tri_coordinate_type*)NULL))
+ {
+ coord->x = (float)temp.x;
+ coord->y = (float)temp.y;
+ }
+ else
+ {
+ for (i=0; i<*count; i++)
+ {
+ coord[i].x = (float)ptr[i].x;
+ coord[i].y = (float)ptr[i].y;
+ }
+ }
+ if (ptr)
+ xvt_free ((char*)ptr);
+ break;
+ }
+
+ default:
+ xvt_note ("GET_XY: no such type %c", table.header[pos].type);
+ break;
+ } /* switch type */
+ return (coord);
+ }
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/get_feat.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/get_feat.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/get_feat.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,31 @@
+/* GET_FEATURE.H */
+
+#ifndef GET_FEATURE_H
+#define GET_FEATURE_H
+
+#ifndef H_VEC_D
+#include "../vec_d.h"
+#endif
+
+/* Prototype Definitions */
+#ifdef PROTO
+ void get_point_feature (POINT_FEATURE*, row_type, vpf_table_type);
+ void get_text_feature (TEXT_FEATURE*, row_type, vpf_table_type);
+ void get_line_feature (LINE_FEATURE*, row_type, vpf_table_type);
+ void get_area_feature (AREA_FEATURE*, int32, vpf_table_type,
+ vpf_table_type, vpf_table_type);
+ void get_ring_coords (RING*, int32, int32, vpf_table_type);
+ int32 next_face_edge (edge_rec_type*, int32*, int32);
+ COORDINATE *get_xy (vpf_table_type, row_type, int32, int32*);
+#else
+ void get_point_feature ();
+ void get_text_feature ();
+ void get_line_feature ();
+ void get_area_feature ();
+ void get_ring_coords ();
+ int32 next_face_edge ();
+ COORDINATE *get_xy ();
+#endif
+
+#endif /* GET_FEATURE_H */
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,12 @@
+#ifndef H_ARC
+#define H_ARC
+
+#ifndef H_ARC_DEF
+#include "arcdef.h"
+#endif
+
+#ifndef H_ARC_FUNC
+#include "arcfunc.h"
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,109 @@
+#ifndef H_ARC_D
+#define H_ARC_D
+
+/************************************************/
+/* Header file for ARC projection software. */
+/* Author: Jeff Buck (JB) */
+/* Company: Spatial Data Sciences (SDS) */
+/************************************************/
+
+#include <ctype.h>
+
+/*
+ * #include <malloc.h>
+ */
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define PI 3.14159265358979323
+#define RADIAN(x) (x * (PI / 180.))
+#define DEGREES(x) (x * (180. / PI))
+#define ROUND(x) ((int32)(x + .5))
+
+#define ARC_FILE "arc.dat" /* name of file containing ARC parameters */
+
+/*
+ * File offsets used by read_arc_parms()
+ */
+#define SCALE_OFFSET 1760 /* file offset to scale
+ * string */
+#define LAMBDA_OFFSET 1793 /* file offset to origin longitude
+ * string */
+#define PHI_OFFSET 1804 /* file offset to origin
+ * latitude string */
+#define TILE_SIZE_OFFSET 1909 /* file offset to tile size string */
+#define ROW1_OFFSET 1879 /* file offset to row upper
+ * left string */
+#define COL1_OFFSET 1897 /* file offset to column
+ * upper left string */
+#define ROW2_OFFSET 1891 /* file offset to row lower
+ * right string */
+#define COL2_OFFSET 1885 /* file offset to column
+ * lowerright string */
+#define ZONE_OFFSET 1769 /* file offset to image zone
+ * number */
+
+/*
+ * Length of strings to be read in by read_arc_parms()
+ */
+#define SCALE_LEN 9 /* length of scale
+ * string */
+#define LAMBDA_LEN 11 /* length of longitude string */
+#define PHI_LEN 10 /* length of latitude string */
+#define TILE_SIZE_LEN 6 /* length of tile size string */
+#define ROW_LEN 6 /* length of row string */
+#define COL_LEN 6 /* length of column string */
+#define ZONE_LEN 2 /* length of zone string */
+
+/*
+ * Error codes returned by arc()
+ */
+#define NO_ERROR 0
+#define BAD_ZONE 34
+#define BAD_SCALE 35
+#define BAD_TILE_SIZE 36
+
+/*
+ * Data structures used by ARC routines
+ */
+typedef struct lpoint
+{
+ int32 row;
+ int32 col;
+} LPOINT;
+
+typedef struct latlon
+{
+ double lat;
+ double lon;
+} LATLON;
+
+typedef struct tile_info
+{
+ int tile_row; /* row number of the tile in the image */
+ int tile_col; /* column number of the tile in the image */
+ int row; /* coordinate's row number relative to the
+ * tile */
+ int col; /* coordinate's column number relative to the
+ * tile */
+} TILE_INFO;
+
+
+#if 0
+typedef struct arc_parms
+{
+ int32 scale; /* scale of the map */
+ LATLON origin; /* lat/lon of map origin (upper left corner) */
+ LPOINT ul; /* image upper left row and column */
+ LPOINT lr; /* image lower right row and column */
+ int tile_size; /* size of a tile in pixels */
+ int zone; /* zone number of upper-left of image */
+} ARC_PARMS;
+#endif
+
+
+extern double fmod();
+extern double fabs();
+#endif /* H_ARC_D */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arc_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,36 @@
+#ifndef H_ARC_F
+#define H_ARC_F
+
+#ifndef H_ARC_D
+#include "arc_d.h"
+#endif
+
+/*
+ * Prototypes for functions in arc.c
+ */
+
+#if XVT_CC_PROTO
+int arc(int, double *, double *, int32 *, int32 *, ARC_PARMS *, TILE_INFO *);
+void arc_to_lat(int32, int32, double, double, double, double, int, double *, double *);
+double dms2dec(char *);
+void get_ab(int, double *, double *);
+int get_arc_zone(double);
+int get_overlap_coords(ARC_PARMS * parms, int32 *north_row, int32 *south_row);
+void lat_to_arc(double, double, double, double, int, double, double, int32 *, int32 *);
+int read_arc_parms(ARC_PARMS *);
+void scale_adjust(double *a, double *b, int32 scale);
+char *strip_str(char *, char);
+#else
+int arc();
+void arc_to_lat();
+double dms2dec();
+void get_ab();
+int get_arc_zone();
+int get_overlap_coords();
+void lat_to_arc();
+int read_arc_parms();
+void scale_adjust();
+char *strip_str();
+#endif
+
+#endif /* H_ARC_F */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arcdef.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arcdef.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arcdef.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,109 @@
+#ifndef H_ARC_DEF
+#define H_ARC_DEF
+
+/************************************************/
+/* Header file for ARC projection software. */
+/* Author: Jeff Buck (JB) */
+/* Company: Spatial Data Sciences (SDS) */
+/************************************************/
+
+#include <ctype.h>
+
+/*
+ * #include <malloc.h>
+ */
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define PI 3.14159265358979323
+#define RADIAN(x) (x * (PI / 180.))
+#define DEGREES(x) (x * (180. / PI))
+#define ROUND(x) ((int32)(x + .5))
+
+#define ARC_FILE "arc.dat" /* name of file containing ARC parameters */
+
+/*
+ * File offsets used by read_arc_parms()
+ */
+#define SCALE_OFFSET 1760 /* file offset to scale
+ * string */
+#define LAMBDA_OFFSET 1793 /* file offset to origin longitude
+ * string */
+#define PHI_OFFSET 1804 /* file offset to origin
+ * latitude string */
+#define TILE_SIZE_OFFSET 1909 /* file offset to tile size string */
+#define ROW1_OFFSET 1879 /* file offset to row upper
+ * left string */
+#define COL1_OFFSET 1897 /* file offset to column
+ * upper left string */
+#define ROW2_OFFSET 1891 /* file offset to row lower
+ * right string */
+#define COL2_OFFSET 1885 /* file offset to column
+ * lowerright string */
+#define ZONE_OFFSET 1769 /* file offset to image zone
+ * number */
+
+/*
+ * Length of strings to be read in by read_arc_parms()
+ */
+#define SCALE_LEN 9 /* length of scale
+ * string */
+#define LAMBDA_LEN 11 /* length of longitude string */
+#define PHI_LEN 10 /* length of latitude string */
+#define TILE_SIZE_LEN 6 /* length of tile size string */
+#define ROW_LEN 6 /* length of row string */
+#define COL_LEN 6 /* length of column string */
+#define ZONE_LEN 2 /* length of zone string */
+
+/*
+ * Error codes returned by arc()
+ */
+#define NO_ERROR 0
+#define BAD_ZONE 34
+#define BAD_SCALE 35
+#define BAD_TILE_SIZE 36
+
+/*
+ * Data structures used by ARC routines
+ */
+typedef struct lpoint
+{
+ int32 row;
+ int32 col;
+} LPOINT;
+
+typedef struct latlon
+{
+ double lat;
+ double lon;
+} LATLON;
+
+typedef struct tile_info
+{
+ int tile_row; /* row number of the tile in the image */
+ int tile_col; /* column number of the tile in the image */
+ int row; /* coordinate's row number relative to the
+ * tile */
+ int col; /* coordinate's column number relative to the
+ * tile */
+} TILE_INFO;
+
+
+#if 0
+typedef struct arc_parms
+{
+ int32 scale; /* scale of the map */
+ LATLON origin; /* lat/lon of map origin (upper left corner) */
+ LPOINT ul; /* image upper left row and column */
+ LPOINT lr; /* image lower right row and column */
+ int tile_size; /* size of a tile in pixels */
+ int zone; /* zone number of upper-left of image */
+} ARC_PARMS;
+#endif
+
+
+extern double fmod();
+extern double fabs();
+#endif /* H_ARC_DEF */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arcfunc.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arcfunc.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/arcfunc.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,32 @@
+#ifndef H_ARC_FUNC
+#define H_ARC_FUNC
+
+/*
+ * Prototypes for functions in arc.c
+ */
+
+#if XVT_CC_PROTO
+int arc(int, double *, double *, int32 *, int32 *, ARC_PARMS *, TILE_INFO *);
+void arc_to_lat(int32, int32, double, double, double, double, int, double *, double *);
+double dms2dec(char *);
+void get_ab(int, double *, double *);
+int get_arc_zone(double);
+int get_overlap_coords(ARC_PARMS * parms, int32 *north_row, int32 *south_row);
+void lat_to_arc(double, double, double, double, int, double, double, int32 *, int32 *);
+int read_arc_parms(ARC_PARMS *);
+void scale_adjust(double *a, double *b, int32 scale);
+char *strip_str(char *, char);
+#else
+int arc();
+void arc_to_lat();
+double dms2dec();
+void get_ab();
+int get_arc_zone();
+int get_overlap_coords();
+void lat_to_arc();
+int read_arc_parms();
+void scale_adjust();
+char *strip_str();
+#endif
+
+#endif /* H_ARC_FUNC */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/bmp.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/bmp.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/bmp.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,73 @@
+#ifndef H_BMP
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+
+#if XVT_OS == XVT_OS_WIN3
+#ifndef __WINDOWS_H
+#include "windows.h"
+#endif
+#else
+typedef short WORD;
+typedef int32 DWORD;
+#define BI_RGB 0
+#define BI_RLE8 1
+#define BI_RLE4 2
+#endif
+typedef char BYTE1;
+
+
+/* BITMAPFILEHEADER structure */
+
+typedef struct tag_BITMAP_FILEHEADER
+ {
+ WORD bfType; /* The type of bitmap */
+ DWORD bfSize; /* The size in DWORDS of the file */
+ WORD bfReserved1; /* Reserved zero */
+ WORD bfReserved2; /* Reserved zero */
+ DWORD bfOffBits; /* The offset in bytes from the
+ BITMAPFILEHEADER to the actual bitmap */
+ } BITMAP_FILEHEADER;
+
+/* BITMAPINFOHEADER structure */
+
+typedef struct tag_BITMAP_INFOHEADER
+ {
+ DWORD biSize; /* The size of the structure */
+ DWORD biWidth; /* The width of the bitmap */
+ DWORD biHeight; /* The height of the bitmap */
+ WORD biPlanes; /* The number of planes = 1 */
+ WORD biBitCount; /* The number of bits per pixel 1 4 8 24 */
+ DWORD biCompression; /* The compression type
+ BI_RGB(0) = not compressed
+ BI_RLE8(1)= run length encoded 8 bitsperpix
+ BI_RLE4(2)= run length encoded 4 bitsperpix */
+ DWORD biSizeImage; /* The size in bytes of the image */
+ DWORD biXPelsPerMeter; /* The horiz resolution in pixels per meter */
+ DWORD biYPelsPerMeter; /* The vert resolution in pixels per meter */
+ DWORD biClrUsed; /* The number of color indexes in the LUT
+ if = 0 use maximum for bit count
+ if not = 0 use actual number */
+ DWORD biClrImportant; /* The number of important colors */
+ } BITMAP_INFOHEADER;
+
+/* RGBQUAD structure */
+
+typedef struct tag_RGB_QUAD
+ {
+ BYTE1 rgbBlue; /* The blue value */
+ BYTE1 rgbGreen; /* The green value */
+ BYTE1 rgbRed; /* The Red value */
+ BYTE1 rgbReserved; /* The Reserved value */
+ } RGB_QUAD;
+
+/* BITMAPINFO structure */
+
+typedef struct tag_BITMAP_INFO
+ {
+ BITMAP_INFOHEADER bmiHeader;
+ RGB_QUAD *bmiColors;
+ } BITMAP_INFO;
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cb_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cb_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cb_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,19 @@
+#ifndef H_CB_DEF
+#define H_CB_DEF
+
+#define AUTO_COORD 10
+#define GUI_COORD 11
+
+#define AUTO_DATUM 20
+#define GUI_DATUM 21
+
+#define AUTO_ELLIPS 30
+#define GUI_ELLIPS 31
+
+#define GET_POINT 40
+
+#define GET_CHILD 88
+
+#define TERMINATE 99
+
+#endif /* H_CB_DEF */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cb_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cb_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cb_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,19 @@
+#ifndef H_CB_DEF
+#define H_CB_DEF
+
+#define AUTO_COORD 10
+#define GUI_COORD 11
+
+#define AUTO_DATUM 20
+#define GUI_DATUM 21
+
+#define AUTO_ELLIPS 30
+#define GUI_ELLIPS 31
+
+#define GET_POINT 40
+
+#define GET_CHILD 88
+
+#define TERMINATE 99
+
+#endif /* H_CB_DEF */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cc1_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cc1_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cc1_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,57 @@
+
+#ifndef H_CC1_F
+#define H_CC1_F
+
+#ifndef H_UNIT_DEF
+#include "unit_d.h"
+#endif
+#ifndef H_COORD_DEF
+#include "coord_d.h"
+#endif
+
+
+#if XVT_CC_PROTO
+ERRSTATUS
+coord_2_gp_radian(POINT_UNITS *user_pt, POINT_DD *radian_pt,
+ COORD_SYS *params, char *err_message);
+#else
+ERRSTATUS
+coord_2_gp_radian();
+#endif
+
+
+#if XVT_CC_PROTO
+ERRSTATUS
+gp_radian_2_coord(POINT_UNITS *user_pt, POINT_DD *radian_pt,
+ COORD_SYS *params, char *err_message);
+#else
+ERRSTATUS
+gp_radian_2_coord();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS
+input_pt_2_output_pt( COORD_SYS *in_sys, COORD_SYS *out_sys,
+ POINT_UNITS *in_pt, DTCC_OUTPUT *out_info );
+#else
+ERRSTATUS
+input_pt_2_output_pt( );
+#endif
+
+#if XVT_CC_PROTO
+void
+convert_pt_to_user_str(COORD_SYS *coord_in, POINT_UNITS *upoint, char *output);
+#else
+void
+convert_pt_to_user_str();
+#endif
+
+#if XVT_CC_PROTO
+void
+conv_lon_to_180_scale(double *rad_lon);
+#else
+void
+convert_pt_to_user_str();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cli_sr_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cli_sr_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cli_sr_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,19 @@
+#ifndef H_CLI_SR_D
+#define H_CLI_SR_D
+
+#define AUTO_COORD 10
+#define GUI_COORD 11
+
+#define AUTO_DATUM 20
+#define GUI_DATUM 21
+
+#define AUTO_ELLIPS 30
+#define GUI_ELLIPS 31
+
+#define GET_POINT 40
+
+#define GET_CHILD 88
+
+#define TERMINATE 99
+
+#endif /* CLI_SR_D */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cli_sr_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cli_sr_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/cli_sr_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,67 @@
+
+
+#ifndef H_CLI_SR_F
+
+#define H_CLI_SR_F
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+extern WINDOW dlg_wait_eh XVT_CC_ARGS((WINDOW xdWindow, EVENT *xdEvent));
+
+
+/***************************************************************
+@ dlg_wait_open()
+****************************************************************
+Invoke dialog that displays wait message while client is waiting for
+information form server
+*/
+#if XVT_CC_PROTO
+void
+dlg_wait_open(WINDOW xdWindow, char *child_str, char *parent_str);
+#else
+void
+dlg_wait_open();
+#endif
+/*
+Description:
+*/
+
+
+/***************************************************************
+@ dlg_wait_close()
+****************************************************************
+Close dialog that displays wait message while client is waiting for
+information form server
+*/
+#if XVT_CC_PROTO
+void
+dlg_wait_close( WINDOW xdWindow );
+#else
+void
+dlg_wait_close();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ do_menu_item_quit()
+****************************************************************
+*/
+#if XVT_CC_PROTO
+void
+do_menu_item_quit(WINDOW xdWindow);
+#else
+void
+do_menu_item_quit();
+#endif
+/*
+Description:
+*/
+
+
+#endif /* H_CLI_SR_F */
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/color_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/color_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/color_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,230 @@
+#ifndef H_COLOR_D
+#define H_COLOR_D
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+/***************************************************************
+@ RGB_BITS
+****************************************************************
+The default number of bits used to store RGB color values
+*/
+#define RGB_BITS 16
+
+/*
+ * Description: RGB values usually are stored as 16 bit unsigned shorts: (0 -
+ * 65545).
+ */
+
+/***************************************************************
+@ RGB_MAX
+****************************************************************
+The maximum value used to store RGB.
+*/
+#define RGB_MAX 65535L
+
+/*
+ * Description: RGB values are stored as 16 bit unsigned shorts: (0 - 65545).
+ */
+
+/***************************************************************
+@ MAX_COLORS
+****************************************************************
+Miximum number of colors allowed
+*/
+#define MAX_COLORS 256
+
+/*
+ * Description: MUSE uses 8 bit indirect color which allows 256 colors. Some
+ * of these colors are reserved by the windowing system and some are reserved
+ * by MUSE-PHIGS. Only 216 colors are available for use in raster displays.
+ */
+
+/***************************************************************
+@ MAX_LUT
+****************************************************************
+Number of look-up-table ranges
+*/
+#define MAX_LUT 6
+
+/*
+ * Description: Since MAX_LUT is used to dimension the LUT data structure,
+ * changing it may cause problems with existing LUT files and maps.
+ */
+
+/**************************************************************
+@ COLOR_PREF
+****************************************************************
+Preference for reconciling lut and palette
+*/
+typedef enum
+{
+ ALL_PURPOSE, /* Both image and terrain use default */
+ FAVOR_IMAGE, /* Lut is mapped to image palette */
+ FAVOR_TERRAIN /* Lut generates the palette */
+}
+ COLOR_PREF;
+
+/*
+ * Description: If all map windows use ALL_PURPOSE, the map windows will all
+ * use the same default palette and will not compete for the system palette.
+ * The FAVOR_IMAGE setting will result in the terrain look-up-table colors
+ * being mapped to the closest existing palette color. The FAVOR_TERRAIN
+ * setting will generate a new palette to match the lut.
+ */
+
+/***************************************************************
+@ PAL_TYPE
+****************************************************************
+Types of palettes
+*/
+
+typedef enum
+{
+ PAL_UNKNOWN, /* non-algorithmic palette- use min dist */
+ PAL_BIT_BINS, /* #bits for R,G, and B */
+ PAL_NUM_BINS, /* #bins for R, G, and B */
+ PAL_GREY /* equal R, G, B */
+}
+ PAL_TYPE;
+
+/*
+ * Description: PAL_TYPE indicates the algorithm by which it was constructed
+ * and thus how it can be used. PAL_UNKNOWN palettes have an unknown origin.
+ * Colors are classified into unknown palettes using minimum distance.
+ * PAL_BIT_BINS and PAL_NUM_BINS palettes are constructed as a 3D matrix of
+ * color with red, green, and blue on the three axes. Colors may be
+ * classified into the PAL_BIT_BINS palettes using fast bit operations.
+ * Colors may be classified into the PAL_NUM_BINS palettes using slightly
+ * slower integer math.
+ */
+
+/***************************************************************
+@ PALETTE_USAGE
+****************************************************************
+Controls use of gray and rgb palette sections
+*/
+typedef enum
+{
+ PAL_BOTH,
+ PAL_RGB_ONLY,
+ PAL_GRAY_ONLY,
+ PAL_NATIVE
+}
+ PALETTE_USAGE;
+/***************************************************************
+@ RGB24
+****************************************************************
+Structure to contain 24 bit RGB pixel
+*/
+typedef struct
+{
+ BYTE r;
+ BYTE g;
+ BYTE b;
+} RGB24;
+
+/*
+ * Description: The red, green, and blue values are stored as BYTE (unsigned
+ * char) with a range of 0-255.
+ */
+
+/***************************************************************
+@ RGB
+****************************************************************
+Structure to contain 48 bit RGB data
+*/
+typedef struct
+{
+ unsigned short r;
+ unsigned short g;
+ unsigned short b;
+} RGB;
+
+/*
+ * Description: The red, green, and blue vbalues range from 0-65535.
+ */
+
+/***************************************************************
+@ PALETTE
+****************************************************************
+Structure for a color palette
+*/
+typedef struct
+{
+ int32 magic; /* structure id */
+ PAL_TYPE type; /* how it was generated and used */
+ RGB bins; /* # bins if type is PAL_RGB_BINS */
+ USHORT first_color;/* index of first valid palette color */
+ USHORT num_colors; /* # of valid colors */
+ RGB rgb[MAX_COLORS]; /* RGBs range 0 - 65535 (16bit) */
+ FILE_SPEC palette_file; /* where it is stored */
+} PALETTE;
+
+/*
+ * Description: These objects may be created and read using
+ * palette_construct(). They may be destroyed and written using
+ * palette-destruct().
+ */
+
+/***************************************************************
+@ SHADE
+****************************************************************
+A structure containing a color saturation and value
+*/
+typedef struct
+{
+ GFLOAT sat; /* 0.0 - 1.0 range */
+ GFLOAT val; /* 0.0 - 1.0 range */
+} SHADE;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ LUT_DESC
+****************************************************************
+A look-up-table descriptor
+*/
+typedef struct
+{
+ int32 num_hues; /* number of color bands */
+ int32 num_shades; /* number of shades of each color */
+ GFLOAT data_range[2];
+ GFLOAT hue_range[2];
+ SHADE shade_range[3];
+} LUT_DESC;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ LUT
+****************************************************************
+A look-up-table
+*/
+typedef struct
+{
+ int32 magic; /* LUT version id */
+ LUT_DESC lut_desc[MAX_LUT]; /* The lut descriptors */
+ /* USHORT map[MAX_COLORS]; *//* map to nearest pal color */
+ BOOLEAN stretch; /* Fit Colors to LUT range */
+ FILE_SPEC lut_file; /* File name */
+} LUT;
+
+/*
+ * Description: Each LUT_DESCriptor defines the data, hue, saturation, and
+ * value ranges for a data range. Lut2pal() generates a palette from a lut.
+ * Lut_lookup() looks a data value up in the lut to determine its color.
+ */
+
+typedef struct
+{
+ int lr, tb, nh, ns;
+} global_sq_size;
+#endif /* H_COLOR_D */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/color_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/color_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/color_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,389 @@
+#ifndef H_COLOR_F
+
+#define H_COLOR_F
+
+#ifndef H_COLOR_D
+#include "color_d.h"
+#endif
+#ifndef H_MAPDOC_D
+#include "mapdoc_d.h"
+#endif
+
+/***************************************************************
+@ add_color_bias()
+****************************************************************
+Adds PAL_OFFSET to the raster bitmap.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API add_color_bias(GHANDLE bitmap);
+#else
+ERRSTATUS MUSE_API add_color_bias();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ color_dist()
+****************************************************************
+Computes distance between two RGB colors.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API color_dist(RGB x, RGB y, int32 *distance);
+#else
+ERRSTATUS MUSE_API color_dist();
+#endif
+
+/*
+ * Description: A simple cartesian 3D distance is computed.
+ */
+
+/***************************************************************
+@ decode_palette()
+****************************************************************
+Convert palette structure to local binary
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+decode_palette(
+ unsigned char *buffer,
+ PALETTE * palette);
+#else
+ERRSTATUS MUSE_API decode_palette();
+#endif
+
+/*
+ * Description: The palette structure information in the character buffer
+ * (binary portable Intel format) is placed into the palette structure in
+ * local binary. Used by the constructor functions while loading in a map
+ * document.
+ */
+
+/***************************************************************
+@ decode_lut()
+****************************************************************
+Convert lut structure to local binary
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+decode_lut(
+ unsigned char *record,
+ LUT * lut);
+#else
+ERRSTATUS MUSE_API decode_lut();
+#endif
+
+/*
+ * Description: The lut structure information in the character buffer (binary
+ * portable Intel format) is placed into the lut structure in local binary.
+ * Used by the constructor functions while loading in a map document.
+ */
+
+/***************************************************************
+@ encode_lut()
+****************************************************************
+Convert lut structure external form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+encode_lut(
+ unsigned char *buffer,
+ LUT * lut);
+#else
+ERRSTATUS MUSE_API encode_lut();
+#endif
+
+/*
+ * Description: The lut structure is converted to the external binary
+ * portable (Intel) format. Used by the destructor functions while preparing
+ * to store a map document.
+ */
+
+/***************************************************************
+@ encode_palette()
+****************************************************************
+Convert palette structure external form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+encode_palette(
+ unsigned char *buffer,
+ PALETTE * palette);
+#else
+ERRSTATUS MUSE_API encode_palette();
+#endif
+
+/*
+ * Description: The palette structure is converted to the external binary
+ * portable (Intel) format. Used by the destructor functions while preparing
+ * to store a map document.
+ */
+
+/***************************************************************
+@ hsv2rgb()
+****************************************************************
+Invoke a user interface dialog or window
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+hsv2rgb(GFLOAT hue, GFLOAT sat, GFLOAT val,
+ GFLOAT * r, GFLOAT * g, GFLOAT * b);
+#else
+ERRSTATUS MUSE_API hsv2rgb();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ lut_construct()
+****************************************************************
+Create a look-up-table.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+lut_construct(
+ FILE * file,
+ PALETTE * pal,
+ LUT ** lut);
+#else
+ERRSTATUS MUSE_API lut_construct();
+#endif
+
+/*
+ * Description: If the file argument is not NULL, the look_up_table will be
+ * read in from the file. Otherwise a default lut will be created. Lut's
+ * define the relationship between data values and the colors used to display
+ * them on the map.
+ */
+
+/***************************************************************
+@ lut_destruct()
+****************************************************************
+Frees up the lut memory.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+lut_destruct(
+ FILE * file,
+ BOOLEAN destruct,
+ LUT ** lut);
+#else
+ERRSTATUS MUSE_API lut_destruct();
+#endif
+
+/*
+ * Description: If the file argument is not NULL the lut is written into the
+ * file using fwrite. If the destruct argument is true the lut is removed
+ * from memory.
+ */
+
+/***************************************************************
+@ lut_lookup()
+****************************************************************
+Look up a data value in a look-up-table
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+lut_lookup(
+ LUT * lut,
+ PALETTE * pal,
+ GFLOAT data,
+ GFLOAT delta,
+ RENDER_INFO * render_info,
+ USHORT * index); /* int32 *color */
+#else
+ERRSTATUS MUSE_API lut_lookup();
+#endif
+
+/*
+ * Description: Looks up the data value and delta in the lut and returns the
+ * color index.
+ *
+ */
+
+#if 0
+/***************************************************************
+@ lut2pal()
+****************************************************************
+Generates a palette from a look-up-table
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+lut2pal(
+ LUT * lut,
+ COLOR_PREF color_pref,
+ PALETTE * pal);
+#else
+ERRSTATUS MUSE_API lut2pal();
+#endif
+
+/*
+ * Description: The color information contained in the lut in the form of
+ * hue, saturation, and value is used to generate the palette.
+ */
+#endif
+
+/***************************************************************
+@ palette_construct()
+****************************************************************
+Construct a color palette.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+palette_construct(
+ FILE * file,
+ PALETTE ** palette);
+#else
+ERRSTATUS MUSE_API palette_construct();
+#endif
+
+/*
+ * Description: If the file argument is not NULL the palette is loaded from
+ * the file. Otherwise, a default palette is created.
+ */
+
+/***************************************************************
+@ palette_destruct()
+****************************************************************
+Destroy the color palette
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+palette_destruct(
+ FILE * file,
+ BOOLEAN destruct,
+ PALETTE ** palette);
+#else
+ERRSTATUS MUSE_API palette_destruct();
+#endif
+
+/*
+ * Description: If the file argument is not NULL, the palette is read from
+ * the file, otherwise a default palette is created.
+ */
+
+/***************************************************************
+@ palette_rgbcube_construct()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API palette_rgbcube_construct(PALETTE ** pointer);
+#else
+ERRSTATUS MUSE_API palette_rgbcube_construct();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ pal_nearest_color()
+****************************************************************
+Gets a palette color from an RGB color
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+pal_nearest_color(
+ PALETTE * palette,
+ PALETTE_USAGE palette_usage,
+ RGB rgb,
+ USHORT * color_index);
+#else
+ERRSTATUS MUSE_API pal_nearest_color();
+#endif
+
+/*
+ * Description: Maps the input RGB color into the palette. The method used
+ * depends on the palette type.
+ *
+ */
+
+/***************************************************************
+@ pal_rgb_bins_construct()
+****************************************************************
+Construct a palette of RGB bins
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+pal_gen(
+ PALETTE * palette);
+#else
+ERRSTATUS MUSE_API pal_gen();
+#endif
+
+/*
+ * Description: Constructs a palette as a 3D matrix of color with red, green,
+ * and blue on the 3 axes. The palette structure must have been initialized
+ * with the desired PAL_TYPE and the bin counts for red, green, and blue. The
+ * total number of bins must not exceed 256.
+ */
+
+/***************************************************************
+@ remove_color_bias()
+****************************************************************
+Removes PAL_OFFSET from the raster bitmap.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API remove_color_bias(GHANDLE bitmap);
+#else
+ERRSTATUS MUSE_API remove_color_bias();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ rgb2uvw()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API rgb2uvw(int32 r, int32 g, int32 b, int32 *u, int32 *v, int32 *w);
+#else
+ERRSTATUS MUSE_API rgb2uvw();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ uvw2rgb()
+****************************************************************
+Sets windows and cursors during a map update.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API uvw2rgb(int32 u, int32 v, int32 w, int32 *r, int32 *g, int32 *b);
+#else
+ERRSTATUS MUSE_API uvw2rgb();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+#endif /* H_COLOR_F */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/coord_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/coord_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/coord_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1099 @@
+#ifndef H_COORD_DEF
+
+#define H_COORD_DEF
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_DATUM_DEF
+#include "datum_d.h"
+#endif
+/*#include "math.h"*/
+
+#define SZ_COORD_SYS 651 /* not used */
+/***************************************************************
+@ Misc. Constants
+****************************************************************
+*/
+#define NORTH_HEMI 0
+#define SOUTH_HEMI 1
+#define EAST_HEMI 0
+#define WEST_HEMI 1
+#define USER_DEFINED 0
+#define GET_USER_POINT 20000
+#define MAX_COORD_NAME_SIZE 60
+#define MAX_COORD_RECORD_SIZE 315
+#define MAX_NO_OF_COORD_TYPES 50
+#define MAX_COORD_UNIT_NAME_SIZE /*10*/ 20 /* 02/22/94 */
+#define MAX_COORD_PROJ_NAME_SIZE 30
+#define PNT_LABEL_LEN 13
+
+/***************************************************************
+@ MISCELLANEOUS DEFINES
+****************************************************************
+*/
+#define MUSE_ERROR(n) xvt_error(n)
+#define MUSE_LOG_CHECK /* enables check for negative log argument */
+
+
+/***************************************************************
+@ COORD_ENUM
+****************************************************************
+*/
+typedef enum
+{
+ COORD_GP,
+ COORD_UTM,
+ COORD_UPS,
+ COORD_MGRS,
+ COORD_XYZ,
+ COORD_AE,
+ COORD_AKRSO,
+ COORD_GEOREF,
+ COORD_LAM,
+ COORD_MADL,
+ COORD_MER,
+ COORD_MRSO,
+ COORD_NZMG,
+ COORD_OBM,
+ COORD_TM
+} COORD_ENUM;
+/*
+Description: User's choice for type of point coordinates.
+*/
+
+/***************************************************************
+@ PROJ_ENUM
+****************************************************************
+*/
+typedef enum
+{
+ UNIT_METERS,
+ UNIT_FEET,
+ UNIT_YARDS,
+ UNIT_INMS,
+ UNIT_MMMS,
+ UNIT_PIXMS
+} PROJ_ENUM;
+/*
+Description: User's choice for type of point coordinates.
+*/
+
+/***************************************************************
+@ GP_ENUM
+****************************************************************
+*/
+typedef enum
+{
+ UNIT_RAD,
+ UNIT_GRAD,
+ UNIT_DD,
+ UNIT_DM,
+ UNIT_DMS
+} GP_ENUM;
+/*
+Description: User's choice for type of point coordinates.
+*/
+
+/***************************************************************
+@ UNIT_ENUM
+****************************************************************
+*/
+
+typedef struct
+{
+ BOOLEAN gp ;
+ GP_ENUM gp_enum ;
+ PROJ_ENUM proj_enum;
+ BOOLEAN uses_paris_merid;
+} UNIT_ENUM;
+/*
+Description: User's choice for type of point coordinates.
+*/
+
+/***************************************************************
+@ USER_CONTROL
+****************************************************************
+*/
+typedef enum
+{
+ USER_DEFINABLE,
+ INTERNALLY_DEFINED,
+ NOT_APPLICABLE
+} USER_CONTROL;
+/*
+Description: Control dialog interface for each instance
+*/
+
+/***************************************************************
+@ DATUM_REF
+****************************************************************
+*/
+typedef struct
+{
+ char index[6];
+ USER_CONTROL user_control;
+} DATUM_REF;
+/*
+Description:
+*/
+
+/***************************************************************
+@ ELLIPS_REF
+****************************************************************
+*/
+typedef struct
+{
+ char index[3];
+ USER_CONTROL user_control;
+} ELLIPS_REF;
+/*
+Description:
+*/
+
+/***************************************************************
+@ COORD_UNIT
+****************************************************************
+*/
+typedef struct
+{
+ UNIT_ENUM unit_enum;
+ char name[MAX_COORD_UNIT_NAME_SIZE];
+ USER_CONTROL user_control;
+} COORD_UNIT;
+/*
+Description:
+*/
+
+/***************************************************************
+@ FN
+****************************************************************
+*/
+typedef struct
+{
+ double value;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} FN;
+/*
+Description:
+*/
+
+/***************************************************************
+@ FE
+****************************************************************
+*/
+typedef struct
+{
+ double value;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} FE;
+/*
+Description:
+*/
+
+/***************************************************************
+@ COORD_PROJ
+****************************************************************
+*/
+typedef struct
+{
+ COORD_ENUM coord_enum;
+ char name[MAX_COORD_PROJ_NAME_SIZE];
+ USER_CONTROL user_control;
+} COORD_PROJ;
+/*
+Description:
+*/
+
+/***************************************************************
+@ COORD_DMS
+****************************************************************
+A geo-coordinate in deg, min, sec
+*/
+typedef struct
+{
+ short d; /* degrees */
+ short m; /* minutes */
+ GFLOAT s; /* seconds */
+} COORD_DMS;
+
+/*
+ * Description:
+ */
+/***************************************************************
+@ POINT_DMS
+****************************************************************
+A point id deg, min, sec
+*/
+typedef struct
+{
+ COORD_DMS lon;
+ COORD_DMS lat;
+} POINT_DMS;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ ORIGIN_LAT
+****************************************************************
+*/
+typedef struct
+{
+ COORD_DMS point;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} ORIGIN_LAT;
+/*
+Description:
+*/
+
+/***************************************************************
+@ ORIGIN_LON
+****************************************************************
+*/
+typedef struct
+{
+ COORD_DMS point;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} ORIGIN_LON;
+/*
+Description:
+*/
+
+/***************************************************************
+@ SP1
+****************************************************************
+*/
+typedef struct
+{
+ COORD_DMS point;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} SP1;
+/*
+Description:
+*/
+
+/***************************************************************
+@ SP2
+****************************************************************
+*/
+typedef struct
+{
+ COORD_DMS point;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} SP2;
+/*
+Description:
+*/
+
+/***************************************************************
+@ CENTRAL_AZIMUTH
+****************************************************************
+*/
+typedef struct
+{
+ COORD_DMS point;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} CENTRAL_AZIMUTH;
+/*
+Description:
+*/
+
+/***************************************************************
+@ CENTRAL_SCALE
+****************************************************************
+*/
+typedef struct
+{
+ double value;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} CENTRAL_SCALE;
+/*
+Description:
+*/
+
+/***************************************************************
+@ EXTENTS
+****************************************************************
+*/
+typedef struct
+{
+ double value;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} EXTENTS;
+/*
+Description:
+*/
+
+/***************************************************************
+@ SCALE_RECIP
+ *****************************************************************/
+typedef struct
+{
+ double value;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} SCALE_RECIP;
+/*
+Description:
+*/
+
+/***************************************************************
+@ SCREEN_PPI
+ *****************************************************************/
+
+typedef struct
+{
+ double value;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} SCREEN_PPI;
+/*
+Description:
+*/
+
+/***************************************************************
+@ COORD_EXTENT
+ *****************************************************************/
+
+typedef struct
+{
+ double value;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} COORD_EXTENT;
+/*
+Description:
+*/
+
+/***************************************************************
+@ COORD_DM
+****************************************************************
+A geo-coordinate in deg, min, sec
+*/
+typedef struct
+{
+ short d; /* degrees */
+ GFLOAT m; /* minutes */
+} COORD_DM;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ POINT_DD
+****************************************************************
+A Point in decimal degrees
+*/
+typedef struct
+{
+ GFLOAT lon;
+ GFLOAT lat;
+ GFLOAT height;
+} POINT_DD;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ POINT_XY
+****************************************************************
+Any point POINT_DD structure
+*/
+
+typedef struct
+{
+ GFLOAT x;
+ GFLOAT y;
+} POINT_XY;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ POINT_XYZ
+****************************************************************
+A Point in decimal degrees
+*/
+typedef struct
+{
+ GFLOAT x;
+ GFLOAT y;
+ GFLOAT z;
+} POINT_XYZ;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ POINT_DM
+****************************************************************
+A geo-coordinate in deg, min
+*/
+typedef struct
+{
+ COORD_DM lon;
+ COORD_DM lat;
+ GFLOAT height;
+} POINT_DM;
+
+
+/***************************************************************
+@ POINT_GEOREF
+****************************************************************
+A point in GEOREF
+*/
+typedef struct
+{
+ char quad_15deg[3];
+ char quad_1deg[3];
+ int32 lonminutes;
+ int32 latminutes;
+ char georef[20]; /* string representation of above */
+ GFLOAT height;
+} POINT_GEOREF;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ POINT_MGRS
+****************************************************************
+A point in Military Grid reference System
+This is struct is to be determined
+*/
+typedef struct
+{
+ char mgrs[30];
+ GFLOAT height;
+} POINT_MGRS;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ POINT_UTM
+****************************************************************
+A point in Universal Transverse Mercator projection
+*/
+typedef struct
+{
+ int zone;
+ GFLOAT northing;
+ GFLOAT easting;
+ GFLOAT height;
+} POINT_UTM;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ POLAR_PARAMS
+****************************************************************
+Parameters for the ADRG Polar projection
+*/
+typedef struct
+{
+ GFLOAT lat0;
+ GFLOAT lon0;
+ GFLOAT brv;
+} POLAR_PARAMS;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ POINT_UNITS
+****************************************************************
+Union of available types of point-oriented user units.
+*/
+typedef union
+{
+ POINT_DD gpoint; /* changed from MUSE structure */
+ POINT_DM dm; /* added to MUSE structure */
+ POINT_DMS dms;
+ POINT_UTM utm;
+ POINT_MGRS mgrs;
+ POINT_GEOREF georef;
+ POINT_XYZ otherpnt;
+} POINT_UNITS;
+/***
+Description: Used in the conversion functions for geographic units.
+***/
+
+/***************************************************************
+@ POINT_TYPE
+****************************************************************
+Union of available types of point-oriented user units.
+*/
+typedef struct
+{
+ char promptstr[40]; /*needed by Fusion */
+ POINT_UNITS point;
+ BOOLEAN valid;
+ char label[PNT_LABEL_LEN];
+ int gp_enum;
+ double north_extent, south_extent, east_extent, west_extent;
+} POINT_TYPE;
+/***
+Description: Used in the conversion functions for geographic units.
+***/
+
+
+/***************************************************************
+@ GEO_EXTENT
+ *****************************************************************/
+
+typedef struct
+{
+ POINT_UNITS point;
+ USER_CONTROL user_control;
+ BOOLEAN valid;
+} GEO_EXTENT;
+/*
+Description:
+*/
+
+/***************************************************************
+@ COORD_PREF
+ *****************************************************************/
+
+typedef enum
+{
+ OFFSET_AND_SCALE,
+ CENTER_POINT_SCALE_IMAGE_EXTENT,
+ GEO_EXTENT_SCALE,
+ GEO_AND_IMAGE_EXTENT
+} COORD_PREF;
+/*
+Description:
+*/
+
+/***************************************************************
+@ COORD_TYPE
+****************************************************************/
+
+typedef struct
+{
+/*
+ THESE VALUES ARE RETRIEVED FROM THE COORDSYS.DAT
+ FILE.
+*/
+ char name[MAX_COORD_NAME_SIZE];
+ BOOLEAN valid;
+ BOOLEAN uses_ellipsoid;
+ DATUM_REF datum_ref;
+ ELLIPS_REF ellips_ref;
+ COORD_UNIT coord_unit;
+ FN fn;
+ FE fe;
+ COORD_PROJ coord_proj;
+ ORIGIN_LAT origin_lat;
+ ORIGIN_LON origin_lon;
+ SP1 sp1;
+ SP2 sp2;
+ CENTRAL_AZIMUTH central_azimuth;
+ CENTRAL_SCALE central_scale;
+ EXTENTS north,south,east,west;
+ SCALE_RECIP scale_reciprocal;
+/*
+ THESE VALUES ARE RETRIEVED FROM THE CLIENT
+ CALLING THIS PROGRAM.
+*/
+ SCREEN_PPI screen_ppi;
+ COORD_EXTENT height,width;
+ GEO_EXTENT geo_upper_right,geo_lower_left,geo_center;
+ COORD_PREF coord_pref;
+/* THESE VALUES ARE DERIVED BY THE "ORIGIN FUNCTIONS" OF THE
+ COORDINATE TYPES (EG TMORIG.C)
+*/
+ double ophi, olam; /* origin lat and lon in radians */
+ double b, e, es; /* additional ellipsoid parameters */
+ double ogam; /* origin meridian convergence angle in radians */
+ double oaz; /* central azimuth in radians */
+ double ta, tb, te; /* projection constants for Oblique Mercator */
+ int32 method, kodor; /* setup codes for Oblique Mercator */
+} COORD_TYPE;
+/*
+Description: Structure for storing one record from the ellipsoids
+file. Fields are the ellipsoid name, semi-major axis, flattening,
+and eccentricity squared.
+*/
+
+
+/***************************************************************
+@ COORD_FILE_INFO
+****************************************************************
+*/
+typedef struct
+{
+ COORD_TYPE coord[MAX_NO_OF_COORD_TYPES];
+ int coord_read;
+} COORD_FILE_INFO;
+/*
+Description: Structure for storing all pre-defined ellipsoids parameters
+from ellipsoids file, as well as total number of ellipsoids read, index of
+current local ellipsoid, and flag indicating whether parameters have been
+entered for the user-specified ellipsoid. ellipsoid_selected is the
+same value as datum_info->datums[datum_info->datum_selected].ellips_num.
+*/
+
+
+/***************************************************************
+@ ARCPOINT
+****************************************************************
+ARC map projection parameters
+*/
+
+typedef struct
+{
+ int32 row;
+ int32 col;
+} ARCPOINT;
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ ASPECT
+****************************************************************
+Aspect of a map projection
+*/
+typedef struct
+{
+ GFLOAT plon;
+ GFLOAT plat;
+ GFLOAT plat1;
+ GFLOAT plat2;
+} ASPECT;
+
+/*
+ * Description: Plon and plat are the points of tangency of the developable
+ * surface. Plat1 and Plat2 are the standard parallels for the Lambert
+ * Conformal Conic.
+ */
+
+
+
+/***************************************************************
+@ DIR_ENUM
+****************************************************************
+Transformation direction
+*/
+typedef enum
+{
+ TO_WGS84,
+ FROM_WGS84
+}
+ DIR_ENUM;
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ GEOGRAPHIC
+****************************************************************
+Geographic coordinates are stored internally in DD.
+*/
+typedef enum
+{
+ DD,
+ DMS,
+ GEOREF,
+ MGRS,
+ MIN,
+ SEC,
+ UTM
+}
+ GEOGRAPHIC;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ GRID_PARAMS
+****************************************************************
+*/
+typedef struct
+{
+ double a;
+ double b;
+ double e;
+ double es;
+ double fe;
+ double fn;
+ double oaz;
+ double ogam;
+ double ok;
+ double olam;
+ double slam;
+ double ta;
+ double tb;
+ double te;
+} GRID_PARAMS;
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ HOR_DATUM
+****************************************************************
+Horizontal datums
+*/
+typedef enum
+{
+ NDEFINED,
+ HD_WGS84,
+ HD_WGS72,
+ HD_NAD27,
+ HD_EUD50
+}
+ HOR_DATUM;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ LAMBER_PARAMS
+****************************************************************
+Lambert Conformal Conic map projection parameters
+*/
+typedef struct
+{
+ GFLOAT n;
+ GFLOAT F;
+ GFLOAT rho0;
+} LAMBER_PARAMS;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ LINEAR_PARAMS
+****************************************************************
+Linear (Platt-Carree) map projection parameters
+*/
+typedef struct
+{
+ GFLOAT dummy;
+} LINEAR_PARAMS;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ MERCAT_PARAMS
+****************************************************************
+Mercator map projection parameters
+*/
+typedef struct
+{
+ GFLOAT dummy;
+} MERCAT_PARAMS;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ DTCC_OUTPUT
+****************************************************************
+Data returned by main coordinate conversion and datum transformation
+routine
+*/
+typedef struct
+{
+ POINT_UNITS output_pt;
+ POINT_DD out_gp_rad_pt;
+ POINT_XYZ trans_error;
+ char err_message[80];
+} DTCC_OUTPUT;
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ PROJ_DIR
+****************************************************************
+Map projection direction
+*/
+typedef enum
+{
+ PROJ_FORWARD,
+ PROJ_REVERSE
+}
+ PROJ_DIR;
+
+/*
+ * Description: PROJ_FORWARD tells map_it() to convert from grographic
+ * coordinates to PHIGS graphics coordinates. PROJ_REVERSE tells map_it() to
+ * convert from PHIGS graphics coordinates back to geographic coordinates.
+ */
+
+/***************************************************************
+@ PROJ_NAME_LEN
+****************************************************************
+Limit on length of a projection name
+*/
+#define PROJ_NAME_LEN 30
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ PROJECTION
+****************************************************************
+Map projections
+*/
+typedef enum
+{
+ PROJ_UNDEFINED,
+ PROJ_LAMBERT1,
+ PROJ_LAMBERT2,
+ PROJ_LINEAR,
+ PROJ_MERCATOR,
+ PROJ_UPS,
+ PROJ_UTM,
+ PROJ_GRAPH,
+ PROJ_POLAR,
+ PROJ_ARC,
+ PROJ_TS
+}
+ PROJECTION;
+
+/*
+ * Projections to be added in the future: PROJ_BONNE, PROJ_MOLLWEIDE,
+ * PROJ_ORTHOGRAPHIC, PROJ_STEREOGRAPHIC, PROJ_TRANSVERSE_MERCATOR,
+ *
+ * Description:
+ */
+
+/***************************************************************
+@ STEREO_PARAMS
+****************************************************************
+Stereographic map projection parameters
+*/
+typedef struct
+{
+ GFLOAT dummy;
+} STEREO_PARAMS;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ TRANSFORM_PARAMS
+****************************************************************
+*/
+typedef struct
+{
+ char from_ellips[3]; /* isph in FORTRAN; nnfr in NT MADTRAN */
+ double from_a;
+ double from_f;
+ double from_e_sq;
+ double da;
+ double df;
+ int dx;
+ int dy;
+ int dz;
+ int ex;
+ int ey;
+ int ez;
+} TRANSFORM_PARAMS;
+/*
+Description: Structure used to store all parameters needed by
+the transformation algorithm.
+*/
+
+
+/***************************************************************
+@ TRANSM_PARAMS
+****************************************************************
+Transverse Mercator map projection parameters
+*/
+typedef struct
+{
+ int32 izone;
+} TRANSM_PARAMS;
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ TS_PARAMS
+****************************************************************
+Tessellated Spheroid map projection parameters
+*/
+typedef struct
+{
+ short ts_zone;
+ short ts_scale;
+} TS_PARAMS;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ UNITS_TYPE
+****************************************************************
+List of available types of units.
+*/
+typedef union
+{
+ GFLOAT dd2;
+ COORD_DMS dms;
+ POINT_UTM utm;
+ POINT_MGRS mgrs;
+ POINT_GEOREF georef;
+ GFLOAT mn;
+ GFLOAT sec;
+} UNITS_TYPE;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ VER_DATUM
+****************************************************************
+*/
+typedef enum
+{
+ UDEFINED,
+ VD_ELIPSOID,
+ VD_MSL
+}
+ VER_DATUM;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ ARC_PARMS
+****************************************************************
+*/
+typedef struct
+{
+ int32 scale;
+ POINT_DD origin;
+ ARCPOINT ul;
+ ARCPOINT lr;
+ int tile_size;
+ int zone;
+} ARC_PARMS;
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ DATUM
+****************************************************************
+Structure to contain the horizontal and vertical datums
+*/
+typedef struct
+{
+ HOR_DATUM hor_datum;
+ VER_DATUM ver_datum;
+} DATUM;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ MAP_POINT
+****************************************************************
+Data needed when getting a new user point
+*/
+typedef struct
+{
+ char prompt_str[80];
+ /* char *user_pt_str[40]; */
+ POINT_UNITS user_pt;
+ POINT_DD dd_pt;
+} MAP_POINT;
+
+/*
+ * Description: Data that is either needed by the dialog box that prompts
+ * user to enter a new data point, or is returned by the box.
+ */
+
+/***************************************************************
+@ PARAMS
+****************************************************************
+The union of projection-specific parameters
+*/
+typedef union
+{
+ LINEAR_PARAMS linear_params;
+ LAMBER_PARAMS lamber_params;
+ MERCAT_PARAMS mercat_params;
+ TRANSM_PARAMS transm_params;
+ ARC_PARMS arc_params;
+ TS_PARAMS ts_params;
+ POLAR_PARAMS polar_params;
+} PARAMS;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ COORD_SYS
+****************************************************************
+*/
+typedef struct
+{
+ COORD_TYPE coord;
+ DATUM_TYPE datum;
+ ELLIPS_PARAMS ellips;
+ BOOLEAN valid;
+} COORD_SYS ;
+/*
+ * Description:
+ */
+
+
+#endif /* H_COORD */
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/coord_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/coord_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/coord_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,775 @@
+#ifndef H_COORD_FUNC
+
+#define H_COORD_FUNC
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+#ifndef H_COORD_DEF
+#include "coord_d.h"
+#endif
+
+#if XVT_CC_PROTO
+void coord_sys_construct ( FILE *file , COORD_SYS **pointer );
+#else
+void coord_sys_construct ();
+#endif
+
+
+/*SR 08/07 changed argument types for geographic units to points */
+/***************************************************************
+@ dd_from_dd()
+****************************************************************
+Decimal degrees from decimal degrees
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_from_dd(
+POINT_DD *dd1, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_from_dd();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_from_dms()
+****************************************************************
+Decimal degrees from degrees, minutes, and seconds
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_from_dms(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_from_dms();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_from_georef()
+****************************************************************
+Decmial degrees from GEOREF point
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_from_georef(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_from_georef();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_from_mgrs()
+****************************************************************
+Decimal degrees from MGRS
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_from_mgrs(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_from_mgrs();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_from_min()
+****************************************************************
+Decimal degrees from minutes
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_from_min(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_from_min();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_from_sec()
+****************************************************************
+Decimal degrees from seconds
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_from_sec(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_from_sec();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_from_utm()
+****************************************************************
+Decimal degrees from UTM
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_from_utm(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_from_utm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_to_dd()
+****************************************************************
+Decimal degrees to decimal degrees
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_to_dd(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_to_dd();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_to_dms();
+****************************************************************
+Decimal degrees to degrees, minutes, and seconds
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_to_dms(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_to_dms();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_to_georef()
+****************************************************************
+Decimal degree to GEOREF point
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_to_georef(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_to_georef();
+#endif
+/*
+Description:
+
+*/
+
+
+/***************************************************************
+@ dd_to_mgrs()
+****************************************************************
+Decimal degree to MGRS
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_to_mgrs(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_to_mgrs();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_to_min()
+****************************************************************
+Decimal degrees to minutes
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_to_min(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_to_min();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dd_to_sec()
+****************************************************************
+Decimal degrees to seconds
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_to_sec(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_to_sec();
+#endif
+/*
+Description:
+
+*/
+
+
+/***************************************************************
+@ dd_to_utm()
+****************************************************************
+Decimal degrees to UTM
+*/
+#if XVT_CC_PROTO
+ERRSTATUS dd_to_utm(
+ POINT_DD *dd, POINT_UNITS *user_unit);
+#else
+ERRSTATUS dd_to_utm();
+#endif
+/*
+Description:
+
+*/
+
+
+/***************************************************************
+@ hm_from_as()
+****************************************************************
+Horizontal meters from arc seconds
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_from_as(
+ GFLOAT *hm, GFLOAT as);
+#else
+ERRSTATUS hm_from_as();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_from_hf()
+****************************************************************
+Horizontal meters from horizontal feet
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_from_hf(
+ GFLOAT *hm, GFLOAT hf);
+#else
+ERRSTATUS hm_from_hf();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_from_hkm()
+****************************************************************
+Horizontal meters from horizontal kilometers
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_from_hkm(
+ GFLOAT *hm, GFLOAT hkm);
+#else
+ERRSTATUS hm_from_hkm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_from_hl()
+****************************************************************
+Horizontal meters from horizontal leagues
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_from_hl(
+ GFLOAT *hm, GFLOAT hl);
+#else
+ERRSTATUS hm_from_hl();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_from_hm()
+****************************************************************
+Horizontal meters from horizontal meters
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_from_hm(
+ GFLOAT *hm1, GFLOAT hm2);
+#else
+ERRSTATUS hm_from_hm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_from_hnm()
+****************************************************************
+Horizontal meters from horizontal nautical miles
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_from_hnm(
+ GFLOAT *hm, GFLOAT hnm);
+#else
+ERRSTATUS hm_from_hnm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_from_hsm()
+****************************************************************
+Horizontal meters from horizontal statute miles
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_from_hsm(
+ GFLOAT *hm, GFLOAT hsm);
+#else
+ERRSTATUS hm_from_hsm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_from_hy()
+****************************************************************
+Horizontal meters from horizontal yards
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_from_hy(
+ GFLOAT *hm, GFLOAT hy);
+#else
+ERRSTATUS hm_from_hy();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_to_as()
+****************************************************************
+Horizontal meters to arc seconds
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_to_as(
+ GFLOAT hm, GFLOAT *as);
+#else
+ERRSTATUS hm_to_as();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_to_hf()
+****************************************************************
+Horizontal meters to horizontal feet
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_to_hf(
+ GFLOAT hm, GFLOAT *hf);
+#else
+ERRSTATUS hm_to_hf();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_to_hkm()
+****************************************************************
+Horizontal meters to horizontal kilometers
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_to_hkm(
+ GFLOAT hm, GFLOAT *hkm);
+#else
+ERRSTATUS hm_to_hkm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_to_hl()
+****************************************************************
+Horizontal meters to horizontal leagues
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_to_hl(
+ GFLOAT hm, GFLOAT *hl);
+#else
+ERRSTATUS hm_to_hl();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_to_hm()
+****************************************************************
+Horizontal meters to horizontal meters
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_to_hm(
+ GFLOAT hm1, GFLOAT *hm2);
+#else
+ERRSTATUS hm_to_hm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_to_hnm()
+****************************************************************
+Horizontal meters to horizontal nautical miles
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_to_hnm(
+ GFLOAT hm, GFLOAT *hnm);
+#else
+ERRSTATUS hm_to_hnm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ hm_to_hsm()
+****************************************************************
+Horizontal meters to horizontal statute miles
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_to_hsm(
+ GFLOAT hm, GFLOAT *hsm);
+#else
+ERRSTATUS hm_to_hsm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ invoke_point_dd
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+WINDOW
+invoke_point_dd(int32 data, WINDOW parent_win, RCT *rct);
+#else
+WINDOW
+invoke_point_dd();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ invoke_point_dm
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+WINDOW
+invoke_point_dm(int32 data, WINDOW parent_win, RCT *rct);
+#else
+WINDOW
+invoke_point_dm();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ invoke_point_dms
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+WINDOW
+invoke_point_dms(int32 data, WINDOW parent_win, RCT *rct);
+#else
+WINDOW
+invoke_point_dms();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ invoke_point_mgrs
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+WINDOW
+invoke_point_mgrs(int32 data, WINDOW parent_win, RCT *rct);
+#else
+WINDOW
+invoke_point_mgrs();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ invoke_point_utm
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+WINDOW
+invoke_point_utm(int32 data, WINDOW parent_win, RCT *rct);
+#else
+WINDOW
+invoke_point_utm();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ hm_to_hy()
+****************************************************************
+Horizontal meters to horizontal yards
+*/
+#if XVT_CC_PROTO
+ERRSTATUS hm_to_hy(
+ GFLOAT hm, GFLOAT *hy);
+#else
+ERRSTATUS hm_to_hy();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ mgrs_to_dd()
+****************************************************************
+Converts Military Grid Reference System to Decimal Deg.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS mgrs_to_dd(POINT_MGRS mgrs, POINT_DD dd);
+#else
+ERRSTATUS mgrs_to_dd();
+#endif
+/*
+Description:
+
+*/
+
+
+/***************************************************************
+@ sr_from_sipd()
+****************************************************************
+Scale reciprocal from scale inches per degree
+*/
+#if XVT_CC_PROTO
+ERRSTATUS sr_from_sipd(
+ GFLOAT *sr, GFLOAT sipd);
+#else
+ERRSTATUS sr_from_sipd();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ sr_from_sr()
+****************************************************************
+Scale reciprocal from scale reciprocal
+*/
+#if XVT_CC_PROTO
+ERRSTATUS sr_from_sr(
+ GFLOAT *sr1, GFLOAT sr2);
+#else
+ERRSTATUS sr_from_sr();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ sr_to_sipd()
+****************************************************************
+Scale reciprocal to scale inches per degree
+*/
+#if XVT_CC_PROTO
+ERRSTATUS sr_to_sipd(
+ double sr, double *user_unit);
+#else
+ERRSTATUS sr_to_sipd();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ sr_to_sr()
+****************************************************************
+Scale reciprocal to scale reciprocal
+*/
+#if XVT_CC_PROTO
+ERRSTATUS sr_to_sr(
+ double sr1, double *user_unit);
+#else
+ERRSTATUS sr_to_sr();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ utm_to_dd()
+****************************************************************
+Converts Universal Transverse Mercator to Decimal Deg.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS utm_to_dd(POINT_UTM utm, POINT_DD dd);
+#else
+ERRSTATUS utm_to_dd();
+#endif
+/*
+Description:
+
+*/
+
+
+/***************************************************************
+@ vm_from_vf()
+****************************************************************
+Vertical meters from vertical fathoms
+*/
+#if XVT_CC_PROTO
+ERRSTATUS vm_from_vf(
+ GFLOAT *vm, GFLOAT vf);
+#else
+ERRSTATUS vm_from_vf();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ vm_from_vft()
+****************************************************************
+Vertical meters from vertical feet
+*/
+#if XVT_CC_PROTO
+ERRSTATUS vm_from_vft(
+ GFLOAT *vm, GFLOAT vft);
+#else
+ERRSTATUS vm_from_vft();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ vm_from_vm()
+****************************************************************
+Vertical meters from vertical meters
+*/
+#if XVT_CC_PROTO
+ERRSTATUS vm_from_vm(
+ GFLOAT *vm1, GFLOAT vm2);
+#else
+ERRSTATUS vm_from_vm();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ vm_to_vf()
+****************************************************************
+Vertical meters to vertical fathoms
+*/
+#if XVT_CC_PROTO
+ERRSTATUS vm_to_vf(
+ GFLOAT vm, GFLOAT *user_unit);
+#else
+ERRSTATUS vm_to_vf();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ vm_to_vft()
+****************************************************************
+Vertical meters to vertical feet
+*/
+#if XVT_CC_PROTO
+ERRSTATUS vm_to_vft(
+ GFLOAT vm, GFLOAT *user_unit);
+#else
+ERRSTATUS vm_to_vft();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ vm_to_vm()
+****************************************************************
+Vertical meters to vertical meters
+*/
+#if XVT_CC_PROTO
+ERRSTATUS vm_to_vm(
+ GFLOAT vm1, GFLOAT *user_unit);
+#else
+ERRSTATUS vm_to_vm();
+#endif
+/*
+Description:
+
+*/
+
+#endif /* H_COORD */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/datum_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/datum_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/datum_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,78 @@
+#ifndef H_DATUM_DEF
+
+#define H_DATUM_DEF
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+#ifndef H_ELLIPS_DEF
+#include "ellips_d.h"
+#endif
+
+
+/***************************************************************
+@ Max Constants
+****************************************************************
+*/
+#define MAX_DATUM_AREA_SIZE 55
+#define MAX_DATUM_NAME_SIZE 45
+#define MAX_DATUM_RECORD_SIZE 250
+#define MAX_NO_OF_DATUMS 300
+/*
+Description: First three constants are used to declare strings
+for storing datum country\area, datum name, and ellipsoid name. Next
+two are for declaring strings to read in each line of datum.dat and
+ellips.dat. Last two are used to declare the arrays which store the
+information in the datum and ellipsoid input files
+*/
+
+/***************************************************************
+@ DATUM_TYPE
+****************************************************************
+*/
+typedef struct
+{
+ char name[MAX_DATUM_NAME_SIZE];
+ char ellips_num[3];
+ int dx;
+ int dy;
+ int dz;
+ char area[MAX_DATUM_AREA_SIZE];
+ int ex;
+ int ey;
+ int ez;
+ int n_points;
+ char index[6];
+ BOOLEAN valid;
+} DATUM_TYPE;
+/*
+Description: Structure for storing one record from the datums
+file. Fields are datum name, index into ellipsoid array for
+the datum's ellipsoid, ellipsoid center translations, country/
+area name, and transformation sigmas.
+*/
+
+/***************************************************************
+@ DATUM_FILE_INFO
+****************************************************************
+*/
+typedef struct
+{
+ DATUM_TYPE datums[MAX_NO_OF_DATUMS];
+ int datums_read;
+ int input_datum; /* new--replaces datum_selected */
+ int output_datum; /* new */
+ BOOLEAN need_user_info;
+} DATUM_FILE_INFO;
+/*
+Description: Structure for storing all pre-defined datums parameters
+from datums file, as well as total number of datums read, index of
+current local datum, and flag indicating whether parameters have been
+entered for the user-specified datum.
+*/
+
+
+
+#endif /* H_DATUM_DEF */
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/datum_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/datum_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/datum_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,87 @@
+
+
+#ifndef H_DATUM_F
+#define H_DATUM_F
+
+
+#include "stdlib.h"
+
+#if XVT_OS == XVT_OS_WIN
+#include "float.h"
+#endif
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+
+/***************************************************************
+@ datum_transform();
+****************************************************************
+Driver for calling various datum transformation routines
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS
+datum_transform(POINT_DD *from_gp_radian_pt, POINT_DD *to_gp_radian_pt,
+ POINT_XYZ *error,
+ DATUM_TYPE *loc_datum, ELLIPS_PARAMS *loc_ellips,
+ int transform_dir);
+#else
+ERRSTATUS
+datum_transform();
+#endif
+
+/* Prototypes formerly in madfunc.h */
+/***************************************************************
+@ molerror();
+****************************************************************
+Calculates transformation uncertainty
+*/
+#if XVT_CC_PROTO
+void molerror( POINT_DD *pt, TRANSFORM_PARAMS *params, POINT_XYZ *error);
+#else
+void molerror();
+#endif
+/*
+Description: Based on the translation sigmas and the coordinates
+of the transformation point, calculates uncertainty of latitude, longitude
+and height in meters. The error equations are derived by geometric
+projection of x, y and z vectors to latitude, longitude and height.
+*/
+
+
+/***************************************************************
+@ molod();
+****************************************************************
+Performs Molodensky datum transformation
+*/
+#if XVT_CC_PROTO
+void molod( POINT_DD *from_pt, POINT_DD *delta,
+ TRANSFORM_PARAMS *params);
+#else
+void molod();
+#endif
+/*
+Description: Performs Molodensky datum transformation in all cases except for WGS72.
+See DMA TR 8350.2.
+*/
+
+
+
+/***************************************************************
+@ wgs72();
+****************************************************************
+Performs datum transformation for the special case when the local
+datum is WGS 1972.
+*/
+#if XVT_CC_PROTO
+void wgs72( POINT_DD *from_pt, POINT_DD *delta,
+ TRANSFORM_PARAMS *params);
+#else
+void wgs72();
+#endif
+/*
+Description: Transforms WGS 72 coordinates to WGS 84 and the reverse.
+*/
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,16 @@
+#ifndef H_DTCC_D
+
+#define H_DTCC_D
+
+#ifndef H_COORD_DEF
+#include "coord_d.h"
+#endif
+#ifndef H_DATUM_DEF
+#include "datum_d.h"
+#endif
+#ifndef H_ELLIPS_DEF
+#include "ellips_d.h"
+#endif
+/*#include "unit_d.h"*/
+
+#endif /*H_DTCC_D*/
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_dn.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_dn.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_dn.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,8 @@
+#ifndef H_DTCC_DN
+#define H_DTCC_DN
+
+#ifndef H_MGM_D
+#include "mgm_d.h"
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,140 @@
+#ifndef H_DTCC_F
+
+#define H_DTCC_F
+
+#ifndef H_COORD_DEF
+#include "coord_d.h"
+#endif
+#ifndef H_COORD_FUNC
+#include "coord_f.h"
+#endif
+
+
+/***************************************************************
+@ check_for_ups();
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+check_for_ups(double sphi, int32 *izone, double *y, double *x, char *mgrs,
+ int32 *iarea, double degrad);
+#else
+BOOLEAN
+check_for_ups();
+#endif
+
+
+/***************************************************************
+@ check_for_zone_and_100kms_error();
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+check_for_zone_and_100kms_error(int iset, char *string);
+#else
+BOOLEAN
+check_for_zone_and_100kms_error();
+#endif
+
+
+/***************************************************************
+@ coord_2_gp_radian();
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+coord_2_gp_radian(POINT_UNITS *user_pt, POINT_DD *radian_pt,
+ COORD_SYS *params, char *err_message);
+#else
+ERRSTATUS
+coord_2_gp_radian();
+#endif
+
+
+/***************************************************************
+@ gp_radian_2_coord();
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+gp_radian_2_coord(POINT_UNITS *user_pt, POINT_DD *radian_pt,
+ COORD_SYS *params, char *err_message);
+#else
+ERRSTATUS
+gp_radian_2_coord();
+#endif
+
+/***************************************************************
+@ datum_transform();
+****************************************************************
+Driver for calling various datum transformation routines
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS
+datum_transform(POINT_DD *from_gp_radian_pt, POINT_DD *to_gp_radian_pt,
+ POINT_XYZ *error,
+ DATUM_TYPE *loc_datum, ELLIPS_PARAMS *loc_ellips,
+ int transform_dir);
+#else
+ERRSTATUS
+datum_transform();
+#endif
+
+/* Prototypes formerly in madfunc.h */
+/***************************************************************
+@ molerror();
+****************************************************************
+Calculates transformation uncertainty
+*/
+#if XVT_CC_PROTO
+void molerror( POINT_DD *pt, TRANSFORM_PARAMS *params, POINT_XYZ *error);
+#else
+void molerror();
+#endif
+/*
+Description: Based on the translation sigmas and the coordinates
+of the transformation point, calculates uncertainty of latitude, longitude
+and height in meters. The error equations are derived by geometric
+projection of x, y and z vectors to latitude, longitude and height.
+*/
+
+
+/***************************************************************
+@ molod();
+****************************************************************
+Performs Molodensky datum transformation
+*/
+#if XVT_CC_PROTO
+void molod( POINT_DD *from_pt, POINT_DD *delta,
+ TRANSFORM_PARAMS *params);
+#else
+void molod();
+#endif
+/*
+Description: Performs Molodensky datum transformation in all cases except for WGS72.
+See DMA TR 8350.2.
+*/
+
+
+
+/***************************************************************
+@ wgs72();
+****************************************************************
+Performs datum transformation for the special case when the local
+datum is WGS 1972.
+*/
+#if XVT_CC_PROTO
+void wgs72( POINT_DD *from_pt, POINT_DD *delta,
+ TRANSFORM_PARAMS *params);
+#else
+void wgs72();
+#endif
+/*
+Description: Transforms WGS 72 coordinates to WGS 84 and the reverse.
+*/
+#endif /* H_DTCC_F */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_fn.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_fn.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/dtcc_fn.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1086 @@
+#ifndef H_DTCC_FN
+#define H_DTCC_FN
+
+/*#include "fusion_d.h"*/
+
+#ifndef H_MGM_FUNC
+#include "mgm_f.h"
+#endif
+#ifndef H_ARC_F
+#include "arc_f.h"
+#endif
+#ifndef H_TS_F
+#include "ts_f.h"
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API polar_geo_to_cr(double *geo, double *cr, double *geo0, double brv);
+ERRSTATUS MUSE_API polar_cr_to_geo(double *cr, double *geo, double *geo0, double brv);
+#else
+ERRSTATUS MUSE_API polar_geo_to_cr();
+ERRSTATUS MUSE_API polar_cr_to_geo();
+#endif
+
+/***************************************************************
+@ bit_to_geo()
+****************************************************************
+Converts a bit map coordinate to geographic
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+bit_to_geo(MGM * mgm,
+ GFLOAT bitx, GFLOAT bity,
+ GFLOAT * londd, GFLOAT * latdd);
+#else
+ERRSTATUS MUSE_API bit_to_geo();
+#endif
+
+/*
+ * Description: Using the map geometry in the first argument, the bitx and
+ * bity are inverse map projected to decimal degrees (last 2 args). Bitmap
+ * coordinates are the indices into the raster basemap files and images.
+ */
+
+/***************************************************************
+@ bit_to_win()
+****************************************************************
+Converts a bitmap coordinate to a window coordinate.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+bit_to_win(WINDOW xvt_win,
+ GFLOAT bitx, GFLOAT bity,
+ GFLOAT * winx, GFLOAT * winy);
+#else
+ERRSTATUS MUSE_API bit_to_win();
+#endif
+
+/*
+ * Description: Bitmap coordinates are indices into the raster objects. Their
+ * origin is at the lower left. Window coordinates are returned in mouse
+ * event records. Their origin is at the upper left.
+ */
+
+/***************************************************************
+@ cot()
+****************************************************************
+cotangent function
+*/
+
+#if XVT_CC_PROTO
+double cot(double a);
+#else
+double cot();
+#endif
+
+/*
+ * Description:
+ *
+ */
+/***************************************************************
+@ geo_to_bit()
+****************************************************************
+Convert the geographic coordinate to a bit map or raster coord.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+geo_to_bit(MGM * mgm,
+ GFLOAT londd, GFLOAT latdd,
+ GFLOAT * bitx, GFLOAT * bity);
+#else
+ERRSTATUS MUSE_API geo_to_bit();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ geo_to_user_str()
+****************************************************************
+Convert the geographic coordinate to user formatted string
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API geo_to_user_str(short geo_units, POINT_DD * value, char *output);
+#else
+ERRSTATUS MUSE_API geo_to_user_str();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API user_str_to_geo(short geo_units, POINT_DD * value, char *output);
+#else
+ERRSTATUS MUSE_API user_str_to_geo();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ geo_to_win()
+****************************************************************
+Convert the geographic coordinate to a window coordinate
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+geo_to_win(MGM * mgm, WINDOW xvt_win,
+ GFLOAT londd, GFLOAT latdd,
+ GFLOAT * winx, GFLOAT * winy);
+#else
+ERRSTATUS MUSE_API geo_to_win();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ geo_to_view()
+****************************************************************
+Convert the geographic coordinate to a view coordinate
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+geo_to_view(MGM * mgm, WINDOW xvt_win,
+ GFLOAT londd, GFLOAT latdd,
+ GFLOAT * viewx, GFLOAT * viewy);
+#else
+ERRSTATUS MUSE_API geo_to_view();
+#endif
+
+/*
+ * Description: The input geographic coordinate is in decimal degrees. The
+ * output is a view coordinate which is a window coordinate which may have
+ * been zoomed and scrolled.
+ */
+
+
+/***********************************************************
+@ get_user_pt()
+************************************************************
+Invoke a dialog box that allows entry of a map point in user units
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API get_user_pt
+ (
+ MAP_POINT * map_point,
+ GEOGRAPHIC user_units
+);
+#else
+ERRSTATUS MUSE_API get_user_pt();
+#endif
+
+/***************************************************************
+@ lamber_config()
+****************************************************************
+Configure the Lambert Conformal Conic projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API lamber_config(MGM * mgm);
+#else
+ERRSTATUS MUSE_API lamber_config();
+#endif
+
+/*
+ * Description: Performs the necessary calculations to fit the requested
+ * geo-area into the image bitmap.
+ *
+ */
+
+/***************************************************************
+@ lamber_map()
+****************************************************************
+Forward Lambert Conformal Conic projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+lamber_map(
+ MGM * mgm,
+ GFLOAT londd,
+ GFLOAT latdd,
+ GFLOAT * x,
+ GFLOAT * y);
+#else
+ERRSTATUS MUSE_API lamber_map();
+#endif
+
+/*
+ * Description: Converts the geo-coordinate into a map image coordinate.
+ *
+ */
+
+/***************************************************************
+@ lamber_unmap()
+****************************************************************
+Reverse Lambert Conformal Conic projection
+
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+lamber_unmap(
+ MGM * mgm,
+ GFLOAT * londd,
+ GFLOAT * latdd,
+ GFLOAT x,
+ GFLOAT y);
+#else
+ERRSTATUS MUSE_API lamber_unmap();
+#endif
+
+/*
+ * Description: Converts the map image coordinate into a geo-coordinate.
+ *
+ */
+
+/***************************************************************
+@ linear_config()
+****************************************************************
+Configure the linear map projction
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API linear_config(MGM * mgm);
+#else
+ERRSTATUS MUSE_API linear_config();
+#endif
+
+/*
+ * Description: Performs the necessary calculations to fit the requested
+ * geo-area into the image bitmap.
+ *
+ */
+
+/***************************************************************
+@ linear_map()
+****************************************************************
+Forward linear projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+linear_map(
+ MGM * mgm,
+ GFLOAT londd,
+ GFLOAT latdd,
+ GFLOAT * x,
+ GFLOAT * y);
+#else
+ERRSTATUS MUSE_API linear_map();
+#endif
+
+/*
+ * Description: Converts the geo-coordinate into a map image coordinate.
+ *
+ */
+
+/***************************************************************
+@ lon180()
+****************************************************************
+Convert longitude to +-180
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API lon180(double *longitude);
+#else
+ERRSTATUS MUSE_API lon180();
+#endif
+
+/*
+ * Description: Longitude in decimal degrees is converted to the range -180
+ * to +180.
+ *
+ */
+
+/***************************************************************
+@ lon360()
+****************************************************************
+Convert longitude to 0-360
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API lon360(double *longitude);
+#else
+ERRSTATUS MUSE_API lon360();
+#endif
+
+/*
+ * Description: Longitude in decimal degrees is converted to the range 0 to
+ * 360.
+ *
+ */
+
+/***************************************************************
+@ linear_unmap()
+****************************************************************
+Reverse linear projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+linear_unmap(
+ MGM * mgm,
+ GFLOAT * londd,
+ GFLOAT * latdd,
+ GFLOAT x,
+ GFLOAT y);
+#else
+ERRSTATUS MUSE_API linear_unmap();
+#endif
+
+/*
+ * Description: Converts the map image coordinate into a geo-coordinate.
+ *
+ */
+
+/***************************************************************
+@ map()
+****************************************************************
+Map the geographic coordinate into a bit map and PHIGS coord
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+map(
+ MGM * mgm,
+ GFLOAT londd,
+ GFLOAT latdd,
+ GFLOAT * x,
+ GFLOAT * y);
+#else
+ERRSTATUS MUSE_API map();
+#endif
+
+/*
+ * Description: Converts the geo-coordinate into a map image coordinate.
+ *
+ */
+/***************************************************************
+@ mercat_config()
+****************************************************************
+Configure Mercator projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API mercat_config(MGM * mgm);
+#else
+ERRSTATUS MUSE_API mercat_config();
+#endif
+
+/*
+ * Description: Performs the necessary calculations to fit the requested
+ * geo-area into the image bitmap.
+ *
+ */
+
+/***************************************************************
+@ mercat_map()
+****************************************************************
+Forward Mercator projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+mercat_map(
+ MGM * mgm,
+ GFLOAT londd,
+ GFLOAT latdd,
+ GFLOAT * x,
+ GFLOAT * y);
+#else
+ERRSTATUS MUSE_API mercat_map();
+#endif
+
+/*
+ * Description: Converts the geo-coordinate into a map image coordinate.
+ *
+ */
+
+/***************************************************************
+@ mercat_unmap()
+****************************************************************
+Reverse Mercator projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+mercat_unmap(
+ MGM * mgm,
+ GFLOAT * londd,
+ GFLOAT * latdd,
+ GFLOAT x,
+ GFLOAT y);
+#else
+ERRSTATUS MUSE_API mercat_unmap();
+#endif
+
+/*
+ * Description: Converts the map image coordinate into a geo-coordinate.
+ *
+ */
+
+/***************************************************************
+@ mgm_adjust()
+****************************************************************
+Adjust the map geometry
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+mgm_adjust(
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API mgm_adjust();
+#endif
+
+/*
+ * Description: Adjusts mgm parameters according to the CONFIG_PREF.
+ *
+ */
+
+/***************************************************************
+@ mgm_config()
+****************************************************************
+Configure an MGM object.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API mgm_config(MGM * mgm);
+#else
+ERRSTATUS MUSE_API mgm_config();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ mgm_construct()
+****************************************************************
+Allocates space for a map MGM object.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+mgm_construct(
+ FILE * file,
+ MGM ** mgm,
+ DEFAULTS * defaults);
+#else
+ERRSTATUS MUSE_API mgm_construct();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ mgm_defaults()
+****************************************************************
+Assigns default parameters for the map geometry.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+mgm_defaults(
+ MGM * mgm, DEFAULTS * defaults);
+#else
+ERRSTATUS MUSE_API mgm_defaults();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ mgm_destruct()
+****************************************************************
+Destroys the MGM object.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+mgm_destruct(
+ FILE * file,
+ BOOLEAN destruct,
+ MGM ** mgm);
+#else
+ERRSTATUS MUSE_API mgm_destruct();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ mgm_fit()
+****************************************************************
+Fit the geographic area to the bit map image
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+mgm_fit(
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API mgm_fit();
+#endif
+
+/*
+ * Description: Performs the necessary calculations to fit the requested
+ * geo-area into an arbitrary output coordinate range.
+ *
+ */
+
+/***************************************************************
+@ map_it()
+****************************************************************
+Performs map projection, both forward and reverse
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+map_it(MGM * mgm, PROJ_DIR forward_or_reverse,
+ GFLOAT * londd, GFLOAT * latdd,
+ GFLOAT * phigs_x, GFLOAT * phigs_y);
+#else
+ERRSTATUS MUSE_API map_it();
+#endif
+
+/*
+ * Description: The map geometry object mgm is used project in the direction
+ * given by forward_or_reverse. Note that forward_or_reverse determine
+ * whether the GP is computed based on the xy or vice versa, so bad things
+ * will happen with no error messages if this function is misused.
+ */
+
+/***************************************************************
+@ mgm_is_ok()
+****************************************************************
+Check the MGM structure for DMA legal usage
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API mgm_is_ok(MGM * mgm, char *what_is_wrong);
+#else
+ERRSTATUS MUSE_API mgm_is_ok();
+#endif
+
+/*
+ * Description: If the mgm object is valid according to the DMA rules of map
+ * projection usage, STAT_SUCCESS is returned. If the mgm object is not
+ * legal, then STAT_INV_PROJ is returned and the string argument
+ * what_is_wrong contains a description of the problem.
+ */
+
+/***************************************************************
+@ mgm_setup()
+****************************************************************
+Setup the map geometry
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API mgm_set
+ (
+ int proj,
+ PROJECTION * projection
+);
+#else
+ERRSTATUS MUSE_API mgm_set();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ mgm_setup()
+****************************************************************
+Setup the map geometry
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+mgm_setup(
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API mgm_setup();
+#endif
+
+/*
+ * Description: Configures the map geometry object according to the mode
+ * specified by MGM->CONFIG_PREF
+ *
+ */
+
+/***************************************************************
+@ mgm_subclass()
+****************************************************************
+Sub-class the map geometry object to a particular projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+mgm_subclass(
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API mgm_subclass();
+#endif
+
+/*
+ * Description: Assigns the generic map, unmap, and mgm_config pointers to a
+ * specific projection.
+ *
+ */
+
+
+/***************************************************************
+@ stereo_config()
+****************************************************************
+Configure the stereographic map projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+stereo_config(
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API stereo_config();
+#endif
+
+/*
+ * Description: Performs the necessary calculations to fit the requested
+ * geo-area into the image bitmap.
+ *
+ */
+
+/***************************************************************
+@ transm_config()
+****************************************************************
+Configure transverse Mercator projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+transm_config(
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API transm_config();
+#endif
+
+/*
+ * Description: Performs the necessary calculations to fit the requested
+ * geo-area into the image bitmap.
+ *
+ */
+
+/***************************************************************
+@ transm_map()
+****************************************************************
+Forward transverse Mercator projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+transm_map(
+ MGM * mgm,
+ GFLOAT londd,
+ GFLOAT latdd,
+ GFLOAT * x,
+ GFLOAT * y);
+#else
+ERRSTATUS MUSE_API transm_map();
+#endif
+
+/*
+ * Description: Converts the geo-coordinate into a map image coordinate.
+ *
+ */
+
+/***************************************************************
+@ transm_unmap()
+****************************************************************
+Reverse transverse Mercator projection
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+transm_unmap(
+ MGM * mgm,
+ GFLOAT * londd,
+ GFLOAT * latdd,
+ GFLOAT x,
+ GFLOAT y);
+#else
+ERRSTATUS MUSE_API transm_unmap();
+#endif
+
+/*
+ * Description: Converts the map image coordinate into a geo-coordinate.
+ *
+ */
+
+/***************************************************************
+@ unmap()
+****************************************************************
+
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+unmap(
+ MGM * mgm,
+ GFLOAT * londd,
+ GFLOAT * latdd,
+ GFLOAT x,
+ GFLOAT y);
+#else
+ERRSTATUS MUSE_API unmap();
+#endif
+
+/*
+ * Description: Converts the display coordinate to the equivalent geographic
+ * coordinate.
+ *
+ */
+
+/********************************************************************
+@ upnset()
+*********************************************************************
+Set MGRS info for northern polar zone
+*/
+
+#if XVT_CC_PROTO
+void
+upnset(
+ int32 n,
+ int32 *ltrlow,
+ int32 *ltrhi,
+ double *feltr,
+ double *fnltr,
+ int32 *ltrhy);
+#else
+void upnset();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/********************************************************************
+@ upsset()
+*********************************************************************
+Set MGRS info for southern polar zone
+*/
+
+#if XVT_CC_PROTO
+void
+upsset(
+ int32 n,
+ int32 *ltrlow,
+ int32 *ltrhi,
+ double *feltr,
+ double *fnltr,
+ int32 *ltrhy);
+#else
+void upsset();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/********************************************************************
+@ utmlim()
+*********************************************************************
+UTM lim
+*/
+
+#if XVT_CC_PROTO
+void
+utmlim(
+ int32 *n,
+ double sphi,
+ int32 izone,
+ double *spsou,
+ double *spnor,
+ double *sleast,
+ double *slwest);
+#else
+void utmlim();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+
+/********************************************************************
+@ shiftr
+*********************************************************************
+Shiftr
+*/
+
+#if XVT_CC_PROTO
+void
+shiftr(
+ char *mgrs,
+ int P1,
+ int32 n,
+ int32 *nchar);
+#else
+void shift();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/********************************************************************
+@ dmsh
+*********************************************************************
+Radians to degrees, minutes, seconds (????)
+*/
+
+#if XVT_CC_PROTO
+void
+dmsh(
+ int32 khem,
+ double radian,
+ int32 *id,
+ int32 *im,
+ double *rs,
+ char *ah,
+ int P1);
+#else
+void dmsh();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+
+
+/*********************************************************************
+@ utmtgp
+**********************************************************************
+Universal Transverse Mercator to GP
+*/
+
+#if XVT_CC_PROTO
+void
+utmtgp(
+ double a,
+ double recf,
+ double *sphi,
+ double *slam,
+ int32 izone,
+ double *y,
+ double x);
+#else
+void utmtgp();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+
+/*********************************************************************
+@ fifdint
+**********************************************************************
+Source code from the Promula.Fortran library
+*/
+
+#if XVT_CC_PROTO
+double
+fifdint(
+ double a);
+#else
+double fifdint();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/********************************************************************
+@ fifdnint
+*********************************************************************
+Source code from the Promula.Fortran library
+*/
+
+#if XVT_CC_PROTO
+double
+fifdnint(
+ double a);
+#else
+double fifdnint();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/**********************************************************************
+@ fifichar
+***********************************************************************
+Source code from the Promula.Fortran library
+*/
+
+#if XVT_CC_PROTO
+int
+fifichar(
+ unsigned char *c1);
+#else
+int fifichar();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/********************************************************************
+@ fifidint
+*********************************************************************
+Source code from the Promula.Fortran library
+*/
+
+#if XVT_CC_PROTO
+int32
+fifidint(
+ double a);
+#else
+int32 fifidint();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/*********************************************************************
+@ fifmod
+**********************************************************************
+Source code from the Promula.Fortran library
+*/
+
+#if XVT_CC_PROTO
+int32
+fifmod(
+ int32 num,
+ int32 dem);
+#else
+int32 fifmod();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/*********************************************************************
+@ fifnint
+**********************************************************************
+Source code from the Promula.Fortran library
+*/
+
+#if XVT_CC_PROTO
+int32
+fifnint(
+ double a);
+#else
+int32 fifnint();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/**********************************************************************
+@ ftncms
+***********************************************************************
+Source code from the Promula.Fortran library
+*/
+
+#if XVT_CC_PROTO
+int
+ftncms(
+ char *s1,
+ int n1,
+ char *s2,
+ int n2);
+#else
+int ftncms();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/**********************************************************************
+@ ftnsac
+***********************************************************************
+Source code from the Promula.Fortran library
+*/
+
+#if XVT_CC_PROTO
+void
+ftnsac(
+ char *s1,
+ int n1,
+ char *s2,
+ int n2);
+#else
+void ftnsac();
+#endif
+
+/*
+ * Description:
+ *
+ */
+#endif /* H_DTCC_FN */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ellips_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ellips_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ellips_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,120 @@
+#ifndef H_ELLIPS_DEF
+
+#define H_ELLIPS_DEF
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+
+/***************************************************************
+@ WGS 84 ellipsoid parameters
+****************************************************************
+*/
+#define WGS84_A 6378137.0
+#define WGS84_F 1.0 / 298.257223563
+#define WGS84_E_SQ 2.0 * WGS84_F - WGS84_F * WGS84_F
+#define WGS84_ELLIPS_INDEX 21
+/*
+Description: Semi-major axis, flattening, eccentricity squared,
+and index in the ellipsoids array
+*/
+
+/***************************************************************
+@ Max Constants
+****************************************************************
+*/
+#define MAX_ELLIPS_NAME_SIZE 60
+#define MAX_ELLIPS_RECORD_SIZE 100
+#define MAX_NO_OF_ELLIPSOIDS 30
+/*
+Description: First three constants are used to declare strings
+for storing datum country\area, datum name, and ellipsoid name. Next
+two are for declaring strings to read in each line of datum.dat and
+ellips.dat. Last two are used to declare the arrays which store the
+information in the datum and ellipsoid input files
+*/
+
+/* API */
+/* TEMP: move #define and IPC to a more suitable location */
+
+#define SIZE_FILENAME SZ_FNAME
+
+/***************************************************************
+@ IPC
+***************************************************************/
+typedef struct
+{
+ char client_name[SIZE_FILENAME];
+ short server_id;
+} IPC;
+/*
+Description: Structure for storing identifiers used in interprocess communication between a client program
+and a server program.
+*/
+
+/***************************************************************
+@ ELLIPS_PARAMS
+***************************************************************/
+typedef struct
+{
+ char name[MAX_ELLIPS_NAME_SIZE];
+ double a_in_meters; /* semi-major axis in meters */
+ double f; /* flattening */
+ double e_sq; /* eccentricity squared */
+ char code[3] ; /* alphanumeric code identifier */
+ IPC ipc; /* info for inter-process, client-server communication */
+ BOOLEAN valid;
+} ELLIPS_PARAMS;
+/*
+Description: Structure for storing one record, containing the parameters for one ellipsoid, from the
+ellipsoids file, "xellips.dat".
+*/
+
+#if 0
+/***************************************************************
+@ ELLIPS_TYPE
+****************************************************************
+*/
+typedef struct
+{
+ char name[MAX_ELLIPS_NAME_SIZE];
+ double a_in_meters;
+ double f;
+ double e_sq;
+ char index[3] ;
+ BOOLEAN valid;
+} ELLIPS_TYPE;
+/*
+Description: Structure for storing one record from the ellipsoids
+file. Fields are the ellipsoid name, semi-major axis, flattening,
+and eccentricity squared.
+*/
+#endif
+
+/***************************************************************
+@ ELLIPS_FILE_INFO
+****************************************************************
+*/
+typedef struct
+{
+ ELLIPS_PARAMS ellipsoids[MAX_NO_OF_ELLIPSOIDS];
+ int ellipsoids_read;
+ int input_ellipsoid; /*new--replaces ellips_selected */
+ int output_ellipsoid;/* new */
+ BOOLEAN need_user_info;
+} ELLIPS_FILE_INFO;
+/*
+Description: Structure for storing all pre-defined ellipsoids parameters
+from ellipsoids file, as well as total number of ellipsoids read, index of
+current local ellipsoid, and flag indicating whether parameters have been
+entered for the user-specified ellipsoid. ellipsoid_selected is the
+same value as datum_info->datums[datum_info->datum_selected].ellips_num.
+*/
+
+
+#endif /* H_ELLIPS_DEF */
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ellips_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ellips_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ellips_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,30 @@
+#ifndef H_ELLIPS_FUNC
+
+#define H_ELLIPS_FUNC
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+
+/***************************************************************
+@ Add new ELLIPS functions, use shell below
+****************************************************************
+*/
+
+
+/***************************************************************
+@ ()
+****************************************************************
+Add short description
+*/
+#if XVT_CC_PROTO
+ERRSTATUS func(void);
+#else
+ERRSTATUS func();
+#endif
+/*
+Description: Add long description here.
+*/
+
+#endif /* H_ELLIPS_FUNC */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/help_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/help_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/help_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,11 @@
+
+
+void
+#if XVT_CC_PROTO
+context_sensitive_help(FILE_SPEC * help_file_spec, char *topic);
+#else
+context_sensitive_help();
+ FILE_SPEC *help_file_spec;
+ char *topic;
+#endif
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/i_stat.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/i_stat.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/i_stat.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,13 @@
+/* I_STAT.H */
+
+#ifndef i_stat_h
+#define i_stat_h
+
+#include "xvt.h"
+
+extern BOOLEAN iCreateStatus XVT_CC_ARGS((char *,char *));
+extern BOOLEAN iUpdateStatus XVT_CC_ARGS((char *,char *));
+extern void iDestroyStatus XVT_CC_ARGS((void));
+extern BOOLEAN iCheckCancel XVT_CC_ARGS((void));
+
+#endif /* i_stat_h */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ibrowse.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ibrowse.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ibrowse.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,22 @@
+/*
+** iBrowse.H Header for iBrowse functions.
+*/
+
+#define NUM_ITEMS 20 /* number items on Windows menu */
+#define M_WINDOWS 300 /* Windows menu tag */
+#define PLACEHOLDER (M_WINDOWS + NUM_ITEMS + 1) /* tag for dummy Win menu item */
+
+#ifndef STANDALONE
+extern void ibrowse_init XVT_CC_ARGS((void));
+extern void ibrowse_destroy XVT_CC_ARGS((void));
+extern void ibrowse_file XVT_CC_ARGS((char *, FILE_SPEC *));
+extern void ibrowse_slist XVT_CC_ARGS((char *, SLIST));
+#else
+static int32 task_eh XVT_CC_ARGS((WINDOW, EVENT *));
+#endif
+
+#define MAGIC 25931 /* magic number */
+#define GRANULE 100 /* allocation granule for lines array */
+#define MGN 2 /* margin (pixels) */
+#define HINTERVAL 50 /* horizontal scrolling interval (pixels) */
+#define VRANGE 10000 /* vertical scrolling range */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/inifunc.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/inifunc.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/inifunc.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,19 @@
+/* INIFUNC.H */
+
+#ifndef INIFUNC_H
+#define INIFUNC_H
+
+#if XVT_CC_PROTO
+extern FILE *ini_open(char *type);
+extern int32 get_ini_string(FILE *fp, char *section, char *entry,
+ char *def, char *string, size_t sizestr);
+extern int32 start_ini_section(char *ini_file, char *section);
+extern int32 section_exist(FILE *fp, char *section);
+#else
+extern FILE *ini_open();
+extern int32 get_ini_string();
+extern int32 start_ini_section();
+extern int32 section_exist();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/link.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/link.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/link.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,148 @@
+#ifndef LINK_H
+#define LINK_H
+
+/*****************************************************************************
+ From "Motif Programming, The Essentials...and More" by Marshall Brain.
+ Published by Digital Press, ISBN 1-55558-089.
+ This is the header file for the link library.
+ ******************************************************************************/
+
+/* link.h */
+
+/* Link module.v1.1, 2/6/92 by Marshal Brain */
+
+/*This module allows a program to form links to other separately executing
+ programs and communicate with them. Links can be opened and closed,
+ and the program using this library can write to and read from the other
+ program over the link. */
+
+/*Warning--This module will not link with all programs. If the program
+ does anything weird with stdout, or if it fails to flush stdout correctly,
+ then this module will fail. If you are creating a stand-alone program
+ that you wish to link to another program with this library, then you
+ MUST make sure that stdout is flushed correctly. Either call
+ "fflush(stdout)" after every printf, or call setbuf(stdout,NULL)" at the
+ beginning of the pr9ogram to eliminate buffering. */
+
+#include "xvt.h"
+
+#if XVT_OS_ISUNIX == TRUE /* only on SUN */
+
+#include <stdio.h>
+#include <strings.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+
+typedef struct /* holds all info relevant to one link */
+{
+ int pipefd1[2], pipefd2[2];
+ int pid;
+ FILE *fpin, *fpout;
+} LinkHandle;
+
+/* Open a link to another program named name, passing a param to the
+ program if desired. This routine will execute name in parallel and you can
+ start communicating with it with LinkRead and LinkWrite.
+ Note - convert over to argv/argc format for long parameter lists -- DONE 24AUG93-sdc .
+ */
+extern LinkOpen(
+#if XVT_CC_PROTO
+ LinkHandle *l,
+ char *argList[]
+#endif
+ );
+
+/* Close the link to a program that has terminated. Use linkkill if the
+ program needs to be terminated as well.
+ */
+extern LinkClose (
+#if XVT_CC_PROTO
+ LinkHandle *l
+#endif
+ );
+
+/* Close the link to a program that has terminated. Use linkkill if the
+ program needs to be terminated as well.
+ */
+extern LinkCloseNoWait (
+#if XVT_CC_PROTO
+ LinkHandle *l
+#endif
+ );
+
+/* Read from the program started with linkopen. Returns a 0 if there was
+ stuff to read, or a 1 if the linked program terminated.
+ */
+extern int LinkRead (
+#if XVT_CC_PROTO
+ LinkHandle *l,
+ char s[]
+#endif
+ );
+
+/* Returns the number of bytes waiting in the input buffer.
+ If 0, then linkread will block if it is called.
+ */
+extern int LinkInputWaiting (
+#if XVT_CC_PROTO
+ LinkHandle *l
+#endif
+ );
+
+/* Write a char, without a newline, to the program.
+ */
+extern LinkWriteChar (
+#if XVT_CC_PROTO
+ LinkHandle *l,
+ int c
+#endif
+ );
+
+/* Write a string to the program, with a newline.
+ */
+extern LinkWrite (
+#if XVT_CC_PROTO
+ LinkHandle *l,
+ char s[]
+#endif
+ );
+
+/* Write a string to the program, without a newline.
+ */
+extern LinkWriteNoEOL (
+#if XVT_CC_PROTO
+ LinkHandle *l,
+ char s[]
+#endif
+ );
+
+/* Kill the program and close the link. If the program has terminated on its
+ own use LinkClose instead.
+ */
+extern LinkKill (
+#if XVT_CC_PROTO
+ LinkHandle *l
+#endif
+ );
+
+/* Quit the program and close the link. If the program has terminated on its
+ own use LinkClose instead.
+ */
+extern LinkQuit (
+#if XVT_CC_PROTO
+ LinkHandle *l
+#endif
+ );
+
+/* Stop the program and close the link. If the program has terminated on its
+ own use LinkClose instead.
+ */
+extern LinkStop (
+#if XVT_CC_PROTO
+ LinkHandle *l
+#endif
+ );
+
+#endif
+
+#endif /* LINK_H */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/machine.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/machine.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/machine.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,46 @@
+#ifndef _MACHINE_
+#define _MACHINE_ 1
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+#define LEAST_SIGNIFICANT 0
+#define MOST_SIGNIFICANT 1
+
+typedef struct
+{
+ long machine;
+ long input;
+ long output;
+} xBYTE_ORDER;
+
+#if SYS_BIG_ENDIAN == 1
+#define MACHINE_BYTE_ORDER MOST_SIGNIFICANT
+#else
+#define MACHINE_BYTE_ORDER LEAST_SIGNIFICANT
+#endif
+
+#ifdef _WINDOWS
+# define DOS 1
+#else /* Not _WINDOWS */
+# define strcmpi(s1,s2) strcasecmp(s1,s2)
+# define stricmp(s1,s2) strcasecmp(s1,s2)
+# define strnicmp(s1,s2, len) strncasecmp(s1,s2, len)
+#endif /* endif _WINDOWS */
+
+#ifndef __INT32DEF__
+#define __INT32DEF__
+#ifdef _ALPHA
+typedef int32_t int32;
+typedef uint32_t uint32;
+#else
+typedef int32_t int32;
+typedef uint32_t uint32;
+#endif
+#endif
+
+#endif /* endif _MACHINE */
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mapdoc_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mapdoc_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mapdoc_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,501 @@
+#ifndef H_MAPDOC_D
+#define H_MAPDOC_D 1
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_MGM_D
+#include "mgm_d.h"
+#endif
+#ifndef H_PHIGS_D
+#include "phigs_d.h"
+#endif
+#ifndef H_UNIT_DEF
+#include "unit_d.h"
+#endif
+#ifndef H_RASTER_D
+#include "raster_d.h"
+#endif
+/*
+ *
+ @#Defines
+ */
+/***************************************************************
+@ SZ_*
+****************************************************************
+SZ_* is size of structure "*" in the map data file.
+
+*/
+#define SZ_PRODUCTS 3072
+#define SZ_GRAT_DATA 512
+#define SZ_BASEMAP 512
+#define SZ_RASTER 1024
+#define SZ_UNITS 512
+#define SZ_MGM 512
+#define SZ_PALETTE 2048
+#define SZ_LUT 2048
+#define SZ_MAP_DOC 512
+#define SZ_VECTOR 512
+#define SZ_VEC_DATA 256
+#define SZ_SQL_DATA 2048
+
+
+/***************************************************************
+@ Magic Numbers
+****************************************************************
+Record structure type and version
+*/
+#define MAGIC_MGM 10000000L
+#define MAGIC_UNITS 20000000L
+#define MAGIC_LUT 30000000L
+#define MAGIC_PALETTE 40000000L
+#define MAGIC_PRODUCTS 50000001L
+#define MAGIC_VIEW 60000000L
+#define MAGIC_BASEMAP 70000000L
+#define MAGIC_RASTER 80000000L
+#define MAGIC_MAP_DOC 90080892L
+#define MAGIC_DEFAULTS 100000000L
+#define MAGIC_VECTOR 110000000L
+#define MAGIC_VEC_DATA 120000001L
+#define MAGIC_GRAT_DATA 130000001L
+#define MAGIC_SQL_DATA 14000000L
+
+/*
+ * Description: These magic numbers are placed into the first 4 bytes of
+ * their respective structures to give the programmer an easy way to verify
+ * that a structure is valid. They may also be used as structure version
+ * identifiers for structures saved in files.
+ */
+
+/***************************************************************
+@ MAX_PRODUCTS
+****************************************************************
+Limits the number of open data products
+*/
+#define MAX_PRODUCTS 10
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ STRUCTURE ID'S
+****************************************************************
+*/
+#define BASEMAP_STRUCT 1
+#define GRAT_STRUCT 2
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ TOTAL_OVERLAYS
+****************************************************************
+Limit on number of overlays
+*/
+#define TOTAL_OVERLAYS 8
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ __V_HDR__
+****************************************************************
+A vector data header structure
+*/
+
+#ifndef __V_HDR__
+#define __V_HDR__
+#define DATA_HDR_EXTENT (X) ((X)->extent)
+#define DATA_HDR_LEFT (x) EXTENT_LEFT (DATA_HDR_EXTENT(x))
+#define DATA_HDR_RIGHT (x) EXTENT_RIGHT (DATA_HDR_EXTENT(x))
+#define DATA_HDR_TOP (x) EXTENT_TOP (DATA_HDR_EXTENT(x))
+#define DATA_HDR_BOTTOM (x) EXTENT_BOTTOM(DATA_HDR_EXTENT(x))
+
+#define EXTENT_LEFT (x) ((x)->left)
+#define EXTENT_RIGHT (x) ((x)->right)
+#define EXTENT_BOTTOM (x) ((x)->bottom)
+#define EXTENT_TOP (x) ((x)->top)
+
+#define V_HDR_DATA_HDR (x) ((x)->v_hdr)
+#define V_HDR_TOP (X) DATA_HDR_TOP (V_HDR_DATA_HDR(x))
+#define V_HDR_BOTTOM (x) DATA_HDR_BOTTOM (V_HDR_DATA_HDR(x))
+#define V_HDR_LEFT (x) DATA_HDR_LEFT (V_HDR_DATA_HDR(x))
+#define V_HDR_RIGHT (x) DATA_HDR_RIGHT (V_HDR_DATA_HDR(x))
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ VER_NUM
+****************************************************************
+Current saved file revision number
+*/
+#define VER_NUM = 0x01;
+
+/*
+ * Description:
+ */
+
+/*
+ * @Enumerated Data Types
+ */
+
+/***************************************************************
+@ PRODUCTS bit flag masks
+****************************************************************
+*/
+#define OVERLAYS_NEED_REDRAW_MASK 0x0002
+#define OVERLAYS_USE_TIMER_MASK 0x0003
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ BASEMAP_TYPE
+****************************************************************
+Type of basemap products
+*/
+typedef enum
+{
+ BM_NONE,
+ BM_SURFACE,
+ BM_GEOIMAGE,
+ BM_RGB_IMAGE,
+ BM_INDIRECT_IMAGE,
+ BM_DATA
+}
+ BASEMAP_TYPE;
+
+/*
+ * Description: DTED and DBDB5 are BM_SURFACE products. ADRG and CAC are
+ * BM_GEOIMAGE products.
+ */
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ OVERLAY_TYPE
+****************************************************************
+Types of overlays
+*/
+typedef enum
+{
+ GRAT,
+ VECT,
+ SQL,
+ AUTOMATE,
+ NONE
+}
+ OVERLAY_TYPE;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ PRODUCT
+****************************************************************
+Basemap products
+*/
+typedef enum
+{
+ BASE_NONE,
+ BASE_ADRG,
+ BASE_ADRI,
+ BASE_CAC,
+ BASE_CADRG,
+ BASE_CIB,
+ BASE_CRG,
+ BASE_DTED,
+ BASE_DBDB5,
+ BASE_DATA,
+ BASE_OTHER,
+ BASE_ASRP,
+ BASE_USRP,
+ BASE_SRG
+
+}
+ PRODUCT;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ BASEMAP_PRODUCT
+****************************************************************
+Info about a basemap product
+*/
+typedef struct
+{
+ char name[30];
+ BASEMAP_TYPE type;
+ char prompt[48];
+ BOOLEAN warpable;
+ FILE_SPEC file_spec;
+} BASEMAP_PRODUCT;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ Grat_Data bit flag masks
+****************************************************************
+*/
+#define GRAT_VALID_MASK 0x0001
+#define GRAT_NEEDS_REDRAW_MASK 0x0002
+
+/*
+ * Description: GRAT_DATA contains a long variable "bit_flags" whose bits can
+ * be set to show the current status of the structure. Currently, bit 0 is
+ * set to show the structure contains valid data, and bit 1 is set if the
+ * grat overlay needs to be redrawn.
+ */
+
+
+/***************************************************************
+@ MARKER
+****************************************************************
+Marker types for PHIGS
+*/
+#if 0
+typedef enum
+{
+ DOT,
+ PLUS,
+ ASTERICK,
+ CIRCLE,
+ CROSS,
+ SOLID_LINE,
+ DASH_LINE,
+ DOT_LINE
+}
+#endif
+typedef Pmarker MARKER;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ GRAT_DATA
+****************************************************************
+Structure to define a graticule
+*/
+typedef struct
+{
+ int32 color;
+ int32 magic; /* SR 10/02 */
+ int32 bit_flags;
+ BOOLEAN contains_valid_data;
+ BOOLEAN border_enable;
+ BOOLEAN border_major_enable;
+ GFLOAT border_major_lat;
+ GEOGRAPHIC border_major_lat_unit;
+ GFLOAT border_major_lon;
+ GEOGRAPHIC border_major_lon_unit;
+ int32 border_major_color;
+
+ BOOLEAN border_minor_enable;
+ GFLOAT border_minor_lat;
+ GEOGRAPHIC border_minor_lat_unit;
+ GFLOAT border_minor_lon;
+ GEOGRAPHIC border_minor_lon_unit;
+ int32 border_minor_color;
+
+ BOOLEAN border_labels_enable;
+ GFLOAT border_labels_lat;
+ GEOGRAPHIC border_labels_lat_unit;
+ GFLOAT border_labels_lon;
+ GEOGRAPHIC border_labels_lon_unit;
+ int32 border_labels_color;
+
+ BOOLEAN grat_enable;
+ BOOLEAN grat_major_enable;
+ MARKER grat_major;
+ BYTE grat_major_ascii_code;
+ GFLOAT grat_major_lat;
+ GEOGRAPHIC grat_major_lat_unit;
+ GFLOAT grat_major_lon;
+ GEOGRAPHIC grat_major_lon_unit;
+ int32 grat_major_color;
+
+ BOOLEAN grat_minor_enable;
+ MARKER grat_minor;
+ BYTE grat_minor_ascii_code;
+ GFLOAT grat_minor_lat;
+ GEOGRAPHIC grat_minor_lat_unit;
+ GFLOAT grat_minor_lon;
+ GEOGRAPHIC grat_minor_lon_unit;
+ int32 grat_minor_color;
+} GRAT_DATA;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ OVERLAYS
+****************************************************************
+The list of overlays
+*/
+typedef struct
+{
+ OVERLAY_TYPE type;
+ char name[64];
+ void *product_pointer;
+} OVERLAYS;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ BASEMAP
+****************************************************************
+Struct to contain the basemap information
+*/
+typedef struct BASEMAP
+{
+ int32 magic;
+ PRODUCT product; /* which product */
+ RASTER *area; /* product dependent */
+ RASTER *bit_map; /* plotable image */
+ RENDER_INFO render_info;/* NULL unless its a DATA product */
+ GFLOAT zoom; /* 0.0<zoom<1.0=downsampling,
+ * zoom>1.0=replication */
+ BASEMAP_TYPE type; /* Product type */
+ BOOLEAN needs_refresh; /* true if needs any work */
+ BOOLEAN needs_redraw; /* true if it needs redrawing */
+ BOOLEAN needs_reload; /* true if it needs to be reloaded */
+ BOOLEAN warp; /* true ifit supports projection warp */
+ FILE_SPEC file_spec; /* where in the file system */
+} BASEMAP;
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ PRODUCTS
+****************************************************************
+The list of products
+*/
+typedef struct
+{
+ int32 magic;
+ int32 bit_flags;
+ short count;
+ short order;
+ short current;
+ OVERLAYS overlays[MAX_PRODUCTS];
+ BASEMAP *basemap;
+} PRODUCTS;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ MAPDOC
+****************************************************************
+The map document structure
+*/
+typedef struct
+{
+ int32 magic; /* for programmer's sanity check */
+ MGM *mgm; /* the map geometry */
+ UNITS *units; /* the selected display units */
+ LUT *lut; /* the look-up-table */
+ PALETTE *palette; /* the palette */
+ PRODUCTS *products; /* the list of products displayed */
+ VIEW *view; /* the viewing parameters, scrool, zoom */
+ /* items below here are not written into the map files */
+ BOOLEAN needs_update; /* TRUE if display is not current */
+ BOOLEAN needs_save; /* TRUE if file is not current */
+ BOOLEAN auto_update;/* TRUE for automatic map updates */
+ CURSOR map_cursor; /* map window cursor type */
+ FILE_SPEC file_spec; /* the map document's file */
+} MAP_DOC;
+
+/*
+ * Description: Contains all the information associated with a map document.
+ * mapdoc_construct() and mapdoc_destruct() are used to create and destroy
+ * and also to read and write.
+ */
+
+/***************************************************************
+@ TEXT
+****************************************************************
+A text structure
+*/
+typedef struct
+{
+ uint32 length;
+ char *string;
+} TEXT;
+
+/*
+ * Description: These are returned by the product meta-data constructors.
+ */
+/***************************************************************
+@ USER_LEVEL
+****************************************************************
+Levels of user experience.
+*/
+typedef enum
+{
+ NOVICE,
+ EXPERIENCED,
+ AUTOMATIC
+}
+ USER_LEVEL;
+
+/*
+ * Description:
+ */
+/***************************************************************
+@ DEFAULTS
+****************************************************************
+The structure of program defaults
+*/
+typedef struct
+{
+ int32 magic; /* magic number to id structure */
+ DATA_MATRIX bitmap_matrix; /* default bit_map size and type */
+ GFLOAT center_lon; /* default map center, DD */
+ GFLOAT center_lat; /* default map center, DD */
+ int red;
+ int green;
+ int blue;
+ COLOR_PREF color_pref; /* default color_pref */
+ USER_LEVEL user_level; /* NOVICE, EXPERIENCED, EXPERT */
+ char map_file_dir[SZ_FNAME]; /* default map directory SR */
+ BOOLEAN needs_save; /* true if needs to be saved */
+ BOOLEAN auto_update;/* if FALSE, the user has to push the Update
+ * Map button */
+ UNITS units; /* user units */
+ FILE_SPEC map_file_spec; /* default map file */
+ FILE_SPEC def_file_spec; /* where the defaults file is stored */
+ CURSOR map_cursor; /* map windows cursor shape */
+} DEFAULTS;
+
+/*
+ * Description:
+ */
+
+
+
+#endif /* ifndef H_MAPDOC_D */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mapdoc_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mapdoc_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mapdoc_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,444 @@
+#ifndef H_MAPDOC_F
+
+#define H_MAPDOC_F
+
+#ifndef H_VECTOR
+#include "vector.h"
+#endif
+
+/***************************************************************
+@ basemap_construct()
+ ****************************************************************
+Constructs the basemap
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+basemap_construct(
+ FILE * file,
+ BASEMAP ** basemap);
+#else
+ERRSTATUS MUSE_API basemap_construct();
+#endif
+
+/*
+ * Description: Constructs a basemap object. IF file is not NULL the basemap
+ * is read in from the file. /***************************************************************
+ * @ basemap_destruct() ***************************************************************
+ *
+ * Destroys the basemap structure
+ */
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+basemap_destruct(
+ FILE * file,
+ BOOLEAN destruct,
+ BASEMAP ** basemap);
+#else
+ERRSTATUS MUSE_API basemap_destruct();
+#endif
+
+/*
+ * Description: If file is not NULL the basemap is written to the file. If
+ * destruct is TRUE the basemap memory is released.
+ */
+
+/***************************************************************
+@ basemap_new_bitmap()
+****************************************************************
+Get a new bit_map raster
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+basemap_new_bitmap(int32 width,
+ int32 height,
+ int32 bits_per_pixel,
+ RASTER ** bit_map,
+ DEFAULTS *defaults);
+#else
+ERRSTATUS MUSE_API basemap_new_bitmap();
+#endif
+
+/*
+ * Description: If the bit_map already exists, it is deleted. A new bit_map
+ * object of type RASTER is created according to the specified dimensions.
+ */
+
+/***************************************************************
+@ basemap_match_geometry()
+****************************************************************
+Sets up the map geometry to match the basemap geometry
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API basemap_match_geometry(BASEMAP * basemap, MGM * mgm);
+#else
+ERRSTATUS MUSE_API basemap_match_geometry();
+#endif
+
+/*
+ * Description: The map geometry object mgm is adjusted to the basemap's
+ * projection and geographic extent, so that vector overlays, and the cursor
+ * readout will be correct.
+ *
+ *
+/*************************************************************** @
+ * basemap_setup() ***************************************************************
+ *
+ * Sets up the basemap
+ */
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+basemap_setup(
+ BASEMAP * basemap,
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API basemap_setup();
+#endif
+
+/*
+ * Description: Sets up the basemap by calling any needed product
+ * constructors and setup functions.
+ *
+ */
+
+/***************************************************************
+@ decode_basemap()
+****************************************************************
+Convert basemap structure to local binary
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+decode_basemap(
+ unsigned char *buffer,
+ BASEMAP * basemap);
+#else
+ERRSTATUS MUSE_API decode_basemap();
+#endif
+
+/*
+ * Description: The basemap structure information in the character buffer
+ * (binary portable Intel format) is placed into the basemap structure in
+ * local binary. Used by the constructor functions while loading in a map
+ * document.
+ */
+
+/***************************************************************
+@ decode_grat()
+****************************************************************
+Convert grat structure to local binary
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API decode_grat(unsigned char *buffer, GRAT_DATA * grat, int32 version);
+#else
+ERRSTATUS MUSE_API decode_grat();
+#endif
+
+/*
+ * Description: The grat structure information in the character buffer
+ * (binary portable Intel format) is placed into the grat structure in local
+ * binary. Used by the constructor functions while loading in a map
+ * document.
+ */
+
+/***************************************************************
+@ decode_mapdoc()
+****************************************************************
+Convert map_doc structure to local binary
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+decode_mapdoc(
+ unsigned char *buffer,
+ MAP_DOC * map_doc);
+#else
+ERRSTATUS MUSE_API decode_mapdoc();
+#endif
+
+/*
+ * Description: The map_doc structure information in the character buffer
+ * (binary portable Intel format) is placed into the map_doc structure in
+ * local binary. Used by the constructor functions while loading in a map
+ * document.
+ */
+/***************************************************************
+@ decode_mgm()
+****************************************************************
+Convert mgm structure to local binary
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+decode_mgm(
+ unsigned char *buffer,
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API decode_mgm();
+#endif
+
+/*
+ * Description: The mgm structure information in the character buffer (binary
+ * portable Intel format) is placed into the mgm structure in local binary.
+ * Used by the constructor functions while loading in a map document.
+ */
+
+/***************************************************************
+@ decode_products()
+****************************************************************
+Convert products structure to local binary
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+decode_products(
+ unsigned char *buffer,
+ PRODUCTS * products);
+#else
+ERRSTATUS MUSE_API decode_products();
+#endif
+
+/*
+ * Description: The products structure information in the character buffer
+ * (binary portable Intel format) is placed into the products structure in
+ * local binary. Used by the constructor functions while loading in a map
+ * document.
+ */
+
+/***************************************************************
+@ encode_basemap()
+****************************************************************
+Convert basemap structure to external form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+encode_basemap(
+ unsigned char *buffer,
+ BASEMAP * basemap);
+#else
+ERRSTATUS MUSE_API encode_basemap();
+#endif
+
+/*
+ * Description: The basemap structure is converted to the external binary
+ * portable (Intel) format. Used by the destructor functions while preparing
+ * to store a map document.
+ */
+
+/***************************************************************
+@ encode_grat()
+****************************************************************
+Convert grat structure to external form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API encode_grat(unsigned char *buffer, GRAT_DATA * grat);
+#else
+ERRSTATUS MUSE_API encode_grat();
+#endif
+
+/*
+ * Description: The grat structure is converted to the external binary
+ * portable (Intel) format. Used by the destructor functions while preparing
+ * to store a map document.
+ */
+
+/***************************************************************
+@ encode_mapdoc()
+****************************************************************
+Convert map_doc structure external form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+encode_mapdoc(
+ unsigned char *buffer,
+ MAP_DOC * map_doc);
+#else
+ERRSTATUS MUSE_API encode_mapdoc();
+#endif
+
+/*
+ * Description: The map_doc structure is converted to the external binary
+ * portable (Intel) format. Used by the destructor functions while preparing
+ * to store a map document.
+ */
+
+/***************************************************************
+@ encode_mgm()
+****************************************************************
+Convert mgm structure external form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+encode_mgm(
+ unsigned char *buffer,
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API encode_mgm();
+#endif
+
+/*
+ * Description: The mgm structure is converted to the external binary
+ * portable (Intel) format. Used by the destructor functions while preparing
+ * to store a map document.
+ */
+
+/***************************************************************
+@ encode_products()
+****************************************************************
+Convert products structure external form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+encode_products(
+ unsigned char *buffer,
+ PRODUCTS * products);
+#else
+ERRSTATUS MUSE_API encode_products();
+#endif
+
+/*
+ * Description: The products structure is converted to the external binary
+ * portable (Intel) format. Used by the destructor functions while preparing
+ * to store a map document.
+ */
+
+/***************************************************************
+@ grat()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API grat(WINDOW map_win, short count, MGM * mgm);
+#else
+ERRSTATUS MUSE_API grat();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ grat_construct()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API grat_construct(FILE * file, GRAT_DATA ** pointer, int32 version);
+#else
+ERRSTATUS MUSE_API grat_construct();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ grat_destruct()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API grat_destruct(FILE * file, BOOLEAN destruct, GRAT_DATA ** grat);
+#else
+ERRSTATUS MUSE_API grat_destruct();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ map_doc_construct()
+****************************************************************
+Create a map document
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API map_doc_construct(
+ FILE * file,
+ MAP_DOC ** pointer,
+ BYTE_ORDER * byte_order,
+ DEFAULTS *defaults);
+#else
+ERRSTATUS MUSE_API map_doc_construct();
+#endif
+
+/*
+ * Description: Calls the constructors for the sub-structures to allocate a
+ * new map document. If the file argument is not NULL, the map document is
+ * read in from the file.
+ */
+/***************************************************************
+@ map_doc_destruct()
+****************************************************************
+Destroy the map document
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+map_doc_destruct(
+ FILE * file,
+ BOOLEAN destruct,
+ MAP_DOC ** map_doc,
+ BYTE_ORDER * bo);
+#else
+ERRSTATUS MUSE_API map_doc_destruct();
+#endif
+
+/*
+ * Description: If the file argument is not NULL, the map document is written
+ * to the file. If the destruct argument is TRUE, the map document is removed
+ * from memory.
+ *
+ */
+
+/***************************************************************
+@ products_construct()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API products_construct(FILE * file, PRODUCTS ** pointer, BYTE_ORDER * bo);
+#else
+ERRSTATUS MUSE_API products_construct();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ products_destruct()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API products_destruct
+ (
+ FILE * file,
+ BOOLEAN destruct,
+ PRODUCTS ** products,
+ BYTE_ORDER * bo
+);
+#else
+ERRSTATUS MUSE_API products_destruct();
+#endif
+
+/*
+ * Description:
+ */
+
+#endif /* H_MAPDOC_F */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mgm_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mgm_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mgm_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,73 @@
+#ifndef H_MGM_D
+#define H_MGM_D
+
+#ifndef H_DTCC_D
+#include "dtcc_d.h"
+#endif
+
+/***************************************************************
+@ CONFIG_PREF
+****************************************************************
+Ways of configuring map geometry
+*/
+typedef enum
+{
+ CONFIG_GEO_EXTENT_AND_DEV_EXTENT,
+ CONFIG_CENTER_AND_SCALE,
+ CONFIG_CENTER_AND_POST_SPACING
+}
+ CONFIG_PREF;
+
+/*
+ * Description: The map geometry module supports these preferences when
+ * mgm_setup is called.
+ */
+
+/***************************************************************
+@ MGM
+****************************************************************
+The map geometry structure
+*/
+typedef struct MGM
+{
+ int32 magic;
+ PROJECTION projection; /* the objects projection */
+ HOR_DATUM hor_datum; /* an enum type */
+ VER_DATUM ver_datum; /* an enum type */
+
+ CONFIG_PREF config_pref;/* how to resolve inconsistent params */
+ POINT_DD map_center; /* geocoord of map center, DD */
+ GFLOAT scale_reciprocal; /* 250000 for scale of 1:250,000 */
+ GFLOAT pixel_size_on_screen; /* meters */
+ GFLOAT pixel_size_on_ground; /* meters */
+ GFLOAT pixel_size_lon; /* size in decimal degrees */
+ GFLOAT pixel_size_lat; /* size in decimal degrees */
+ EXTENT dev_extent; /* bounding device rectangle */
+ GFLOAT dev_ymin; /* smallest y on map */
+ GFLOAT dev_ymax; /* largest y on map */
+ int32 xpixels; /* width in pixels */
+ int32 ypixels; /* height in pixels */
+ int32 bit_map_depth; /* bits per pixel 1, 4, 8, or 24 */
+ EXTENT geo_extent; /* bounding geographic rectangle, DD */
+ GFLOAT pixasp; /* aspect ratio of pixel, (Y/X) */
+ GFLOAT horizontal_accuracy; /* of most inaccurate
+ * product, meters */
+ GFLOAT vertical_accuracy; /* of most inaccurate product, meters */
+ BOOLEAN user_aspect;/* If true user aspect used, else default */
+ ASPECT aspect; /* aspect of projection */
+ PARAMS params; /* projection dependent params */
+ BOOLEAN valid; /* FALSE indicates an invalid projection
+ * object */
+
+ GFLOAT sx; /* empirical x scale */
+ GFLOAT sy; /* empirical y scale */
+ GFLOAT tx; /* empirical x shift */
+ GFLOAT ty; /* empirical y shift */
+ BOOLEAN is_locked; /* true when locked to basemap */
+} MGM;
+
+/*
+ * Description: The sx,sy, tx, ty items fit the projection space to the
+ * bitmap space.
+ */
+#endif /* H_MGM_D */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mgm_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mgm_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/mgm_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,331 @@
+#ifndef H_MGM_FUNC
+#define H_MGM_FUNC
+
+#include "math.h"
+/* JLL#include "tx.h" */
+
+#ifndef H_ARC
+/* JLL#include "arc.h" */
+#endif
+
+/*
+ * The only reason for including XVT.H is to define XVT_CC_PROTO properly for
+ * the compiler in use. XVT_CC_PROTO should be defined if the compiler uses
+ * ANSII prototypes.
+ */
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+#ifndef H_UNIT_FUNC
+#include "unit_f.h"
+#endif
+
+
+#ifndef ERRSTATUS
+#define ERRSTATUS short
+#endif
+
+/***************************************************************
+@ gptlam()
+****************************************************************
+GP to Lambert Conformal Conic map projection 2 standard parallels
+*/
+
+#if XVT_CC_PROTO
+void
+gptlam(
+ double a,
+ double recf,
+ double ophi,
+ double olam,
+ double fn,
+ double fe,
+ double ok,
+ double sphi,
+ double slam,
+ double *y,
+ double *x);
+#else
+void gptlam();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+
+/***************************************************************
+@ gptotm()
+****************************************************************
+GP to transverse Mercator map projection
+*/
+
+#if XVT_CC_PROTO
+void
+gptotm(
+ double a,
+ double recf,
+ double ophi,
+ double olam,
+ double fn,
+ double fe,
+ double ok,
+ double sphi,
+ double slam,
+ double *y,
+ double *x);
+#else
+void gptotm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ gptups()
+****************************************************************
+GP to UPS map projection
+*/
+
+#if XVT_CC_PROTO
+void
+gptups(
+ double a,
+ double recf,
+ double sphi,
+ double slam,
+ double *y,
+ double *x);
+#else
+void gptups();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ lamb()
+****************************************************************
+Lambert Conformal Conic map projection 2 standard parallels
+*/
+
+#if XVT_CC_PROTO
+void
+lamb(
+ double *p,
+ double *l,
+ int32 dir,
+ double *a,
+ double f,
+ double op,
+ double ol,
+ double *fn,
+ double *fe,
+ double *ok,
+ double *y,
+ double *x,
+ int32 *ierr);
+#else
+void lamb();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ merc()
+****************************************************************
+Mercator map projection
+*/
+
+#if XVT_CC_PROTO
+void
+merc(
+ double *p,
+ double *l,
+ int32 dir,
+ double *a,
+ double f,
+ double op,
+ double ol,
+ double *fn,
+ double *fe,
+ double *ok,
+ double *y,
+ double *x,
+ int32 *ierr);
+#else
+void merc();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ mertgp()
+****************************************************************
+Mercator map projection to geog posn
+*
+
+#if XVT_CC_PROTO
+void
+mertgp(
+ double a,
+ double recf,
+ double ophi,
+ double olam,
+ double fn,
+ double fe,
+ double ok,
+ double *sphi,
+ double *slam,
+ double y,
+ double x);
+#else
+void mertgp();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ tmtogp()
+****************************************************************
+Transverse Mercator map projection to geog posn
+*/
+
+#if XVT_CC_PROTO
+void
+tmtogp(
+ double a,
+ double recf,
+ double ophi,
+ double olam,
+ double fn,
+ double fe,
+ double ok,
+ double *sphi,
+ double *slam,
+ double y,
+ double x);
+#else
+void tmtogp();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ upstgp()
+****************************************************************
+UPS map projection to geog posn
+*/
+
+#if XVT_CC_PROTO
+void
+upstgp(
+ double a,
+ double recf,
+ double *sphi,
+ double *slam,
+ double *y,
+ double x);
+#else
+void mertgp();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ upolar()
+****************************************************************
+Universal Polar Stereographic map projection
+*/
+
+#if XVT_CC_PROTO
+void
+upolar(
+ double *p,
+ double *l,
+ int32 dir,
+ double *a,
+ double f,
+ double *y,
+ double *x,
+ int32 *ierr);
+#else
+void upolar();
+#endif
+
+/*
+ * Description:
+ *
+ */
+/***************************************************************
+@ utm()
+****************************************************************
+Universal Transverse Mercator map projection
+*/
+
+#if XVT_CC_PROTO
+void
+utm(
+ double *p,
+ double *l,
+ int32 dir,
+ int32 *izone,
+ double *a,
+ double f,
+ double *ok,
+ double *y,
+ double *x,
+ int32 zflag,
+ int32 *ierr);
+#else
+void utm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ unflow()
+****************************************************************
+Universal Transverse Mercator map projection
+*/
+
+#if XVT_CC_PROTO
+void
+unflow(
+ double *value,
+ int32 kode);
+#else
+void unflow();
+#endif
+
+/*
+ * Description:
+ *
+ */
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,112 @@
+
+#ifndef H_MUSE
+#define H_MUSE
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_SYSTEM_D
+#include "system_d.h"
+#endif
+#ifndef H_COLOR_DEF
+#include "color_d.h"
+#endif
+#ifndef H_DTCC_D
+#include "dtcc_d.h"
+#endif
+#ifndef H_PHIGS_D
+#include "phigs_d.h"
+#endif
+#ifndef H_UNIT_DEF
+#include "unit_d.h"
+#endif
+#ifndef H_MAPDOC_D
+#include "mapdoc_d.h"
+#endif
+#ifndef H_SUNR_DEF
+#include "sunras_d.h"
+#endif
+#ifndef H_SQLLIB_D
+#include "sqllib_d.h"
+#endif
+#ifndef H_CLI_SR_D
+#include "cli_sr_d.h"
+#endif
+#ifndef H_COORD_DEF
+#include "coord_d.h"
+#endif
+#ifndef H_ELLIPS_DEF
+#include "ellips_d.h"
+#endif
+#ifndef H_DATUM_DEF
+#include "datum_d.h"
+#endif
+#ifndef H_COORD_FUNC
+#include "coord_f.h"
+#endif
+#ifndef H_ELLIPS_FUNC
+#include "ellips_f.h"
+#endif
+#ifndef H_DATUM_F
+#include "datum_f.h"
+#endif
+#ifndef H_MUSE_IPC
+#include "muse_ipc.h"
+#endif
+#ifndef H_MUSE_SQL
+#include "muse_sql.h"
+#endif
+#ifndef H_SYSTEM_F
+#include "system_f.h"
+#endif
+#ifndef H_COLOR_F
+#include "color_f.h"
+#endif
+#ifndef H_DTCC_F
+#include "dtcc_f.h"
+#endif
+#ifndef H_DTCC_FN
+#include "dtcc_fn.h" /* DT&CC functions pulled from old MUSEDEF.H */
+#endif
+#ifndef H_PHIGS_F
+#include "phigs_f.h"
+#endif
+#ifndef H_RASTER_F
+#include "raster_f.h"
+#endif
+#ifndef H_SUNR_FUNC
+#include "sunras_f.h"
+#endif
+#ifndef H_UNIT_FUNC
+#include "unit_f.h"
+#endif
+#ifndef H_VIEW_FUNC
+#include "view_f.h"
+#endif
+#ifndef H_MAPDOC_F
+#include "mapdoc_f.h"
+#endif
+#ifndef H_VEC_D
+#include "vec_d.h"
+#endif
+#ifndef H_VEC_F
+#include "vec_f.h"
+#endif
+#ifndef H_VECTOR
+#include "vector.h"
+#endif
+#ifndef XVTCM_INCL
+#include "xvtcm.h"
+#endif
+#ifndef H_SQLLIB_F
+#include "sqllib_f.h"
+#endif
+#ifndef H_CLI_SR_F
+#include "cli_sr_f.h"
+#endif
+
+#endif /* H_MUSE */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse1.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse1.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse1.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,155 @@
+#ifndef H_MUSE1
+
+#define H_MUSE1
+
+
+/***************************************************************
+@ MUSE_API
+****************************************************************
+Define the parameter _API at the compilers command line
+to have all API functions compiled for use in Windows DLLs.
+*/
+#ifdef _API
+#define MUSE_API FAR _export
+#else
+#define MUSE_API
+#endif
+
+/***************************************************************
+@ Misc. Constants
+****************************************************************
+*/
+#define ANIOTA 1.0E-4
+
+/***************************************************************
+@ BYTE
+****************************************************************
+*/
+#ifdef BYTE
+#undef BYTE
+#endif
+typedef unsigned char BYTE;
+/*
+Description:
+*/
+
+/***************************************************************
+@ ERRSTATUS
+****************************************************************
+*/
+typedef short ERRSTATUS;
+/*
+Description:
+*/
+
+/***************************************************************
+@ GFLOAT
+****************************************************************
+*/
+typedef double GFLOAT;
+/*
+Description:
+*/
+
+/***************************************************************
+@ pHMEM
+****************************************************************
+pointer to High MEMory
+*/
+#ifndef _WINDOWS
+#if 0
+# if XVT_OS == XVT_OS_WIN
+# define pHMEM _huge *
+# else
+# endif
+#endif
+# define pHMEM *
+#else
+# define pHMEM *
+#endif
+/*
+Description:
+PC's require programming backflips in order to use the
+installed hardware memory. A pHMEM is the pointer you
+get when you lock down an item on the global heap. See
+XVT functions galloc, glock, gfree.
+*/
+
+/***************************************************************
+@ USHORT
+****************************************************************
+*/
+typedef unsigned short USHORT;
+/*
+Description:
+*/
+/*
+ * @ Multiples of Pi
+ */
+#define PXPI 3.14159265358979323846
+#define PX2_PI 6.28318530717958647693
+#define PXPI_OVER_2 1.57079632679489661923
+#define PXDEGREES_TO_RADIANS 0.0174532925199432957692
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ NULL
+****************************************************************
+A long 0
+*/
+#ifndef NULL
+#define NULL 0L
+#endif
+/*
+Description:
+*/
+/*
+#ifndef BOOLEAN
+typedef int BOOLEAN;
+#endif
+*/
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+
+/***************************************************************
+@ EXTENT
+****************************************************************
+The bounds of something
+*/
+typedef struct
+{
+ GFLOAT left; /* Leftmost extent of the dataset in DD */
+ GFLOAT right; /* Rightmost extent of the dataset in DD */
+ GFLOAT bottom; /* Bottommost extent of the dataset in DD */
+ GFLOAT top; /* Topmost extent of the dataset in DD */
+} EXTENT;
+
+/*
+ * Description:
+ */
+
+
+
+
+#endif /* H_MUSE1 */
+
+
+
+
+
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_ask.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_ask.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_ask.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,101 @@
+#include "xvt.h"
+#if (XVT_CC == XVT_CC_SUNB)
+#include <sys/varargs.h>
+#else
+#include <stdarg.h>
+#endif
+
+#ifndef MUSE_ASK
+#define MUSE_ASK 103
+#endif
+#ifndef M_RESP_DEFAULT
+#define M_RESP_DEFAULT 1
+#endif
+#ifndef M_RESP_2
+#define M_RESP_2 2
+#endif
+#ifndef M_RESP_3
+#define M_RESP_3 3
+#endif
+#ifndef M_RESP_4
+#define M_RESP_4 4
+#endif
+#ifndef M_RESP_5
+#define M_RESP_5 5
+#endif
+#ifndef M_RESP_6
+#define M_RESP_6 6
+#endif
+#ifndef M_RESP_7
+#define M_RESP_7 7
+#endif
+#ifndef M_RESP_8
+#define M_RESP_8 8
+#endif
+#ifndef M_RESP_9
+#define M_RESP_9 9
+#endif
+#ifndef M_RESP_10
+#define M_RESP_10 10
+#endif
+#ifndef M_MSG
+#define M_MSG 11
+#endif
+
+#if XVTWS == PMWS
+#ifndef URL_SRC_WIDTH
+#define URL_SRC_WIDTH 6
+#endif
+#ifndef URL_SRC_HEIGHT
+#define URL_SRC_HEIGHT 16
+#endif
+#else
+#ifndef URL_SRC_WIDTH
+#define URL_SRC_WIDTH 8
+#endif
+#ifndef URL_SRC_HEIGHT
+#define URL_SRC_HEIGHT 16
+#endif
+#endif
+
+#if XVTWS == WINWS || XVTWS == PMWS
+#define UNITS U_SEMICHARS
+#undef URL_DEST_WIDTH
+#define URL_DEST_WIDTH 4
+#undef URL_DEST_HEIGHT
+#define URL_DEST_HEIGHT 8
+#elif XVTWS == WMWS
+#define UNITS U_CHARS
+#undef URL_DEST_WIDTH
+#define URL_DEST_WIDTH 1
+#undef URL_DEST_HEIGHT
+#define URL_DEST_HEIGHT 1
+#else
+#define UNITS U_PIXELS
+#ifndef URL_DEST_WIDTH
+#define URL_DEST_WIDTH URL_SRC_WIDTH
+#endif
+#ifndef URL_DEST_HEIGHT
+#define URL_DEST_HEIGHT URL_SRC_HEIGHT
+#endif
+#endif
+
+/* define utility macros */
+
+#define X_OFF(x) ((x)*URL_DEST_WIDTH)/URL_SRC_WIDTH
+#define Y_OFF(y) ((y)*URL_DEST_HEIGHT)/URL_SRC_HEIGHT
+#define WIDTH(w) ((w)*URL_DEST_WIDTH)/URL_SRC_WIDTH
+#define HEIGHT(h) ((h)*URL_DEST_HEIGHT)/URL_SRC_HEIGHT
+
+/* get control window in dialog */
+
+#define CTL_WIN(id) get_ctl_window(win,(id))
+
+STATICFCN int32 dlg_eh XVT_CC_ARGS((WINDOW win, EVENT *ep));
+STATICFCN void do_control XVT_CC_ARGS((WINDOW win, short id, CONTROL_INFO *cip));
+
+#if (XVT_CC == XVT_CC_SUNB)
+extern int32 muse_ask XVT_CC_ARGS((char* msgbuf, int num_buttons, va_list arg_ptr ));
+#else
+extern int32 muse_ask XVT_CC_ARGS((char* msgbuf, int num_buttons, ... ));
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_ipc.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_ipc.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_ipc.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,154 @@
+#ifndef H_MUSE_IPC
+
+#define H_MUSE_IPC
+
+/*
+ * Function prototypes
+ */
+
+#if XVT_OS == XVT_OS_MAC
+/***************************************************************
+@ my_event_hook(int dlg_id, BOOLEAN is_modal, EventRecord *my_event);
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+BOOLEAN my_event_hook(WINDOW dlg_id, BOOLEAN is_modal, EventRecord *my_event);
+#else
+BOOLEAN my_event_hook();
+#endif
+
+/***************************************************************
+@ xvtmi_init(void)
+****************************************************************
+*/
+void
+#if XVT_CC_PROTO
+ xvtmi_init(void);
+#else
+ xvtmi_init();
+#endif
+
+#if XVT_CC_PROTO
+VOID get_message(int task_id);
+#else
+VOID get_message( );
+#endif
+
+#if XVT_CC_PROTO
+VOID look_for_message(int task_id);
+#else
+VOID look_for_message( );
+#endif
+
+#endif
+
+/* end of mac specific prototypes */
+
+
+/*
+ * The communications buffer size
+ */
+#define COMM_BUFFER_SIZE 4096
+#define COMM_DATA_SIZE (COMM_BUFFER_SIZE-4)
+
+/*
+ * Function prototypes
+ */
+
+#if XVT_CC_PROTO
+int muse_ipc_spawn (char *program);
+VOID muse_ipc_send (int task_id, int status);
+VOID muse_ipc_command (int task_id, int command);
+int muse_ipc_receive (int task_id);
+int muse_ipc_peek (int task_id);
+VOID muse_ipc_init_child (int *argc, char **argv);
+
+VOID muse_ipc_call_back (int task_id, VOID (*f)(int) );
+
+int muse_ipc_setup_client (char *host, char *program, int port);
+int muse_ipc_setup_server (int port);
+
+int muse_ipc_echo (VOID);
+
+VOID muse_ipc_close (int taskid);
+
+VOID muse_ipc_init_send(int task_id);
+
+VOID muse_ipc_add_string (int task_id, char *s);
+VOID muse_ipc_add_bytes (int task_id, VOID *b, int n);
+VOID muse_ipc_add_char (int task_id, int c);
+VOID muse_ipc_add_short (int task_id, int n);
+VOID muse_ipc_add_int (int task_id, int n);
+VOID muse_ipc_add_long (int task_id, int32 n);
+VOID muse_ipc_add_float (int task_id, double n);
+VOID muse_ipc_add_double (int task_id, double n);
+VOID muse_ipc_add_shorts (int task_id, int n, short *array );
+VOID muse_ipc_add_ints (int task_id, int n, int *array );
+VOID muse_ipc_add_longs (int task_id, int n, int32 *array );
+VOID muse_ipc_add_floats (int task_id, int n, float *array );
+VOID muse_ipc_add_doubles (int task_id, int n, double *array );
+
+VOID muse_ipc_get_string (int task_id, char *s);
+VOID muse_ipc_get_bytes (int task_id, VOID *b, int n);
+VOID muse_ipc_get_char (int task_id, char *c);
+VOID muse_ipc_get_short (int task_id, short *n);
+VOID muse_ipc_get_int (int task_id, int *n);
+VOID muse_ipc_get_long (int task_id, int32 *n);
+VOID muse_ipc_get_float (int task_id, float *n);
+VOID muse_ipc_get_double (int task_id, double *n);
+VOID muse_ipc_get_shorts (int task_id, int n, short *array );
+VOID muse_ipc_get_ints (int task_id, int n, int *array );
+VOID muse_ipc_get_longs (int task_id, int n, int32 *array );
+VOID muse_ipc_get_floats (int task_id, int n, float *array );
+VOID muse_ipc_get_doubles (int task_id, int n, double *array );
+#else
+int muse_ipc_spawn ();
+VOID muse_ipc_send ();
+VOID muse_ipc_command ();
+int muse_ipc_receive ();
+int muse_ipc_peek ();
+VOID muse_ipc_init_child ();
+
+VOID muse_ipc_call_back ();
+
+int muse_ipc_setup_client ();
+int muse_ipc_setup_server ();
+
+int muse_ipc_echo ();
+
+VOID muse_ipc_close ();
+
+VOID muse_ipc_init_send();
+
+VOID muse_ipc_add_string ();
+VOID muse_ipc_add_bytes ();
+VOID muse_ipc_add_char ();
+VOID muse_ipc_add_short ();
+VOID muse_ipc_add_int ();
+VOID muse_ipc_add_long ();
+VOID muse_ipc_add_float ();
+VOID muse_ipc_add_double ();
+VOID muse_ipc_add_shorts ();
+VOID muse_ipc_add_ints ();
+VOID muse_ipc_add_longs ();
+VOID muse_ipc_add_floats ();
+VOID muse_ipc_add_doubles ();
+
+VOID muse_ipc_get_string ();
+VOID muse_ipc_get_bytes ();
+VOID muse_ipc_get_char ();
+VOID muse_ipc_get_short ();
+VOID muse_ipc_get_int ();
+VOID muse_ipc_get_long ();
+VOID muse_ipc_get_float ();
+VOID muse_ipc_get_double ();
+VOID muse_ipc_get_shorts ();
+VOID muse_ipc_get_ints ();
+VOID muse_ipc_get_longs ();
+VOID muse_ipc_get_floats ();
+VOID muse_ipc_get_doubles ();
+
+#endif
+
+#endif /* H_MUSE_IPC */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_sql.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_sql.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/muse_sql.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,111 @@
+#ifndef H_MUSE_SQL
+
+#define H_MUSE_SQL
+
+/*
+ * Symbolic constants for C data types related to database data types
+ */
+#define MUSE_SQL_CHAR 1
+#define MUSE_SQL_SHORT 2
+#define MUSE_SQL_INT 3
+#define MUSE_SQL_LONG 4
+#define MUSE_SQL_FLOAT 5
+#define MUSE_SQL_DOUBLE 6
+
+#define MUSE_SQL_CHAR_ARRAY 11
+#define MUSE_SQL_SHORT_ARRAY 12
+#define MUSE_SQL_INT_ARRAY 13
+#define MUSE_SQL_LONG_ARRAY 14
+#define MUSE_SQL_FLOAT_ARRAY 15
+#define MUSE_SQL_DOUBLE_ARRAY 16
+
+#define MUSE_SQL_CHAR_ARRAY2 21
+#define MUSE_SQL_SHORT_ARRAY2 22
+#define MUSE_SQL_INT_ARRAY2 23
+#define MUSE_SQL_LONG_ARRAY2 24
+#define MUSE_SQL_FLOAT_ARRAY2 25
+#define MUSE_SQL_DOUBLE_ARRAY2 26
+
+#define MUSE_SQL_CHAR_ARRAY3 31
+#define MUSE_SQL_SHORT_ARRAY3 32
+#define MUSE_SQL_INT_ARRAY3 33
+#define MUSE_SQL_LONG_ARRAY3 34
+#define MUSE_SQL_FLOAT_ARRAY3 35
+#define MUSE_SQL_DOUBLE_ARRAY3 36
+
+/*
+ * Symbolic constants to represent API calls
+ *
+ */
+#define MUSE_SQL_CONNECT 1
+#define MUSE_SQL_LOGIN 2
+#define MUSE_SQL_CURSOR_OPEN 3
+#define MUSE_SQL_PREPARE 4
+#define MUSE_SQL_SET_PARAM 5
+#define MUSE_SQL_BIND 6
+#define MUSE_SQL_EXECUTE 7
+#define MUSE_SQL_FETCH 8
+#define MUSE_SQL_CURSOR_CLOSE 9
+#define MUSE_SQL_TABLES 10
+#define MUSE_SQL_DESCRIBE_TABLE 11
+#define MUSE_SQL_DESCRIBE_COLUMNS 12
+#define MUSE_SQL_COMMIT 13
+#define MUSE_SQL_ROLLBACK 14
+#define MUSE_SQL_LOGOUT 15
+#define MUSE_SQL_DISCONNECT 16
+#define MUSE_SQL_FOREIGN_TABLES 17
+#define MUSE_SQL_DESCRIBE_FOREIGN_TABLE 18
+#define MUSE_SQL_GET_VARRAY 19
+#define MUSE_SQL_SET_VARRAY 20
+
+/*
+ * Functions
+ */
+
+#if XVT_CC_PROTO
+int muse_sql_connect( char *dbname, char *host );
+int muse_sql_login( int db, char *login, char *passwd, char *database );
+int muse_sql_get_varray( int db, char *pathname );
+int muse_sql_set_varray( int db, char *pathname );
+int muse_sql_cursor_open( int db, char *cursor_name );
+int muse_sql_cursor_close( int db, int cursor );
+int muse_sql_prepare( int db, int cursor, char *sql_stmt );
+int muse_sql_set_param( int db, int cursor, int param, int type,
+ VOID *address, int length, int *var_length );
+int muse_sql_bind( int db, int cursor, int column, int type,
+ VOID *address, int length, int *ret_length );
+int muse_sql_execute( int db, int cursor );
+int muse_sql_fetch( int db, int cursor );
+int muse_sql_tables( int db, int cursor );
+int muse_sql_describe_table( int db, int cursor, char *table );
+int muse_sql_describe_columns( int db, int cursor1, int cursor2 );
+int muse_sql_commit( int db, int cursor );
+int muse_sql_rollback( int db, int cursor );
+int muse_sql_logout( int db );
+int muse_sql_disconnect( int db );
+int muse_sql_foreign_tables( int db, int cursor );
+int muse_sql_describe_foreign_table( int db, int cursor, char *table );
+#else
+int muse_sql_connect( );
+int muse_sql_login( );
+int muse_sql_get_varray( );
+int muse_sql_set_varray( );
+int muse_sql_cursor_open( );
+int muse_sql_cursor_close( );
+int muse_sql_prepare( );
+int muse_sql_set_param( );
+int muse_sql_bind( );
+int muse_sql_execute( );
+int muse_sql_fetch( );
+int muse_sql_tables( );
+int muse_sql_describe_table( );
+int muse_sql_describe_columns( );
+int muse_sql_commit( );
+int muse_sql_rollback( );
+int muse_sql_logout( );
+int muse_sql_disconnect( );
+int muse_sql_foreign_tables( );
+int muse_sql_describe_foreign_table( );
+#endif
+
+#endif /* H_MUSE_SQL */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museapi.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museapi.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museapi.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,24 @@
+#ifndef H_MUSEAPI
+#define H_MUSEAPI
+
+#ifndef H_MUSECONV
+#include "museconv.h"
+#endif
+
+#ifndef H_MUSEPACY
+#include "musepacy.h"
+#endif
+
+#ifndef H_MUSEPHIG
+#include "musephig.h"
+#endif
+
+#ifndef H_MUSESYS
+#include "musesys.h"
+#endif
+
+#ifndef H_MUSERAS
+#include "museras.h"
+#endif
+
+#endif /* H_MUSEAPI */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museconv.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museconv.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museconv.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,71 @@
+#ifndef H_MUSECONV
+
+#define H_MUSECONV
+
+#ifndef H_VECTOR
+#include "vector.h"
+#endif
+
+#if XVT_CC_PROTO
+MUSE_API encode_raster_hdr(unsigned char *record, RASTER * raster);
+MUSE_API decode_raster_hdr(unsigned char *record, RASTER * raster);
+MUSE_API encode_lut(unsigned char *record, LUT * lut);
+MUSE_API decode_lut(unsigned char *record, LUT * lut);
+MUSE_API encode_palette(unsigned char *record, PALETTE * palette);
+MUSE_API decode_palette(unsigned char *record, PALETTE * palette);
+MUSE_API encode_mapdoc(unsigned char *record, MAP_DOC * mapdoc);
+MUSE_API decode_mapdoc(unsigned char *record, MAP_DOC * mapdoc);
+MUSE_API encode_mgm(unsigned char *record, MGM * mgm);
+MUSE_API decode_mgm(unsigned char *record, MGM * mgm);
+MUSE_API encode_units(unsigned char *record, UNITS * units);
+MUSE_API decode_units(unsigned char *record, UNITS * units);
+MUSE_API encode_products(unsigned char *record, PRODUCTS * products);
+MUSE_API decode_products(unsigned char *record, PRODUCTS * products);
+MUSE_API encode_view(unsigned char *record, VIEW * view);
+MUSE_API decode_view(unsigned char *record, VIEW * view);
+MUSE_API encode_defaults(unsigned char *record, DEFAULTS * defaults);
+MUSE_API decode_defaults(unsigned char *record, DEFAULTS * defaults);
+MUSE_API encode_basemap(unsigned char *record, BASEMAP * basemap);
+MUSE_API decode_basemap(unsigned char *record, BASEMAP * basemap);
+MUSE_API encode_grat(unsigned char *record, GRAT_DATA * grat);
+MUSE_API decode_grat(unsigned char *record, GRAT_DATA * grat, int32 version);
+MUSE_API encode_vec_data(unsigned char *record, VEC_DATA * vec_data);
+MUSE_API decode_vec_data(unsigned char *record, VEC_DATA * vec_data);
+MUSE_API long_to_char(unsigned char *record, int32 *l, short big_endian, int32 *c);
+MUSE_API short_to_char(unsigned char *record, short *s, short big_endian, int32 *c);
+MUSE_API char_to_double(unsigned char *record, double *d, short big_endian, int32 *c);
+MUSE_API char_to_long(unsigned char *record, int32 *l, short big_endian, int32 *c);
+MUSE_API char_to_short(unsigned char *record, short *s, short big_endian, int32 *c);
+#else
+MUSE_API encode_raster_hdr();
+MUSE_API decode_raster_hdr();
+MUSE_API encode_lut();
+MUSE_API decode_lut();
+MUSE_API encode_palette();
+MUSE_API decode_palette();
+MUSE_API encode_mapdoc();
+MUSE_API decode_mapdoc();
+MUSE_API encode_mgm();
+MUSE_API decode_mgm();
+MUSE_API encode_units();
+MUSE_API decode_units();
+MUSE_API encode_products();
+MUSE_API decode_products();
+MUSE_API encode_view();
+MUSE_API decode_view();
+MUSE_API encode_defaults();
+MUSE_API decode_defaults();
+MUSE_API encode_basemap();
+MUSE_API decode_basemap();
+MUSE_API encode_grat();
+MUSE_API decode_grat();
+MUSE_API encode_vec_data();
+MUSE_API decode_vec_data();
+MUSE_API long_to_char();
+MUSE_API short_to_char();
+MUSE_API char_to_double();
+MUSE_API char_to_long();
+MUSE_API char_to_short();
+#endif
+
+#endif /* H_MUSECONV */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musedfun.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musedfun.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musedfun.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,26 @@
+#ifndef H_MUSED_FUNC
+#define H_MUSED_FUNC
+
+#ifndef H_MUSEDEF
+#include "musedef.h"
+#endif
+
+#ifndef H_MUSED_DEF
+#include "museddef.h"
+#endif
+
+#if XVT_OS != XVT_OS_MAC
+
+#if XVT_CC_PROTO
+ERRSTATUS muse_dll_link(char *parent_program, char *dll_filename, FARPROC * function_ptr);
+ERRSTATUS muse_dll_unlink(void);
+ERRSTATUS muse_dll_error(char *user_message);
+#else
+ERRSTATUS muse_dll_link();
+ERRSTATUS muse_dll_unlink();
+ERRSTATUS muse_dll_error();
+#endif
+
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musedir.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musedir.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musedir.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,79 @@
+/* MUSEDIR.H */
+#ifndef H_MUSEDIR
+#define H_MUSEDIR
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+#ifdef _UNIX
+#include <unistd.h>
+#endif
+
+#ifndef _WINDOWS
+#ifdef _MAC
+#define FILE_SEP ':'
+#define FILE_EXT1 ""
+#define FILE_EXT2 ""
+#endif
+
+#ifdef _MSDOS
+#define FILE_SEP '\\'
+#define FILE_EXT1 ""
+#define FILE_EXT2 ""
+#endif
+
+#ifdef _UNIX
+#define FILE_SEP '/'
+#define FILE_EXT1 ""
+#define FILE_EXT2 ""
+#endif
+#if XVT_OS == XVT_OS_HPUX
+#define FILE_SEP '/'
+#endif
+#else
+#define FILE_SEP '\\'
+#define FILE_EXT1 ""
+#define FILE_EXT2 ""
+#endif
+
+#define ERRSTATUS short
+
+#ifndef STAT_SUCCESS
+#define STAT_SUCCESS 0
+#endif
+
+#if PROTO
+ERRSTATUS dir_create (char*);
+ERRSTATUS dir_pop(char *);
+ERRSTATUS dir_push(char *, char *);
+ERRSTATUS dir_restore (char *);
+ERRSTATUS dir_save(char *);
+ERRSTATUS dir_current(char *);
+/* ERRSTATUS file_spec_to_string (FILE_SPEC *, char *);*/
+FILE *file_open (char*, char*);
+int muse_access (char *, int);
+int32 muse_filelength (char *);
+void muse_check_path (char*);
+#else
+ERRSTATUS dir_create ();
+ERRSTATUS dir_pop();
+ERRSTATUS dir_push();
+ERRSTATUS dir_restore ();
+ERRSTATUS dir_save();
+ERRSTATUS dir_current();
+ERRSTATUS file_spec_to_string ();
+FILE *file_open ();
+int muse_access ();
+int32 muse_filelength ();
+void muse_check_path ();
+#endif
+
+
+#endif /* H_MUSEDIR */
+
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musepacy.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musepacy.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musepacy.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,15 @@
+#ifndef H_MUSEPACY
+
+#if XVT_CC_PROTO
+MUSE_API
+set_pac_win(WINDOW task, WINDOW pac);
+MUSE_API
+pacify(char *dummy_message, short dummy_percent_complete);
+#else
+MUSE_API
+set_pac_win();
+MUSE_API
+pacify();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museras.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museras.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/museras.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,41 @@
+#ifndef H_MUSERAS
+
+#define H_MUSERAS
+
+#if XVT_CC_PROTO
+MUSE_API raster_construct(FILE * file, RASTER ** pointer);
+MUSE_API raster_destruct(FILE * file, BOOLEAN destruct, RASTER ** raster);
+MUSE_API raster_xform(RASTER * in, RASTER * out, RENDER_INFO * render_info, LUT * default_lut, PALETTE * default_palette);
+MUSE_API palette_construct(FILE * file, PALETTE ** pointer);
+MUSE_API palette_destruct(FILE * file, BOOLEAN destruct, PALETTE ** palette);
+MUSE_API lut_construct(FILE * file, PALETTE * pal, LUT ** pointer);
+MUSE_API lut_destruct(FILE * file, BOOLEAN destruct, LUT ** lut);
+MUSE_API raster_draw(RASTER * raster, WINDOW map_window);
+MUSE_API pal_nearest_color(PALETTE * pal, RGB rgb, USHORT * pal_color);
+MUSE_API file_spec_to_string(FILE_SPEC * file_spec, char *string);
+MUSE_API string_to_file_spec(FILE_SPEC * file_spec, char *string);
+MUSE_API add_color_bias(GHANDLE bitmap);
+MUSE_API remove_color_bias(GHANDLE bitmap);
+MUSE_API muse_error(ERRSTATUS status);
+MUSE_API hsv2rgb(GFLOAT h, GFLOAT s, GFLOAT v, GFLOAT * r, GFLOAT * g, GFLOAT * b);
+MUSE_API pal_gen(PALETTE * pal);
+#else
+MUSE_API raster_construct();
+MUSE_API raster_destruct();
+MUSE_API raster_xform();
+MUSE_API palette_construct();
+MUSE_API palette_destruct();
+MUSE_API lut_construct();
+MUSE_API lut_destruct();
+MUSE_API raster_draw();
+MUSE_API pal_nearest_color();
+MUSE_API file_spec_to_string();
+MUSE_API string_to_file_spec();
+MUSE_API add_color_bias();
+MUSE_API remove_color_bias();
+MUSE_API muse_error();
+MUSE_API hsv2rgb();
+MUSE_API pal_gen();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musesys.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musesys.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/musesys.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,29 @@
+#ifndef H_MUSESYS
+
+#define H_MUSESYS
+
+#if XVT_CC_PROTO
+int32
+muse_filelength(char *path);
+FILE *
+file_open(char *path, char *mode);
+MUSE_API
+dir_restore(char *path);
+MUSE_API
+dir_push(char *sub_dir, char *path);
+MUSE_API
+dir_create(char *path);
+#else
+int32
+muse_filelength();
+FILE *
+file_open();
+MUSE_API
+dir_restore();
+MUSE_API
+dir_push();
+MUSE_API
+dir_create();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,19 @@
+/*
+ at Phigs
+*/
+
+#ifndef H_PHIGS
+
+#define H_PHIGS
+
+
+#ifndef H_PHIGS_DEF
+#include "phigs_d.h"
+#endif
+
+#ifndef H_PHIGS_FUNC
+#include "phigs_f.h"
+#endif
+
+#endif
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,357 @@
+#ifndef H_PHIGS_D
+#define H_PHIGS_D
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_VIEW_DEF
+#include "view_d.h"
+#endif
+
+/***************************************************************
+ at PHIGS #Defines
+****************************************************************
+*/
+
+
+/***************************************************************
+@ PHIGS Line Primitives
+****************************************************************
+PHIGS polyline definitions.
+*/
+#define PLINE_SOLID 1
+#define PLINE_DASH 2
+#define PLINE_DOT 3
+#define PLINE_DOT_DASH 4
+/*
+Description:
+Definitions for PHIGS line styles.
+*/
+
+/***************************************************************
+@ PHIGS Marker Primitives
+****************************************************************
+PHIGS polymarker definitions.
+*/
+#define PMARKER_DOT 1
+#define PMARKER_PLUS 2
+#define PMARKER_ASTERICK 3
+#define PMARKER_CIRCLE 4
+#define PMARKER_CROSS 5
+/*
+Description:
+Definitions for PHIGS marker styles.
+*/
+
+/***************************************************************
+@ PHIGS Color Primitive
+****************************************************************
+PHIGS color definitions.
+*/
+#define BLACK 0
+#define WHITE 1
+#define RED 2
+#define GREEN 3
+#define BLUE 4
+#define YELLOW 5
+#define CYAN 6
+#define MAGENTA 7
+/*
+Description:
+Definitions for PHIGS color primitives for lines,
+markers and text.
+*/
+
+/***************************************************************
+@ PHIGS Primitives
+****************************************************************
+PHIGS primitive definitions.
+*/
+#define PLINE 0
+#define PMARKER 1
+#define PTEXT 2
+#define PEDGE 3
+#define PAREA 4
+/*
+Description:
+*/
+
+/***************************************************************
+@ Pconnid
+****************************************************************
+A PHIGS connection id.
+*/
+typedef char* Pconnid;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ Pfloat
+****************************************************************
+A PHIGS float.
+*/
+typedef double Pfloat;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ Pint
+****************************************************************
+A PHIGS integer.
+*/
+typedef int32 Pint;
+/*
+Description:
+
+*/
+
+/**************************************************************
+@ Pmatrix
+****************************************************************
+A PHIGS matrix.
+*/
+typedef Pfloat Pmatrix[3][3];
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ PMARKER
+****************************************************************
+Marker types for PHIGS
+*/
+typedef enum
+{
+ DOT,
+ PLUS,
+ ASTERICK,
+ CIRCLE,
+ CROSS,
+ SOLID_LINE,
+ DASH_LINE,
+ DOT_LINE
+} Pmarker;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ Pedge_flag
+****************************************************************
+The PHIGS edge flag.
+*/
+typedef enum
+{
+ PEDGE_ON,
+ PEDGE_OFF
+} Pedge_flag;
+/*
+Description:
+Display fill area edges on or off.
+*/
+
+/***************************************************************
+@ Pint_size
+****************************************************************
+A PHIGS size structure.
+*/
+typedef struct
+{
+ Pint size_x;
+ Pint size_y;
+} Pint_size;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ Pint_style
+****************************************************************
+The PHIGS interior style structure.
+*/
+typedef enum
+{
+ PSTYLE_HOLLOW,
+ PSTYLE_SOLID,
+ PSTYLE_PAT,
+ PSTYLE_HATCH,
+ PSTYLE_EMPTY
+} Pint_style;
+/*
+Description:
+The current PHIGS update state.
+*/
+
+/***************************************************************
+@ Pint_list
+****************************************************************
+A PHIGS integer list structure.
+*/
+typedef struct
+{
+ Pint num_ints;
+ Pint *ints;
+} Pint_list;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ Plimit
+****************************************************************
+A PHIGS bounding limit structure.
+*/
+typedef struct
+{
+ Pfloat x_min;
+ Pfloat x_max;
+ Pfloat y_min;
+ Pfloat y_max;
+} Plimit;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ Ppat_rep
+****************************************************************
+A PHIGS pattern representative structure.
+*/
+typedef struct
+{
+ Pint_size dims;
+ unsigned char pHMEM colr_array;
+ Pint pix_per_byte;
+} Ppat_rep;
+/*
+Description:
+A structure containing a stretchable image.
+*/
+
+/***************************************************************
+@ Ppoint
+****************************************************************
+A PHIGS point structure.
+*/
+typedef struct
+{
+ Pfloat x;
+ Pfloat y;
+} Ppoint;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ Ppoint_list
+****************************************************************
+A list of PHIGS points list structure.
+*/
+typedef struct
+{
+ Pint num_points;
+#ifndef _WINDOWS
+ Ppoint *points;
+#else
+ Ppoint *points;
+#endif
+} Ppoint_list;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ Ppoint_list_list
+****************************************************************
+A list of PHIGS point list structures.
+*/
+typedef struct
+{
+ Pint num_point_lists;
+ Ppoint_list *point_lists;
+} Ppoint_list_list;
+/*
+Description:
+Used for displaying fill area sets.
+*/
+
+/***************************************************************
+@ Prect
+****************************************************************
+A PHIGS rectangle structure.
+*/
+typedef struct
+{
+ Ppoint p;
+ Ppoint q;
+} Prect;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ Pregen_flag
+****************************************************************
+A PHIGS regeneration flag enumerater.
+*/
+typedef enum
+{
+ PFLAG_PERFORM,
+ PFLAG_POSTPONE
+} Pregen_flag;
+/*
+Description:
+The PGLAG_POSTPONE value will defer updates to the PHIGS
+workstation.
+*/
+
+/***************************************************************
+@ Pupd_st
+****************************************************************
+The PHIGS update state structure.
+*/
+typedef enum
+{
+ PUPD_NOT_PEND,
+ PUPD_PEND
+} Pupd_st;
+/*
+Description:
+The current PHIGS update state.
+*/
+
+/***************************************************************
+@ Pvec
+****************************************************************
+A PHIGS vector position structure.
+*/
+typedef struct
+{
+ Pfloat delta_x;
+ Pfloat delta_y;
+} Pvec;
+/*
+Description:
+A PHIGS relative position.
+*/
+
+#endif /* H_PHIGS_D */
+
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/phigs_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,595 @@
+/*
+ at PHIGS Functions
+*/
+
+#ifndef H_PHIGS_F
+#define H_PHIGS_F
+
+#ifndef H_PHIGS_D
+#include "phigs_d.h"
+#endif /* H_PHIGS_DEF */
+
+#ifndef H_COLOR_D
+#include "color_d.h"
+#endif
+
+/***************************************************************
+@ pcell_array()
+****************************************************************
+Draw PHIGS Cell Array.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pcell_array(Prect *rectangle, Ppat_rep colr_array);
+#else
+ERRSTATUS MUSE_API pcell_array();
+#endif
+/*
+Description:
+The image contained in colr_array is stretched to fit the
+rectangle.
+*/
+
+/***************************************************************
+@ pclose_phigs()
+****************************************************************
+Close PHIGS Graphics.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pclose_phigs(void);
+#else
+ERRSTATUS MUSE_API pclose_phigs();
+#endif
+/*
+Description:
+Terminate PHIGS graphics.
+*/
+
+/***************************************************************
+@ pclose_structure()
+****************************************************************
+Close a PHIGS structure.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pclose_struct(void);
+#else
+ERRSTATUS MUSE_API pclose_struct();
+#endif
+/*
+Description:
+Close a PHIGS graphics structurte.
+*/
+
+/***************************************************************
+@ pclose_ws()
+****************************************************************
+Close a PHIGS Workstation.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pclose_ws(Pint ws_id);
+#else
+ERRSTATUS MUSE_API pclose_ws();
+#endif
+/*
+Description:
+A workstation is a XVT window.
+*/
+
+/***************************************************************
+@ pdel_struct()
+****************************************************************
+Delete PHIGS structure.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pdel_struct(Pint struct_id);
+#else
+ERRSTATUS MUSE_API pdel_struct();
+#endif
+/*
+Description:
+Delete a PHIGS graphics structure.
+*/
+
+/***************************************************************
+@ pemergency_close_phigs()
+****************************************************************
+Emergency PHIGS close.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pemergency_close_phigs(void);
+#else
+ERRSTATUS MUSE_API pemergency_close_phigs();
+#endif
+/*
+Description:
+Emergency program terminitation.
+*/
+
+/***************************************************************
+@ pfill_area_set()
+****************************************************************
+PHIGS fill area set.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pfill_area_set(Ppoint_list_list *sets);
+#else
+ERRSTATUS MUSE_API pfill_area_set();
+#endif
+/*
+Description:
+Display a set of fill areas. This has the
+capability to display holes in fill areas.
+*/
+
+/***************************************************************
+@ pinq_bitmap()
+****************************************************************
+Inquire bitmap from operating system.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pinq_bitmap(Pint ws_id , GHANDLE bitmap, PALETTE_USAGE palette_usage );
+#else
+ERRSTATUS MUSE_API pinq_bitmap();
+#endif
+/*
+Description:
+This function will return a bitmap of the screen
+from the underlying graphics system.
+*/
+
+/***************************************************************
+@ pinq_open_wss()
+****************************************************************
+Inquire open workstation setup.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pinq_open_wss(Pint length, Pint start, Pint *error,
+ Pint_list *ws_id_list, Pint *total_length);
+#else
+ERRSTATUS MUSE_API pinq_open_wss();
+#endif
+/*
+Description:
+This function will determine whether a workstation
+is open or not.
+*/
+
+/***************************************************************
+@ pinq_wss_trans()
+****************************************************************
+Inquire current PHIGS transformation.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pinq_wss_trans(Pint ws, Pint *error_ind, Pupd_st *upd_st,
+ Plimit *cur_win_lim, Plimit *cur_vp_lim,
+ Pvec *scale_vector, Pvec *trans_vector);
+#else
+ERRSTATUS MUSE_API pinq_wss_trans();
+#endif
+/*
+Description:
+Returns the current setup of the display
+transformation.
+*/
+
+/***************************************************************
+@ popen_phigs()
+****************************************************************
+Open PHIGS graphics.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API popen_phigs(char *error_file, size_t memory);
+#else
+ERRSTATUS MUSE_API popen_phigs();
+#endif
+/*
+Description:
+Must be the first PHIGS call to initialize PHIGS.
+*/
+
+/***************************************************************
+@ popen_struct()
+****************************************************************
+Open PHIGS graphics structure.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API popen_struct(Pint struct_id);
+#else
+ERRSTATUS MUSE_API popen_struct();
+#endif
+/*
+Description:
+Open an existing structure or create a new one.
+*/
+
+/***************************************************************
+@ popen_ws()
+****************************************************************
+Open PHIGS Workstation.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API popen_ws(Pint ws_id, Pconnid *conn_id, Pint ws_type);
+#else
+ERRSTATUS MUSE_API popen_ws();
+#endif
+/*
+Description:
+A PHIGS workstation is a XVT window.
+*/
+
+/***************************************************************
+@ ppolyline()
+****************************************************************
+Draw PHIGS polyline.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API ppolyline(Ppoint_list *point_list);
+#else
+ERRSTATUS MUSE_API ppolyline();
+#endif
+/*
+Description:
+Point_list contains the points to be connected using the
+current line style and color.
+*/
+
+/***************************************************************
+@ ppolymarker()
+****************************************************************
+Draw PHIGS polymakers.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API ppolymarker(Ppoint_list *point_list);
+#else
+ERRSTATUS MUSE_API ppolymarker();
+#endif
+/*
+Description:
+Point_list contains the points at which to place the markers.
+*/
+
+/***************************************************************
+@ ppost_struct()
+****************************************************************
+Post a PHIGS graphics structure.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API ppost_struct(Pint ws_id, Pint struct_id, Pfloat priority);
+#else
+ERRSTATUS MUSE_API ppost_struct();
+#endif
+/*
+Description:
+Sends the PHIGS structure to a workstation.
+PHIGS structures are created by opening, drawing into , and
+closing them.
+*/
+
+/***************************************************************
+@ pput_pal()
+****************************************************************
+Put a PHIGS palette.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pput_pal(Pint ws_id, PALETTE *palette);
+#else
+ERRSTATUS MUSE_API pput_pal();
+#endif
+/*
+Description:
+Assigns the palette argument to the currently open
+phigs workstation. (A window is a PHIGS workstation.)
+*/
+
+/***************************************************************
+@ pscale()
+****************************************************************
+PHIGS scale transformation.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pscale(Pvec scale_vector, Pint error_id, Pmatrix m);
+#else
+ERRSTATUS MUSE_API pscale();
+#endif
+/*
+Description:
+Used to zoom the image.
+*/
+
+/***************************************************************
+@ pset_char_ht()
+****************************************************************
+Set PHIGS character height.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_char_ht(Pfloat height);
+#else
+ERRSTATUS MUSE_API pset_char_ht();
+#endif
+/*
+Description:
+Sets character height scale factor.
+*/
+
+/***************************************************************
+@ pset_edge_colr_ind()
+****************************************************************
+Set PHIGS edge line colour index.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_edge_colr_ind (Pint index);
+#else
+ERRSTATUS MUSE_API pset_edge_colr_ind();
+#endif
+/*
+Description:
+Sets the edge line colour to one of the defined
+line types.
+*/
+
+
+/***************************************************************
+@ pset_edge_flag()
+****************************************************************
+Set to display PHIGS edges on or off.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_edge_flag(Pedge_flag edge_flag);
+#else
+ERRSTATUS MUSE_API pset_edge_flag();
+#endif
+/*
+Description:
+When diplaying fill areas this function determines
+whether the edges are visible or not.
+*/
+
+/***************************************************************
+@ pset_edgetype()
+****************************************************************
+Set PHIGS edge line type.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_edgetype(Pint edgetype);
+#else
+ERRSTATUS MUSE_API pset_edgetype();
+#endif
+/*
+Description:
+Sets the edge line type to one of the defined
+line types.
+*/
+
+/***************************************************************
+@ pset_edgewidth()
+****************************************************************
+Set PHIGS edge width.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_edgewidth(Pfloat width);
+#else
+ERRSTATUS MUSE_API pset_edgewidth();
+#endif
+/*
+Description:
+Sets edge line width.
+*/
+
+/***************************************************************
+@ pset_int_style()
+****************************************************************
+Set PHIGS fill area interior style.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_int_style (Pint_style style);
+#else
+ERRSTATUS MUSE_API pset_int_style();
+#endif
+/*
+Description:
+Sets the fill area interior style to line one of the
+defined types.
+*/
+
+/***************************************************************
+@ pset_int_colr_ind()
+****************************************************************
+Set PHIGS fill area interior colour index.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_int_colr_ind(Pint index);
+#else
+ERRSTATUS MUSE_API pset_int_colr_ind();
+#endif
+/*
+Description:
+Sets the fill area interior color to one of the
+defined types.
+*/
+
+
+
+/***************************************************************
+@ pset_line_colr_ind()
+****************************************************************
+Set PHIGS line colour index.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_line_colr_ind (Pint index);
+#else
+ERRSTATUS MUSE_API pset_line_colr_ind();
+#endif
+/*
+Description:
+Sets the line colour to one of the defined types.
+*/
+
+/***************************************************************
+@ pset_linetype()
+****************************************************************
+Set PHIGS line type.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_linetype(Pint linetype);
+#else
+ERRSTATUS MUSE_API pset_linetype();
+#endif
+/*
+Description:
+Sets the line type to one of the defined types.
+*/
+
+/***************************************************************
+@ pset_linewidth()
+****************************************************************
+Set PHIGS line width.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_linewidth(Pfloat width);
+#else
+ERRSTATUS MUSE_API pset_linewidth();
+#endif
+/*
+Description:
+Sets polyline line width.
+*/
+
+/***************************************************************
+@ pset_marker_colr_ind()
+****************************************************************
+Set PHIGS marker colour index.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_marker_colr_ind (Pint index);
+#else
+ERRSTATUS MUSE_API pset_marker_colr_ind();
+#endif
+/*
+Description:
+Sets the marker colour to one of the defined types.
+*/
+
+/***************************************************************
+@ pset_marker_size()
+****************************************************************
+Set PHIGS marker size.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_marker_size(Pfloat size);
+#else
+ERRSTATUS MUSE_API pset_maker_size();
+#endif
+/*
+Description:
+Sets marker scale factor.
+*/
+
+/***************************************************************
+@ pset_marker_type()
+****************************************************************
+Set PHIGS Set Marker Type.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_marker_type(Pint markertype);
+#else
+ERRSTATUS MUSE_API pset_marker_type();
+#endif
+/*
+Description:
+Sets the marker type to one of the defined types.
+*/
+
+/***************************************************************
+@ pset_text_colr_ind()
+****************************************************************
+Set PHIGS Text Colour Index.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_text_colr_ind (Pint index);
+#else
+ERRSTATUS MUSE_API pset_text_colr_ind();
+#endif
+/*
+Description:
+Sets the text colour to one of the defined types.
+*/
+
+/***************************************************************
+@ pset_ws_vp()
+****************************************************************
+Set PHIGS workstation viewport.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pset_ws_vp (Pint ws_id, Plimit *viewport);
+#else
+ERRSTATUS MUSE_API pset_ws_vp();
+#endif
+/*
+Description:
+Changes the area of the drawing surface.
+*/
+
+/***************************************************************
+@ ptext()
+****************************************************************
+Draw PHIGS text.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API ptext(Ppoint *text_pt, char *text);
+#else
+ERRSTATUS MUSE_API ptext();
+#endif
+/*
+Description:
+Plots text at the text_pt position using the current
+color and style.
+*/
+
+/***************************************************************
+@ ptranslate()
+****************************************************************
+PHIGS translation transformation.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API ptranslate(Pvec trans_vector, Pint error_id, Pmatrix m);
+#else
+ERRSTATUS MUSE_API ptranslate();
+#endif
+/*
+Description:
+Scrolls the display.
+*/
+
+/***************************************************************
+@ pupd_ws()
+****************************************************************
+Update the PHIGS workstation
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API pupd_ws(Pint ws, Pregen_flag regen_flag);
+#else
+ERRSTATUS MUSE_API pupd_ws();
+#endif
+/*
+Description:
+Updates lastest additions to graphics structures
+to the screen.
+*/
+
+/***************************************************************
+@ ws_is_open()
+****************************************************************
+Is PHIGS workstation is open.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API ws_is_open(Pint ws);
+#else
+ERRSTATUS MUSE_API ws_is_open();
+#endif
+/*
+Description:
+Commonly used non-phigs function to test to see if
+workstation is open.
+*/
+
+
+#endif /* #ifndef H_PHIGS_F */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pnt_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pnt_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pnt_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,409 @@
+
+
+#ifndef H_PNT_F
+
+#define H_PNT_F
+
+#ifndef H_COORD_DEF
+#include "coord_d.h"
+#endif
+
+#ifndef H_VALIDFUN
+#include "valid_f.h"
+#endif
+
+
+/***************************************************************
+@ check_for_ltr_x_error()
+****************************************************************
+Check for invalid zones when latitude band is X
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+check_for_ltr_x_error(char *mgrs);
+#else
+BOOLEAN
+check_for_ltr_x_error();
+#endif
+/*
+Description: In MGRS, zones 32, 34, and 36 do not exist in latitude band X.
+If user has entered one of these zones
+followed by an X, return an error message in the MGRS string.
+*/
+
+/***************************************************************
+@ check_for_zone_and_100kms_error()
+****************************************************************
+Check for incompatibility between the MGRS zone and the first
+letter of the 100,000-meter square designation
+*/
+#if XVT_CC_PROTO
+BOOLEAN check_for_zone_and_100kms_error(int iset, char *string);
+#else
+BOOLEAN check_for_zone_and_100kms_error();
+#endif
+/*
+Description: An MGRS zone belongs to one of six zone sets, and the
+set determines which letters are valid for the first character of the
+100,000-meter square. This function returns TRUE if incompatiibility
+is found. See Appendix B of DMA TM 8358.1.
+*/
+
+
+/***************************************************************
+@ check_for_zone_and_100kms_error()
+****************************************************************
+Check for incompatibility between the MGRS zone and the first
+letter of the 100,000-meter square designation
+*/
+#if XVT_CC_PROTO
+BOOLEAN check_for_zone_and_100kms_error(int iset, char *string);
+#else
+BOOLEAN check_for_zone_and_100kms_error();
+#endif
+/*
+Description: An MGRS zone belongs to one of six zone sets, and the
+set determines which letters are valid for the first character of the
+100,000-meter square. This function returns TRUE if incompatiibility
+is found. See Appendix B of DMA TM 8358.1.
+*/
+
+
+/***************************************************************
+@ check_integer()
+****************************************************************
+Check that edit field contains a valid integer with no more
+than the given number of digits
+*/
+#if XVT_CC_PROTO
+BOOLEAN check_integer(short length, char *string, BOOLEAN negs_ok,
+ int *caret_pos);
+#else
+BOOLEAN check_integer();
+#endif
+/*
+Description: Checks each character in a string and
+returns TRUE if a non-digit or too many digits are found. This
+method is used for dialog box fields because E_CHAR events are not
+sent or are not portable.
+*/
+
+
+/***************************************************************
+@ check_real()
+****************************************************************
+Check that edit field contains a valid real number with no
+more than the given total number of digits and the given number
+of digits to the right of the decimal place
+*/
+#if XVT_CC_PROTO
+BOOLEAN check_real(short width, short precision, char *string,
+ int *caret_pos);
+#else
+BOOLEAN check_real();
+#endif
+/*
+Description: checks each character in a string and
+returns TRUE if a non-digit or too many digits are found. This
+method is used for dialog box fields because E_CHAR events are not
+sent or are not portable.
+*/
+
+/***************************************************************
+@ get_input_pt();
+****************************************************************
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+get_input_pt( COORD_TYPE *coord_type, POINT_TYPE *point, int *pt_task_id,
+ char *client_name );
+#else
+ERRSTATUS
+get_input_pt( );
+#endif
+
+
+/***************************************************************
+@ notify_inv_UTM_easting();
+****************************************************************
+Displays error message for out-of-range easting value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_UTM_easting(BOOLEAN *flag, WINDOW win, int control_id);
+#else
+BOOLEAN
+notify_inv_UTM_easting();
+#endif
+/*
+Description: In UTM point-entry screen, displays message and returns focus
+to the easting field if field is blank or value is not in the range
+100000 to 900000.
+*/
+
+/***************************************************************
+@ notify_inv_lat_band()
+****************************************************************
+Displays error message for blank latitude band field
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_lat_band(BOOLEAN *flag, WINDOW win, int control_id);
+#else
+BOOLEAN
+notify_inv_lat_band();
+#endif
+/*
+Description: In MGRS point-entry screen, displays message and returns focus
+to the latitude band field if it is blank
+*/
+
+
+/***************************************************************
+ at notify_inv_lat_deg()
+****************************************************************
+Displays error message for out-of-range GP latitude value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_lat_deg(BOOLEAN *flag, WINDOW win, int control_id, double maxval);
+#else
+BOOLEAN
+notify_inv_lat_deg();
+#endif
+/*
+Description: In point-entry screen, displays message and returns focus to
+the latitude degrees field if value > 90.
+*/
+
+/***************************************************************
+ at notify_inv_lon_deg()
+****************************************************************
+Displays error message for out-of-range GP longitude value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_lon_deg(BOOLEAN *flag, WINDOW win, int control_id, double maxval);
+#else
+BOOLEAN
+notify_inv_lon_deg();
+#endif
+/*
+Description: In point-entry screen, displays message and returns focus to
+the longitude degrees field if value > 180.
+*/
+
+
+/***************************************************************
+ at notify_inv_lat_min_sec()
+****************************************************************
+Displays error message for out-of-range latitude minutes or seconds value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_lat_min_sec(BOOLEAN *flag, WINDOW win, int control_id,
+ int deg_control_id);
+#else
+BOOLEAN
+notify_inv_lat_min_sec();
+#endif
+/*
+Description: In GP point-entry screen, displays message and returns focus to
+a field with an out-of-range value for minutes or seconds;
+*/
+
+
+/***************************************************************
+ at notify_inv_lon_min_sec()
+****************************************************************
+Displays error message for out-of-range longitude minutes or seconds value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_lon_min_sec(BOOLEAN *flag, WINDOW win, int control_id,
+ int deg_control_id);
+#else
+BOOLEAN
+notify_inv_lon_min_sec();
+#endif
+/*
+Description: In GP point-entry screen, displays message and returns focus to
+a field with an out-of-range value for minutes or seconds;
+*/
+
+/***************************************************************
+@ notify_inv_MGRS_zone()
+****************************************************************
+Displays error message for out-of-range zone value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_MGRS_zone(BOOLEAN *flag, WINDOW win, int control_id);
+#else
+BOOLEAN
+notify_inv_MGRS_zone();
+#endif
+/*
+Description: In MGRS point-entry screen, displays error message and
+returns focus to field if zone is invalid
+*/
+
+
+/***************************************************************
+@ notify_inv_UTM_northing()
+****************************************************************
+Displays error message for out-of-range northing value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_UTM_northing(BOOLEAN *flag, WINDOW win, int control_id);
+#else
+BOOLEAN
+notify_inv_UTM_northing();
+#endif
+/*
+Description: In UTM point-entry screen, displays error message and
+returns focus to field if northing > 10000000
+*/
+
+
+/***************************************************************
+@ notify_inv_UPS_northing()
+****************************************************************
+Displays error message for out-of-range northing value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_UPS_northing(BOOLEAN *flag, WINDOW win, int control_id);
+#else
+BOOLEAN
+notify_inv_UPS_northing();
+#endif
+/*
+Description: In UPS point-entry screen, displays error message and
+returns focus to field if northing is bad.
+*/
+
+
+/***************************************************************
+@ notify_inv_UPS_easting()
+****************************************************************
+Displays error message for out-of-range easting value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_UPS_easting(BOOLEAN *flag, WINDOW win, int control_id);
+#else
+BOOLEAN
+notify_inv_UPS_easting();
+#endif
+/*
+Description: In UPS point-entry screen, displays error message and
+returns focus to field if easting is bad.
+*/
+
+
+/***************************************************************
+@ notify_inv_UTM_zone()
+****************************************************************
+Displays error message for out-of-range zone value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_UTM_zone(BOOLEAN *flag, WINDOW win, int control_id);
+#else
+BOOLEAN
+notify_inv_UTM_zone();
+#endif
+/*
+Description: In UTM and MGRS point-entry screen, displays
+message and returns focus to field with an out-of-range value for zone;
+ie value < 1 or > 60.
+*/
+
+
+/***************************************************************
+@ notify_inv_100kms()
+****************************************************************
+Displays error message for invalid 100,000-meter square value
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_100kms(BOOLEAN *flag, WINDOW win, int control_id);
+#else
+BOOLEAN
+notify_inv_100kms();
+#endif
+/*
+Description: In MGRS point-entry screen, displays message and
+returns focus to 100,000-meter square field if value has less than
+two characters.
+*/
+
+/***************************************************************
+@ notify_invalid_dm_fields()
+****************************************************************
+Displays error messages for all invalid DM edit fields
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_invalid_dm_fields(WINDOW xdWindow);
+#else
+BOOLEAN
+notify_invalid_dm_fields();
+#endif
+/*
+Description: Calls individual notify functions for each of the
+GP DM point-entry edit controls
+*/
+
+/***************************************************************
+@ notify_invalid_dms_fields()
+****************************************************************
+Displays error messages for all invalid DMS edit fields
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_invalid_dms_fields(WINDOW win);
+#else
+BOOLEAN
+notify_invalid_dms_fields();
+#endif
+/*
+Description: Calls individual notify functions for each of the
+GP DMS point-entry edit controls
+*/
+
+
+/***************************************************************
+@ notify_inv_x()
+****************************************************************
+Displays error message for invalid value in grid easting edit field
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_x(BOOLEAN *flag, WINDOW win, int control_id, double east_extent,
+ double west_extent);
+#else
+BOOLEAN
+notify_inv_x();
+#endif
+
+/***************************************************************
+@ notify_inv_y()
+****************************************************************
+Displays error message for invalid value in grid easting edit field
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+notify_inv_y(BOOLEAN *flag, WINDOW win, int control_id, double north_extent,
+ double south_extent);
+#else
+BOOLEAN
+notify_inv_y();
+#endif
+
+
+#endif /* H_PNT_F */
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pntappl.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pntappl.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pntappl.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,41 @@
+#ifndef H_PNTAPPL
+#define H_PNTAPPL
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_COORD_DEF
+#include "coord_d.h"
+#endif
+
+#ifndef H_UNIT_DEF
+#include "unit_d.h"
+#endif
+#ifndef H_ELLIPS_DEF
+#include "ellips_d.h"
+#endif
+#ifndef H_DATUM_DEF
+#include "datum_d.h"
+#endif
+#ifndef H_CB_DEF
+#include "cb_d.h"
+#endif
+#ifndef H_PNT_F
+#include "pnt_f.h"
+#endif
+#ifndef H_PNTGUI_F
+#include "pntgui_f.h"
+#endif
+#ifndef H_VALIDFUN
+#include "valid_f.h"
+#endif
+#ifndef H_UNIT_FUNC
+#include "unit_f.h"
+#endif
+#ifndef H_MUSEIPC
+#include "muse_ipc.h"
+#endif
+
+#endif /* H_PNTAPPL */
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pntgui_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pntgui_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/pntgui_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,899 @@
+#ifndef H_PNTGUI_F
+#define H_PNTGUI_F
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+/***************************************************************
+@ pnt_call_back
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+extern void pnt_call_back(int task_id);
+#else
+extern void pnt_call_back();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ send_pnt
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+ERRSTATUS send_pnt(void *point);
+#else
+ERRSTATUS send_pnt();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dmpnt_call_back
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+extern int dmpnt_call_back(int task_id);
+#else
+extern int dmpnt_call_back();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ dmspnt_call_back
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+extern int dmspnt_call_back(int task_id);
+#else
+extern int dmspnt_call_back();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ georfpnt_call_back
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+extern int georfpnt_call_back(int task_id);
+#else
+extern int georfpnt_call_back();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ mgrspnt_call_back
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+extern int mgrspnt_call_back(int task_id);
+#else
+extern int mgrspnt_call_back();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ otherpnt_call_back
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+extern int otherpnt_call_back(int task_id);
+#else
+extern int otherpnt_call_back();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ utmpnt_call_back
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+extern int utmpnt_call_back(int task_id);
+#else
+extern int utmpnt_call_back();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ upspnt_call_back
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+extern int upspnt_call_back(int task_id);
+#else
+extern int upspnt_call_back();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ do_menu_item_quit
+****************************************************************
+do_menu_item_quit
+*/
+#if XVT_CC_PROTO
+void do_menu_item_quit(WINDOW xdWindow);
+#else
+void do_menu_item_quit();
+#endif
+/*
+Description:
+
+*/
+
+
+/***************************************************************
+@ do_e_close
+****************************************************************
+do_e_close
+*/
+#if XVT_CC_PROTO
+void
+do_e_close( void );
+#else
+void
+do_e_close();
+#endif
+
+
+/***************************************************************
+@ do_menu_item_enter_point
+****************************************************************
+do_menu_item_enter_point
+*/
+#if XVT_CC_PROTO
+void do_menu_item_enter_point(WINDOW xdWindow);
+#else
+void do_menu_item_test_enter_point();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_e_create
+****************************************************************
+do_d101_e_create
+*/
+#if XVT_CC_PROTO
+void do_d101_e_create(WINDOW xdWindow);
+#else
+void do_d101_e_create();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ do_d101_lost_focus
+****************************************************************
+do_d101_lost_focus
+*/
+#if XVT_CC_PROTO
+void do_d101_lost_focus(WINDOW xdWindow);
+#else
+void do_d101_lost_focus();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_cancel
+****************************************************************
+do_d101_cancel
+*/
+#if XVT_CC_PROTO
+void do_d101_cancel(WINDOW xdWindow);
+#else
+void do_d101_cancel();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_pb_cancel
+****************************************************************
+do_d101_cancel
+*/
+#if XVT_CC_PROTO
+void do_d101_pb_cancel(WINDOW xdWindow);
+#else
+void do_d101_pb_cancel();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_pb_done
+****************************************************************
+do_d101_pb_done
+*/
+#if XVT_CC_PROTO
+void do_d101_pb_done(WINDOW xdWindow);
+#else
+void do_d101_pb_done();
+#endif
+/*
+Description:
+
+*/
+
+
+/***************************************************************
+@ do_d101_ed_lat_changed
+****************************************************************
+do_d101_ed_lat_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lat_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_lat_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_pb_ed_lat_changed
+****************************************************************
+do_d101_pb_ed_lat_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_pb_ed_lat_changed(WINDOW xdWindow);
+#else
+void do_d101_pb_ed_lat_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_latd_changed
+****************************************************************
+do_d101_pb_ed_latd_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_latd_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_latd_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_latm_changed
+****************************************************************
+do_d101_pb_ed_latm_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_latm_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_latm_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lats_changed
+****************************************************************
+do_d101_pb_ed_lats_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lats_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_lats_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lon_changed
+****************************************************************
+do_d101_ed_lon_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lon_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_lon_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lond_changed
+****************************************************************
+do_d101_pb_ed_lond_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lond_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_lond_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lonm_changed
+****************************************************************
+do_d101_pb_ed_lonm_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lonm_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_lonm_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lons_changed
+****************************************************************
+do_d101_pb_ed_lons_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lons_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_lons_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_rb_n
+****************************************************************
+do_d101_rb_n
+*/
+#if XVT_CC_PROTO
+void do_d101_rb_n(WINDOW xdWindow);
+#else
+void do_d101_rb_n();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_rb_s
+****************************************************************
+do_d101_rb_s
+*/
+#if XVT_CC_PROTO
+void do_d101_rb_s(WINDOW xdWindow);
+#else
+void do_d101_rb_s();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_rb_e
+****************************************************************
+do_d101_rb_e
+*/
+#if XVT_CC_PROTO
+void do_d101_rb_e(WINDOW xdWindow);
+#else
+void do_d101_rb_e();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_rb_w
+****************************************************************
+do_d101_rb_w
+*/
+#if XVT_CC_PROTO
+void do_d101_rb_w(WINDOW xdWindow);
+#else
+void do_d101_rb_w();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lat_focus_active
+****************************************************************
+do_d101_ed_lat_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lat_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_lat_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_latd_focus_active
+****************************************************************
+do_d101_ed_lat_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_latd_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_latd_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_latm_focus_active
+****************************************************************
+do_d101_ed_latm_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_latm_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_latm_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lats_focus_active
+****************************************************************
+do_d101_ed_lats_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lats_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_lats_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lon_focus_active
+****************************************************************
+do_d101_ed_lon_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lon_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_lon_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lond_focus_active
+****************************************************************
+do_d101_ed_lon_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lond_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_lond_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lonm_focus_active
+****************************************************************
+do_d101_ed_lonm_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lonm_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_lonm_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lons_focus_active
+****************************************************************
+do_d101_ed_lons_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lons_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_lons_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lonmin_changed
+****************************************************************
+do_d101_ed_lonmin_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lonmin_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_lonmin_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_latmin_changed
+****************************************************************
+do_d101_ed_latmin_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_latmin_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_latmin_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_latmin_focus_active
+****************************************************************
+do_d101_ed_latmin_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_latmin_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_latmin_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lonmin_focus_active
+****************************************************************
+do_d101_ed_lonmin_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lonmin_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_lonmin_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_quad15_changed
+****************************************************************
+do_d101_ed_quad15_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_quad15_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_quad15_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_quad1_changed
+****************************************************************
+do_d101_ed_quad1_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_quad1_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_quad1_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_quad1_focus_active
+****************************************************************
+do_d101_ed_quad1_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_quad1_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_quad1_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_quad15_focus_active
+****************************************************************
+do_d101_ed_quad15_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_quad15_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_quad15_focus_active();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ do_d101_ed_zone_changed
+****************************************************************
+do_d101_ed_zone_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_zone_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_zone_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_zone_focus_active
+****************************************************************
+do_d101_ed_zone_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_zone_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_zone_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lb_changed
+****************************************************************
+do_d101_ed_lb_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lb_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_lb_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_lb_focus_active
+****************************************************************
+do_d101_ed_lb_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_lb_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_lb_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_sq_changed
+****************************************************************
+do_d101_ed_sq_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_sq_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_sq_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_sq_focus_active
+****************************************************************
+do_d101_ed_sq_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_sq_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_sq_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_easting_changed
+****************************************************************
+do_d101_ed_easting_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_easting_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_easting_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_easting_focus_active
+****************************************************************
+do_d101_ed_easting_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_easting_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_easting_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_northing_changed
+****************************************************************
+do_d101_ed_northing_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_northing_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_northing_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_northing_focus_active
+****************************************************************
+do_d101_ed_northing_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_northing_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_northing_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_x_changed
+****************************************************************
+do_d101_ed_x_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_x_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_x_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_x_focus_active
+****************************************************************
+do_d101_ed_x_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_x_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_x_focus_active();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_y_changed
+****************************************************************
+do_d101_ed_y_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_y_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_y_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_y_focus_active
+****************************************************************
+do_d101_ed_y_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_y_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_y_focus_active();
+#endif
+/*
+Description:
+
+*/
+/*template*/
+#if 0
+/***************************************************************
+@ do_d101_ed_zzz_changed
+****************************************************************
+do_d101_ed_zzz_changed
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_zzz_changed(WINDOW xdWindow);
+#else
+void do_d101_ed_zzz_changed();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ do_d101_ed_zzz_focus_active
+****************************************************************
+do_d101_ed_zzz_focus_active
+*/
+#if XVT_CC_PROTO
+void do_d101_ed_zzz_focus_active(WINDOW xdWindow);
+#else
+void do_d101_ed_zzz_focus_active();
+#endif
+/*
+Description:
+
+*/
+#endif
+
+#endif /*H_PNTGUI_F*/
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/print_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/print_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/print_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,25 @@
+#ifndef H_PRINT_FUNC
+
+#define H_PRINT_FUNC
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+void
+#if XVT_CC_PROTO
+get_printer_size(PRINT_RCD *pr, int32 *height, int32 *width);
+#else
+get_printer_size();
+#endif
+
+#if XVT_CC_PROTO
+BOOLEAN
+print_path( void );
+#else
+BOOLEAN
+print_path();
+#endif
+
+#endif
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/raster_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/raster_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/raster_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,161 @@
+#ifndef H_RASTER_D
+#define H_RASTER_D
+
+#ifndef H_COLOR_D
+#include "color_d.h"
+#endif
+
+
+/*
+ * Description: These are the number types that can be stored in RASTER's.
+ */
+
+/***************************************************************
+@ DATA_MATRIX
+****************************************************************
+A structure for matrix data
+*/
+typedef struct
+{
+ int32 width; /* Num of columns */
+ int32 height; /* Num of rows */
+ int32 bits_per_pixel; /* Num bits for each matrix value */
+ int32 bytes_per_row; /* All rows must be word(16 bit)
+ * alligned */
+ NUM_TYPE num_type; /* Numeric type and size */
+ DATA_TYPE data_type; /* Data or color type */
+ GHANDLE ghandle; /* Global handle defined by XVT */
+} DATA_MATRIX;
+
+/*
+ * Description: To allow portable big arrays, the global heap is used. See
+ * the XVT User's Guide, Chap 15, Memory Allocation. If you are not using XVT
+ * you may need to redefine GHANDLE to void *.
+ */
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ ACCURACY
+****************************************************************
+*/
+typedef struct
+{
+ GFLOAT rel_hor; /* relative horizontal accuracy */
+ GFLOAT abs_hor; /* absolute horizontal accuracy */
+ GFLOAT rel_ver; /* relative data value accuracy */
+ GFLOAT abs_ver; /* absolute data value accuracy */
+} ACCURACY;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ DATE
+****************************************************************
+Date structure
+*/
+typedef struct
+{
+ char year[3];
+ char month[3];
+ char day[3];
+ char hour[3];
+ char minute[3];
+ char second[3];
+} DATE;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ DATA_HDR STRUCTURE
+****************************************************************
+A header structure for all extracted data
+*/
+typedef struct
+{
+ char source[30]; /* Source of the data */
+ GEOGRAPHIC h_units; /* Horizonal units of measurement */
+ VER_DISTANCE v_units; /* Vertical units of measurement */
+ GFLOAT x_res; /* X resoultion of the data in h_units */
+ GFLOAT y_res; /* Y Resolution of the data in h_units */
+ PROJECTION projection; /* Projection name of the data */
+ POINT_DD center; /* Center of the data in geographics */
+ EXTENT extent; /* Bounding geocoordinates of the data */
+ DATUM datum; /* Horizonal and vertical datum */
+ ACCURACY accuracy; /* Accuricy of the data */
+ DATE date; /* Date the data was created/extracted */
+ GFLOAT zoom; /* 0->1 for downsampling, >1 for
+ * interpolation */
+ GFLOAT data_min; /* minimum data value */
+ GFLOAT data_max; /* maximum data value */
+} DATA_HDR;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ RASTER
+****************************************************************
+Contains a grid of image or other data
+*/
+typedef struct
+{
+ int32 magic;
+ DATA_HDR data_hdr;
+ DATA_MATRIX data_matrix;
+ LUT *lut; /* NULL unless data_type is DATA */
+ PALETTE *palette; /* NULL unless data_type is COLOR_INDIRECT */
+} RASTER;
+
+/*
+ * Description: The functions raster_construct() ans raster_destruct are used
+ * to create and destroy these, as well as read and write them from files.
+ */
+
+/***************************************************************
+@ RENDER_INFO
+****************************************************************
+Info to render a DATA raster into a COLOR_INDIRECT raster
+*/
+typedef struct
+{
+ GFLOAT shade_threshold;
+ GFLOAT precision;
+ int32 sunx;
+ int32 suny;
+ PALETTE_USAGE palette_usage;
+} RENDER_INFO;
+
+/*
+ * Description: The shade_threshold is the data differencebetween the data
+ * value and the one located at relative position sunx, suny within the data
+ * raster that is needed to move the color a shade lighter or darker
+ * (depending on sign). The precision can be increased to make the rendering
+ * faster. If the the previous data value and delta are within precision of
+ * the last data value and delta, the last color is used.
+ */
+
+/***************************************************************
+@ MATRIX
+****************************************************************
+A data matrix of any kind
+*/
+typedef struct
+{
+ int32 width; /* of data matrix */
+ int32 height; /* of data matrix */
+ GHANDLE gh;
+ short pHMEM data; /* Row major, bottom to top (short data) */
+} MATRIX;
+
+/*
+ * Description: A major component of the RASTER structure
+ */
+#endif /* H_RASTER_D */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/raster_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/raster_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/raster_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,301 @@
+#ifndef H_RASTER_F
+
+#define H_RASTER_F
+
+/***************************************************************
+@ decode_raster_hdr()
+****************************************************************
+Convert raster_hdr structure to local binary
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+decode_raster_hdr(
+ unsigned char *buffer,
+ RASTER * raster);
+#else
+ERRSTATUS MUSE_API decode_raster_hdr();
+#endif
+
+/*
+ * Description: The raster structure information in the character buffer
+ * (binary portable Intel format) is placed into the raster structure in
+ * local binary. Used by the constructor functions while loading in a map
+ * document.
+ */
+
+/***************************************************************
+@ encode_raster_hdr()
+****************************************************************
+Convert raster_hdr structure external form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+encode_raster_hdr(
+ unsigned char *buffer,
+ RASTER * raster);
+#else
+ERRSTATUS MUSE_API encode_raster_hdr();
+#endif
+
+/*
+ * Description: The raster structure is converted to the external binary
+ * portable (Intel) format. Used by the destructor functions while preparing
+ * to store a map document.
+ */
+
+/***************************************************************
+@ is_raster_ok()
+****************************************************************
+Check for a good raster magic number.
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API is_raster_ok(FILE * file);
+#else
+ERRSTATUS MUSE_API is_raster_ok();
+#endif
+
+/*
+ * Description: Check to see if there a
+ * good raster by checking the raster number.
+ */
+
+/***************************************************************
+@ raster_construct()
+****************************************************************
+Construct a RASTER object
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_construct(
+ FILE * file,
+ RASTER ** pointer);
+#else
+ERRSTATUS MUSE_API raster_construct();
+#endif
+
+/*
+ * Description: If the file argument is not NULL, the raster is read in from
+ * the file, otherwise a default raster is created.
+ */
+
+/***************************************************************
+@ raster_construct_data()
+****************************************************************
+Allocates memory for the raster data
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_construct_data(
+ RASTER * raster);
+#else
+ERRSTATUS MUSE_API raster_construct_data();
+#endif
+
+/*
+ * Description: Once the raster has been created (using raster-construct())
+ * and the width, height, and bits_per_pixel initialized, this function may
+ * be called to allocate global heap space for the data.
+ */
+
+/***************************************************************
+@ raster_copy()
+****************************************************************
+Copy an object of type RASTER
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_copy(
+ RASTER * in,
+ RASTER * out);
+#else
+ERRSTATUS MUSE_API raster_copy();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ raster_data_to_indirect()
+****************************************************************
+Convert a raster containing non-image data into a color image
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_data_to_indirect(
+ RASTER * in,
+ RASTER * out,
+ RENDER_INFO * render_info,
+ LUT * default_lut,
+ PALETTE * default_palette);
+#else
+ERRSTATUS MUSE_API raster_data_to_indirect();
+#endif
+
+/*
+ * Description: Pseudocoloring using a look-up-table is used to produce the
+ * image raster.
+ *
+ */
+
+/***************************************************************
+@ raster_destruct()
+****************************************************************
+Destroy the object of type RASTER
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_destruct(
+ FILE * file,
+ BOOLEAN destruct,
+ RASTER ** pointer);
+#else
+ERRSTATUS MUSE_API raster_destruct();
+#endif
+
+/*
+ * Description: If the file argument is not NULL, the raster is written to
+ * the file. If destruct is TRUE the object of type RASTER is removed from
+ * memory.
+ *
+ */
+
+/***************************************************************
+@ raster_draw()
+****************************************************************
+Draw the (drawable) raster to the map window
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_draw(
+ RASTER * raster, WINDOW map_window);
+#else
+ERRSTATUS MUSE_API raster_draw();
+#endif
+
+/*
+ * Description: The raster must be in drawable form. To be drawable, a
+ * raster must contain data of type COLOR_INDIRECT. Rraster_xform() is used
+ * to convert the various data rasters to a drawable form.
+ *
+ */
+
+/***************************************************************
+@ raster_indirect_to_indirect()
+****************************************************************
+Convert the indirect raster to a new palette
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_indirect_to_indirect(
+ RASTER * in,
+ RASTER * out,
+ PALETTE * new_palette,
+ RENDER_INFO * render_info);
+#else
+ERRSTATUS MUSE_API raster_indirect_to_indirect();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ raster_indirect_to_rgb()
+****************************************************************
+Convert the indirect raster containing an RGB raster
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_indirect_to_rgb(
+ RASTER * in,
+ RASTER * out);
+#else
+ERRSTATUS MUSE_API raster_indirect_to_rgb();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ raster_rgb_to_indirect()
+****************************************************************
+Convert the raster containing an RGB image to a color map image
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_rgb_to_indirect(
+ RASTER * in,
+ RASTER * out,
+ PALETTE * default_palette,
+ RENDER_INFO * render_info);
+#else
+ERRSTATUS MUSE_API raster_rgb_to_indirect();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ raster_setup()
+****************************************************************
+Setup the object of type RASTER
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+raster_setup(
+ BASEMAP * basemap,
+ MGM * mgm);
+#else
+ERRSTATUS MUSE_API raster_setup();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ raster_xform()
+****************************************************************
+Convert a raster to a displayable image form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API raster_xform
+ (
+ RASTER * in,
+ RASTER * out,
+ RENDER_INFO * render_info,
+ LUT * default_lut,
+ PALETTE * default_palette
+);
+#else
+ERRSTATUS MUSE_API raster_xform();
+#endif
+
+/*
+ * Description: Rasters containing non-image data are rendered. RGB images
+ * rasters are converted to color map rasters.
+ */
+
+#endif /* H_RASTER_F */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/reduce2.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/reduce2.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/reduce2.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,27 @@
+#ifndef THIN_DIG_H
+#define THIN_DIG_H
+
+typedef struct
+ {
+ double x;
+ double y;
+ } COORDS;
+
+/* Prototype Definitions */
+#ifdef __STDC__
+void Reduca (COORDS*, int32*, COORDS*, int32*, double*, int32*);
+void Reduc1 (COORDS*, int32*, COORDS*, int32*, double*, int32*);
+void Reduc2 (COORDS*, int32*, COORDS*, int32*, double*, int32*);
+void Xcheck (int32*, double*, double*, int32*, double*, double*, int32*,
+ int32*, double*, double*, int32*, int32*);
+void Plnit (double*, double*, double*, double*, double*, double*,
+ int32*, int32*);
+#else
+ void Reduca ();
+ void Reduc1 ();
+ void Reduc2 ();
+ void Xcheck ();
+ void Plnit ();
+#endif
+
+#endif /* THIN_DIG_H */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/setup.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/setup.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/setup.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,29 @@
+/* SETUP_H */
+
+#ifndef SETUP_H
+#define SETUP_H
+
+#include "vpf.h"
+
+/* Output format types */
+typedef enum {M_VEC=1, VPF, ASCII, DIG} format_type;
+
+typedef struct
+ {
+ char *db_path;
+ char *db_name;
+ char *lib_name;
+ char *cov_name;
+ char *fclass;
+ char *expression;
+ vpf_feature_type feature_type;
+ format_type output_format;
+ double x_min;
+ double x_max;
+ double y_min;
+ double y_max;
+ } SEL_THEME;
+
+
+
+#endif /* SETUP_H */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sql_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sql_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sql_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,6 @@
+#ifndef H_MUSE
+#include "muse.h"
+#endif
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sqllib_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sqllib_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sqllib_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,88 @@
+#ifndef H_SQLLIB_D
+#define H_SQLLIB_D
+
+#ifndef H_VEC_D
+#include "vec_d.h"
+#endif
+
+#ifndef ERRSTATUS
+#define ERRSTATUS short
+#endif
+
+#ifndef MUSE_API
+#define MUSE_API
+#endif
+
+
+#define MAX_QUERY_NAME_LEN 80
+#define MAX_SQL_STMT_LEN 1000
+#define MAX_NAME_LEN 32
+#define MAX_LINE_LEN 1000
+#define MAX_COLUMNS 100
+#define MAX_VALUE_LEN 512
+
+/*#define MAX_FIELDS 50 */
+/*#define MAX_FIELD_LEN 512*/
+#define RR_COUNT 18 /* number of points to approx a circle */
+
+#define COMMA '\,'
+#define TAB '\ '
+#define MUSE_SQL_TEXT_DELIM '\''
+#define IMPORT_TEXT_DELIM '\"'
+#define NULL_CHAR '\0'
+
+typedef union
+{
+ char char_val [MAX_VALUE_LEN];
+ short short_val;
+ int int_val;
+ int32 long_val;
+ float float_val;
+ double double_val;
+} SQL_VALUE;
+
+typedef struct
+{
+ char name[MAX_NAME_LEN + 1];
+ int type;
+ int length;
+ SQL_VALUE value;
+} CELL;
+
+typedef struct
+{
+ char name[MAX_NAME_LEN + 1];
+ short num_columns;
+ CELL cell[MAX_COLUMNS];
+} TUPLE;
+
+
+typedef struct
+{
+ char name[MAX_QUERY_NAME_LEN];
+ char sql_stmt[MAX_SQL_STMT_LEN];
+ char host[MAX_NAME_LEN];
+ char server[MAX_NAME_LEN];
+ char database[MAX_NAME_LEN];
+ char username[MAX_NAME_LEN];
+ char password[MAX_NAME_LEN];
+} SQL_QUERY;
+
+/***************************************************************
+@ SQL_DATA
+****************************************************************
+Defines a vector data structure
+*/
+typedef struct
+{
+ int32 magic;
+ BOOLEAN needs_setup;
+ BOOLEAN needs_execute;
+ BOOLEAN needs_redraw;
+ BOOLEAN needs_refresh;
+ SQL_QUERY sql_query;
+ VEC *vec;
+} SQL_DATA;
+
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sqllib_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sqllib_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sqllib_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,273 @@
+#ifndef H_SQLLIB_F
+#define H_SQLLIB_F
+
+#ifndef H_MUSE
+#include "muse.h"
+#endif
+
+#if XVT_CC_PROTO
+BOOLEAN MUSE_API is_update_stmt(char *sql_stmt);
+#else
+BOOLEAN MUSE_API is_update_stmt();
+#endif
+
+#if XVT_CC_PROTO
+BOOLEAN MUSE_API is_select_stmt(char *sql_stmt);
+#else
+BOOLEAN MUSE_API is_select_stmt();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS freshen_muse_tables ( int db );
+#else
+ERRSTATUS freshen_muse_tables ();
+#endif
+
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API muse_str_trim(char *a, char *b);
+#else
+ERRSTATUS MUSE_API muse_str_trim();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS sqllib_paste_into_table(SQL_DATA *sql_data, char *output_table);
+#else
+ERRSTATUS sqllib_paste_into_table();
+#endif
+
+#if XVT_CC_PROTO
+int32 sqllib_tuple_find ( TUPLE *tuple, char *column_name);
+#else
+int32 sqllib_tuple_find ();
+#endif
+
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API sqllib_do_group_fuction(int db, char *group_function,
+ char *column_name, int column_type, char *table_name, void *return_value);
+#else
+ERRSTATUS MUSE_API sqllib_do_group_fuction();
+#endif
+#if XVT_CC_PROTO
+int32 MUSE_API muse_str_locate(char *a, char *b);
+#else
+int32 MUSE_API muse_str_locate();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS sqllib_bind_select(int db, int cursor, TUPLE *tuple);
+#else
+ERRSTATUS sqllib_bind_select();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS sqllib_describe_table(int db, char *table_name, TUPLE *tuple);
+#else
+ERRSTATUS sqllib_describe_table();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS sqllib_describe_select(int db, int select_cursor, TUPLE *tuple);
+#else
+ERRSTATUS sqllib_describe_select();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS sqllib_map_tuples(TUPLE *tuple_in, TUPLE *tuple_out, int32 tuple_map[]);
+#else
+ERRSTATUS sqllib_map_tuples();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS sqllib_read_definitions ( FILE *fp, TUPLE *tuple, char *primary_key);
+#else
+ERRSTATUS sqllib_read_definitions ();
+#endif
+/* loads tuple structure from a definition file
+ format: column_name column_type column_length initial value
+ Column names beginning with * will become PRIMARY KEYS.
+ Lines beginning with # are ignored.
+*/
+
+
+#if XVT_CC_PROTO
+ERRSTATUS sqllib_units_dms_to_dd(char *point, double *latdd, double *londd);
+ERRSTATUS dmsdd(double dms, double *dd);
+#else
+ERRSTATUS sqllib_units_dms_to_dd();
+ERRSTATUS dmsdd();
+#endif
+
+
+/***************************************************************
+@ sql_data_construct()
+****************************************************************
+function to costruct sql_data structure
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS sql_data_construct(FILE * file, SQL_DATA ** sql_data, BYTE_ORDER * bo);
+#else
+ERRSTATUS sql_data_costruct();
+#endif
+
+
+/***************************************************************
+@ sql_data_destruct()
+****************************************************************
+function to destruct sql_data structure
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS sql_data_destruct(FILE * file, BOOLEAN destruct, SQL_DATA ** sql_data, BYTE_ORDER * bo);
+#else
+ERRSTATUS sql_data_destruct();
+#endif
+
+
+/***************************************************************
+@ decode_sql_data()
+****************************************************************
+function to decode sql_data structure
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS decode_sql_data(unsigned char *record, SQL_DATA * sql_data);
+#else
+ERRSTATUS decode_sql_data();
+#endif
+
+
+/***************************************************************
+@ encode_sql_data()
+****************************************************************
+function to encode sql_data structure
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS encode_sql_data(unsigned char *record, SQL_DATA * sql_data);
+#else
+ERRSTATUS encode_sql_data();
+#endif
+
+
+/***************************************************************
+@ sqllib_generate_vec()
+****************************************************************
+Execute the SQL query drawing into a VEC
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+sqllib_generate_vec(SQL_DATA *sql_data);
+#else
+ERRSTATUS
+sqllib_generate_vec();
+#endif
+/*
+Description:
+*/
+
+
+/***************************************************************
+@ sqllib_close()
+****************************************************************
+Close and disconnect from the MUSE SQL database
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+sqllib_close(SQL_QUERY *sql_query, int *db_handle);
+#else
+ERRSTATUS
+sqllib_close();
+#endif
+/*
+Description:
+*/
+
+
+/***************************************************************
+@ sqllib_import()
+****************************************************************
+Import ASCII table into the MUSE SQL database
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+sqllib_import(int db_handle, char *filename);
+#else
+ERRSTATUS
+sqllib_import();
+#endif
+/*
+Description:
+The table must be comma delimited ASCII with the first
+line coantaining field names. It must be in the default
+directory,
+*/
+
+/***************************************************************
+@ sqllib_open()
+****************************************************************
+Connect and login to the MUSE SQL database
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+sqllib_open(SQL_QUERY *sql_query, int *db_handle);
+#else
+ERRSTATUS
+sqllib_open();
+#endif
+/*
+Description:
+*/
+
+
+/***************************************************************
+@ sqllib_units_dms_to_dd()
+****************************************************************
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+sqllib_units_dms_to_dd(char *point, double *latdd, double *londd);
+#else
+ERRSTATUS
+sqllib_units_dms_to_dd();
+#endif
+/*
+Description:
+*/
+/***************************************************************
+@ sqllib_test_connection()
+****************************************************************
+*/
+#if XVT_CC_PROTO
+BOOLEAN
+sqllib_test_connection(SQL_QUERY *sql_query);
+#else
+BOOLEAN
+sqllib_test_connection();
+#endif
+/*
+Description:
+Returns TRUE if the connection fails.
+Returns FALSE if the connection succeeds.
+*/
+
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API sqllib_parse_CDA_column_names(char *line, TUPLE *tuple);
+ERRSTATUS MUSE_API sqllib_parse_CDA_column_types(char *line, TUPLE *tuple);
+ERRSTATUS MUSE_API sqllib_parse_CDA_values(char *line, TUPLE *tuple);
+ERRSTATUS MUSE_API sqllib_create_table(int db, TUPLE *tuple, char *primary_key);
+ERRSTATUS MUSE_API sqllib_insert_tuple(int db, TUPLE *tuple);
+ERRSTATUS MUSE_API sqllib_cell_value_set(char *value, CELL *cell);
+#else
+ERRSTATUS MUSE_API sqllib_parse_CDA_column_names();
+ERRSTATUS MUSE_API sqllib_parse_CDA_column_types();
+ERRSTATUS MUSE_API sqllib_parse_CDA_values();
+ERRSTATUS MUSE_API sqllib_create_table();
+ERRSTATUS MUSE_API sqllib_insert_tuple();
+ERRSTATUS MUSE_API sqllib_cell_value_set();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunras_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunras_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunras_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,43 @@
+#ifndef H_SUNR_DEF
+#define H_SUNR_DEF
+
+struct rasterfile
+{
+ int32 ras_magic; /* magic number */
+ int32 ras_width; /* width (pixels) of image */
+ int32 ras_height; /* height (pixels) of image */
+ int32 ras_depth; /* depth (1, 8, or 24 bits) of pixel */
+ int32 ras_length; /* length (bytes) of image */
+ int32 ras_type; /* type of file; see RT_* below */
+ int32 ras_maptype;/* type of colormap; see RMT_* below */
+ int32 ras_maplength; /* length (bytes) of following map */
+ /* color map follows for ras_maplength bytes, followed by image */
+};
+#define RAS_MAGIC 0x59a66a95
+
+/* Sun supported ras_type's */
+#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */
+#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */
+#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */
+#define RT_FORMAT_RGB 3 /* XRGB or RGB instead of XBGR or BGR */
+#define RT_FORMAT_TIFF 4 /* tiff <-> standard rasterfile */
+#define RT_FORMAT_IFF 5 /* iff (TAAC format) <-> standard rasterfile */
+#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */
+
+/* Sun registered ras_maptype's */
+#define RMT_RAW 2
+/* Sun supported ras_maptype's */
+#define RMT_NONE 0 /* ras_maplength is expected to be 0 */
+#define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */
+
+/*
+ * NOTES: Each line of the image is rounded out to a multiple of 16 bits.
+ * This corresponds to the rounding convention used by the memory pixrect
+ * package (/usr/include/pixrect/memvar.h) of the SunWindows system. The
+ * ras_encoding field (always set to 0 by Sun's supported software) was
+ * renamed to ras_length in release 2.0. As a result, rasterfiles of type 0
+ * generated by the old software claim to have 0 length; for compatibility,
+ * code reading rasterfiles must be prepared to compute the true length from
+ * the width, height, and depth fields.
+ */
+#endif /* !H_SUNR_DEF */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunras_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunras_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunras_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,55 @@
+/*
+ * @Contents SUNRFUNC.H includes definitions commonly used in MUSE
+ * applications.
+ */
+
+#ifndef H_SUNR_FUNC
+
+/*
+ * @#Defines Press the Next button to view. H_SUNR_FUNC H_SUNR_FUNC is
+ * defined to indicate that the SUNRFUNC.H header has been included.
+ */
+
+#define H_SUNR_FUNC
+
+
+/*
+ * @#Includes
+ */
+
+/*
+ * JLL #ifndef H_MUSEDEF #include "musedef.h" #endif
+ */
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+
+/*
+ * @Functions
+ */
+
+/*
+ * @ raster_to_sunraster
+ */
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API raster_to_sunraster(RASTER * raster, FILE_SPEC file_spec);
+#else
+ERRSTATUS MUSE_API raster_to_sunraster();
+#endif
+
+/*
+ * @ lan_to_raster
+ */
+
+#if 0
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API sunraster_to_raster(FILE_SPEC file_spec, RASTER * raster);
+#else
+ERRSTATUS MUSE_API sunraster_to_raster();
+#endif
+
+#endif
+
+#endif /* end H_SUNR_FUNC */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrast.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrast.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrast.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,12 @@
+#ifndef H_SUNRAST
+#define H_SUNRAST
+
+#ifndef H_SUNR_DEF
+#include "sunrdef.h"
+#endif
+
+#ifndef H_SUNR_FUNC
+#include "sunrfunc.h"
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrdef.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrdef.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrdef.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,43 @@
+#ifndef H_SUNR_DEF
+#define H_SUNR_DEF
+
+struct rasterfile
+{
+ int32 ras_magic; /* magic number */
+ int32 ras_width; /* width (pixels) of image */
+ int32 ras_height; /* height (pixels) of image */
+ int32 ras_depth; /* depth (1, 8, or 24 bits) of pixel */
+ int32 ras_length; /* length (bytes) of image */
+ int32 ras_type; /* type of file; see RT_* below */
+ int32 ras_maptype;/* type of colormap; see RMT_* below */
+ int32 ras_maplength; /* length (bytes) of following map */
+ /* color map follows for ras_maplength bytes, followed by image */
+};
+#define RAS_MAGIC 0x59a66a95
+
+/* Sun supported ras_type's */
+#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */
+#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */
+#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */
+#define RT_FORMAT_RGB 3 /* XRGB or RGB instead of XBGR or BGR */
+#define RT_FORMAT_TIFF 4 /* tiff <-> standard rasterfile */
+#define RT_FORMAT_IFF 5 /* iff (TAAC format) <-> standard rasterfile */
+#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */
+
+/* Sun registered ras_maptype's */
+#define RMT_RAW 2
+/* Sun supported ras_maptype's */
+#define RMT_NONE 0 /* ras_maplength is expected to be 0 */
+#define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */
+
+/*
+ * NOTES: Each line of the image is rounded out to a multiple of 16 bits.
+ * This corresponds to the rounding convention used by the memory pixrect
+ * package (/usr/include/pixrect/memvar.h) of the SunWindows system. The
+ * ras_encoding field (always set to 0 by Sun's supported software) was
+ * renamed to ras_length in release 2.0. As a result, rasterfiles of type 0
+ * generated by the old software claim to have 0 length; for compatibility,
+ * code reading rasterfiles must be prepared to compute the true length from
+ * the width, height, and depth fields.
+ */
+#endif /* !H_SUNR_DEF */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrfunc.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrfunc.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/sunrfunc.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,52 @@
+/*
+ * @Contents SUNRFUNC.H includes definitions commonly used in MUSE
+ * applications.
+ */
+
+#ifndef H_SUNR_FUNC
+
+/*
+ * @#Defines Press the Next button to view. H_SUNR_FUNC H_SUNR_FUNC is
+ * defined to indicate that the SUNRFUNC.H header has been included.
+ */
+
+#define H_SUNR_FUNC
+
+
+/*
+ * @#Includes
+ */
+
+#ifndef H_MUSE
+#include "muse.h"
+#endif
+
+/*
+ * @Functions
+ */
+
+/*
+ * @ raster_to_sunraster
+ */
+
+#if XVT_CC_PROTO
+ERRSTATUS raster_to_sunraster(RASTER * raster, FILE_SPEC file_spec);
+#else
+ERRSTATUS raster_to_sunraster();
+#endif
+
+/*
+ * @ lan_to_raster
+ */
+
+#if 0
+
+#if XVT_CC_PROTO
+ERRSTATUS sunraster_to_raster(FILE_SPEC file_spec, RASTER * raster);
+#else
+ERRSTATUS sunraster_to_raster();
+#endif
+
+#endif
+
+#endif /* end H_SUNR_FUNC */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/system_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/system_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/system_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,522 @@
+/* SYSTEM_D.H */
+
+#ifndef H_SYSTEM_D
+#define H_SYSTEM_D
+
+#include <stdio.h>
+
+#ifndef INCL_XVTH
+#include "xvt.h" /* to define the conditional compilation
+ * constants */
+#endif /* INCL_XVTH */
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+
+/***************************************************************
+@ DATA_TYPE
+****************************************************************
+Type of data contained in a RASTER object
+*/
+typedef enum
+{
+ COLOR_INDIRECT, /* color index numbers */
+ COLOR_RGB, /* rgb values */
+ DATA, /* non-color data values */
+ GRAY_SCALE /* gray scale values */
+}
+ DATA_TYPE;
+
+/*
+ * Description: COLOR_INDIRECT rasters contain a matrix of color-map indices.
+ * COLOR_RGB rasters contain an RGB true-color image. DATA rasters contain
+ * data which must be rendered before being displayed.
+ */
+
+
+/***************************************************************
+@ NUM_TYPE
+****************************************************************
+Types of numbers
+*/
+typedef enum
+{
+ ONEBIT, /* binary data (0 or 1) */
+ UINT_4BIT, /* unsigned 4 bit data (0 -> 15) */
+ SINT_8BIT, /* signed 8 bit data (-128 -> 127) */
+ UINT_8BIT, /* unsigned 8 bit data (0 -> 255) */
+ SINT_16BIT, /* signed 16 bit (-32768 -> 32767) */
+ UINT_16BIT, /* unsigned 16 bit ( 0 -> 64K) */
+ DTED_16BIT, /* Univac signed magnitude */
+ RGB_24BIT, /* RGB (0 -> 255) interleaved by pixel */
+ RGB_48BIT, /* RGB (0 -> 65535) interleaved by pixel */
+ SINT_32BIT, /* signed 32 bit */
+ UINT_32BIT, /* unsigned 32 bit */
+ IEEE_32BIT, /* same as float */
+ IEEE_64BIT /* same as double */
+}
+ NUM_TYPE;
+
+
+
+/****************************************************************/
+/* THINK C for the Macintosh II running MAC OS */
+/****************************************************************/
+
+#if XVT_OS == XVT_OS_MAC
+/* Standard THINK C libraries */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+
+#define DTED_EXT ".DT1;1"
+#define PAL_OFFSET 0
+#endif /* if XVT_OS == XVT_OS_MAC */
+
+
+/****************************************************************/
+/* TURBO C for the IBM PC running MS-DOS */
+/****************************************************************/
+
+#if XVT_OS == XVT_OS_WIN
+/* Standard TURBO C header files */
+
+#include <stdio.h>
+#include <io.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+#include <fcntl.h>
+#include <process.h>
+
+/* Other useful macros */
+#define TRUE 1
+#define FALSE 0
+#define DLongSwap(a,b)
+
+#define DTED_EXT ".DT1"
+#define PAL_OFFSET 0
+#endif /* if XVT_OS == XVT_OS_WIN */
+
+
+/****************************************************************/
+/* Sun Workstation */
+/****************************************************************/
+
+#if XVT_OS_IS_SUNOS
+/* Standard SUN C headers */
+#include <stdio.h>
+#include <fcntl.h>
+#include <math.h>
+
+/* Other useful SUN macros and typedefs */
+#define TRUE 1
+#define FALSE 0
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#define O_BINARY 0
+
+/* typedef unsigned short size_t; */
+
+#define DTED_EXT ".dt1"
+#define PAL_OFFSET 38
+#endif
+
+/****************************************************************/
+/* SGI Workstation */
+/****************************************************************/
+
+#if XVT_OS == XVT_OS_IRIX
+/* Standard IRIX C headers */
+#include <stdio.h>
+#include <fcntl.h>
+#include <math.h>
+
+/* Other useful SGI macros and typedefs */
+#define TRUE 1
+#define FALSE 0
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#define O_BINARY 0
+
+/* typedef unsigned short size_t; */
+
+#define DTED_EXT ".dt1"
+#define PAL_OFFSET 38
+#endif
+
+/****************************************************************/
+/* HP Workstation */
+/****************************************************************/
+
+#if XVT_OS == XVT_OS_HPUX
+/* Standard HP headers */
+#include <stdio.h>
+#include <fcntl.h>
+#include <math.h>
+
+/* Other useful HP macros and typedefs */
+#define TRUE 1
+#define FALSE 0
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#define O_BINARY 0
+
+#define DTED_EXT ".dt1"
+#define PAL_OFFSET 38
+#endif
+
+/****************************************************************/
+/* SCO Workstation */
+/****************************************************************/
+
+#if XVT_OS == XVT_OS_SCOUNIX
+/* Standard SCO headers */
+#include <stdio.h>
+#include <fcntl.h>
+#include <math.h>
+
+/* Other useful SCO macros and typedefs */
+#define TRUE 1
+#define FALSE 0
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#define O_BINARY 0
+
+#define DTED_EXT ".dt1"
+#define PAL_OFFSET 38
+
+typedef unsigned int size_t;
+#endif
+
+/****************************************************/
+/* SPECIFY FILE TYPES */
+/****************************************************/
+
+#define FT_LUT "lut"
+#define FT_MAP "map"
+#define FT_PAL "pal"
+#define FT_RAS "ras"
+#define FT_RAS_ADRG "adr"
+#define FT_RAS_ADRI "adi"
+#define FT_RAS_CAC "cac"
+#define FT_RAS_CIB "cib"
+#define FT_RAS_CADRG "cad"
+#define FT_RAS_CRG "crg"
+#define FT_RAS_DATA "ima"
+#define FT_RAS_DBDB5 "dbd"
+#define FT_RAS_ASRP "asr"
+#define FT_RAS_USRP "usr"
+#define FT_RAS_SRG "srg"
+#define FT_DTC "dtc"
+#define FT_TXT "txt"
+#define FT_RAS_DTED "dte"
+#define FT_VEC "vec"
+#define FT_UNKNOWN "\0"
+
+/****************************************************/
+/* PROCESSOR BYTE ORDER DEPENDENCIES */
+/****************************************************/
+
+#if (XVT_OS == XVT_OS_MAC) || (XVT_OS_IS_SUNOS) || (XVT_OS == XVT_OS_IRIX)
+/* Motorola, Sparc, or other BigEndian processors */
+
+#define BigEndianToShortArray(byteCount,shortPtr)
+#define BigEndianToLongArray(byteCount,longPtr)
+
+#if XVT_CC_PROTO
+void LittleEndianToLongArray(int32 byteCount, int32 *longPtr);
+void LittleEndianToShortArray(int32 byteCount, short *shortPtr);
+void SignedMagnitudeToShortArray(int32 byteCount, short *shortPtr);
+#else
+void LittleEndianToLongArray();
+void LittleEndianToShortArray();
+void SignedMagnitudeToShortArray();
+#endif
+
+#endif
+
+#if (XVT_OS == XVT_OS_WIN) || (XVT_OS == XVT_OS_SCOUNIX) || (XVT_OS == XVT_OS_HPUX)
+/* Intel, or LittleEndian processor */
+
+#define LittleEndianToLongArray(s,d)
+#define LittleEndianToShortArray(s,d)
+#define BigEndianToShortArray(s, d) swab((char *)(d), (char *)(d), (int)(s))
+#define TwosComplimentToShortArray(s,d)
+
+#if XVT_CC_PROTO
+void BigEndianToLongArray(int32 size, int32 *data);
+void SignedMagnitudeToShortArray(int32 size, short *data);
+#else
+void BigEndianToLongArray();
+void SignedMagnitudeToShortArray();
+#endif
+
+#endif
+
+#if XVT_OS_IS_SUNOS
+#include <sys/stdtypes.h>
+#endif
+
+#if XVT_OS == XVT_OS_MAC
+#define FILE_SEP ':'
+#elif XVT_OS == XVT_OS_WIN
+#define FILE_SEP '\\'
+#elif XVT_OS_ISUNIX || XVT_OS == XVT_OS_IRIX || XVT_OS == XVT_OS_HPUX
+#define FILE_SEP '/'
+#endif
+
+#ifndef MUSE_DEBUG
+#define muse_malloc(a, b) malloc(a)
+#define muse_free(a, b) free(a)
+#endif
+
+/***************************************************************
+@ Sign
+****************************************************************
+*/
+#define Sign(x) ( (x) < 0.0 ? -1 : 1 )
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ DivBy
+****************************************************************
+A set of bit shifting divide macros
+*/
+#define DivBy2(i) ( (i) >> 1 )
+#define DivBy4(i) ( (i) >> 2 )
+#define DivBy8(i) ( (i) >> 3 )
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ Flip
+****************************************************************
+Byte fliping macros
+*/
+#define Flip(a) ( sizeof(a) == 4 ? Flip4(a) : Flip2(a) )
+
+#define Flip2(a) ( ( ( (a) & 0x0000FF ) << 8 ) | \
+ ( ( (a) & 0x00FF00 ) >> 8 ) )
+
+#define Flip4(a) ( ( ( (a) & 0x000000FF ) << 24 ) | \
+ ( ( (a) & 0x0000FF00 ) << 8 ) | \
+ ( ( (a) & 0x00FF0000 ) >> 8 ) | \
+ ( ( (a) & 0xFF000000 ) >> 24 ) )
+
+/*
+ * Description: These macros are used by the "Endian" functions that
+ * rearrange the bytes to allow integer data written on Motorola style
+ * computers to be read on Intel style computers, and vice versa.
+ */
+
+/***************************************************************
+@ ERROR CODES
+****************************************************************
+Error code values
+*/
+
+/*
+ * Error Code Masks
+ */
+
+#define STAT_MASK_SEV 0xE000
+#define STAT_MASK_GRP 0x1F00
+#define STAT_MASK_COD 0x00FF
+
+/*
+ * Severity Codes
+ */
+
+#define STAT_SEV_NO_ERR 0x0000
+#define STAT_SEV_MESSAGE 0x2000
+#define STAT_SEV_WARNING 0x4000
+#define STAT_SEV_ERROR 0x6000
+#define STAT_SEV_FATAL 0x8000
+#define STAT_SEV_CRITICAL 0xA000
+
+/*
+ * Group Codes
+ */
+
+#define STAT_GRP_NO_ERR 0x0000
+#define STAT_GRP_SYSTEM 0x0100
+#define STAT_GRP_FILE 0x0200
+#define STAT_GRP_MATH 0x0300
+#define STAT_GRP_DATA 0x0400
+#define STAT_GRP_PARAM 0x0500
+
+/*
+ * No Error Group Error Codes
+ */
+#define STAT_SUCCESS ( STAT_GRP_NO_ERR | \
+ STAT_SEV_NO_ERR | \
+ 0x0000 )
+/* Error allocating memory */
+
+/*
+ * System Group Error Codes
+ */
+
+#define STAT_MEM_ALLOC_ERR ( STAT_GRP_SYSTEM | \
+ STAT_SEV_CRITICAL | \
+ 0x0001 )
+/* Error allocating memory */
+#define STAT_OS_ERROR ( STAT_GRP_SYSTEM | \
+ STAT_SEV_CRITICAL | \
+ 0x0002 )
+/* An unknown operating system error */
+#define STAT_SOFTWARE_BUG ( STAT_GRP_SYSTEM | \
+ STAT_SEV_CRITICAL | \
+ 0x0003 )
+/* A possible bug in the software was found */
+/* Abort condition */
+#define STAT_ABORT ( STAT_GRP_SYSTEM | \
+ STAT_SEV_MESSAGE | \
+ 0x0004)
+
+/*
+ * File Group Error Codes
+ */
+
+#define STAT_FILE_CREAT_ERR ( STAT_GRP_FILE | \
+ STAT_SEV_ERROR | \
+ 0x0001 )
+/* Unable to create file */
+#define STAT_FILE_CLOSE_ERR ( STAT_GRP_FILE | \
+ STAT_SEV_ERROR | \
+ 0x0002 )
+/* Unable to close file */
+#define STAT_FILE_NOT_FOUND ( STAT_GRP_FILE | \
+ STAT_SEV_ERROR | \
+ 0x0003 )
+/* Could not open file */
+#define STAT_FILE_READ_ERR ( STAT_GRP_FILE | \
+ STAT_SEV_ERROR | \
+ 0x0004 )
+/* Error reading from file */
+#define STAT_FILE_TYPE_ERR ( STAT_GRP_FILE | \
+ STAT_SEV_ERROR | \
+ 0x0005 )
+/* The specified file is of the wrong type */
+#define STAT_FILE_WRITE_ERR ( STAT_GRP_FILE | \
+ STAT_SEV_ERROR | \
+ 0x0006 )
+/* Error writing to a file */
+
+/*
+ * Math Group Error Codes
+ */
+
+#define STAT_DIV_BY_ZERO ( STAT_GRP_MATH | \
+ STAT_SEV_ERROR | \
+ 0x0001 )
+/* Attempt to divide by zero */
+
+/*
+ * Data Group Error Codes
+ */
+
+#define STAT_DATA_ERR ( STAT_GRP_DATA | \
+ STAT_SEV_FATAL | \
+ 0x0001 )
+/* Data index or corrupt data error */
+#define STAT_NO_DATA ( STAT_GRP_DATA | \
+ STAT_SEV_WARNING | \
+ 0x0002 )
+/* No data for given location */
+
+/*
+ * Parameter Group Error Codes
+ */
+
+#define STAT_INV_PROJ ( STAT_GRP_PARAM | \
+ STAT_SEV_FATAL | \
+ 0x0001 )
+/* Invalid projection */
+#define STAT_BAD_PARM ( \
+ STAT_GRP_PARAM | \
+ STAT_SEV_ERROR | \
+ 0x0002 \
+ )
+#define STAT_PARM_OVERFLOW ( \
+ STAT_GRP_PARAM | \
+ STAT_SEV_ERROR | \
+ 0x0003 \
+ )
+#define STAT_BAD_CLR_NAME ( STAT_GRP_PARAM | \
+ STAT_SEV_FATAL | \
+ 0x0004 )
+/* Unknown color name */
+
+/*
+ * Description: All MUSE functions return an error status code. The status
+ * code STAT_SUCCESS is zero so a boolean test map be performed. The function
+ * muse_error() can be called to handle the error code.
+ */
+
+/***************************************************************
+@ FILE_CREATOR
+****************************************************************
+Associates data exchange files with FUSION program
+*/
+#define FILE_CREATOR "MUSE"
+
+/*
+ * Description: The data extractor programs should call the XVT function
+ * set_file_type() to set the extracted file's creator to this value.
+ */
+
+/***************************************************************
+@ GetErr
+****************************************************************
+*/
+#define GerErrCode(status) (status & STAT_MASK_COD)
+#define GetErrGroup(status) (status & STAT_MASK_GRP)
+#define GetErrSeverity(status) (status & STAT_MASK_SEV)
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ BITS_PER_BYTE
+****************************************************************
+All supported systems have an 8 bit byte.
+*/
+#define BITS_PER_BYTE 8L
+
+/*
+ * Description:
+ *
+ */
+/***************************************************************
+@ pHMEM_NULL
+****************************************************************
+*/
+#define pHMEM_NULL ((pvHMEM) 0L)
+typedef void pHMEM pvHMEM;
+
+/*
+ * Description:
+ */
+#endif /* H_SYSTEM_D */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/system_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/system_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/system_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,540 @@
+/* SYSTEM_F.H */
+
+#ifndef H_SYSTEM_F
+#define H_SYSTEM_F
+
+#include <stdio.h>
+
+/*
+ * JLL #if XVT_OS_IS_SUNOS #include <sys/stdtypes.h> #endif
+ */
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API muse_error(ERRSTATUS status);
+#else
+ERRSTATUS MUSE_API muse_error();
+#endif
+
+#if XVT_CC_PROTO
+void lowercase(char *);
+void eol(char *, char *);
+#else
+void lowercase();
+void eol();
+#endif
+
+/***************************************************************
+@ big_fread()
+****************************************************************
+Reads in an arbitrarily large chunk of data
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+big_fread(
+ FILE * file,
+ GHANDLE handle,
+ uint32 length_in_bytes,
+ NUM_TYPE num_type,
+ DATA_TYPE data_type);
+#else
+ERRSTATUS MUSE_API big_fread();
+#endif
+
+/*
+ * Description: Big_fread allows reading of blocks of data larger than 64K
+ * bytes on all systems, including DOS.
+ */
+
+/***************************************************************
+@ big_fwrite()
+****************************************************************
+Writes an arbitrarily large chunk of data
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+big_fwrite(
+ FILE * file,
+ GHANDLE handle,
+ uint32 length_in_bytes,
+ NUM_TYPE num_type,
+ DATA_TYPE data_type);
+#else
+ERRSTATUS MUSE_API big_fwrite();
+#endif
+
+/*
+ * Description: Big_fwrite allows writing of blocks of data larger than 64K
+ * bytes on all systems, including DOS.
+ */
+
+/***************************************************************
+@ char_to_double()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API char_to_double(unsigned char *record, double *d, short big_endian, int32 *c);
+#else
+ERRSTATUS MUSE_API char_to_double();
+#endif
+
+/***************************************************************
+@ char_to_long()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API char_to_long(unsigned char *record, int32 *l, short big_endian, int32 *c);
+#else
+ERRSTATUS MUSE_API char_to_long();
+#endif
+
+/***************************************************************
+@ char_to_short()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API char_to_short(unsigned char *record, short *s, short big_endian, int32 *c);
+#else
+ERRSTATUS MUSE_API char_to_short();
+#endif
+
+/***************************************************************
+@ char_to_ushort()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API char_to_ushort(unsigned char *record, USHORT * s, short big_endian, int32 *c);
+#else
+ERRSTATUS MUSE_API char_to_ushort();
+#endif
+
+/***************************************************************
+@ context_sensitive_help()
+****************************************************************
+Invokes the MUSE context sensitive help
+*/
+
+#if XVT_CC_PROTO
+void
+context_sensitive_help(
+ FILE_SPEC * help_file_spec,
+ char *help_topic);
+#else
+void context_sensitive_help();
+#endif
+
+/*
+ * Description: This extension of the XVT help facility (provided by XVT as
+ * \xvt\source\vhelp.c) is to be called when the user pushes the HELP button
+ * in a dialog. The first argument is the XVT FILE_SPEC of the help file.
+ * The second argument is the specific help topic that relates to dialog that
+ * contains the help button. The help_topic given as the second argument
+ * must contain no leading or trailing spaces.
+ */
+
+/***************************************************************
+@ convert_double()
+****************************************************************
+Converts among double machine formats
+*/
+
+#if XVT_CC_PROTO
+void
+convert_double(
+ unsigned char *the_double,
+ int32 type);
+#else
+void convert_double();
+#endif
+
+/*
+ * Description: This function converts the_double number between different
+ * local double number formats.
+ *
+ * The type argument determines the type of conversion performed. The following
+ * are supported
+ *
+ * TYPE CONVERSION
+ *
+ * 1 = IEEE to VAX 2 = VAX to IEEE 3 = IEEE to SUN 4 = SUN to IEEE 5 = SUN to
+ * VAX 6 = VAX to SUN 7 = IEEE to MAC 8 = MAC to IEEE
+ *
+ */
+
+/***************************************************************
+ at dir_create()
+****************************************************************
+Create a new directory
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API dir_create(char *);
+#else
+ERRSTATUS MUSE_API dir_create();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+ at dir_pop()
+****************************************************************
+Move to the parent directory
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API dir_pop(char *);
+#else
+ERRSTATUS MUSE_API dir_pop();
+#endif
+
+/*
+ * Description: Call this function to change to a parent directory. If
+ * chg_def_flag is TRUE then operating system calls will be made. In any
+ * case the last argument path will be set to a non-portable string
+ * representation of the path.
+ */
+/***************************************************************
+ at dir_push()
+****************************************************************
+Move to the subdirectory directory
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API dir_push(char *, char *);
+#else
+ERRSTATUS MUSE_API dir_push();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+ at dir_restore()
+****************************************************************
+Restores the saved directory
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API dir_restore(char *);
+#else
+ERRSTATUS MUSE_API dir_restore();
+#endif
+
+/*
+ * Description:
+ *
+/*************************************************************** @dir_save() ***************************************************************
+ *
+ * Save the current directory
+ */
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API dir_save(char *);
+#else
+ERRSTATUS MUSE_API dir_save();
+#endif
+
+/*
+ * Description:
+ *
+/***************************************************************
+ * @dir_current() ***************************************************************
+ *
+ * Get the current directory
+ */
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API dir_current(char *);
+#else
+ERRSTATUS MUSE_API dir_current();
+#endif
+
+/***************************************************************
+@ double_to_char()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+double_to_char(
+ unsigned char *record,
+ double *l,
+ short big_endian,
+ int32 *c);
+#else
+ERRSTATUS MUSE_API double_to_char();
+#endif
+
+/***************************************************************
+@ file_spec_to_string()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API file_spec_to_string
+ (
+ FILE_SPEC * file_spec,
+ char *string
+);
+#else
+ERRSTATUS MUSE_API file_spec_to_string();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ get_ini_string()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+get_ini_string(
+ FILE * ini_file,
+ char *section_name,
+ char *item_name,
+ char *default_value,
+ char *value,
+ size_t len);
+#else
+ERRSTATUS MUSE_API get_ini_string();
+#endif
+
+/*
+ * Description: Opens the file MUSE.INI in the staartup directory. Retuns a
+ * file pointer on success or NULL on failure.
+ */
+
+/***************************************************************
+@ ini_open()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+FILE *ini_open(char *);
+#else
+FILE *ini_open();
+#endif
+
+/*
+ * Description: Opens the file MUSE.INI in the staartup directory. Retuns a
+ * file pointer on success or NULL on failure.
+ */
+
+/***************************************************************
+@ muse_open_file_dlg()
+****************************************************************
+Get a file spec for opening.
+*/
+
+#if XVT_CC_PROTO
+FL_STATUS MUSE_API
+muse_open_file_dlg(
+ FILE_SPEC *temp_file_spec,
+ char *message);
+#else
+FL_STATUS MUSE_API muse_open_file_dlg();
+#endif
+
+/*
+ * Description: Modifies XVT's open_file_dlg on the Macintosh
+ * to filter based on the three letters following a period in
+ * file name. It makes the Mac see files more like
+ * Motif and Win.
+ */
+
+/***************************************************************
+@ long_to_char()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API long_to_char(unsigned char *record, int32 *l, short big_endian, int32 *c);
+#else
+ERRSTATUS MUSE_API long_to_char();
+#endif
+
+/***************************************************************
+@ short_to_char()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API short_to_char(unsigned char *record, short *s, short big_endian, int32 *c);
+#else
+ERRSTATUS MUSE_API short_to_char();
+#endif
+
+/***************************************************************
+@ start_ini_section()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+start_ini_section(
+ char *ini_file_name,
+ char *section_name);
+#else
+ERRSTATUS MUSE_API start_ini_section();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ string_to_file_spec()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API string_to_file_spec(FILE_SPEC * file_spec, char *string);
+#else
+ERRSTATUS MUSE_API string_to_file_spec();
+#endif
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ ushort_to_char()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API ushort_to_char(unsigned char *record, USHORT * l, short big_endian, int32 *c);
+#else
+ERRSTATUS MUSE_API ushort_to_char();
+#endif
+
+/**************************************************************************/
+/* FILE_OPEN */
+/**************************************************************************/
+
+#if XVT_CC_PROTO
+FILE *file_open(char *, char *);
+#else
+FILE *file_open();
+#endif
+
+/**************************************************************************/
+/* MUSE_ACCESS */
+/**************************************************************************/
+
+#if XVT_CC_PROTO
+int muse_access(char *, int);
+#else
+int muse_access();
+#endif
+
+/**************************************************************************/
+/* MUSE_FILELENGTH */
+/**************************************************************************/
+
+#if XVT_CC_PROTO
+int32 muse_filelength(char *);
+#else
+int32 muse_filelength();
+#endif
+
+#if MUSE_DEBUG
+
+#if XVT_CC_PROTO
+void *muse_malloc(size_t size, char *string);
+#else
+void *muse_malloc();
+#endif
+
+#endif
+
+#if MUSE_DEBUG
+
+#if XVT_CC_PROTO
+void muse_free(void *block, char *string);
+#else
+void muse_free();
+#endif
+
+#endif
+
+#if XVT_CC_PROTO
+void *Talloc(size_t size, int32 *index, char *str);
+#else
+void *Talloc();
+#endif
+
+#if XVT_CC_PROTO
+void Tfree(unsigned char *block, int32 *index, char *str);
+#else
+void Tfree();
+#endif
+
+#if XVT_CC_PROTO
+void muse_log(char *string);
+#else
+void muse_log();
+#endif
+
+
+/***************************************************************
+@ EndTalloc()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+void EndTalloc(void);
+#else
+void EndTalloc();
+#endif
+
+
+
+void
+#if XVT_CC_PROTO
+context_sensitive_help(FILE_SPEC * help_file_spec, char *topic);
+#else
+context_sensitive_help();
+ FILE_SPEC *help_file_spec;
+ char *topic;
+#endif
+
+/***************************************************************
+@ pacify()
+****************************************************************
+Inform user of program status
+*/
+
+#if XVT_CC_PROTO
+BOOLEAN MUSE_API
+pacify(
+ char *message,
+ short percent_complete);
+#else
+BOOLEAN MUSE_API pacify();
+#endif
+
+/*
+ * Description: The message and percent_complete are displayed in the status
+ * window. The status window has a cancel button Pacify returns TRUE if the
+ * user has pressed this cancel button. In this case you should terminate the
+ * operation and call pacify with a "Ready" message and a NULL
+ * percent_complete.
+ */
+
+#endif /* H_SYSTEM_F */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/tifffunc.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/tifffunc.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/tifffunc.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,61 @@
+/*
+ at Contents
+TIFFFUNC.H includes definitions commonly
+used in MUSE applications.
+*/
+
+#ifndef H_TIFFFUNC
+
+/*
+@#Includes
+*/
+#include<math.h>
+#include<stdlib.h>
+#ifndef H_MUSE
+#include "muse.h"
+#endif
+
+#ifndef _TIFFIO_
+#include "tiffio.h"
+#endif
+
+/*
+@#Defines
+Press the Next button to view.
+ H_TIFFFUNC
+H_TIFFFUNC is defined to indicate that
+the TIFFFUNC.H header has been included.
+*/
+#define H_TIFFFUNC
+
+/*
+ at Enumerated Data Types
+Press the Next button to view.
+@
+*/
+
+/*
+ at Simple Types
+Push the Next button to view.
+@
+*/
+
+/*
+ at Complex Data Types
+Press the Next button to view.
+*/
+/*
+ at Functions
+Press the Next button to view.
+@ raster_to_tiff
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS raster_to_tiff(RASTER *raster, FILE_SPEC file_spec);
+#else
+ERRSTATUS raster_to_tiff();
+#endif
+
+#endif /* end h_TIFFFUNC */
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ts_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ts_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ts_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ *++
+ * MAP DATA FORMATTING FACILITY
+ *
+ ******************************************************************************
+ *
+ * TITLE: m4_const.h
+ *
+ * DESCRIPTION: Constants defining the Model 4 Tesselated Spheriod projection.
+ *
+ * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE *
+ *
+ * Any modification made to this module MUST be made to M4_CONSTANTS.INC also.
+ *
+ * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE *
+ *
+ * SYNTAX:
+ *
+ * ARGUMENTS:
+ *
+ * REQUIRED SUBROUTINES:
+ *
+ * HISTORY:
+ * Written: P.B.Wischow (NOARL) November 1990, Written to provide
+ * Model 4 TS projection constants in "C".
+ *
+ * Modified: S.A.Myrick (NRL), 22 January 1992. Added TS zone segment
+ * boundaries and integer constants (for each TS zone)
+ *
+ *==
+ ******************************************************************************
+ */
+
+#ifndef H_TS_D
+#define H_TS_D 1
+/* Number of zones in the Model 4 TS projection system */
+#define NUM_ZONES 5
+
+/* Zone constants in Model 4 TS projection system */
+
+/*
+ * static int SP_ZONE = 0; static int ST_ZONE = 1; static int EQ_ZONE = 2;
+ * static int NT_ZONE = 3; static int NP_ZONE = 4;
+ */
+
+
+/* Number of tesselations in any latitude */
+static int nbr_tess_lat = 195;
+
+/* Number of columns per zone at 1:2M scale, half hemisphere */
+static int nbr_tess[5] = {
+190, 152, 190, 152, 190};
+
+/* Number of columns per zone at 1:2M scale, for the entire globe */
+/* static int nbr_tess2[5] = {380,304,380,304,380}; */
+
+/* Latitude boundary between model 4 temperate and equator zone */
+/* static double zborder_tempequ = 31.38461538; */
+
+/* Latitude boundary between model 4 polar and temperate zone */
+/* static double zborder_polartemp = 51.69230769; */
+
+/****** NOTE ******************************************************************/
+/* If point falls on a boundary, then the point is in the next northern zone. */
+/****** NOTE ******************************************************************/
+
+
+
+static double bot_zone_lat_tbl[5] = /* Bottom zone latitude table */
+{
+ -90.0,
+ -51.69230769,
+ -31.38461538,
+ 31.38461538,
+51.69230769};
+
+/***** The following are used as descriptive indeces for ZONE_SEG_BOUND *****
+#define ZONE_TOP 1 /* Top of zone boundry */
+#define ZONE_BOT 2 /* Bottom of zone boundry */
+
+/***** The following are the Max/Min rows for each scale and *****/
+/***** non-polar zone. Because the polar zone row/column *****/
+/***** boundaries are by definition undefined, they are *****/
+/***** zeroed here. These bounds EXCLUDE the two segment *****/
+/***** overlap. *****/
+
+/* Note that array dimensions are: scale, zone, top/bottom rows. */
+/* Due to language differences, this C program uses array dimensions */
+/* that differ from the FORTRAN version of this file! Currently, */
+/* there are six scales and five zones. */
+
+/*
+ * static int zone_seg_bound [6][5][2] = { 0, 0, * Top, Bottom, SP
+ * Scale = TLM * -1361, -2240, * ST *
+ * 1359, -1360, * EQ * 2239, 1360, *
+ * NT * 0, 0, * NP * 0,
+ * 0, * Top, Bottom, SP Scale = 100k * -681, -1120, *
+ * ST * 679, -680, * EQ *
+ * 1119, 680, * NT * 0, 0, *
+ * NP * 0, 0, * Top, Bottom SP Scale = JOG *
+ * -273, -448, * ST * 271, -272, *
+ * EQ * 447, 272, * NT * 0,
+ * 0, * NP * 0, 0, * Top, Bottom SP
+ * Scale = TPC * -137, -224, * ST *
+ * 135, -136, * EQ * 223, 136, *
+ * NT * 0, 0, * NP * 0,
+ * 0, * Top, Bottom SP Scale = ONC * -69, -112, * ST *
+ * 67, -68, * EQ * 111, 68, *
+ * NT * 0, 0, * NP * 0,
+ * 0, * Top, Bottom SP Scale = JNC * -35, -56, *
+ * ST * 33, -34, * EQ * 55,
+ * 34, * NT * 0, 0 * NP *
+ * };
+ */
+
+#define TABLE_OFFSET 9
+
+/* Model 4 TS zones */
+/* static char *zone_table[5]={"SP","ST","EQ","NT","NP"}; */
+
+/* Number of tesselations in each Model 4 zone */
+/* where, MSCALE_Number * scale = 2 million */
+static int mscale[TABLE_OFFSET] = {
+40, 20, 8, 4, 2, 1, 0, 200, 25};
+
+/*
+ * static char *scale_table[TABLE_OFFSET]={ "50K ","100K","250K","500K","1M
+ * ","2M ", "5M ","10K ","80K" }; static char *chart_series[TABLE_OFFSET]={
+ * "TLM","XXX","JOG","TPC","ONC","JNC","GNC","CG ","H2 " }; static char
+ * *scale_codes[18]={ "TL","XX","JA","TP","ON","JN","GN","CG","H2",
+ * "XX","XX","JC","XX","XX","XX","XX","XX","XX" };
+ */
+#endif /* H_TS_D */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ts_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ts_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/ts_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,40 @@
+#ifndef H_TS_F
+
+#define H_TS_F
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+
+#if XVT_CC_PROTO
+short find_zone(char[]);
+void rc_calc(double *, double *, short *, short *, double *, double *);
+void
+latlon_calc(short *, short *, double *, double *,
+ double *, double *);
+void eq2pol(double *, double *, double *, double *, short *);
+void pol2eq(double *, double *, double *, double *);
+short calczone(double, int);
+ERRSTATUS cac_zone_compute(double latitude, int32 *zone);
+void
+ts(double *p, double *l, int32 dir,
+ short ts_scale, short ts_zone,
+ double *y, double *x, int32 *ierr);
+
+ERRSTATUS ts_config(MGM * mgm);
+
+#else
+
+/* CAC reading function prototypes */
+short find_zone();
+void rc_calc();
+void latlon_calc();
+void eq2pol();
+void pol2eq();
+short calczone();
+ERRSTATUS cac_zone_compute();
+void ts();
+ERRSTATUS ts_config();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/unit_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/unit_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/unit_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,155 @@
+#ifndef H_UNIT_DEF
+
+#define H_UNIT_DEF
+
+#ifndef H_COORD_DEF
+#include "coord_d.h"
+#endif
+
+/***************************************************************
+@ UNIT_LIST
+****************************************************************
+List of available units of measure.
+*/
+typedef struct
+{
+ char label[30];
+ short count;
+ short setting;
+ char list[20][30]; /*Change: 20 strings instead of 10 */
+ char help_topic[49];
+} UNIT_LIST;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ UNITS_LIST
+****************************************************************
+The list of lists of available units
+*/
+typedef struct
+{
+ char label[30];
+ short count;
+ short setting;
+ char list[7][15];
+ UNIT_LIST units[8];
+} UNITS_LIST;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ AREA
+****************************************************************
+Area is stored internally in SQ_METERS
+*/
+typedef enum
+{
+ SQ_METERS,
+ SQ_FEET,
+ SQ_KM,
+ SQ_NM,
+ SQ_SM
+}
+ UAREA;
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ VOLUME
+****************************************************************
+Volume is stored internally in CU_METERS
+*/
+typedef enum
+{
+ CU_METERS,
+ CU_FT,
+ CU_KM,
+ CU_NM,
+ CU_SM
+}
+ VOLUME;
+
+/***************************************************************
+@ HOR_DISTANCE
+****************************************************************
+Horizontal distance is stored internally in meters.
+*/
+typedef enum
+{
+ HOR_METERS,
+ HOR_FEET,
+ HOR_KILOMETERS,
+ HOR_LEAGUES,
+ HOR_NAUTICAL_MILES,
+ HOR_STATUTE_MILES,
+ HOR_SEC_OF_ARC,
+ HOR_YARDS
+}
+ HOR_DISTANCE;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ SCALE
+****************************************************************
+Scale is stored internally as SCALE_RECIPROCAL.
+*/
+typedef enum
+{
+ SCALE_RECIPROCAL,
+ SCALE_IN_PER_DEG
+}
+ SCALE;
+
+/*
+ * Description:
+ */
+
+/***************************************************************
+@ VER_DISTANCE
+****************************************************************
+Vertical distance is stored internally in meters.
+*/
+typedef enum
+{
+ VER_METERS,
+ VER_FATHOMS,
+ VER_FEET
+}
+ VER_DISTANCE;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ UNITS
+****************************************************************
+Structure to contain the users units selections
+*/
+typedef struct
+{
+ int32 magic;
+ SCALE scale;
+ HOR_DISTANCE hor_distance;
+ VER_DISTANCE ver_distance;
+ UAREA area;
+ VOLUME volume;
+ GEOGRAPHIC geographic;
+} UNITS;
+
+#endif /* H_UNIT_DEF */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/unit_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/unit_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/unit_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1646 @@
+
+
+#ifndef H_UNIT_FUNC
+#define H_UNIT_FUNC
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+#ifndef H_CC1_F
+#include "cc1_f.h"
+#endif
+
+#include "math.h"
+
+/****************************************************************
+@ aemtgp()
+*****************************************************************
+Azimuthal Equidistant to Geodetic
+*/
+#if XVT_CC_PROTO
+void
+aemtgp(double a, double recf, double ophi, double olam, double fn, double fe,
+ double *sphi, double *slam, double y, double x);
+#else
+void
+aemtgp();
+#endif
+
+/****************************************************************
+@ aeorig()
+*****************************************************************
+Validate system origin parameters for Azimuthal Equidistant to/from Geodetic
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS
+aeorig( int32 itype, COORD_TYPE *coord_type );
+#else
+ERRSTATUS
+aeorig();
+#endif
+
+/****************************************************************
+@ convergence_and_scale_factor()
+*****************************************************************
+Calls the appropriate function to calculate convergence and
+scale factor for the current coordinate system
+*/
+ERRSTATUS
+#if XVT_CC_PROTO
+convergence_and_scale_factor(POINT_UNITS *user_pt, POINT_DD *radian_pt,
+ COORD_SYS *coord_sys,
+ COORD_DMS *convergence, double *scale_factor);
+#else
+convergence_and_scale_factor( );
+#endif
+
+/****************************************************************
+@ deg_to_degmin()
+*****************************************************************
+Convert decimal degrees to degrees and minutes
+*/
+#if XVT_CC_PROTO
+void deg_to_degmin( double dd, short *deg, double *mn);
+#else
+void deg_to_degmin();
+#endif
+/****************************************************************
+@ deg_to_degminsec()
+*****************************************************************
+Convert decimal degrees to degrees, minutes, and seconds
+*/
+#if XVT_CC_PROTO
+void deg_to_degminsec( double dd, short *deg, short *mn, double *sec);
+#else
+void deg_to_degminsec();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ geo_conv_from()
+****************************************************************
+Geo. conversion functions from user units to internal units
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+ geo_conv_from(short tag, POINT_DD * dd, POINT_UNITS * user_unit);
+#else
+ERRSTATUS MUSE_API geo_conv_from();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+ @ geo_conv_to()
+****************************************************************
+ Geo. conversion functions from internal units to user units
+ */
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+ geo_conv_to(short tag, POINT_DD * dd, POINT_UNITS * user_unit);
+#else
+ geo_conv_to();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+
+/****************************************************************
+@ gptaem()
+*****************************************************************
+Geodetic to Azimuthal Equidistant
+*/
+#if XVT_CC_PROTO
+void
+gptaem( double a, double recf, double ophi, double olam, double fn, double fe,
+ double sphi, double slam, double *y, double *x);
+#else
+void
+gptaem();
+#endif
+/*
+Description:
+*/
+
+
+/****************************************************************
+@ gpgref()
+*****************************************************************
+Geodetic to GEOREF
+*/
+#if XVT_CC_PROTO
+void
+gpgref(char *georef, /*int P1,*/ double *sphi, double *slam, int32 ndec);
+#else
+void
+gpgref();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ ftnblkd()
+****************************************************************
+Initialize block data
+*/
+#if XVT_CC_PROTO
+void ftnblkd(void);
+#else
+void ftnblkd();
+#endif
+/*
+Description:
+*/
+
+/****************************************************************
+@ gptlam()
+*****************************************************************
+GP to LAMBERT
+*/
+#if XVT_CC_PROTO
+void
+gptlam(double a, double recf, double ophi, double olam, double fn,
+ double fe, double ok, double sphi, double slam, double *y,
+ double *x);
+#else
+void
+gptlam();
+#endif
+
+/****************************************************************
+@ gptmer()
+*****************************************************************
+GP to MERCATOR
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+gptmer(double a, double recf, double ophi, double olam, double fn,
+ double fe, double ok, double sphi, double slam, double *y,
+ double *x);
+#else
+ERRSTATUS
+gptmer();
+#endif
+/*
+Description:
+*/
+
+/****************************************************************
+@ gptmgr()
+*****************************************************************
+GP to MGRS and UTM grids
+*/
+#if XVT_CC_PROTO
+void gptmgr(
+ double *a,
+ double *recf,
+ double *sphi,
+ double *slam,
+ int32 *izone,
+ double *y,
+ double *x,
+ char *mgrs,
+ int P1,
+ char *azone,
+ int P2,
+ /*int32 *isph,*/char *isph,
+ int32 *igrpin);
+#else
+void gptmgr();
+#endif
+/*
+Description:
+*/
+
+
+/****************************************************************
+@ gptobm()
+*****************************************************************
+GP to Oblique Mercator Projection
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+gptobm(int32 *isolut, int32 kodor, double sphi, double slam,
+ double *u, double *v, double *y, double *x,
+ double e, double es, double fn, double fe,
+ double ogam, double olam, double oaz,
+ double ta, double tb, double te);
+#else
+ERRSTATUS
+gptobm();
+#endif
+
+/****************************************************************
+@ gptoyx()
+*****************************************************************
+GP to TRANSVERSE MERCATOR map projection
+*/
+#if XVT_CC_PROTO
+void
+gptoyx(double a, double recf, double ophi, double olam, double fn, double fe,
+ double ok, double sphi, double slam, double *y, double *x);
+#else
+void gptoyx();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ gptups()
+****************************************************************
+GP to UPS map projection
+*/
+#if XVT_CC_PROTO
+void gptups(
+ double a,
+ double recf,
+ double sphi,
+ double slam,
+ double *y,
+ double *x);
+#else
+void gptups();
+#endif
+/*
+Description:
+*/
+
+/******************************************************************
+@ gptutm()
+*******************************************************************
+GP to UTM grid
+*/
+#if XVT_CC_PROTO
+void gptutm(
+ double a,
+ double recf,
+ double sphi,
+ double slam,
+ int32 *izone,
+ double *y,
+ double *x,
+ int32 ifixz);
+#else
+void gptutm();
+#endif
+/*
+Description:
+*/
+
+/****************************************************************
+@ gpgref()
+*****************************************************************
+GEOREF to GP
+*/
+#if XVT_CC_PROTO
+void
+grefgp(char *georef, /*int P1,*/ double *sphi, double *slam, int32 *ierr);
+#else
+void
+grefgp();
+#endif
+/*
+Description:
+*/
+
+/****************************************************************
+@ iset_from_zone_str()
+*****************************************************************
+GEOREF to GP
+*/
+#if XVT_CC_PROTO
+short
+iset_from_zone_str(char *string);
+#else
+short
+iset_from_zone_str();
+#endif
+/*
+Description:
+*/
+
+/*******************************************************************
+@ lamorg()
+********************************************************************
+VALIDATION OF INPUT ORIGIN PARAMETERS AND CONVERSION TO RADIANS, AND
+DERIVATION OF OTHER ORIGIN PARAMETERS FOR LAMBERT TO GP AND GP TO LAMBERT
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+lamorg(double a, double recf, COORD_TYPE *coord_type);
+#else
+ERRSTATUS
+lamorg();
+#endif
+
+/******************************************************************
+@ lamtgp()
+*******************************************************************
+LAMBERT to GP
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+lamtgp(double a, double recf, double ophi, double olam, double fn,
+ double fe, double ok, double *sphi, double *slam, double y,
+ double x);
+#else
+ERRSTATUS
+lamtgp();
+#endif
+
+/*******************************************************************
+@ merorg()
+********************************************************************
+VALIDATION OF ORIGIN PARAMETERS, CONVERSION OF ORIGIN TO RADIANS, AND
+SCALE FACTOR CALCULATION FOR MERCATOR TO GP AND GP TO MERCATOR
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+merorg(double a, double recf, COORD_TYPE *coord_type );
+#else
+ERRSTATUS
+merorg();
+#endif
+
+
+/*******************************************************************
+@ mertgp()
+********************************************************************
+Mercator to GP
+*/
+#if XVT_CC_PROTO
+void
+mertgp(double a, double recf, double ophi, double olam, double fn,
+ double fe, double ok, double *sphi, double *slam, double y, double x);
+#else
+void
+mertgp();
+#endif
+
+/*******************************************************************
+@ milref()
+********************************************************************
+GP to MGRS
+*/
+#if XVT_CC_PROTO
+void milref(
+ int32 *iarea,
+ double *a,
+ double *recf,
+ double *sphi,
+ double slam,
+ int32 *izone,
+ double y,
+ double x,
+ char *mgrs,
+ int P2,
+ char *azone,
+ int P1,
+ /*int32 *isph,*/ char *isph,
+ int32 *igrpin);
+#else
+void milref();
+#endif
+/*
+Description:
+*/
+
+/********************************************************************
+@ nzmggp()
+*********************************************************************
+Convert New Zealand Map Grid coordinates to GP radians
+*/
+#if XVT_CC_PROTO
+void
+nzmggp(double a, double ophi, double olam, double fn, double fe,
+ double *sphi, double *slam, double y, double x);
+#else
+void
+nzmggp();
+#endif
+
+
+/********************************************************************
+@ obmorg()
+*********************************************************************
+VALIDATION OF USER-ENTERED ORIGIN PARAMETERS, CONVERSION TO RADIANS, AND
+DERIVATION OF ADDITIONAL ORIGIN PARAMETERS FOR OBLIQUE MERCATOR TO GP AND
+GP TO OBLIQUE MERCATOR
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+obmorg( double a, double recf, COORD_TYPE *coord_type, int32 itype );
+#else
+ERRSTATUS
+obmorg();
+#endif
+
+
+/********************************************************************
+@ obmtgp()
+*********************************************************************
+Convert from Oblique Mercator to GP
+*/
+#if XVT_CC_PROTO
+void obmtgp(int32 method, int32 kodor, double *sphi, double *slam,
+ double *u, double *v, double *y, double *x,
+ double es, double fn, double fe,
+ double ogam, double olam, double oaz,
+ double ta, double tb, double te);
+#else
+void obmtgp();
+#endif
+
+/********************************************************************
+@ savmgr()
+*********************************************************************
+Save MGRS
+*/
+#if XVT_CC_PROTO
+void savmgr(
+ char *mgrs,
+ int P1,
+ int32 nchar,
+ double xltr,
+ double yltr,
+ int32 ltrnum[],
+ double spsou,
+ double spnor,
+ double sleast,
+ double slwest,
+ double ylow,
+ double yslow,
+ int32 iarea,
+ int32 izone,
+ int32 ltrlow,
+ int32 ltrhi,
+ int32 ltrhy,
+ double fnltr,
+ double feltr,
+ char *azone,
+ int P2);
+#else
+void savmgr();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ scale_conv_from()
+****************************************************************
+Scale conversion functions from user units to internal units
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+ scale_conv_from(short user_unit_index, double *recip, double user_unit);
+#else
+ scale_conv_from();
+#endif
+
+/*
+ * Description: This is the declaration of an array of pointers to functions.
+ * The user unit is represented by set of enumerated constants for this unit.
+ * This constant is used as the index into the array of pointers to
+ * functions, so as to call the particular conversion function.
+ *
+ * Ex: GFLOAT scale_in_per_deg, scale_reciprocal; status =
+ * (*scale_conf_from[SCALE_IN_PER_DEG]) (scale_in_per_deg,
+ * &scale_reciprocal);
+ */
+
+
+/***************************************************************
+@ scale_conv_to()
+****************************************************************
+Scale conversion functions from internal units to user units
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+ scale_conv_to(short user_unit_index, double recip, double *user_unit);
+#else
+ scale_conv_to();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ scale_to_user_str
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API scale_to_user_str
+ (
+ UNITS * units,
+ GFLOAT scale_reciprocal,
+ char *output
+);
+#else
+ERRSTATUS MUSE_API scale_to_user_str();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/*******************************************************************
+@ tmorig()
+********************************************************************
+VALIDATION OF ORIGIN PARAMETERS FOR TRANSVERSE MERCATOR TO GP AND
+GP TO TRANSVERSE MERCATOR AND CONVERSION OF ORIGIN TO RADIANS
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+tmorig( COORD_TYPE *coord_type );
+#else
+ERRSTATUS
+tmorig();
+#endif
+
+/***************************************************************
+@ units_construct()
+****************************************************************
+Construct the units object
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+units_construct(
+ FILE * file,
+ UNITS ** pointer);
+#else
+ERRSTATUS MUSE_API units_construct();
+#endif
+
+/*
+ * Description: The units object contains a list of the user selected map
+ * units.
+ */
+
+/***************************************************************
+@ units_destruct()
+****************************************************************
+Destroy the object of type UNITS
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+units_destruct(
+ FILE * file,
+ BOOLEAN destruct,
+ UNITS ** pointer);
+#else
+ERRSTATUS MUSE_API units_destruct();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+ /***************************************************************
+@ ver_conv_from()
+****************************************************************
+Converts from user vertical distance units to internal (meters)
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+ver_conv_from(short user_unit_index, double *mtr_1, double mtr_2
+);
+#else
+ver_conv_from();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ ver_conv_to()
+****************************************************************
+Converts from internal vertical distance to user units
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+ ver_conv_to(short user_unit_index, double mtr_1, double *mtr_2);
+#else
+ ver_conv_to();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+
+/***************************************************************
+@ yxtogp()
+****************************************************************
+Transverse Mercator map projection to GP
+*/
+#if XVT_CC_PROTO
+void
+yxtogp(double a, double recf, double ophi, double olam, double fn, double fe,
+ double ok, double *sphi, double *slam, double y, double x);
+#else
+void
+yxtogp();
+#endif
+/*
+Description:
+*/
+
+
+/***************************************************************
+@ unflow()
+****************************************************************
+Check for underflow
+*/
+#if XVT_CC_PROTO
+void unflow(
+ double *value,
+ int32 kode);
+#else
+void unflow();
+#endif
+/*
+Description:
+*/
+
+
+
+/********************************************************************
+@ upnset()
+*********************************************************************
+Set MGRS info for northern polar zone
+*/
+#if XVT_CC_PROTO
+void upnset(
+ int32 n,
+ int32 *ltrlow,
+ int32 *ltrhi,
+ double *feltr,
+ double *fnltr,
+ int32 *ltrhy);
+#else
+void upnset();
+#endif
+/*
+Description:
+
+*/
+
+
+/********************************************************************
+@ upsset()
+*********************************************************************
+Set MGRS info for southern polar zone
+*/
+#if XVT_CC_PROTO
+void upsset(
+ int32 n,
+ int32 *ltrlow,
+ int32 *ltrhi,
+ double *feltr,
+ double *fnltr,
+ int32 *ltrhy);
+#else
+void upsset();
+#endif
+/*
+Description:
+
+*/
+
+
+
+/***************************************************************
+@ upstgp()
+****************************************************************
+UPS map projection to geog posn
+*/
+#if XVT_CC_PROTO
+void upstgp(
+ double a,
+ double recf,
+ double *sphi,
+ double *slam,
+ double *y,
+ double x);
+#else
+void upstgp();
+#endif
+/*
+Description:
+
+*/
+
+
+/********************************************************************
+@ utmlim()
+*********************************************************************
+UTM lim
+*/
+#if XVT_CC_PROTO
+void utmlim(
+ int32 *n,
+ double sphi,
+ int32 izone,
+ double *spsou,
+ double *spnor,
+ double *sleast,
+ double *slwest);
+#else
+void utmlim();
+#endif
+/*
+Description:
+
+*/
+
+
+/*********************************************************************
+@ utmset
+**********************************************************************
+UTM set
+*/
+#if XVT_CC_PROTO
+void utmset(
+ int32 izone,
+ int32 *ltrlow,
+ int32 *ltrhi,
+ double *fnltr,
+ char *isph,
+ int32 igrpin);
+#else
+void utmset();
+#endif
+/*
+Description:
+
+*/
+
+
+/********************************************************************
+@ mgrtgp
+*********************************************************************
+MGRS to GP
+*/
+#if XVT_CC_PROTO
+void mgrtgp(
+ char *mgrs,
+ int P1,
+ char *azone,
+ int P2,
+ /*int32 *isph,*/ char *isph,
+ int32 *igrpin,
+ double *a,
+ double *recf,
+ double *sphi,
+ double *slam,
+ int32 *izone,
+ double *y,
+ double *x,
+ int32 *ierr);
+#else
+void mgrtgp();
+#endif
+/*
+Description:
+
+*/
+
+
+/********************************************************************
+@ radian
+*********************************************************************
+Radian
+*/
+#if XVT_CC_PROTO
+void
+radian(double *rad, double rd, double rm, double rs);
+#else
+void
+radian();
+#endif
+/*
+Description:
+
+*/
+
+
+/********************************************************************
+@ radian_and_dd
+*********************************************************************
+Radian
+*/
+#if XVT_CC_PROTO
+void
+radian_and_dd(double *rad, double *rd, double rm, double rs);
+#else
+void
+radian_and_dd();
+#endif
+/*
+Description:
+
+*/
+
+
+/********************************************************************
+@ shiftr
+*********************************************************************
+Shiftr
+*/
+#if XVT_CC_PROTO
+void shiftr(
+ char *mgrs,
+ int P1,
+ int32 n,
+ int32 *nchar);
+#else
+void shiftr();
+#endif
+/*
+Description:
+
+*/
+
+
+/********************************************************************
+@ dmsh
+*********************************************************************
+Radians to degrees, minutes, seconds (????)
+*/
+#if XVT_CC_PROTO
+void dmsh(
+ int32 khem,
+ double radian,
+ int32 *id,
+ int32 *im,
+ double *rs,
+ char *ah,
+ int P1);
+#else
+void dmsh();
+#endif
+/*
+Description:
+
+*/
+
+
+
+
+/*********************************************************************
+@ utmtgp
+**********************************************************************
+Universal Transverse Mercator to GP
+*/
+#if XVT_CC_PROTO
+void utmtgp(
+ double a,
+ double recf,
+ double *sphi,
+ double *slam,
+ int32 izone,
+ double *y,
+ double x);
+#else
+void utmtgp();
+#endif
+/*
+Description:
+
+*/
+
+
+/**********************************************************************
+@ yxtmgr
+***********************************************************************
+UTM to MGRS and UTM
+*/
+#if XVT_CC_PROTO
+void yxtmgr(
+ double *a,
+ double *recf,
+ double *sphi,
+ double *slam,
+ int32 *izone,
+ double *y,
+ double *x,
+ char *mgrs,
+ int P1,
+ char *azone,
+ int P2,
+ /*int32 *isph,*/char *isph,
+ int32 *igrpin,
+ int32 *ierr);
+#else
+void yxtmgr();
+#endif
+/*
+Description:
+
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS
+horiz_conv_from_user_units ( short tag , double *hor_1 , double hor_2,
+ double scale_recip, double screen_PPI );
+#else
+ERRSTATUS
+horiz_conv_from_user_units ( );
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS
+horiz_conv_to_user_units ( short tag , double hor_1 , double *hor_2,
+ double scale_recip, double screen_PPI );
+#else
+ERRSTATUS
+horiz_conv_to_user_units ( );
+#endif
+
+/* Prototypes for functions related to Promula.Fortran library */
+
+typedef struct
+{
+ double cr;
+ double ci;
+} DCOMPLEX;
+
+
+/*********************************************************************
+@ dpxadd
+**********************************************************************
+Returns the double complex sum of two double complex arguments
+*/
+#if XVT_CC_PROTO
+DCOMPLEX
+dpxadd( DCOMPLEX a, DCOMPLEX b);
+#else
+DCOMPLEX
+dpxadd();
+#endif
+
+/*********************************************************************
+@ dpxdbl
+**********************************************************************
+Converts a double precision number to a double complex whose real part is the
+double precsion argument, and whose imaginary part is zero.
+*/
+#if XVT_CC_PROTO
+DCOMPLEX
+dpxdbl( double dbl );
+#else
+DCOMPLEX
+dpxdbl();
+#endif
+
+/*********************************************************************
+@ dpxdiv
+**********************************************************************
+Returns the double complex quotient of two double complex arguments.
+Based on Cdiv() in Numerical Recipes in C by Press, et alii.
+*/
+#if XVT_CC_PROTO
+DCOMPLEX
+dpxdiv( DCOMPLEX a, DCOMPLEX b);
+#else
+DCOMPLEX
+dpxdiv();
+#endif
+
+/*********************************************************************
+@ dpxdpx
+**********************************************************************
+Converts the two double arguments to a double complex number, which is returned
+*/
+#if XVT_CC_PROTO
+DCOMPLEX
+dpxdpx( double d1, double d2);
+#else
+DCOMPLEX
+dpxdpx( );
+#endif
+
+/*********************************************************************
+@ dpxima
+**********************************************************************
+Returns the imaginary part of the double complex argument
+*/
+#if XVT_CC_PROTO
+double
+dpxima( DCOMPLEX a );
+#else
+double
+dpxima( );
+#endif
+
+/*********************************************************************
+@ dpxlongpow
+**********************************************************************
+Raises the double complex argument to the long argument power and returns the
+double complex result
+*/
+/***DO: Switch to formula using polar coordinates if this isn't accurate enough */
+#if XVT_CC_PROTO
+DCOMPLEX
+dpxlongpow( DCOMPLEX a, int32 b);
+#else
+DCOMPLEX
+dpxlongpow();
+#endif
+
+/*********************************************************************
+@ dpxmul
+**********************************************************************
+Returns the double complex product of two double complex arguments.
+*/
+#if XVT_CC_PROTO
+DCOMPLEX
+dpxmul( DCOMPLEX a, DCOMPLEX b);
+#else
+DCOMPLEX
+dpxmul();
+#endif
+
+/*********************************************************************
+@ dpxreal
+**********************************************************************
+Returns the real part of the double complex argument
+*/
+#if XVT_CC_PROTO
+double
+dpxreal( DCOMPLEX a );
+#else
+double
+dpxreal( );
+#endif
+
+
+/*********************************************************************
+@ fifdint
+**********************************************************************
+Source code from the Promula.Fortran library
+*/
+#if XVT_CC_PROTO
+double fifdint(
+ double a);
+#else
+double fifdint();
+#endif
+/*
+Description:
+
+*/
+
+
+/********************************************************************
+@ fifdnint
+*********************************************************************
+Source code from the Promula.Fortran library
+*/
+#if XVT_CC_PROTO
+double fifdnint(
+ double a);
+#else
+double fifdnint();
+#endif
+/*
+Description:
+*/
+
+/**********************************************************************
+@ fifdsign
+***********************************************************************
+Source code from the Promula.Fortran library
+*/
+#if XVT_CC_PROTO
+double
+fifdsign( double mag, double sgn );
+#else
+double
+fifdsign( );
+#endif
+
+
+
+/**********************************************************************
+@ fifichar
+***********************************************************************
+Source code from the Promula.Fortran library
+*/
+#if XVT_CC_PROTO
+int fifichar(
+ unsigned char* c1);
+#else
+int fifichar();
+#endif
+/*
+Description:
+
+*/
+
+
+/********************************************************************
+@ fifidint
+*********************************************************************
+Source code from the Promula.Fortran library
+*/
+#if XVT_CC_PROTO
+int32 fifidint(
+ double a);
+#else
+int32 fifidint();
+#endif
+/*
+Description:
+
+*/
+
+
+/*********************************************************************
+@ fifmod
+**********************************************************************
+Source code from the Promula.Fortran library
+*/
+#if XVT_CC_PROTO
+int32 fifmod(
+ int32 num,
+ int32 dem);
+#else
+int32 fifmod();
+#endif
+/*
+Description:
+
+*/
+
+
+/*********************************************************************
+@ fifnint
+**********************************************************************
+Source code from the Promula.Fortran library
+*/
+#if XVT_CC_PROTO
+int32 fifnint(
+ double a);
+#else
+int32 fifnint();
+#endif
+/*
+Description:
+
+*/
+
+
+/**********************************************************************
+@ ftncms
+***********************************************************************
+Source code from the Promula.Fortran library
+*/
+#if XVT_CC_PROTO
+int ftncms(
+ char* s1,
+ int n1,
+ char* s2,
+ int n2);
+#else
+int ftncms();
+#endif
+/*
+Description:
+
+*/
+
+
+/**********************************************************************
+@ ftnsac
+***********************************************************************
+Source code from the Promula.Fortran library
+*/
+#if XVT_CC_PROTO
+void ftnsac(
+ char* s1,
+ int n1,
+ char* s2,
+ int n2);
+#else
+void ftnsac();
+#endif
+/*
+Description:
+
+*/
+
+/**********************************************************************
+@ dd_to_dm_formatted
+***********************************************************************
+*/
+void
+#if XVT_CC_PROTO
+dd_to_dm_formatted( double dd, short *deg, double *mn);
+#else
+dd_to_dm_formatted( );
+#endif
+
+
+
+/**********************************************************************
+@ dd_to_dms_formatted
+***********************************************************************
+*/
+
+void
+#if XVT_CC_PROTO
+dd_to_dms_formatted( double dd, short *deg, short *mn, double *sec);
+#else
+dd_to_dms_formatted( );
+#endif
+
+
+
+/**********************************************************************
+@ hor_m_from_m
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_from_m(double *hor_mtr1, double hor_mtr2);
+#else
+hor_m_from_m( );
+#endif
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_from_ft(double *hor_meter, double hor_feet);
+#else
+hor_m_from_ft( );
+#endif
+
+
+/**********************************************************************
+@ hor_m_from_yd
+***********************************************************************
+*/
+
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_from_yd(double *hor_meter, double hor_yard);
+#else
+hor_m_from_yd( );
+#endif
+
+
+/**********************************************************************
+@ hor_m_from_in_at_map_scale
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_from_in_at_map_scale(double *hor_meter, double hor_in, double scale_recip);
+#else
+hor_m_from_in_at_map_scale( );
+#endif
+
+
+
+
+/**********************************************************************
+@ hor_m_from_mm_at_map_scale
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_from_mm_at_map_scale(double *hor_meter, double hor_mm, double scale_recip);
+#else
+hor_m_from_mm_at_map_scale( );
+#endif
+
+
+/**********************************************************************
+@ hor_m_from_pixels
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_from_pixels ( double *hor_meter , double hor_pix, double scale_recip,
+ double screen_PPI );
+#else
+hor_m_from_pixels ( );
+#endif
+
+
+/**********************************************************************
+@ hor_m_to_m
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_to_m(double hor_mtr1, double *hor_mtr2);
+#else
+hor_m_to_m( );
+#endif
+
+
+
+
+/**********************************************************************
+@ hor_m_to_ft
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_to_ft(double hor_meter, double *hor_feet);
+#else
+hor_m_to_ft( );
+#endif
+
+
+
+/**********************************************************************
+@ hor_m_to_yd
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_to_yd(double hor_meter, double *hor_yard);
+#else
+hor_m_to_yd( );
+#endif
+
+
+
+/**********************************************************************
+@ hor_m_to_in_at_map_scale
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_to_in_at_map_scale ( double hor_meter, double *hor_in, double scale_recip );
+#else
+hor_m_to_in_at_map_scale( );
+#endif
+
+
+
+/**********************************************************************
+@ hor_m_to_mm_at_map_scale
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_to_mm_at_map_scale( double hor_meter, double *hor_mm, double scale_recip );
+#else
+hor_m_to_mm_at_map_scale( );
+#endif
+
+
+
+
+/**********************************************************************
+@ hor_m_to_pixels
+***********************************************************************
+*/
+
+ERRSTATUS
+#if XVT_CC_PROTO
+hor_m_to_pixels ( double hor_meter , double *hor_pix, double scale_recip,
+ double screen_PPI );
+#else
+hor_m_to_pixels ( );
+#endif
+
+
+
+/**********************************************************************
+@ madlgp
+***********************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS
+madlgp(double a,double recf,double *sphi,double *slam,double y,double x,
+ double *ygs,double *xgs,double ophi,double ophis,double olam,
+ double fn,double fe,double ok,double al,double Const,double r,
+ double ca, double cb, double cc, double cd);
+#else
+ERRSTATUS
+madlgp( );
+#endif
+
+
+/**********************************************************************
+@ madlor
+***********************************************************************
+*/
+
+
+#if XVT_CC_PROTO
+ERRSTATUS
+madlor(COORD_TYPE *coord_type,
+ double a,double recf,double *parism, double *ophi, double *ophis,
+ double *olam, /*double *fn,double *fe,double *ok, */
+ double *al,double *Const,
+ double *r,double *ca, double *cb, double *cc, double *cd);
+#else
+ERRSTATUS
+madlor( );
+#endif
+
+
+
+/**********************************************************************
+@ convert_user_str_to_pt
+***********************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS
+convert_user_str_to_pt(COORD_SYS *coord_in, POINT_UNITS *upoint, char *pntstr);
+#else
+ERRSTATUS
+convert_user_str_to_pt( );
+#endif
+
+
+/**********************************************************************
+@ gplam()
+***********************************************************************
+*/
+
+void
+#if XVT_CC_PROTO
+gpclam(double a, double recf, double ophi, double olam, double ok,
+ double sphi, double slam, double *conv, double *sk);
+#else
+gpclam();
+#endif
+
+/**********************************************************************
+@ gpcmer()
+***********************************************************************
+*/
+
+void
+#if XVT_CC_PROTO
+gpcmer(double a, double recf, double ok, double sphi, double *conv,
+ double *sk);
+#else
+gpcmer();
+#endif
+
+/**********************************************************************
+@ gpcnzm()
+***********************************************************************
+*/
+
+void
+#if XVT_CC_PROTO
+gpcnzm(double a, double recf, double ophi, double olam,
+ double sphi, double slam, double *conv, double *sk);
+#else
+gpcnzm();
+#endif
+
+
+/**********************************************************************
+@ gpcobm()
+***********************************************************************
+*/
+
+void
+#if XVT_CC_PROTO
+gpcobm(double a, int32 kodor, double sphi, double slam, double u,
+ double *conv, double *sk, double olam, double e, double es,
+ double ogam, double oaz, double ta, double tb, double te);
+#else
+gpcobm();
+#endif
+
+/**********************************************************************
+@ gpconv_tm()
+***********************************************************************
+*/
+
+void
+#if XVT_CC_PROTO
+gpconv_tm(double a, double recf, double olam, double ok, double sphi,
+ double slam, double *conv, double *sk);
+#else
+gpconv_tm();
+#endif
+
+/**********************************************************************
+@ gpconv_ups()
+***********************************************************************
+*/
+
+void
+#if XVT_CC_PROTO
+gpconv_ups(double a, double recf, double sphi, double slam,
+ double *conv, double *sk);
+#else
+gpconv_ups();
+#endif
+
+/**********************************************************************
+@ gpconv_utm()
+***********************************************************************
+*/
+
+void
+#if XVT_CC_PROTO
+gpconv_utm( double a, double recf, double sphi, double slam,
+ int32 izone, double *conv, double *sk);
+#else
+gpconv_utm();
+#endif
+
+
+/**********************************************************************
+@ gpmadl
+***********************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS
+gpmadl(double a,double recf,double sphi,double slam,
+ double *y,double *x,double *ygs,double *xgs,
+ double ophis,double olam,double fn,double fe,double ok,double al,
+ double Const,double r,double ca,double cb);
+#else
+ERRSTATUS
+gpmadl( );
+#endif
+
+
+/**********************************************************************
+@ gpnzmg
+***********************************************************************
+*/
+#if XVT_CC_PROTO
+void gpnzmg(double a, double ophi, double olam, double fn, double fe,
+ double sphi, double slam, double *y, double *x);
+#else
+void gpnzmg( );
+#endif
+
+
+
+/**********************************************************************
+@ nzmgor
+***********************************************************************
+*/
+void
+#if XVT_CC_PROTO
+nzmgor( COORD_TYPE *coord_type );
+#else
+nzmgor( );
+#endif
+
+
+
+#endif
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/units_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/units_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/units_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,101 @@
+#ifndef H_UNITS_D
+#define H_UNITS_D
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_DTCC_D
+#include "dtcc_d.h"
+#endif
+
+/***************************************************************
+@ UNIT_LIST
+****************************************************************
+List of available units of measure.
+*/
+typedef struct
+{
+ char label[30];
+ short count;
+ short setting;
+ char list[20][30]; /* Change: 20 strings instead of 10 */
+ char help_topic[49];
+} UNIT_LIST;
+
+/*
+ * Description:
+ */
+
+
+/***************************************************************
+@ UNITS_LIST
+****************************************************************
+The list of lists of available units
+*/
+typedef struct
+{
+ char label[30];
+ short count;
+ short setting;
+ char list[7][15];
+ UNIT_LIST units[8];
+} UNITS_LIST;
+
+/*
+ * Description:
+ */
+/***************************************************************
+@ AREA
+****************************************************************
+Area is stored internally in SQ_METERS
+*/
+typedef enum
+{
+ SQ_METERS,
+ SQ_FEET,
+ SQ_KM,
+ SQ_NM,
+ SQ_SM
+}
+ UAREA;
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ VOLUME
+****************************************************************
+Volume is stored internally in CU_METERS
+*/
+typedef enum
+{
+ CU_METERS,
+ CU_FT,
+ CU_KM,
+ CU_NM,
+ CU_SM
+}
+ VOLUME;
+
+/*
+ * Description:
+ */
+/***************************************************************
+@ UNITS
+****************************************************************
+Structure to contain the users units selections
+*/
+typedef struct
+{
+ int32 magic;
+ SCALE scale;
+ HOR_DISTANCE hor_distance;
+ VER_DISTANCE ver_distance;
+ UAREA area;
+ VOLUME volume;
+ GEOGRAPHIC geographic;
+} UNITS;
+#endif /* H_UNITS_D */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/units_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/units_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/units_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,929 @@
+#ifndef H_UNITS_F
+#define H_UNITS_F
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_UNITS_D
+#include "units_d.h"
+#endif
+
+#if 0 /* JLL */
+************
+ at area_conv_from[5] ()
+****************************************************************
+Area conversion functions from user units to internal units
+* /
+
+#if XVT_CC_PROTO
+
+#if XVT_CC == XVT_CC_THINK
+extern ERRSTATUS MUSE_API(*area_conv_from[5]) (...);
+#else
+extern ERRSTATUS MUSE_API(*area_conv_from[5]) ();
+#endif
+
+#else
+extern ERRSTATUS MUSE_API(*area_conv_from[5]) ();
+#endif
+
+/*
+ * Description: This is the declaration of an array of pointers to functions.
+ * The user unit is represented by a set of enumerated constants for this
+ * unit. This constant is used as the index into the array of pointers to
+ * functions, so as to call the particular conversion function.
+ *
+ * Ex: GFLOAT area_in_sq_feet, area_in_sq_meters; status =
+ * (*area_conv_from[SQ_FEET]) (area_in_sq_feet, &area_in_sq_meters);
+ */
+
+/***************************************************************
+@ (*area_conv_to[5])()
+****************************************************************
+Area conversion functions from internal units to user units
+*/
+
+#if XVT_CC_PROTO
+
+#if XVT_CC == XVT_CC_THINK
+extern ERRSTATUS MUSE_API(*area_conv_to[5]) (...);
+#else
+extern ERRSTATUS MUSE_API(*area_conv_to[5]) ();
+#endif
+
+#else
+extern ERRSTATUS MUSE_API(*area_conv_to[5]) ();
+#endif
+
+/*
+ * Description: This is the declaration of an array of pointers to functions.
+ * The user unit is represented by a set of enumerated constants for this
+ * unit. This constant is used as the index into the array of pointers to
+ * functions, so as to call the particular conversion function.
+ *
+ * Ex: GFLOAT area_in_sq_feet, area_in_sq_meters; status =
+ * (*area_conv_to[SQ_FEET]) (area_in_sq_meters, &area_in_sq_feet);
+ *
+ */
+
+/***************************************************************
+@ (*volume_conv_from[5])()
+****************************************************************
+Volume conversion functions from user units to internal units
+*/
+
+#if XVT_CC_PROTO
+
+#if XVT_CC == XVT_CC_THINK
+extern ERRSTATUS MUSE_API(*volume_conv_from[5]) (...);
+#else
+extern ERRSTATUS MUSE_API(*volume_conv_from[5]) ();
+#endif
+
+#else
+extern ERRSTATUS MUSE_API(*volume_conv_from[5]) ();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ (*volume_conv_to[5])()
+****************************************************************
+Volume conversion functions from internal units to user units
+*/
+
+#if XVT_CC_PROTO
+
+#if XVT_CC == XVT_CC_THINK
+extern ERRSTATUS MUSE_API(*volume_conv_to[5]) (...);
+#else
+extern ERRSTATUS MUSE_API(*volume_conv_to[5]) ();
+#endif
+
+#else
+extern ERRSTATUS MUSE_API(*volume_conv_to[5]) ();
+#endif
+
+/*
+ * Description:
+ *
+ */
+#endif
+
+/***************************************************************
+@ ver_conv_from()
+****************************************************************
+Converts from user vertical distance units to internal (meters)
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+ ver_conv_from(short user_unit_index, double *mtr_1, double mtr_2);
+#else
+ ver_conv_from();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ ver_conv_to()
+****************************************************************
+Converts from internal vertical distance to user units
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+ver_conv_to(short user_unit_index, double mtr_1, double *mtr_2);
+#else
+ver_conv_to();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ hor_conv_from()
+****************************************************************
+Horizonal conversion functions from user units to internal units
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+hor_conv_from(short user_unit_index, double *hor_1, double hor_2);
+#else
+hor_conv_from();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ hor_conv_to()
+****************************************************************
+Horizonal conversion functions from internal units to user units
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+hor_conv_to(short user_unit_index, double hor_1, double *hor_2);
+#else
+hor_conv_to();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ scale_conv_from()
+****************************************************************
+Scale conversion functions from user units to internal units
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+ scale_conv_from(short user_unit_index, double *recip, double user_unit);
+#else
+scale_conv_from();
+#endif
+
+/*
+ * Description: This is the declaration of an array of pointers to functions.
+ * The user unit is represented by set of enumerated constants for this unit.
+ * This constant is used as the index into the array of pointers to
+ * functions, so as to call the particular conversion function.
+ *
+ * Ex: GFLOAT scale_in_per_deg, scale_reciprocal; status =
+ * (*scale_conf_from[SCALE_IN_PER_DEG]) (scale_in_per_deg,
+ * &scale_reciprocal);
+ */
+
+
+/***************************************************************
+@ scale_conv_to()
+****************************************************************
+Scale conversion functions from internal units to user units
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+ scale_conv_to(short user_unit_index, double recip, double *user_unit);
+#else
+scale_conv_to();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_from_cubf()
+****************************************************************
+Cubic meters from cubic feet
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_from_cubf(
+ double *meter, double feet);
+#else
+ERRSTATUS MUSE_API cubm_from_cubf();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_from_cubkm()
+****************************************************************
+Cubic meters from cubic kilometers
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_from_cubkm(
+ double *meter, double kmeter);
+#else
+ERRSTATUS MUSE_API cubm_from_cubkm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_from_cubm()
+****************************************************************
+Cubic meters from cubic meters
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_from_cubm(
+ double *meter1, double meter2);
+#else
+ERRSTATUS MUSE_API cubm_from_cubm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_from_cubnm()
+****************************************************************
+Cubic meters from cubic nautical miles
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_from_cubnm(
+ double *meter, double nmile);
+#else
+ERRSTATUS MUSE_API cubm_from_cubnm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_from_cubsm()
+****************************************************************
+Cubic meters from cubic statute miles
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_from_cubsm(
+ double *meter, double stmile);
+#else
+ERRSTATUS MUSE_API cubm_from_cubsm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_to_cubf()
+****************************************************************
+Cubic meters to cubic feet
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_to_cubf(
+ double meter, double *feet);
+#else
+ERRSTATUS MUSE_API cubm_to_cubf();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_to_cubkm()
+****************************************************************
+Cubic meters to cubic kilometers
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_to_cubkm(
+ double meter, double *kmeter);
+#else
+ERRSTATUS MUSE_API cubm_to_cubkm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_to_cubm()
+****************************************************************
+Cubic meters to cubic meters
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_to_cubm(
+ double meter1, double *meter2);
+#else
+ERRSTATUS MUSE_API cubm_to_cubm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_to_cubnm()
+****************************************************************
+Cubic meters to cubic nautical miles
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_to_cubnm(
+ double meter, double *nmile);
+#else
+ERRSTATUS MUSE_API cubm_to_cubnm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ cubm_to_cubsm()
+****************************************************************
+Cubic meters to cubic statute miles
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+cubm_to_cubsm(
+ double meter, double *stmile);
+#else
+ERRSTATUS MUSE_API cubm_to_cubsm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ decode_units()
+****************************************************************
+Convert units structure to local binary
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+decode_units(
+ unsigned char *buffer,
+ UNITS * units);
+#else
+ERRSTATUS MUSE_API decode_units();
+#endif
+
+/*
+ * Description: The units structure information in the character buffer
+ * (binary portable Intel format) is placed into the units structure in local
+ * binary. Used by the constructor functions while loading in a map
+ * document.
+ */
+
+/***************************************************************
+@ encode_units()
+****************************************************************
+Convert units structure external form
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+encode_units(
+ unsigned char *buffer,
+ UNITS * units);
+#else
+ERRSTATUS MUSE_API encode_units();
+#endif
+
+/*
+ * Description: The units structure is converted to the external binary
+ * portable (Intel) format. Used by the destructor functions while preparing
+ * to store a map document.
+ */
+
+/***************************************************************
+@ geo_conv_from()
+****************************************************************
+Geo. conversion functions from user units to internal units
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+geo_conv_from(short tag, POINT_DD * dd, POINT_UNITS * user_unit);
+#else
+ERRSTATUS MUSE_API geo_conv_from();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ geo_conv_to()
+****************************************************************
+Geo. conversion functions from internal units to user units
+*/
+ERRSTATUS MUSE_API
+
+#if XVT_CC_PROTO
+geo_conv_to(short tag, POINT_DD * dd, POINT_UNITS * user_unit);
+#else
+geo_conv_to();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ ftnblkd()
+****************************************************************
+Initialize block data
+*/
+
+#if XVT_CC_PROTO
+void ftnblkd(void);
+#else
+void ftnblkd();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+
+/****************************************************************
+@ gptmgr()
+*****************************************************************
+GP to MGRS and UTM grids
+*/
+
+#if XVT_CC_PROTO
+void
+gptmgr(
+ double *a,
+ double *recf,
+ double *sphi,
+ double *slam,
+ int32 *izone,
+ double *y,
+ double *x,
+ char *mgrs,
+ int P1,
+ char *azone,
+ int P2,
+ int32 *isph,
+ int32 *igrpin);
+#else
+void gptmgr();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+
+
+/******************************************************************
+@ gptutm()
+*******************************************************************
+GP to UTM grid
+*/
+
+#if XVT_CC_PROTO
+void
+gptutm(
+ double a,
+ double recf,
+ double sphi,
+ double slam,
+ int32 *izone,
+ double *y,
+ double *x,
+ int32 ifixz);
+#else
+void gptutm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/*******************************************************************
+@ milref()
+********************************************************************
+GP to MGRS
+*/
+
+#if XVT_CC_PROTO
+void
+milref(
+ int32 *iarea,
+ double *a,
+ double *recf,
+ double *sphi,
+ double slam,
+ int32 *izone,
+ double y,
+ double x,
+ char *mgrs,
+ int P2,
+ char *azone,
+ int P1,
+ int32 *isph,
+ int32 *igrpin);
+#else
+void milref();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ pdmstodd()
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+void pdmstodd
+ (
+ float pdms,
+ float *dd
+);
+#else
+void pdmstodd();
+#endif
+
+/*
+ * Description:
+ */
+
+/********************************************************************
+@ savmgr()
+*********************************************************************
+Save MGRS
+*/
+
+#if XVT_CC_PROTO
+void
+savmgr(
+ char *mgrs,
+ int P1,
+ int32 nchar,
+ double xltr,
+ double yltr,
+ int32 ltrnum[],
+ double spsou,
+ double spnor,
+ double sleast,
+ double slwest,
+ double ylow,
+ double yslow,
+ int32 iarea,
+ int32 izone,
+ int32 ltrlow,
+ int32 ltrhi,
+ int32 ltrhy,
+ double fnltr,
+ double feltr,
+ char *azone,
+ int P2);
+#else
+void savmgr();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+
+
+
+/***************************************************************
+@ scale_to_user_str
+****************************************************************
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API scale_to_user_str
+ (
+ UNITS * units,
+ GFLOAT scale_reciprocal,
+ char *output
+);
+#else
+ERRSTATUS MUSE_API scale_to_user_str();
+#endif
+
+/*
+ * Description:
+ *
+ */
+/***************************************************************
+@ sqm_from_sqf()
+****************************************************************
+Square meters from square feet
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_from_sqf(
+ GFLOAT * sqm, GFLOAT sqf);
+#else
+ERRSTATUS MUSE_API sqm_from_sqf();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ sqm_from_sqkm()
+****************************************************************
+Square meters from square kilometers
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_from_sqkm(
+ GFLOAT * sqm, GFLOAT sqkm);
+#else
+ERRSTATUS MUSE_API sqm_from_sqkm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ sqm_from_sqm()
+****************************************************************
+Square meters from square meters
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_from_sqm(
+ GFLOAT * sqm1, GFLOAT sqm2);
+#else
+ERRSTATUS MUSE_API sqm_from_sqm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ sqm_from_sqnm()
+****************************************************************
+Square meters from square nautical miles
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_from_sqnm(
+ GFLOAT * sqm, GFLOAT sqnm);
+#else
+ERRSTATUS MUSE_API sqm_from_sqnm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ sqm_from_sqsm()
+****************************************************************
+Square meters from square statue miles
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_from_sqsm(
+ GFLOAT * sqm, GFLOAT sqnm);
+#else
+ERRSTATUS MUSE_API sqm_from_sqsm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ sqm_to_sqf()
+****************************************************************
+Square meters to square feet
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_to_sqf(
+ GFLOAT sqm, GFLOAT * sqf);
+#else
+ERRSTATUS MUSE_API sqm_to_sqf();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ sqm_to_sqkm()
+****************************************************************
+Square meters to square kilometers
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_to_sqkm(
+ GFLOAT sqm, GFLOAT * sqkm);
+#else
+ERRSTATUS MUSE_API sqm_to_sqkm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ sqm_to_sqm()
+****************************************************************
+Square meters to square meters
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_to_sqm(
+ GFLOAT sqm1, GFLOAT * sqm2);
+#else
+ERRSTATUS MUSE_API sqm_to_sqm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ sqm_to_sqnm()
+****************************************************************
+Square meters to square nautical miles
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_to_sqnm(
+ GFLOAT sqm, GFLOAT * sqnm);
+#else
+ERRSTATUS MUSE_API sqm_to_sqnm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ sqm_to_sqsm()
+****************************************************************
+Square meters to square statute miles
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+sqm_to_sqsm(
+ GFLOAT sqm, GFLOAT * sqsm);
+#else
+ERRSTATUS MUSE_API sqm_to_sqsm();
+#endif
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ units_construct()
+****************************************************************
+Construct the units object
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+units_construct(
+ FILE * file,
+ UNITS ** pointer);
+#else
+ERRSTATUS MUSE_API units_construct();
+#endif
+
+/*
+ * Description: The units object contains a list of the user selected map
+ * units.
+ */
+
+/***************************************************************
+@ units_destruct()
+****************************************************************
+Destroy the object of type UNITS
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API
+units_destruct(
+ FILE * file,
+ BOOLEAN destruct,
+ UNITS ** pointer);
+#else
+ERRSTATUS MUSE_API units_destruct();
+#endif
+
+/*
+ * Description:
+ *
+ */
+#endif /* H_UNITS_F */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/valid_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/valid_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/valid_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,74 @@
+#ifndef H_VALIDFUN
+#define H_VALIDFUN
+
+/***************************************************************
+@ check_integer()
+****************************************************************
+Check that edit field contains a valid integer with no more
+than the given number of digits
+*/
+#if XVT_CC_PROTO
+BOOLEAN check_integer(short length, char *string, BOOLEAN negs_ok,
+ int *caret_pos);
+#else
+BOOLEAN check_integer();
+#endif
+/*
+Description: Checks each character in a string and
+returns TRUE if a non-digit or too many digits are found. This
+method is used for dialog box fields because E_CHAR events are not
+sent or are not portable.
+*/
+
+
+/***************************************************************
+@ check_real()
+****************************************************************
+Check that edit field contains a valid real number with no
+more than the given total number of digits and the given number
+of digits to the right of the decimal place
+*/
+#if XVT_CC_PROTO
+BOOLEAN check_real(short width, short precision, char *string,
+ int *caret_pos);
+#else
+BOOLEAN check_real();
+#endif
+/*
+Description: checks each character in a string and
+returns TRUE if a non-digit or too many digits are found. This
+method is used for dialog box fields because E_CHAR events are not
+sent or are not portable.
+*/
+
+
+#if XVT_CC_PROTO
+BOOLEAN
+check_for_ltr_x_error(char *mgrs);
+#else
+BOOLEAN
+check_for_ltr_x_error();
+#endif
+
+
+#if XVT_CC_PROTO
+BOOLEAN
+check_for_non_mgrs_ellips(char *mgrs, char *isph, int input_type_code);
+#else
+BOOLEAN
+check_for_non_mgrs_ellips();
+#endif
+
+
+#if XVT_CC_PROTO
+BOOLEAN
+check_for_ups(double sphi, int32 *izone, double *y, double *x, char *mgrs,
+ int32 *iarea, double degrad);
+#else
+BOOLEAN
+check_for_ups();
+#endif
+
+
+#endif
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vec_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vec_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vec_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,326 @@
+#ifndef H_VEC_D
+#define H_VEC_D
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_VIEW_DEF
+#include "view_d.h"
+#endif
+#ifndef H_PHIGS_D
+#include "phigs_d.h"
+#endif
+
+#ifndef __VPF_H__
+/* VPF feature types */
+typedef enum { LINE=1, AREA, ANNO, POINTS, COMPLEX=6 } vpf_feature_type;
+#endif
+
+
+#define MAGIC_VEC2_DATA 120000002L
+
+
+#define MAXPOINTS 16000
+#define MAXLINES 16000
+#define MAXAREAS 16000
+#define MAXTEXT 16000
+#define MAXRINGS 5000
+#define MAXSEGS 5000
+#define MAXCOORDS 5000
+#define MAXSTRING 80
+
+#define SZ_VEC 60
+#define SZ_VEC_EXTENTS 32
+#define SZ_VEC_LINES 4
+#define SZ_VEC_TEXT 4
+#define SZ_VEC_POINTS 4
+#define SZ_VEC_AREAS 4
+#define SZ_VEC_SYMBOLOGY 16
+#define SZ_VEC_INFO 8
+#define SZ_SYMB_LINES 20
+#define SZ_SYMB_TEXT 16
+#define SZ_SYMB_POINTS 16
+#define SZ_SYMB_AREAS 10
+#define SZ_COORDINATE 16
+
+#define SZ_LONG 4
+#define SZ_DOUBLE 8
+
+
+/***************************************************************
+@ FEATURE_EDIT_FLAGS
+****************************************************************
+A set of flags used in feature editing.
+*/
+typedef struct
+{
+ BOOLEAN selected; /*TRUE if selected*/
+ BOOLEAN deleted; /*TRUE if flagged for deletion*/
+ BOOLEAN modified; /*TRUE if recently modified*/
+} FEATURE_EDIT_FLAGS;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ POINT_SYMB
+****************************************************************
+Point Symbology structure for display of markers.
+*/
+typedef struct
+{
+ Pint marker_color;
+ Pint marker_type;
+ Pfloat marker_scale;
+} POINT_SYMB;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ LINE_SYMB
+****************************************************************
+Line Symbology structure for display of lines.
+*/
+typedef struct
+{
+ Pint line_color;
+ Pint line_style;
+ Pfloat line_width;
+ POINT_SYMB *point_symb;
+} LINE_SYMB;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ TEXT_SYMB
+****************************************************************
+Text Symbology structure for display of text.
+*/
+typedef struct
+{
+ Pint text_color;
+ Pfloat text_scale;
+ POINT_SYMB *point_symb;
+} TEXT_SYMB;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ AREA_SYMB
+****************************************************************
+Area Symbology structure for display of areas.
+*/
+typedef struct
+{
+ Pint area_color;
+ Pint_style area_style;
+ LINE_SYMB *line_symb;
+} AREA_SYMB;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ COORDINATE
+****************************************************************
+Geospatial coordinate pair.
+*/
+typedef struct
+ {
+ float x;
+ float y;
+ } COORDINATE;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ SEGMENT
+****************************************************************
+Line/edge segment.
+*/
+typedef struct
+ {
+ int32 id;
+ int32 nr_coords;
+ COORDINATE *coords;
+ } SEGMENT;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ POINT_FEATURE
+****************************************************************
+Point Feature structure.
+*/
+typedef struct
+ {
+ int32 id;
+ COORDINATE *coord;
+ POINT_SYMB *point_symb;
+ FEATURE_EDIT_FLAGS flags;
+ } POINT_FEATURE;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ LINE_FEATURE
+****************************************************************
+Line Feature structure.
+*/
+typedef struct
+ {
+ int32 id;
+ int32 nr_segs;
+ SEGMENT **segs;
+ LINE_SYMB *line_symb;
+ FEATURE_EDIT_FLAGS flags;
+ } LINE_FEATURE;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ RING
+****************************************************************
+Ring structure.
+*/
+typedef struct
+ {
+ int32 id;
+ int32 nr_segs;
+ SEGMENT **segs;
+ } RING;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ AREA_FEATURE
+****************************************************************
+Area Feature structure.
+*/
+typedef struct
+ {
+ int32 id;
+ int32 nr_rings;
+ RING **rings;
+ AREA_SYMB *area_symb;
+ FEATURE_EDIT_FLAGS flags;
+ } AREA_FEATURE;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ TEXT_FEATURE
+****************************************************************
+Text Feature structure.
+*/
+typedef struct
+ {
+ int32 id;
+ char *string;
+ int32 nr_coords;
+ COORDINATE *coords;
+ TEXT_SYMB *text_symb;
+ FEATURE_EDIT_FLAGS flags;
+ } TEXT_FEATURE;
+/*
+Description:
+
+*/
+
+/****************************************************************************
+@ VEC_EXTENT
+*****************************************************************************
+Spatial extents of the data-set.
+*/
+typedef struct
+{
+ double xmin;
+ double ymin;
+ double xmax;
+ double ymax;
+} VEC_EXTENT;
+/*
+Description:
+
+*/
+
+/****************************************************************************
+@ VEC_INFO
+*****************************************************************************
+Spatial extents of the data-set.
+*/
+typedef struct
+{
+ char *type;
+ char *info;
+} VEC_INFO;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ SYMBOLOGY
+****************************************************************
+Symbology structure for displaying of VECs.
+*/
+typedef struct
+{
+ LINE_SYMB *line_symb;
+ TEXT_SYMB *text_symb;
+ POINT_SYMB *point_symb;
+ AREA_SYMB *area_symb;
+} SYMBOLOGY;
+/*
+Description:
+
+*/
+
+/***********************************************************************
+@ VEC
+************************************************************************
+A MUSE structure to hold vector overlay data.
+*/
+typedef struct
+ {
+ int32 magic;
+ vpf_feature_type feature_type;
+ int32 nr_features;
+ int32 nr_lines;
+ int32 nr_text;
+ int32 nr_points;
+ int32 nr_areas;
+ VEC_EXTENT *extents;
+ VEC_INFO *info;
+ LINE_FEATURE **lines;
+ TEXT_FEATURE **text;
+ POINT_FEATURE **points;
+ AREA_FEATURE **areas;
+ SYMBOLOGY *symbology;
+ } VEC;
+/*
+Description:
+
+*/
+
+#endif /* H_VEC_DEF */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vec_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vec_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vec_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,733 @@
+#ifndef H_VEC_F
+#define H_VEC_F
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+#ifndef H_VEC_D
+#include "vec_d.h"
+#endif
+#ifndef H_MGM_D
+#include "mgm_d.h"
+#endif
+
+/***************************************************************
+@ area_feature_construct()
+****************************************************************
+Area feature constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API area_feature_construct(FILE *file, AREA_FEATURE ***area,
+ int32 nr_features);
+#else
+ERRSTATUS MUSE_API area_feature_construct();
+#endif
+/*
+Description:
+If file is not NULL the area feature is written to the file.
+If destruct is TRUE the area feature is released.
+*/
+
+
+/***************************************************************
+@ line_feature_construct()
+****************************************************************
+Line feature constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API line_feature_construct(FILE *file,LINE_FEATURE ***lines,
+ int32 nr_features);
+#else
+ERRSTATUS MUSE_API line_feature_construct();
+#endif
+/*
+Description:
+If file is not NULL the line feature is written to the file.
+If destruct is TRUE the line feature is released.
+*/
+
+/***************************************************************
+@ point_feature_construct()
+****************************************************************
+Point feature constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API point_feature_construct(FILE *file, POINT_FEATURE ***points,
+ int32 nr_features);
+#else
+ERRSTATUS MUSE_API point_feature_construct();
+#endif
+/*
+Description:
+If file is not NULL the point feature is written to the file.
+If destruct is TRUE the point feature is released.
+*/
+
+/***************************************************************
+@ text_feature_construct()
+****************************************************************
+Text feature constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API text_feature_construct(FILE *file, TEXT_FEATURE ***text,
+ int32 nr_features);
+#else
+ERRSTATUS MUSE_API text_feature_construct();
+#endif
+/*
+Description:
+If file is not NULL the text feature is written to the file.
+If destruct is TRUE the text feature is released.
+*/
+
+/***************************************************************
+@ decode_area_symb()
+****************************************************************
+Decode area symbology.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API decode_area_symb(unsigned char *record, AREA_SYMB *area_symb);
+#else
+ERRSTATUS MUSE_API decode_area_symb();
+#endif
+/*
+Description:
+Decodes data into the AREA_SYMB structure after read from file.
+*/
+
+/***************************************************************
+@ area_symb_construct()
+****************************************************************
+Area symbology constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API area_symb_construct(FILE *file, AREA_SYMB **area_symb);
+#else
+ERRSTATUS MUSE_API area_symb_construct();
+#endif
+/*
+Description:
+If file is not NULL the area symbology is written to the file.
+If destruct is TRUE the area symbology is released.
+*/
+
+/***************************************************************
+@ decode_line_symb()
+****************************************************************
+Decode line symbology.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API decode_line_symb(unsigned char *record, LINE_SYMB *line_symb);
+#else
+ERRSTATUS MUSE_API decode_line_symb();
+#endif
+/*
+Description:
+Decodes data into the LINE_SYMB structure after read from file.
+*/
+
+
+/***************************************************************
+@ line_symb_construct()
+****************************************************************
+Line symbology constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API line_symb_construct(FILE *file, LINE_SYMB **line_symb);
+#else
+ERRSTATUS MUSE_API line_symb_construct();
+#endif
+/*
+Description:
+If file is not NULL the line symbology is written to the file.
+If destruct is TRUE the line symbology is released.
+*/
+
+/***************************************************************
+@ decode_point_symb()
+****************************************************************
+Decode point symbology.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API decode_point_symb(unsigned char *record, POINT_SYMB *point_symb);
+#else
+ERRSTATUS MUSE_API decode_point_symb();
+#endif
+/*
+Description:
+Decodes data into the POINT_SYMB structure after read from file.
+*/
+
+/***************************************************************
+@ point_symb_construct()
+****************************************************************
+Point symbology constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API point_symb_construct(FILE *file, POINT_SYMB **point_symb);
+#else
+ERRSTATUS MUSE_API point_symb_construct();
+#endif
+/*
+Description:
+If file is not NULL the point symbology is written to the file.
+If destruct is TRUE the point symbology is released.
+*/
+
+/***************************************************************
+@ decode_symbology()
+****************************************************************
+Decode symbology.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API decode_symbology(unsigned char *record, SYMBOLOGY *symb);
+#else
+ERRSTATUS MUSE_API decode_symbology();
+#endif
+/*
+Description:
+Decodes data into the SYMBOLOGY structure after read from file.
+*/
+
+/***************************************************************
+@ symbology_construct()
+****************************************************************
+Symbology constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API symbology_construct(FILE *file, SYMBOLOGY **symb);
+#else
+ERRSTATUS MUSE_API symbology_construct();
+#endif
+/*
+Description:
+If file is not NULL the symbology is written to the file.
+If destruct is TRUE the symbology is released.
+*/
+
+
+/***************************************************************
+@ decode_text_symb()
+****************************************************************
+Decode text symbology
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API decode_text_symb(unsigned char *record, TEXT_SYMB *text_symb);
+#else
+ERRSTATUS MUSE_API decode_text_symb();
+#endif
+/*
+Description:
+Decodes data into the TEXT_SYMB structure after read from file.
+*/
+
+
+/***************************************************************
+@ text_symb_construct()
+****************************************************************
+Text symbology constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API text_symb_construct(FILE *file, TEXT_SYMB **text_symb);
+#else
+ERRSTATUS MUSE_API text_symb_construct();
+#endif
+/*
+Description:
+If file is not NULL the text symbology is written to the file.
+If destruct is TRUE the text symbology is released.
+*/
+
+/***************************************************************
+@ decode_vec_extents()
+****************************************************************
+Decode vector extents.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API decode_vec_extents(unsigned char *record, VEC_EXTENT *extents);
+#else
+ERRSTATUS MUSE_API decode_vec_extents();
+#endif
+/*
+Description:
+Decodes data into the VEC_EXTENT structure after read from file.
+*/
+
+/***************************************************************
+@ vec_extent_construct()
+****************************************************************
+Vector extent constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API vec_extent_construct(FILE *file, VEC_EXTENT **extents);
+#else
+ERRSTATUS MUSE_API vec_extent_construct();
+#endif
+/*
+Description:
+If file is not NULL the vector extent is written to the file.
+If destruct is TRUE the vector extent is released.
+*/
+
+/***************************************************************
+@ vec_info_construct()
+****************************************************************
+Vector information constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API vec_info_construct(FILE *file, VEC_INFO **info);
+#else
+ERRSTATUS MUSE_API vec_info_construct();
+#endif
+/*
+Description:
+If file is not NULL the vector information is written to the file.
+If destruct is TRUE the vector information is released.
+*/
+
+/***************************************************************
+@ decode_vec()
+****************************************************************
+Decode Vector.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API decode_vec(unsigned char *record, VEC *vec);
+#else
+ERRSTATUS MUSE_API decode_vec();
+#endif
+/*
+Description:
+Decodes data into the VECTOR structure after read from file.
+*/
+
+
+/***************************************************************
+@ vec_construct()
+****************************************************************
+Vector constructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API vec_construct(FILE *file, VEC **vec);
+#else
+ERRSTATUS MUSE_API vec_construct();
+#endif
+/*
+Description:
+If file is not NULL the vector is written to the file.
+If destruct is TRUE the vector is released.
+*/
+
+/***************************************************************
+@ is_vec_ok()
+****************************************************************
+Test Vector Magic number for validity.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API is_vec_ok(FILE *file);
+#else
+ERRSTATUS MUSE_API is_vec_ok();
+#endif
+/*
+Description:
+Checks a newly opened vector file to see
+is it has a correct magic number.
+*/
+
+
+
+/***************************************************************
+@ area_feature_destruct()
+****************************************************************
+Area feature destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API area_feature_destruct(FILE *file, BOOLEAN destruct, AREA_FEATURE ***area,
+ int32 nr_areas);
+#else
+ERRSTATUS MUSE_API area_feature_destruct();
+#endif
+/*
+Description:
+Constructs a area feature object. If file is not NULL the area
+feature is read in from the file.
+*/
+
+/***************************************************************
+@ line_feature_destruct()
+****************************************************************
+Line feature destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API line_feature_destruct(FILE *file, BOOLEAN destruct, LINE_FEATURE ***lines,
+ int32 nr_lines);
+#else
+ERRSTATUS MUSE_API line_feature_destruct();
+#endif
+/*
+Description:
+Constructs a line feature object. If file is not NULL the line
+feature is read in from the file.
+*/
+
+/***************************************************************
+@ point_feature_destruct()
+****************************************************************
+Point feature destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API point_feature_destruct(FILE *file, BOOLEAN destruct, POINT_FEATURE ***points,
+ int32 nr_points);
+#else
+ERRSTATUS MUSE_API point_feature_destruct();
+#endif
+/*
+Description:
+Constructs a point feature object. If file is not NULL the point
+feature is read in from the file.
+*/
+
+/***************************************************************
+@ text_feature_destruct()
+****************************************************************
+Text feature destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API text_feature_destruct(FILE *file, BOOLEAN destruct, TEXT_FEATURE ***text,
+ int32 nr_text);
+#else
+ERRSTATUS MUSE_API text_feature_destruct();
+#endif
+/*
+Description:
+Constructs a text feature object. If file is not NULL the text
+feature is read in from the file.
+*/
+
+/***************************************************************
+@ encode_area_symb()
+****************************************************************
+Encode area symbology.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API encode_area_symb(unsigned char *record, AREA_SYMB *area_symb);
+#else
+ERRSTATUS MUSE_API encode_area_symb();
+#endif
+/*
+Description:
+Encodes the AREA_SYMB structure so that it can be written
+portably.
+*/
+
+/***************************************************************
+@ area_symb_destruct()
+****************************************************************
+Area symbology destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API area_symb_destruct(FILE *file, BOOLEAN destruct, AREA_SYMB **area_symb);
+#else
+ERRSTATUS MUSE_API area_symb_destruct();
+#endif
+/*
+Description:
+Constructs a area symbology object. If file is not NULL the area
+symbology is read in from the file.
+*/
+
+/***************************************************************
+@ encode_line_symb()
+****************************************************************
+Encode line symbology.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API encode_line_symb(unsigned char *record, LINE_SYMB *line_symb);
+#else
+ERRSTATUS MUSE_API encode_line_symb();
+#endif
+/*
+Description:
+Encodes the LINE_SYMB structure so that it can be written
+portably.
+*/
+
+
+/***************************************************************
+@ line_symb_destruct()
+****************************************************************
+Line symbology destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API line_symb_destruct(FILE *file, BOOLEAN destruct, LINE_SYMB **line_symb);
+#else
+ERRSTATUS MUSE_API line_symb_destruct();
+#endif
+/*
+Description:
+Constructs a vector line symbology. If file is not NULL the line
+symbology is read in from the file.
+*/
+
+/***************************************************************
+@ encode_point_symb()
+****************************************************************
+Encode point symbology.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API encode_point_symb(unsigned char *record, POINT_SYMB *point_symb);
+#else
+ERRSTATUS MUSE_API encode_point_symb();
+#endif
+/*
+Description:
+Encodes the POINT_SYMB structure so that it can be written
+portably.
+*/
+
+/***************************************************************
+@ point_symb_destruct()
+****************************************************************
+Point symbology destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API point_symb_destruct(FILE *file, BOOLEAN destruct, POINT_SYMB **point_symb);
+#else
+ERRSTATUS MUSE_API point_symb_destruct();
+#endif
+/*
+Description:
+Constructs a point symbology object. If file is not NULL the point
+symbology is read in from the file.
+*/
+
+/***************************************************************
+@ encode_symbology()
+****************************************************************
+Encode symbology.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API encode_symbology(unsigned char *record, SYMBOLOGY *symb);
+#else
+ERRSTATUS MUSE_API encode_symbology();
+#endif
+/*
+Description:
+Encodes the SYMBOLOGY structure so that it can be written
+portably.
+*/
+
+/***************************************************************
+@ symbology_destruct()
+****************************************************************
+Symbology destructor
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API symbology_destruct(FILE *file, BOOLEAN destruct, SYMBOLOGY **symb);
+#else
+ERRSTATUS MUSE_API symbology_destruct();
+#endif
+/*
+Description:
+Constructs a symbology object. If file is not NULL the symbology
+is read in from the file.
+*/
+
+/***************************************************************
+@ encode_text_symb()
+****************************************************************
+Encode text symbology.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API encode_text_symb(unsigned char *record, TEXT_SYMB *text_symb);
+#else
+ERRSTATUS MUSE_API encode_text_symb();
+#endif
+/*
+Description:
+Encodes the TEXT_SYMB structure so that it can be written
+portably.
+*/
+
+/***************************************************************
+@ text_symb_destruct()
+****************************************************************
+Text symbology destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API text_symb_destruct(FILE *file, BOOLEAN destruct, TEXT_SYMB **text_symb);
+#else
+ERRSTATUS MUSE_API text_symb_destruct();
+#endif
+/*
+Description:
+Constructs a text symbology object. If file is not NULL the text
+symbology is read in from the file.
+*/
+
+
+/***************************************************************
+@ encode_vec_extents()
+****************************************************************
+Encode vector extents.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API encode_vec_extents(unsigned char *record, VEC_EXTENT *extents);
+#else
+ERRSTATUS MUSE_API encode_vec_extents();
+#endif
+/*
+Description:
+Encodes the VEC_EXTENT structure so that it can be written
+portably.
+*/
+
+/***************************************************************
+@ vec_extent_destruct()
+****************************************************************
+Vector extent destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API vec_extent_destruct(FILE *file, BOOLEAN destruct, VEC_EXTENT **extents);
+#else
+ERRSTATUS MUSE_API vec_extent_destruct();
+#endif
+/*
+Description:
+Constructs a vector extent object. If file is not NULL the vector
+extent is read in from the file.
+*/
+
+/***************************************************************
+@ vec_info_destruct()
+****************************************************************
+Vector information destructor
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API vec_info_destruct(FILE *file, BOOLEAN destruct, VEC_INFO **info);
+#else
+ERRSTATUS MUSE_API vec_info_destruct();
+#endif
+/*
+Description:
+Constructs a vector information object. If file is not NULL the
+vector information is read in from the file.
+*/
+
+/***************************************************************
+@ encode_vec()
+****************************************************************
+Encode vector.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API encode_vec(unsigned char *record, VEC *vec);
+#else
+ERRSTATUS MUSE_API encode_vec();
+#endif
+/*
+Description:
+Encodes the VECTOR structure so that it can be written
+portably.
+*/
+
+/***************************************************************
+@ vec_destruct()
+****************************************************************
+Vector destructor.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API vec_destruct(FILE *file, BOOLEAN destruct, VEC **vec);
+#else
+ERRSTATUS MUSE_API vec_destruct();
+#endif
+/*
+Description:
+Constructs a vector object. If file is not NULL the vector
+is read in from the file.
+*/
+
+/***************************************************************
+@ draw_vec()
+****************************************************************
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API draw_vec(
+ MGM *mgm,
+ VEC *vec,
+ WINDOW map_win,
+ BOOLEAN *no_process_vector);
+#else
+ERRSTATUS MUSE_API draw_vec();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ draw_vec_areas()
+****************************************************************
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API draw_vec_areas(
+ MGM * mgm,
+ VEC * vec,
+ WINDOW map_win,
+ BOOLEAN * npv);
+#else
+ERRSTATUS MUSE_API draw_vec_areas();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ draw_vec_lines()
+****************************************************************
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API draw_vec_lines(
+ MGM * mgm,
+ VEC * vec,
+ WINDOW map_win,
+ BOOLEAN * npv);
+#else
+ERRSTATUS MUSE_API draw_vec_lines();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ draw_vec_points()
+****************************************************************
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API draw_vec_points(
+ MGM * mgm,
+ VEC * vec,
+ WINDOW map_win,
+ BOOLEAN * npv);
+#else
+ERRSTATUS MUSE_API draw_vec_points();
+#endif
+/*
+Description:
+*/
+
+/***************************************************************
+@ draw_vec_text()
+****************************************************************
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API draw_vec_text(
+ MGM * mgm,
+ VEC * vec,
+ WINDOW map_win,
+ BOOLEAN * npv);
+#else
+ERRSTATUS MUSE_API draw_vec_text();
+#endif
+/*
+Description:
+*/
+
+#endif /* H_VEC_F */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vector.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vector.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vector.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,145 @@
+#ifndef H_VECTOR
+#define H_VECTOR
+
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_PHIGS_D
+#include "phigs_d.h"
+#endif
+#ifndef H_VEC_D
+#include "vec_d.h"
+#endif
+#ifndef H_SQLLIB_D
+#include "sqllib_d.h"
+#endif
+
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+#ifndef MAGIC_VECTOR
+#define MAGIC_VECTOR 110000000L
+#endif
+
+#ifndef MAGIC_VEC_DATA /* SR 10/02 */
+#define MAGIC_VEC_DATA 120000001L
+#endif
+
+/* SR 10/02 */
+/***************************************************************
+@ Vec_Data flags
+****************************************************************
+*/
+#define VEC_DATA_VALID_MASK 0x0001
+#define VEC_DATA_NEEDS_REDRAW_MASK 0x0002
+#define VEC_DATA_USE_TIMER_MASK 0x0003
+
+/*
+ * Description:
+ */
+
+
+/* SR 09/16 */
+/***************************************************************
+@ VEC_DATA
+****************************************************************
+Defines a vector data structure
+*/
+typedef struct
+{
+ int32 magic;
+ int32 bit_flags;
+ BOOLEAN contains_valid_data;
+/*to compile SEL_THEME sel_theme;*/
+ VEC *vector;
+
+ FILE_SPEC file_spec;
+ int32 vec_timer;
+} VEC_DATA;
+
+
+
+/*
+ * SR 09/25--list of functions for constructing map versions with different
+ * vec_data structures
+ */
+
+#if XVT_CC_PROTO
+ERRSTATUS vec_con_vers0(FILE * file, VEC_DATA ** pointer, BYTE_ORDER * bo);
+#else
+ERRSTATUS vec_con_vers0();
+#endif
+
+/*
+ * Memory allocation and initialization for version 0 maps whose
+ * product_pointers point to a VECTOR structure. Only called when opening an
+ * old .map file: added overlays will be created with vec_data_construct for
+ * the latest version of maps.
+ */
+
+
+#if XVT_CC_PROTO
+ERRSTATUS vec_con_vers1(FILE * file, VEC_DATA ** pointer, BYTE_ORDER * bo);
+#else
+ERRSTATUS vec_con_vers1();
+#endif
+
+/*
+ * Memory allocation and initialization of the VEC_DATA structure in version
+ * 1 maps, which contains edge color and width, text and point color, and a
+ * pointer to a VECTOR structure.
+ */
+
+
+/***************************************************************
+@ (*vec_data_construct[])()
+****************************************************************
+list of functions to construct vec_data structure for each map version
+*/
+
+#if XVT_CC_PROTO
+extern ERRSTATUS(*vec_data_construct[2]) (FILE * file, VEC_DATA ** pointer, BYTE_ORDER * bo);
+#else
+extern ERRSTATUS(*vec_data_construct[2]) ();
+#endif
+
+
+/***************************************************************
+@ vec_data_destruct()
+****************************************************************
+function to destruct vec_data structure
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS vec_data_destruct(FILE * file, BOOLEAN destruct, VEC_DATA ** vec_data, BYTE_ORDER * bo);
+#else
+ERRSTATUS vec_data_destruct();
+#endif
+
+
+/************************************************************************
+@ decode_vec_data()
+*************************************************************************
+function to decode the vec_data structure
+*/
+
+#if XVT_CC_PROTO
+ERRSTATUS decode_vec_data(unsigned char *record, VEC_DATA * vec_data);
+#else
+ERRSTATUS decode_vec_data();
+#endif
+
+/************************************************************************
+@ encode_vec_data()
+*************************************************************************
+A function to encode the vec_data structure*/
+
+#if XVT_CC_PROTO
+ERRSTATUS encode_vec_data(unsigned char *record, VEC_DATA * vec_data);
+#else
+ERRSTATUS encode_vec_data();
+#endif
+
+#endif /* H_VECTOR */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,14 @@
+#ifndef H_VIEW
+
+#define H_VIEW
+
+#ifndef H_VIEW_DEF
+#include "viewdef.h"
+#endif
+
+#ifndef H_VIEW_FUNC
+#include "viewfunc.h"
+#endif
+
+#endif /* H_VIEW */
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,61 @@
+/*
+ at Viewstruct
+*/
+#ifndef H_VIEW_DEF
+#define H_VIEW_DEF
+
+#ifndef _WINDOWS
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+/***************************************************************
+@ VIEW
+****************************************************************
+The structure of bitmap viewing parmeters
+*/
+typedef struct
+{
+ int32 magic;
+ int bitmap_xsize;
+ int bitmap_ysize;
+ int bitmap_xmin;
+ int bitmap_ymin;
+ int bitmap_xmax;
+ int bitmap_ymax;
+ int scroll_x;
+ int scroll_y;
+ int status;
+ double zoomx;
+ double zoomy;
+ void *winstuff;
+ BOOLEAN new_palette; /* has a palette been made? */
+} VIEW;
+/*
+Description:
+bit_maps may contain 1, 4, 8, or 24 bits per pixel.
+The bit_map begins at the upper left corner of the image.
+The order is row-major, left-to-right, then top-to-bottom.
+Each row is 0 padded (if necessary) so that the next row
+ begins on an even (2 byte) word.
+The bit_map is useable directly on Macintosh and MS Windows.
+*/
+
+#ifdef _WINDOWS
+/***************************************************************
+@ WINVIEW
+****************************************************************
+A window list and corresponding view list.
+*/
+typedef struct
+{ WINDOW list[100];
+ VIEW view[100];
+} WINVIEW;
+#endif
+/*
+Description:
+
+*/
+#endif /* _WINDOWS */
+#endif /* #ifndef H_VIEW_DEF */
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/view_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,279 @@
+/*
+ at Viewfunc
+*/
+#ifndef H_VIEW_FUNC
+#define H_VIEW_FUNC
+
+#ifndef H_MUSEDEF
+/*JLL#include "musedef.h"*/
+#endif
+
+#if XVT_OS == XVT_OS_WIN
+#ifndef __WINDOWS_H
+#include "windows.h"
+#endif
+#endif
+
+/***************************************************************
+@ view_close();
+****************************************************************
+Close map view.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_close(WINDOW xvt_win);
+#else /* !XVT_CC_PROTO */
+ERRSTATUS view_close();
+#endif /* XVT_CC_PROTO */
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_construct()
+****************************************************************
+Allocates memory for VIEW structure.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_construct(void);
+#else
+ERRSTATUS view_construct();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_create();
+****************************************************************
+Creates map view of screen.
+*/
+#if XVT_CC_PROTO
+#if XVTWS == WINWS
+ERRSTATUS view_create(WINDOW xvt_win, HDC MSmem, HBITMAP MSbitmap);
+#elif XVTWS == MTFWS
+#include <X11/Xlib.h>
+ERRSTATUS view_create(WINDOW xvt_win, XImage* image, BYTE pHMEM data, Pixmap pix);
+#else /* XVTWS == MACWS */
+ERRSTATUS view_create(WINDOW xvt_win);
+#endif
+#else /* !XVT_CC_PROTO */
+ERRSTATUS view_create();
+#endif /* XVT_CC_PROTO */
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_destruct()
+****************************************************************
+Deallocates memory for VIEW structure.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_destruct(void);
+#else
+ERRSTATUS view_destruct();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_get_color()
+****************************************************************
+Returns a valid color to phigs.
+*/
+#if XVT_CC_PROTO
+void view_get_color(WINDOW xvt_win, int index, int type);
+#else
+void view_get_color();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_color_dist()
+****************************************************************
+Returns a dist color.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API view_color_dist(RGB x, RGB y, int32 *distance);
+#else
+ERRSTATUS MUSE_API view_color_dist();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_get_cur()
+****************************************************************
+Gets current view associated with the window.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS MUSE_API view_get_cur(WINDOW xvt_win, VIEW **view);
+#else
+ERRSTATUS MUSE_API view_get_cur();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_new_win()
+****************************************************************
+Set a new view window.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_new_win(WINDOW xvt_win);
+#else
+ERRSTATUS view_new_win();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_open();
+****************************************************************
+Opens map view to write into.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_open(WINDOW xvt_win);
+#else /* !XVT_CC_PROTO */
+ERRSTATUS view_open();
+#endif /* XVT_CC_PROTO */
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_put_palette()
+****************************************************************
+Puts the palette out to the native window manager
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_put_palette(WINDOW xvt_win, PALETTE *palette);
+#else
+ERRSTATUS view_put_palette();
+#endif
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_reset()
+****************************************************************
+Resets map view to original pix map.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_reset(WINDOW xvt_win);
+#else /* !XVT_CC_PROTO */
+ERRSTATUS view_reset();
+#endif /* XVT_CC_PROTO */
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_scale();
+****************************************************************
+Opens map view to write into.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_scale(WINDOW xvt_win);
+#else
+ERRSTATUS view_scale();
+#endif
+/*
+Description:
+
+*/
+/***************************************************************
+@ view_update()
+****************************************************************
+Refreshes map view
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_update(WINDOW xvt_win, BOOLEAN force_resample);
+#else /* !XVT_CC_PROTO */
+ERRSTATUS view_update();
+#endif /* XVT_CC_PROTO */
+/*
+Description:
+
+*
+/
+/***************************************************************
+@ view_remove_bitmap()
+****************************************************************
+Remove bitmap from view list.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_remove_bitmap(WINDOW xvt_win);
+#else /* !XVT_CC_PROTO */
+ERRSTATUS view_remove_bitmap();
+#endif /* XVT_CC_PROTO */
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_remove_win()
+****************************************************************
+Remove window from view list.
+*/
+#if XVT_CC_PROTO
+ERRSTATUS view_remove_win(WINDOW xvt_win);
+#else /* !XVT_CC_PROTO */
+ERRSTATUS view_remove_win();
+#endif /* XVT_CC_PROTO */
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ view_nearest_color()
+****************************************************************
+
+*/
+#if XVT_CC_PROTO
+ERRSTATUS
+view_nearest_color(PALETTE * pal, PALETTE_USAGE palette_usage, RGB rgb, USHORT * pal_color);
+#else
+ERRSTATUS
+view_nearest_color();
+#endif
+
+#if XVT_CC_PROTO
+ERRSTATUS
+view_get_list(Pint_list * ws_id_list);
+#else
+ERRSTATUS
+view_get_list();
+#endif
+
+#endif /* #ifndef H_VIEW_FUNC */
+
+
+
+
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vpf_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vpf_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vpf_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,638 @@
+#ifndef H_VPF_DEF
+#define H_VPF_DEF
+#include <stdio.h>
+
+#define CLOSED 0
+#define OPENED 1
+
+/* define NULL values */
+
+#define VARIABLE_STRING_NULL_LENGTH 10
+#define NULLCHAR ' '
+#define NULLTEXT " "
+#define NULLSHORT -SHRT_MAX
+#define NULLINT -LONG_MAX
+#define NULLDATE " "
+
+#if XVT_OS_ISUNIX
+#define NULLFLOAT ((float) quiet_nan (0))
+#define NULLDOUBLE ((double) quiet_nan (0))
+#elif XVT_CC == XVT_THINK
+#define NULLFLOAT ((float)3.40282346638528860e+38)
+#define NULLDOUBLE ((double)1.797693134862315708e+308)
+#else
+#define NULLFLOAT ((float) 3.402823466e+38)
+#define NULLDOUBLE ((double) 1.7976931348623158e+30)
+#endif
+
+/* These are all the metacharacters used to parse out input text files */
+#define COMPONENT_SEPERATOR ';'
+#define LINE_CONTINUE '\\'
+#define SPACE ' '
+#define TEXT_NULL "-"
+#define COMMENT_CHAR '"'
+#define FIELD_COUNT '='
+#define FIELD_SEPERATOR ','
+#define END_OF_FIELD ':'
+#define FIELD_PARTITION '^'
+#define NEXT_ELEMENT '|'
+#define COMMENT '#'
+#define NEW_LINE '\n'
+#define VARIABLE_COUNT '*'
+#define TAB '\t'
+
+/* These macros help determine the type in the key datatype */
+
+#define TYPE0(cell) ((cell>>6)&(3))
+#define TYPE1(cell) ((cell>>4)&(3))
+#define TYPE2(cell) ((cell>>2)&(3))
+#define TYPE3(cell) ((cell)&(3))
+
+typedef enum
+{
+ VpfNull,
+ VpfChar,
+ VpfShort,
+ VpfInteger,
+ VpfFloat,
+ VpfDouble,
+ VpfDate,
+ VpfKey,
+ VpfCoordinate,
+ VpfTriCoordinate,
+ VpfDoubleCoordinate,
+ VpfDoubleTriCoordinate,
+ VpfUndefined
+}
+ VpfDataType;
+
+
+typedef union
+{
+ unsigned char f1;
+ unsigned short int f2;
+ uint32 f3;
+} key_field;
+
+typedef
+char VDATE[21]; /* Include null end of string */
+
+typedef union
+{
+ char *Char;
+ short Short;
+ int32 Int;
+ float Float;
+ double Double;
+ VDATE Date;
+ char Other;
+} null_field;
+
+
+typedef enum
+{
+ Read,
+ Write
+}
+ file_mode;
+
+
+
+/* Each column in a table row has a count and a pointer to the data */
+/* and a null value default */
+typedef struct
+{
+ int32 count;
+ void *ptr;
+} COLUMN;
+
+/* A table row is an array of columns */
+typedef COLUMN *ROW;
+
+/* Index for variable width tables. */
+/* One index cell for each row in the table. */
+typedef struct
+{
+ uint32 pos;
+ uint32 length;
+} INDEX;
+
+
+/* The basic information carried for each field in the table */
+typedef struct
+{
+ char *name; /* Name of the field */
+ char description[81]; /* Field description */
+ char keytype; /* Type of key - (P)rimary, (F)oreign,
+ * (N)onkey */
+ char vdt[13]; /* Value description table name */
+ char *tdx; /* Thematic index file name */
+ char type; /* Data type - T,I,F,K,D */
+ int32 count; /* Number of items in this column (-1
+ * =>variable) */
+ null_field nullval; /* This is used for the converter */
+ char *narrative; /* Name of a narrative table describing the
+ * field */
+} header_cell, *header_type;
+
+
+typedef struct
+{
+ float x;
+ float y;
+} XY_COORDINATE;
+
+typedef struct
+{
+ double x;
+ double y;
+} XY_DCOORDINATE;
+
+typedef struct
+{
+ float x;
+ float y;
+ float z;
+} XYZ_COORDINATE;
+
+typedef struct
+{
+ double x;
+ double y;
+ double z;
+} XYZ_DCOORDINATE;
+
+typedef struct
+{
+ unsigned char type;
+ int32 id;
+ int32 tile;
+ int32 exid;
+} ID_TRIPLET;
+
+/***************************************************************
+@ HEADER_SIZE
+****************************************************************
+Size of header to be read.
+*/
+typedef struct
+{
+ int32 header_length;
+ char byte_order;
+} HEADER_SIZE;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ STANDARD_HEADER
+****************************************************************
+Table Desciption and documentation filename.
+*/
+typedef struct
+{
+ char table_description[101];
+ char separator_1;
+ char narrative_table[13];
+
+} STANDARD_HEADER;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ REPEAT_HEADER
+****************************************************************
+Repeated for each column defined header.
+*/
+typedef struct
+{
+ char name[17];
+ char separator_1;
+ char data_type;
+ char separator_2;
+ char number[5];
+ char separator_3;
+ char key_type;
+ char separator_4;
+ char column_description[101];
+ char separator_5;
+ char value_description[13];
+ char separator_6;
+ char thematic_index[13];
+ char separator_7;
+ char separator_8;
+} REPEAT_HEADER;
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ VPF_TABLE
+****************************************************************
+VPF Table Structure (standard header).
+*/
+typedef struct
+{
+ HEADER_SIZE header_size;
+ char separator_1;
+ STANDARD_HEADER standard_header;
+ char separator_2;
+ REPEAT_HEADER repeat_header[34];
+ char separator_3;
+} VPF_TABLE, VPT;
+
+/*
+ * Description:
+ *
+ */
+
+
+
+
+/***************************************************************
+************ FILE STRUCTURES **************************
+***************************************************************/
+
+
+/***************************************************************
+@ DHT
+****************************************************************
+Database Header Table.
+*/
+typedef struct
+{
+ VPT *vpt;
+ int32 id;
+ char vpf_version[11];
+ char database_name[9];
+ char database_desc[101];
+ char media_standard[21];
+ char originator[51];
+ char addressee[101];
+ char media_volumes;
+ char seq_numbers;
+ char num_data_sets;
+ char security_class;
+ char downgrading[4];
+ char downgrade_date[21];
+ char releasability[21];
+ char other_std_name[51];
+ char other_std_date[21];
+ char other_std_ver[11];
+ char transmittal_id;
+ char edition_number[11];
+ char edition_date[21];
+} DHT;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ LAT
+****************************************************************
+Library Attribute Table.
+*/
+typedef struct
+{
+ VPT *vpt;
+ int32 id;
+ char library_name[9];
+ float xmin;
+ float ymin;
+ float xmax;
+ float ymax;
+} LAT;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ LHT
+****************************************************************
+Library Header Table.
+*/
+typedef struct
+{
+ VPT *vpt;
+ int32 id;
+ char product_type[13];
+ char library_name[13];
+ char description[101];
+ char data_struct_code;
+ int32 scale;
+ char source_series[16];
+ char source_id[31];
+ char source_edition[21];
+ char source_name[101];
+ char source_date[21];
+ char security_class;
+ char downgrading[4];
+ char downgrading_date[21];
+ char releasability[21];
+} LHT;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ GRT
+****************************************************************
+Geographic Refernce Table.
+*/
+typedef struct
+{
+ VPT *vpt;
+ int32 id;
+ char data_type[4];
+ char units[4];
+ char ellipsoid_name[16];
+ char ellipsoid_detail[51];
+ char vert_datum_name[16];
+ char vert_datum_code[4];
+ char sound_datum_name[16];
+ char sound_datum_code[4];
+ char geo_datum_name[16];
+ char geo_datum_code[11];
+ char projection_name[21];
+ char projection_code[3];
+ char parameter1[21];
+ char parameter2[21];
+ char parameter3[21];
+ char parameter4[21];
+ char false_origin_x[21];
+ char false_origin_y[21];
+ char false_origin_z[21];
+ char reg_pt[11];
+ char reg_long[16];
+ char reg_lat[16];
+ char reg_z[6];
+ char reg_table_x[16];
+ char reg_table_y[16];
+ char reg_table_z[16];
+ char diag_pt[11];
+ char diag_long[16];
+ char diag_lat[16];
+ char diag_z[6];
+ char diag_table_x[16];
+ char diag_table_y[16];
+ char diag_table_z[16];
+} GRT;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ CAT
+****************************************************************
+Coverage Attribute Table.
+*/
+typedef struct
+{
+ VPT *vpt;
+ int32 id;
+ char coverage_name[9];
+ char description[51];
+ int32 level;
+} CAT;
+
+/*
+ * Description:
+ *
+ */
+
+/**************************************************************************/
+/* DATA STRUCTURES */
+/**************************************************************************/
+
+/***************************************************************
+@ INDEX_DATA
+****************************************************************
+Offset and Length.
+*/
+typedef struct
+{
+ int32 offset;
+ int32 length;
+} INDEX_DATA;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ INDEX
+****************************************************************
+Index for index table.
+*/
+typedef struct
+{
+ int32 nr_records;
+ int32 size;
+ INDEX_DATA **record;
+} IDX, EDX, TXX, ENX;
+
+/*
+ * Description:
+ *
+ */
+
+
+/***************************************************************
+@ FT
+****************************************************************
+Feature Table.
+*/
+typedef struct
+{
+ VPT *vpt;
+ int32 id;
+ short tile_id;
+ int32 table;
+ void *data;
+} FT, LFT, TFT, PFT;
+
+/*
+ * Description:
+ *
+ */
+
+/***************************************************************
+@ END_RECORD
+****************************************************************
+Entity Node Primitive Record (Points).
+*/
+typedef struct
+{
+ int32 id;
+ int32 pft_id;
+ int32 contain_face;
+ char first_edge[2]; /* to be defined as NULL */
+ int32 nr_coordinates; /* Not a VPF specified field */
+ XY_COORDINATE **coordinate;
+} END_RECORD;
+
+/*
+ * Description:
+ *
+ */
+/***************************************************************
+@ END
+****************************************************************
+Entity Node Primitive Table (Points)
+*/
+typedef struct
+{
+ VPT *vpt;
+ int32 nr_records; /* Nat a VPF specified field */
+ END_RECORD **record;
+} END;
+
+/*
+ * Description:
+ *
+ */
+/***************************************************************
+@ EDG_RECORD
+****************************************************************
+Edge Primitive Record (Lines).
+*/
+typedef struct
+{
+ int32 id;
+ int32 lft_id;
+ int32 start_node;
+ int32 end_node;
+ ID_TRIPLET *right_face;
+ ID_TRIPLET *left_face;
+ ID_TRIPLET *right_edge;
+ ID_TRIPLET *left_edge;
+ int32 nr_coordinates; /* Not a VPF specified field */
+ XY_COORDINATE **coordinate;
+} EDG_RECORD;
+
+/*
+ * Description:
+ *
+ */
+/***************************************************************
+@ EDG
+****************************************************************
+Edge Primitive Table (Lines)
+*/
+typedef struct
+{
+ VPT *vpt;
+ int32 nr_records; /* Nat a VPF specified field */
+ EDG_RECORD **record;
+} EDG;
+
+/*
+ * Description:
+ *
+ */
+/***************************************************************
+@ TXT_RECORD
+****************************************************************
+Text Primitive Record.
+*/
+typedef struct
+{
+ int32 id;
+ int32 txt_id;
+ char *string;
+ int32 nr_coordinates; /* Not a VPF specified field */
+ XY_COORDINATE **coordinate;
+} TXT_RECORD;
+
+/*
+ * Description:
+ *
+ */
+/***************************************************************
+@ TXT
+****************************************************************
+Text Primitive Table
+*/
+typedef struct
+{
+ VPT *vpt;
+ int32 nr_records; /* Nat a VPF specified field */
+ TXT_RECORD **record;
+} TXT;
+
+/*
+ * Description:
+ *
+ */
+/**************************************************************************/
+/* TABLE_DATA */
+/**************************************************************************/
+typedef struct
+{
+ int32 offset;
+ int32 size;
+} TABLE_DATA;
+
+/**************************************************************************/
+/* VECTOR */
+/**************************************************************************/
+typedef struct
+{
+ int32 magic;
+ DHT *dht;
+ LAT *lat;
+ CAT *cat;
+ GRT *grt;
+ LHT *lht;
+ EDG *edg;
+ EDX *edx;
+ LFT *lft;
+ TXT *txt;
+ TXX *txx;
+ TFT *tft;
+ ENX *enx;
+ END *end;
+ PFT *pft;
+} VECTOR;
+
+/* VPF table structure: */
+typedef struct
+{
+ char name[13]; /* Table filename */
+ int32 nfields; /* Number of fields */
+ char description[81]; /* Table description */
+ char narrative[13]; /* Table narrative file name */
+ header_type header; /* Table header structure */
+ FILE *fp; /* Table file pointer */
+ FILE *xfp; /* Index table file pointer */
+ IDX *idx; /* Index data */
+ int32 nrows; /* Number of rows in the table */
+ ROW *row; /* Array of table rows */
+ int32 size; /* Size of table in bytes */
+ int32 reclen; /* Table record length (-1 = variable) */
+ int32 ddlen; /* Header length */
+ int32 offset; /* Offset in bytes to start of current table */
+ int32 fpos; /* Location of the filepointer */
+ char *defstr; /* rdf, definition string */
+ file_mode mode; /* Table is either reading or writing */
+ unsigned char status; /* VPF table status - OPENED or CLOSED */
+ unsigned char byte_order; /* Byte order of the table's data */
+} VPFTABLE;
+#endif /* H_VPF */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vpf_f.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vpf_f.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/include/vpf_f.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,100 @@
+#ifndef H_VPF_FUNC
+#define H_VPF_FUNC
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+/* Prototype Definitions */
+
+#if XVT_CC_PROTO
+ID_TRIPLET read_key(VPFTABLE *, BYTE_ORDER *);
+void *get_table_element(int32, ROW, VPFTABLE *, void *, int32 *);
+char *get_string(int32 *, char *, char);
+char get_char(int32 *, char *);
+int32 get_vpf_string(VPFTABLE *, ROW *, int32, char *, int32);
+int32 get_number(int32 *, char *, char);
+int32 parse_header(VPFTABLE *, BYTE_ORDER *);
+ROW get_row(int32, VPFTABLE *, BYTE_ORDER *);
+void free_row(ROW, VPFTABLE *);
+void format_date(VDATE, char *);
+ERRSTATUS open_table(char *, VPFTABLE *, BYTE_ORDER *);
+void close_table(VPFTABLE *);
+void clear_table(VPFTABLE *);
+char *rightjust(char *);
+char *cpy_del(char *, char, int32 *);
+void swap_two(char *, char *);
+void swap_four(char *, char *);
+void swap_eight(char *, char *);
+int32 file_read(void *, VpfDataType, size_t, FILE *, BYTE_ORDER *);
+int32 file_write(void *, VpfDataType, size_t, FILE *, BYTE_ORDER *);
+ERRSTATUS header_read(VPT **, VPFTABLE *, BYTE_ORDER *);
+ERRSTATUS dht_read(VPFTABLE *, DHT **, BYTE_ORDER *);
+ERRSTATUS lat_read(VPFTABLE *, LAT **, BYTE_ORDER *);
+ERRSTATUS cat_read(VPFTABLE *, CAT **, BYTE_ORDER *);
+ERRSTATUS grt_read(VPFTABLE *, GRT **, BYTE_ORDER *);
+ERRSTATUS lht_read(VPFTABLE *, LHT **, BYTE_ORDER *);
+ERRSTATUS idx_read(VPFTABLE *, IDX **, BYTE_ORDER *);
+ERRSTATUS edg_read(VPFTABLE *, EDG **, IDX *, BYTE_ORDER *);
+ERRSTATUS txt_read(VPFTABLE *, TXT **, IDX *, BYTE_ORDER *);
+ERRSTATUS end_read(VPFTABLE *, END **, IDX *, BYTE_ORDER *);
+ERRSTATUS vpf_write(char *, VECTOR *, BYTE_ORDER *);
+ERRSTATUS hdr_write(VPFTABLE *, VPT *, BYTE_ORDER *);
+ERRSTATUS dht_write(VPFTABLE *, DHT *, BYTE_ORDER *);
+ERRSTATUS lat_write(VPFTABLE *, LAT *, BYTE_ORDER *);
+ERRSTATUS lht_write(VPFTABLE *, LHT *, BYTE_ORDER *);
+ERRSTATUS grt_write(VPFTABLE *, GRT *, BYTE_ORDER *);
+ERRSTATUS cat_write(VPFTABLE *, CAT *, BYTE_ORDER *);
+ERRSTATUS idx_write(VPFTABLE *, IDX *, BYTE_ORDER *);
+ERRSTATUS edg_write(VPFTABLE *, EDG *, BYTE_ORDER *);
+ERRSTATUS txt_write(VPFTABLE *, TXT *, BYTE_ORDER *);
+ERRSTATUS end_write(VPFTABLE *, END *, BYTE_ORDER *);
+#else
+ID_TRIPLET read_key();
+ERRSTATUS open_table();
+void close_table();
+void clear_table();
+void *get_table_element();
+char *get_string();
+char get_char();
+int32 get_number();
+int32 get_vpf_string();
+int32 parse_header();
+void free_row();
+void format_date();
+ROW get_row();
+char *rightjust();
+char *cpy_del();
+void swap_two();
+void swap_four();
+void swap_eight();
+int32 file_read();
+int32 file_write();
+ERRSTATUS header_read();
+ERRSTATUS dht_read();
+ERRSTATUS lat_read();
+ERRSTATUS cat_read();
+ERRSTATUS grt_read();
+ERRSTATUS lht_read();
+ERRSTATUS idx_read();
+ERRSTATUS edg_read();
+ERRSTATUS txt_read();
+ERRSTATUS end_read();
+ERRSTATUS vpf_write();
+ERRSTATUS hdr_write();
+ERRSTATUS dht_write();
+ERRSTATUS lat_write();
+ERRSTATUS lht_write();
+ERRSTATUS grt_write();
+ERRSTATUS cat_write();
+ERRSTATUS idx_write();
+ERRSTATUS edg_write();
+ERRSTATUS txt_write();
+ERRSTATUS end_write();
+#endif
+
+#endif /* H_VPF_FUNC */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/linklist.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/linklist.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/linklist.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,814 @@
+
+/*************************************************************************
+ *
+ *N Module LINKLIST.C
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This module contains functions that make up a singly linked list
+ * data structure. It is generic in the sense that it can hold any
+ * type of data, including user-defined types and structures. That
+ * is why you must treat the data element as a void pointer and pass
+ * in its size when inserting into the list. These routines are
+ * assured of working with "non-pointer" types of data elements.
+ * If you try storing other lists, or structures with pointers hanging
+ * off of them, the results will become unpredictable.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * N/A
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ * Dan Maddux Jan. 1994 Windows, Sun & Mac Port
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * linked_list_type ll_init();
+ * int32 ll_empty( linked_list_type list );
+ * position_type ll_first( linked_list_type list );
+ * position_type ll_last( linked_list_type list );
+ * position_type ll_next( position_type position );
+ * position_type ll_previous( position_type position, linked_list_type
+ * list );
+ * int32 ll_end( position_type position );
+ * void ll_element( position_type position, void *element );
+ * void ll_insert( void *element, unsigned size, position_type position );
+ * void ll_delete( position_type position );
+ * void ll_reset( linked_list_type list );
+ * position_type ll_locate( void *element, linked_list_type list );
+ * void ll_replace( void *element, position_type position );
+ *E
+ *************************************************************************/
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+#if 0
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <string.h>
+#endif
+#ifndef __LINKLIST_H__
+#include "linklist.h"
+#endif
+
+/*************************************************************************
+ *
+ *N ll_init
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function allocates and initializes a new linked list structure.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * ll_init <output> == (linked_list_type) initialized head of the list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+linked_list_type ll_init()
+ {
+ linked_list_type list;
+
+ if ((list = (linked_list_type) xvt_malloc( sizeof(cell_type) ))==NULL)
+ {
+ xvt_note ("LL_INIT: Out of memory");
+ exit(1);
+ }
+ list->element = NULL;
+ list->element_size = 0;
+ list->next = NULL;
+ return list;
+ }
+
+/*************************************************************************
+ *
+ *N ll_empty
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function TRUE if the list is empty and FALSE if it is not.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * list <input> == (linked_list_type) linked list being checked.
+ * ll_empty <output> == (int32) boolean function result.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+
+#ifdef PROTO
+int32 ll_empty( linked_list_type list )
+#else
+int32 ll_empty( list )
+linked_list_type list;
+#endif
+{
+ if (list == NULL) return TRUE;
+ if (list->next == NULL)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+
+/*************************************************************************
+ *
+ *N ll_first
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the head of the list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * list <input> == (linked_list_type) linked list.
+ * ll_first <output> == (position_type) head of the list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+position_type ll_first( linked_list_type list )
+#else
+position_type ll_first( list )
+linked_list_type list;
+#endif
+{
+ return ((position_type) list);
+}
+
+
+/*************************************************************************
+ *
+ *N ll_last
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns *THE* last position in the list, which is
+ * not useable. Use ll_previous to get to the last USEABLE link in
+ * the list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * list <input> == (linked_list_type) linked list.
+ * ll_last <output> == (position_type) tail of the list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+position_type ll_last( linked_list_type list )
+#else
+position_type ll_last( list )
+linked_list_type list;
+#endif
+{
+ position_type p;
+
+ p = (position_type) list;
+ while (p->next != NULL)
+ p = p->next;
+ return p;
+}
+
+
+/*************************************************************************
+ *
+ *N ll_next
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the next position in the list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * position <input> == (position_type) current position in the list.
+ * ll_next <output> == (position_type) next position in the list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+position_type ll_next( position_type position )
+#else
+position_type ll_next( position )
+position_type position;
+#endif
+{
+ return(position->next);
+}
+
+
+/*************************************************************************
+ *
+ *N ll_previous
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the previous position in the list. Note:
+ * This is a singly linked list -> no backward pointer -> this
+ * operation is relatively inefficient.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * position <input> == (position_type) current position.
+ * list <input> == (linked_list_type) linked list.
+ * ll_previous <output> == (position_type) previous position in the list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+position_type ll_previous (position_type position, linked_list_type list)
+#else
+position_type ll_previous (position, list)
+position_type position;
+linked_list_type list;
+#endif
+{
+ position_type p;
+
+ if (position==list) return(position);
+ p = list;
+ while (p->next != position)
+ p = p->next;
+ return(p);
+}
+
+
+/*************************************************************************
+ *
+ *N ll_end
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function determines if the given position is at the end of the
+ * list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * position <input> == (position_type) current position in the list.
+ * ll_end <output> == (int32) TRUE -- if position is the end of the list.
+ * FALSE -- if not.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 ll_end (position_type position)
+#else
+int32 ll_end (position)
+position_type position;
+#endif
+{
+ if (position == NULL)
+ return(TRUE);
+ else {
+ if (position->next == NULL)
+ return(TRUE);
+ else
+ return(FALSE);
+ }
+}
+
+
+/*************************************************************************
+ *
+ *N ll_element
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function copies the contents of the element at position
+ * currently being pointed to by "position" into the output data
+ * element.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * position <input> == (position_type) position in the list.
+ * element <output> == (void *) pointer to the element data.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void ll_element (position_type position, void *element)
+#else
+void ll_element (position, element)
+position_type position;
+void *element;
+#endif
+ {
+ memcpy (element, position->next->element, position->next->element_size);
+ return;
+ }
+
+
+/*************************************************************************
+ *
+ *N ll_element_size
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the size of the contents of the element at
+ * position currently being pointed to by "position".
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * position <input> == (position_type) position in the list.
+ * size <output> == (size_t) size in byte of the current element.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dan Maddux May 1993
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+size_t ll_element_size (position_type position)
+#else
+size_t ll_element_size (position)
+position_type position;
+#endif
+ {
+ return (position->next->element_size);
+ }
+
+
+
+/*************************************************************************
+ *
+ *N ll_insert
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function inserts a new cell into the list at position that will
+ * contain the data pointed to by element.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * element <input> == (void *) pointer to the data element to insert.
+ * size <input> == (size_t) size of the data element.
+ * position <input> == (position_type) position to insert the new cell.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void ll_insert (void *element, size_t size, position_type position)
+#else
+void ll_insert (element, size, position)
+void *element;
+size_t size;
+position_type position;
+#endif
+
+ {
+ position_type temp;
+
+ if ((temp = (position_type)xvt_malloc (sizeof(cell_type))) == NULL)
+ {
+ xvt_note ("LL_INSERT: out of memory");
+ abort();
+ }
+ temp->next = position->next;
+ position->next = temp;
+ temp->element_size = size;
+ if ((temp->element = xvt_malloc (size)) == NULL)
+ {
+ xvt_note ("LL_INSERT: out of memory");
+ abort();
+ }
+ memcpy (temp->element, element, size);
+ return;
+ }
+
+
+/*************************************************************************
+ *
+ *N ll_delete
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function deletes and disposes of a cell from the linked list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * position <input> == (position_type) position in the list to delete.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void ll_delete( position_type position )
+#else
+void ll_delete( position )
+position_type position;
+#endif
+{
+ position_type p;
+
+ if (position != NULL) { /* Cut the element out of the chain */
+ p = position->next;
+ position->next = p->next;
+ xvt_free( p->element );
+ xvt_free ((char*)p);
+ }
+}
+
+
+
+
+/*************************************************************************
+ *
+ *N ll_reset
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function empties out a linked list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * list <inout> == (linked_list_type) linked list to be emptied.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void ll_delete( position_type position );
+ * int32 ll_empty( linked_list_type list );
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void ll_reset (linked_list_type list)
+#else
+void ll_reset ( list )
+linked_list_type list;
+#endif
+ {
+ while (! ll_empty(list))
+ ll_delete(ll_first(list));
+ xvt_free ((char*)list);
+ list = NULL;
+ }
+
+
+
+/*************************************************************************
+ *
+ *N ll_locate
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function locates a position in the list by comparing data.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * element <input> == (void *) pointer to the data element to locate.
+ * list <input> == (linked_list_type) linked list.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+position_type ll_locate( void *element, linked_list_type list )
+#else
+position_type ll_locate( element, list )
+void *element;
+linked_list_type list;
+#endif
+{
+ position_type p;
+
+ p = list;
+ while (p->next != NULL) {
+ if ( memcmp(p->next->element,element,p->next->element_size) == 0 )
+ return p;
+ else
+ p = p->next;
+ }
+ return NULL;
+}
+
+
+/*************************************************************************
+ *
+ *N ll_replace
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function replaces an element in the linked list at the given
+ * position. WARNING: The new data element must be the same size as
+ * the previous data element or you will get some rather INTERESTING
+ * results.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * element <input> == (void *) data element to replace existing data.
+ * position <input> == (position_type) position in the list to replace
+ * the data.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Feb. 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void ll_replace (void *element, position_type position)
+#else
+void ll_replace (element, position)
+void *element;
+position_type position;
+#endif
+ {
+ memcpy (position->next->element, element, position->next->element_size);
+ }
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/linklist.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/linklist.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/linklist.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,74 @@
+/* ====================================================================
+
+ Environmental Systems Research Institute (ESRI) Applications Programming
+
+ Project: Conversion from ARC/INFO to VPF
+ Original Coding: Tom Wood Fall 1990
+ Modifications: David Flinn February 1991
+
+ ================================================================== */
+
+#ifndef __LINKLIST_H__
+#define __LINKLIST_H__
+
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+typedef struct linked_list_cell
+ {
+ void *element;
+ size_t element_size;
+ struct linked_list_cell *next;
+ } cell_type, *linked_list_type, *position_type;
+
+
+#define LL_FIRST(list) (position_type)list
+
+#define LL_NEXT(position) position->next
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+#ifdef PROTO
+ linked_list_type ll_init(void);
+ position_type ll_locate (void *element, linked_list_type list);
+ position_type ll_first (linked_list_type list );
+ position_type ll_last (linked_list_type list );
+ position_type ll_next (position_type position );
+ position_type ll_previous (position_type position, linked_list_type list);
+ int32 ll_empty (linked_list_type list );
+ int32 ll_end (position_type position );
+ void ll_element (position_type position, void *element);
+ void ll_insert (void *element, size_t size, position_type position);
+ void ll_delete (position_type position );
+ void ll_reset (linked_list_type list );
+ void ll_replace (void *element, position_type position);
+ size_t ll_element_size (position_type position);
+#else
+ linked_list_type ll_init ();
+ int32 ll_empty ();
+ position_type ll_first ();
+ position_type ll_last ();
+ position_type ll_next ();
+ position_type ll_previous ();
+ int32 ll_end ();
+ void ll_element ();
+ void ll_insert ();
+ void ll_delete ();
+ void ll_reset ();
+ position_type ll_locate ();
+ void ll_replace ();
+ size_t ll_element_size ();
+
+#endif
+
+#endif /* ifdef __LINKLIST_H__ */
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/makefile
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/makefile 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/makefile 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 1997 Logiciels et Applications Scientifiques (L.A.S.) Inc.
+# Il est strictement interdit de publier ou de devoiler le contenu de ce
+# programme sans avoir prealablement obtenu la permission de L.A.S. Inc.
+# It is strictly forbidden to publish or divulge the content of
+# these programs without the prior permission of L.A.S. Inc.
+#
+
+TOBEGEN = vpf
+TARGETGEN=$(ARCHGEN)
+
+SOURCES = vpfselec.c \
+ vpftidx.c \
+ vpfwrite.c \
+ vpftable.c \
+ vpfrelat.c \
+ vpfprim.c \
+ vpfquery.c \
+ get_feat.c \
+ vpfdproj.c \
+ coorgeom.c \
+ vpfspx.c \
+ set.c \
+ linklist.c \
+ reduce2.c \
+ vpfread.c \
+ vpfprop.c \
+ strfunc.c \
+ musedir.c
+
+INCLUDES = $(CURRENT_INCLUDE) $(GENERAL_INCLUDE) $(VPF_INCLUDE)
+
+CFLAGS = $(INCLUDES) $(COMMON_CFLAGS) $(UNIX_DEFINE) \
+ -DSYS_BIG_ENDIAN=$(BIG_ENDIAN)
+
+include $(TOPDIR)/config/common.mak
+
+all: MKOBJECTDIR
+ $(MAKE) --directory $(OBJDIR) -f ../makefile PASS='depend' $(TARGETGEN)
+
+clean: default-clean
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/musedir.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/musedir.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/musedir.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,457 @@
+/*
+ * MUSEDIR.C- a set of directory and file utilities implemented over XVT
+ * functions. These functions could also be implemented over a specific
+ * operating system to wean from XVT.
+ *
+ * This file contains the following functions: dir_create dir_current dir_pop
+ * dir_push dir_restore dir_save file_open file_spec_to_string muse_access
+ * muse_filelength muse_check_path
+ */
+
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+#ifdef unix
+/* #include "direct.h" */
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#include "machine.h"
+
+#include "musedir.h"
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifdef _MSDOS
+#include "io.h"
+#endif
+
+#ifdef _WINDOWS
+#include <stdio.h>
+#include <io.h>
+#endif
+
+#include <ctype.h>
+
+
+/**************************************************************************/
+/* FILE_OPEN */
+/**************************************************************************/
+
+
+
+#if XVT_CC_PROTO
+FILE *
+muse_file_open(char *path, char *mode)
+#else
+FILE *
+muse_file_open(path, mode)
+ char *path;
+ char *mode;
+#endif
+
+{
+ FILE *file;
+ char pathext[SZ_FNAME];
+ char lobuf[SZ_FNAME];
+ char upbuf[SZ_FNAME];
+ int i, len;
+ BOOLEAN DOT_FOUND = 0;
+ int32 lenup;
+ char *s;
+
+ strcpy(pathext, path);
+ muse_check_path(pathext);
+
+#ifdef _WINDOWS
+ file = fopen(pathext, mode);
+ return (file);
+#endif
+
+#ifdef unix
+ memset(lobuf, (char) NULL, SZ_FNAME);
+ memset(upbuf, (char) NULL, SZ_FNAME);
+ len = strlen(pathext);
+ strcpy(upbuf, pathext);
+ strcpy(lobuf, pathext);
+
+ for (i = len-1; i >= 0; i--)
+ {
+ if (pathext[i] == '.')
+ {
+ DOT_FOUND = TRUE;
+ }
+ if (pathext[i] == (int) FILE_SEP)
+ break;
+ }
+#if 0
+ for (i = len - 1; (i >= 0 && pathext[i] != (int) FILE_SEP); i--)
+ {
+ upbuf[i] = toupper(pathext[i]);
+ lobuf[i] = tolower(pathext[i]);
+ }
+#endif
+ s = strchr(&pathext[1],'/');
+ if (s != (char *)NULL)
+ lenup = strlen(s);
+ else
+ lenup = len;
+ for (i = len - lenup; i < len; i++)
+ {
+ upbuf[i] = toupper(pathext[i]);
+ lobuf[i] = tolower(pathext[i]);
+ }
+
+ if ((file = fopen(pathext, mode)) == (FILE *) NULL)
+ {
+
+ if (!DOT_FOUND)
+ strcat(pathext, ".");
+ if ((file = fopen(pathext, mode)) == (FILE *) NULL)
+ {
+ strcat(pathext, ";1");
+ file = fopen(pathext, mode);
+ }
+ }
+ if (file == (FILE *) NULL)
+ {
+ if ((file = fopen(lobuf, mode)) == (FILE *) NULL)
+ {
+
+ if (!DOT_FOUND)
+ strcat(lobuf, ".");
+ if ((file = fopen(lobuf, mode)) == (FILE *) NULL)
+ {
+ strcat(lobuf, ";1");
+ file = fopen(lobuf, mode);
+ }
+ }
+ }
+ if (file == (FILE *) NULL)
+ {
+ if ((file = fopen(upbuf, mode)) == (FILE *) NULL)
+ {
+
+ if (!DOT_FOUND)
+ strcat(upbuf, ".");
+ if ((file = fopen(upbuf, mode)) == (FILE *) NULL)
+ {
+ strcat(upbuf, ";1");
+ file = fopen(upbuf, mode);
+ }
+ }
+ }
+
+ return (file);
+#endif
+
+/*
+#ifdef _MAC
+ if ((file = fopen(pathext, mode)) == (FILE *) NULL)
+ {
+
+ if (strchr(pathext, '.') == NULL)
+ strcat(pathext, ".");
+ strcat(pathext, ";1");
+ file = fopen(pathext, mode);
+ }
+ return (file);
+#endif
+*/
+}
+
+
+
+/**************************************************************************/
+/* FIL_OPEN */
+/**************************************************************************/
+
+/*
+
+#if XVT_CC_PROTO
+int
+fil_open(char *path, int mode)
+#else
+int
+fil_open(path, mode)
+ char *path;
+ int mode;
+#endif
+
+{
+ int file;
+ char pathext[SZ_FNAME];
+ char lobuf[SZ_FNAME];
+ char upbuf[SZ_FNAME];
+ int i, len;
+ BOOLEAN DOT_FOUND = 0;
+ int32 lenup;
+ char *s;
+
+ strcpy(pathext, path);
+
+#ifdef _WINDOWS
+ file = open(pathext, mode);
+ return (file);
+#endif
+
+#ifdef unix
+ memset(lobuf, (char) NULL, SZ_FNAME);
+ memset(upbuf, (char) NULL, SZ_FNAME);
+ len = strlen(pathext);
+ strcpy(upbuf, pathext);
+ strcpy(lobuf, pathext);
+
+ for (i = len-1; i >= 0; i--)
+ {
+ if (pathext[i] == '.')
+ {
+ DOT_FOUND = TRUE;
+ }
+ if (pathext[i] == (int) FILE_SEP)
+ break;
+ }
+#if 0
+ for (i = len - 1; (i >= 0 && pathext[i] != (int) FILE_SEP); i--)
+ {
+ upbuf[i] = toupper(pathext[i]);
+ lobuf[i] = tolower(pathext[i]);
+ }
+#endif
+ s = strchr(&pathext[1],'/');
+ if (s != (char *)NULL)
+ lenup = strlen(s);
+ else
+ lenup = len;
+ for (i = len - lenup; i < len; i++)
+ {
+ upbuf[i] = toupper(pathext[i]);
+ lobuf[i] = tolower(pathext[i]);
+ }
+
+ if ((file = open(pathext, mode)) < 0)
+ {
+
+ if (!DOT_FOUND)
+ strcat(pathext, ".");
+ if ((file = open(pathext, mode)) < 0)
+ {
+ strcat(pathext, ";1");
+ file = open(pathext, mode);
+ }
+ }
+ if (file < 0)
+ {
+ if ((file = open(lobuf, mode)) < 0)
+ {
+
+ if (!DOT_FOUND)
+ strcat(lobuf, ".");
+ if ((file = open(lobuf, mode)) < 0)
+ {
+ strcat(lobuf, ";1");
+ file = open(lobuf, mode);
+ }
+ }
+ }
+ if (file < 0)
+ {
+ if ((file = open(upbuf, mode)) < 0)
+ {
+
+ if (!DOT_FOUND)
+ strcat(upbuf, ".");
+ if ((file = open(upbuf, mode)) < 0)
+ {
+ strcat(upbuf, ";1");
+ file = open(upbuf, mode);
+ }
+ }
+ }
+ return (file);
+#endif
+
+}
+
+*/
+
+/**************************************************************************/
+/* MUSE_ACCESS */
+/**************************************************************************/
+
+
+
+#if XVT_CC_PROTO
+int
+muse_access(char *path, int amode)
+#else
+int
+muse_access(path, amode)
+ char *path;
+ int amode;
+#endif
+
+{
+
+ char pathext[SZ_FNAME];
+ int acc;
+ char lobuf[SZ_FNAME];
+ char upbuf[SZ_FNAME];
+ int i, len;
+ BOOLEAN DOT_FOUND = 0;
+ int32 lenup;
+ char *s;
+
+ strcpy(pathext, path);
+
+#ifdef _WINDOWS
+ acc = _access(pathext, amode);
+ return (acc);
+#endif
+
+#ifdef unix
+ memset(lobuf, (char) NULL, SZ_FNAME);
+ memset(upbuf, (char) NULL, SZ_FNAME);
+ len = strlen(pathext);
+ strcpy(upbuf, pathext);
+ strcpy(lobuf, pathext);
+
+ for (i = len-1; i >= 0; i--)
+ {
+ if (pathext[i] == '.')
+ {
+ DOT_FOUND = TRUE;
+ }
+ if (pathext[i] == (int) FILE_SEP)
+ break;
+ }
+#if 0
+ for (i = len - 1; (i >= 0 && pathext[i] != (int) FILE_SEP); i--)
+ {
+ upbuf[i] = toupper(pathext[i]);
+ lobuf[i] = tolower(pathext[i]);
+ }
+#endif
+ s = strchr(&pathext[1],'/');
+ if (s != (char *)NULL)
+ lenup = strlen(s);
+ else
+ lenup = len;
+ for (i = len - lenup; i < len; i++)
+ {
+ upbuf[i] = toupper(pathext[i]);
+ lobuf[i] = tolower(pathext[i]);
+ }
+
+ if ((acc = access(pathext, amode)) == -1)
+ {
+
+ if (!DOT_FOUND)
+ strcat(pathext, ".");
+ if ((acc = access(pathext, amode)) == -1)
+ {
+ strcat(pathext, ";1");
+ acc = access(pathext, amode);
+ }
+ }
+ if (acc == -1)
+ {
+ if ((acc = access(lobuf, amode)) == -1)
+ {
+
+ if (!DOT_FOUND)
+ strcat(lobuf, ".");
+ if ((acc = access(lobuf, amode)) == -1)
+ {
+ strcat(lobuf, ";1");
+ acc = access(lobuf, amode);
+ }
+ }
+ }
+ if (acc == -1)
+ {
+ if ((acc = access(upbuf, amode)) == -1)
+ {
+
+ if (!DOT_FOUND)
+ strcat(upbuf, ".");
+ if ((acc = access(upbuf, amode)) == -1)
+ {
+ strcat(upbuf, ";1");
+ acc = access(upbuf, amode);
+ }
+ }
+ }
+ return (acc);
+#endif
+
+}
+
+
+
+/**************************************************************************/
+/* MUSE_FILELENGTH */
+/**************************************************************************/
+
+
+
+#if XVT_CC_PROTO
+int32
+muse_filelength(char *path)
+#else
+int32
+muse_filelength(path)
+ char *path;
+#endif
+
+{
+
+#ifdef unix
+ struct stat buf;
+#endif
+
+ FILE *file;
+ int32 length;
+
+ length = 0;
+ file = muse_file_open(path, "rb");
+ if (file != NULL) {
+#ifdef _WINDOWS
+ length = _filelength(fileno(file));
+#else
+ if (fstat(fileno(file),&buf) == 0) {
+ length = (int32) buf.st_size;
+ } else {
+ length = 0;
+ }
+#endif
+ fclose(file);
+ }
+ return (length);
+}
+
+
+
+/************************************************************************/
+/* MUSE_CHECK_PATH */
+/************************************************************************/
+
+void
+muse_check_path(path)
+ char *path;
+{
+ int32 i, length;
+
+ length = strlen(path);
+
+ for (i = 0; i < length; i++)
+ if (path[i] == '\\')
+ path[i] = FILE_SEP;
+ return;
+}
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/musedir.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/musedir.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/musedir.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,87 @@
+/* MUSEDIR.H */
+#ifndef H_MUSEDIR
+#define H_MUSEDIR
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+#ifdef _MACHINE_
+#include "machine.h"
+#endif
+#ifdef _UNIX
+#include <unistd.h>
+#endif
+
+#ifndef _WINDOWS
+#ifdef _MAC
+#define FILE_SEP ':'
+#define FILE_EXT1 ""
+#define FILE_EXT2 ""
+#endif
+
+#ifdef _MSDOS
+#define FILE_SEP '\\'
+#define FILE_EXT1 ""
+#define FILE_EXT2 ""
+#endif
+
+#ifdef _UNIX
+#define FILE_SEP '/'
+#define FILE_EXT1 ""
+#define FILE_EXT2 ""
+#endif
+#if XVT_OS == XVT_OS_HPUX
+#define FILE_SEP '/'
+#endif
+#else
+#define FILE_SEP '\\'
+#define FILE_EXT1 ""
+#define FILE_EXT2 ""
+#endif
+
+#define ERRSTATUS short
+
+#ifndef STAT_SUCCESS
+#define STAT_SUCCESS 0
+#endif
+
+#if PROTO
+ERRSTATUS dir_create (char*);
+ERRSTATUS dir_pop(char *);
+ERRSTATUS dir_push(char *, char *);
+ERRSTATUS dir_restore (char *);
+ERRSTATUS dir_save(char *);
+ERRSTATUS dir_current(char *);
+/* ERRSTATUS file_spec_to_string (FILE_SPEC *, char *);*/
+FILE *muse_file_open (char*, char*);
+int muse_access (char *, int);
+int32 muse_filelength (char *);
+void muse_check_path (char*);
+#else
+ERRSTATUS dir_create ();
+ERRSTATUS dir_pop();
+ERRSTATUS dir_push();
+ERRSTATUS dir_restore ();
+ERRSTATUS dir_save();
+ERRSTATUS dir_current();
+ERRSTATUS file_spec_to_string ();
+FILE *muse_file_open ();
+int muse_access ();
+#ifdef _ALPHA
+int32_t muse_filelength ();
+#else
+int32_t muse_filelength ();
+#endif
+void muse_check_path ();
+#endif
+
+
+#endif /* H_MUSEDIR */
+
+
+
+
+
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/reduce2.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/reduce2.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/reduce2.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,802 @@
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+#include <math.h>
+#if 0
+#include <stdio.h>
+#include <malloc.h>
+#endif
+#include "machine.h"
+#ifndef THIN_DIG_H
+#include "reduce2.h"
+#endif
+
+//#define MAX(m,n) (((m) > (n)) ? (m) : (n))
+//#define MIN(m,n) (((m) < (n)) ? (m) : (n))
+#define DOCNT(i,t,n) (_d_l=n, (_d_m=(t-(i)+_d_l)/_d_l) > 0 ? _d_m : 0L )
+
+/* General purpose tools for polyline reduction:
+ Reduca - Closed polygon reduction which preserves small shapes.
+ Reduc1 - Preprocessor to set up reduction parameters.
+ Reduc2 - Douglas Peuker reduction.
+ Xcheck - Post processing check/repair to preserve topology.
+ Plnint - Detects intersection of polylines.
+
+
+-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*-*-
+ UNIT NAME: REDUCA
+
+ FUNCTIONAL DESCRIPTION: Customizes Douglas-Peuker polygon reduction by
+ changing resolution tolerance as required to
+ prevent small areas from degenerating.
+
+ INPUT FILES/PARAMETERS: in, nin - polyline of length nin
+ relem - Resolution element length
+ CHGMAX - Limit % area change for polygons.
+ merc - Mercator compensation for world map
+
+ OUTPUT FILES/PARAMETERS: out, nout - reduced polyline
+
+ SUBROUTINES CALLED: Reduc1 - For polyline reduction
+
+ PROGRAMMER: DATE OF LAST CHANGE REASON FOR CHANGE
+ Tom Wescott NOSC April 92 Original entry
+ Jim Bellenger SC/WGEA Dec 92 Cleaned up the FORTRAN
+ conversion
+
+-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*- */
+
+#define CHGMAX 0.2E0
+
+#if XVT_CC_PROTO
+void Reduca (COORDS *in, int32 *nin, COORDS *out, int32 *nout,
+ double *relem, int32 *merc)
+#else
+void Reduca (in, nin, out, nout, relem, merc)
+COORDS *in;
+int32 *nin;
+COORDS *out;
+int32 *nout;
+double *relem;
+int32 *merc;
+#endif
+ {
+ int32 i, j;
+ double ain, aout, change, toler;
+ double x1, x2, y1, y2;
+ void Reduc1();
+
+ toler = *relem;
+
+ /* Calculate area of input polygon. */
+
+ ain = 0.E0;
+
+ if ( (in[0].x == in[*nin - 1].x) && (in[0].y == in[*nin - 1].y) )
+ {
+ for (i=0; i < *nin; i++ )
+ {
+ j = i + 1;
+ if( j == *nin )
+ j = 0;
+ x1 = in[i].x;
+ x2 = in[j].x;
+ y1 = in[i].y;
+ y2 = in[j].y;
+ ain = ain + 0.5E0*(x1*y2 - y1*x2);
+ }
+ }
+ else
+ {
+ /* Leave ain = 0.0 to fully reduce all unclosed polylines. */
+ }
+
+ /* Do Until (% change under CHGMAX) */
+
+ do
+ {
+
+ /* Reduce the polygon. */
+
+ Reduc1( in, nin, out, nout, &toler, merc );
+
+ /* Check for drastic change in area. */
+
+ if (ain == 0.0 )
+ change = 0.0;
+ else
+ {
+ /* Calculate area of reduced polygon. */
+
+ aout = 0.0;
+ for (i=0; i < *nout; i++)
+ {
+ j = i + 1;
+ if (j == *nout )
+ j = 0;
+ x1 = out[i].x;
+ x2 = out[j].x;
+ y1 = out[i].y;
+ y2 = out[j].y;
+ aout = aout + 0.5E0*(x1*y2 - y1*x2);
+ }
+ change = fabs( (aout - ain)/ain );
+ }
+
+ /* Decrease the tolerance. if change too small */
+
+ if ( change > CHGMAX )
+ toler = toler*.707E0;
+
+ } while (change > CHGMAX); /* End do */
+
+ return;
+
+ } /* end of function */
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*-
+ UNIT NAME: REDUC1
+
+ FUNCTIONAL DESCRIPTION: Customizes Douglas-Peuker polyline reduction by
+ breaking int32 input polylines, and defining the
+ coordinate system used.
+
+ INPUT FILES/PARAMETERS: in, nin - Polyline of length nin
+ relem - Resolution element length
+ merc - Mercator compensation if not 0.
+ DLIMIT - Prohibits long output segments
+ from reducing to two points.
+
+ OUTPUT FILES/PARAMETERS: out, nout - Reduced polyline
+
+ SUBROUTINES CALLED: Reduc2 - Actual D-P reduction.
+
+ PROGRAMMER: DATE OF LAST CHANGE REASON FOR CHANGE
+ Tom Wescott NOSC March 90 Original entry
+ Jim Bellenger SC/WGEA Dec 92 Cleaned up the FORTRAN
+ conversion
+
+-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*-*/
+#if XVT_CC_PROTO
+void Reduc1 (COORDS *in, int32 *nin, COORDS *out, int32 *nout,
+ double *relem, int32 *merc)
+#else
+void Reduc1 (in, nin, out, nout, relem, merc)
+COORDS *in;
+int32 *nin;
+COORDS *out;
+int32 *nout;
+double *relem;
+int32 *merc;
+#endif
+ {
+ int32 i, iend, j, k, llsph, ng, nlimit;
+ double coslat, dlimit, dmax, toler, xmax, xmin, ymax, ymin;
+ void Reduc2();
+
+ /* Limit processing group verticies to speed (n-squared) execution. */
+
+ nlimit = 1000;
+
+ /* Limit processing group span to avoid excessively long output segments. */
+
+ dlimit = 30.E0*(*relem);
+
+ j = 0;
+ iend = 0;
+
+ /* Break long polylines into groups with ends (i,iend) and length (ng).
+ While (input not exhausted) do */
+
+ do
+ {
+
+ /* SET UP PROCESSING GROUP */
+
+ toler = *relem;
+
+ /* Set first point in group back to the last input point we want to keep. */
+
+ i = iend;
+ ng = 0;
+ xmin = in[i].x;
+ xmax = in[i].x;
+ ymin = in[i].y;
+ ymax = in[i].y;
+ dmax = 0.0;
+ for (k=i; k < *nin; k++)
+ {
+ xmin = MIN( xmin, in[k].x );
+ xmax = MAX( xmax, in[k].x );
+ ymin = MIN( ymin, in[k].y );
+ ymax = MAX( ymax, in[k].y );
+ dmax = MAX( xmax - xmin, ymax - ymin );
+ if ( (ng >= 2) && ((dmax > dlimit) || (ng >= nlimit)) )
+ {
+ /* Process group without including this point. */
+ break;
+ }
+ else
+ {
+ /* Update last point in group to pt. k */
+ ng = ng + 1;
+ iend = k;
+ }
+ }
+
+ /* Do a Douglas-Peuker reduction. */
+
+ if ( *merc != 0 )
+ {
+ /* SET MERCATOR COMPENSATION: For low resolution output only...
+ If Reduced resolution versions are to be used to draw mercator
+ or similar world maps, modifying toler to decrease with latitude
+ provides uniform display resolution. Storage penalty is slight.
+ */
+ coslat = MAX( cos( in[i].y ), 0.1E0 );
+ toler = toler*coslat;
+ /* Use Plane Geometry for the reduction. */
+ llsph = 0;
+ }
+ else
+ {
+ /* Use Spherical Geometry for the reduction. */
+ llsph = 1;
+ }
+
+ Reduc2 (&in[i], &ng, &out[j], nout,
+ &toler, &llsph );
+
+ /* Insure first point survives after possible degenerate first group. */
+
+ if ( j == 0 )
+ {
+ out[0].x = in[0].x;
+ out[0].y = in[0].y;
+ }
+
+ j = j + *nout - 1;
+ *nout = j;
+
+ } while ( iend < *nin-1 ); /* End while. */
+
+ /* Insure last point survives after possible degenerate final group. */
+
+ if ( (in[*nin - 1].x != out[*nout - 1].x) ||
+ (in[*nin - 1].y != out[*nout - 1].y) )
+ {
+ *nout = *nout + 1;
+ out[*nout - 1].x = in[*nin - 1].x;
+ out[*nout - 1].y = in[*nin - 1].y;
+ }
+
+ /* POST PROCESSING QC:
+ Prohibit short line segments from degenerating to single points. */
+
+ if ( (*nout == 1) && ((in[0].x != in[*nin - 1].x) ||
+ (in[0].y != in[*nin - 1].y)) )
+ {
+ *nout = 2;
+ out[*nout - 1].x = in[*nin - 1].x;
+ out[*nout - 1].y = in[*nin - 1].y;
+ }
+
+ return;
+ } /* end of function */
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*-*
+ UNIT NAME: REDUC2
+
+ FUNCTIONAL DESCRIPTION: DOUGLAS-PEUKER POLYLINE REDUCTION
+ Reduces the number of verticies in a polyline
+ by deleting those producing no effect below a
+ specified resolution or tolerance.
+
+ INPUT FILES/PARAMETERS: xin,yin,nin - Polyline of length nin.
+ toler - Resolution element length, same units
+ lldeg - Coordinate system to be used.
+ = 1 Units must be in decimal degrees.
+ Spherical trig approximated.
+ <>1 Any units, plane geometry used.
+
+ OUTPUT FILES/PARAMETERS: xout,yout,nout - reduced polyline
+
+ SUBROUTINES CALLED: none.
+
+ REFERENCE: Douglas & Peucker, Canadian Cartographer 1973
+
+ PROGRAMMER: DATE OF LAST CHANGE REASON FOR CHANGE
+ Tom Wescott NOSC March 90 Original entry
+ Jim Bellenger SC/WGEA Dec 92 Cleaned up the FORTRAN
+ conversion
+ Dan Maddux SC/WGEA 15 Apr 93 Dynamic allocation
+
+-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*-*/
+#define MXVRT 10000
+
+#if XVT_CC_PROTO
+void Reduc2 (COORDS *in, int32 *nin, COORDS *out, int32 *nout,
+ double *toler, int32 *lldeg)
+#else
+void Reduc2 (in, nin, out, nout, toler, lldeg)
+COORDS *in;
+int32 *nin;
+COORDS *out;
+int32 *nout;
+double *toler;
+int32 *lldeg;
+#endif
+ {
+ int32 aptr, fptr, maxptr, stkptr, tptr, *stack;
+ double coslat, rlat;
+ double a, b, cterm, dist2, len2, maxd2, numerator, toler2, xa, xf,
+ xt, ya, yf, yt;
+ double pi=4.E0/atan(1.E0);
+
+ /* Allocate stack */
+ stack = (int32*)xvt_malloc (MXVRT * sizeof (int32));
+
+ /* Initialize the pointers for the anchor,tester and float pts. */
+
+ *nout = 0;
+ aptr = 0;
+ fptr = *nin - 1;
+ stkptr = 0;
+ maxptr = 0;
+ toler2 = *toler**toler;
+ if ( *lldeg == 1 )
+ {
+ /* Set an abcissa multiplier to approximate meridian convergence. */
+ rlat = in[0].y *pi/180.E0;
+ coslat = cos( rlat );
+ }
+ else
+ {
+ /* Set a constant multiplier to calculate distances in Plane Geometry. */
+ coslat = 1.E0;
+ }
+
+ /* While (line not finished) do */
+
+ while (1)
+ {
+
+ /* Set the anchor and float points. */
+
+ xa = in[aptr].x *coslat;
+ ya = in[aptr].y;
+ xf = in[fptr].x *coslat;
+ yf = in[fptr].y;
+
+ /* Calculate constant constant values associated with line
+ segment AF (components, length squared, & cross term.) */
+
+ a = xf - xa;
+ b = yf - ya;
+ len2 = a*a + b*b;
+ cterm = yf*xa - ya*xf;
+
+ /* Identify the intermediate point furthest from line segment AF. */
+
+ maxd2 = 0.E0;
+ for (tptr=aptr+1; tptr < fptr-1; tptr++ )
+ {
+ /* get a test point */
+
+ xt = in[tptr].x *coslat;
+ yt = in[tptr].y;
+
+ /* Calculate distance squared perpendicular to line segment AF. */
+
+ if ( (a != 0.E0) || (b != 0.E0) )
+ {
+ numerator = yt*a - xt*b + cterm;
+ dist2 = numerator*numerator/len2;
+ }
+ else
+ {
+ dist2 = (xt - xa)*(xt - xa) + (yt - ya)*(yt - ya);
+ }
+
+ if ( dist2 > maxd2 )
+ {
+ maxptr = tptr;
+ maxd2 = dist2;
+ }
+ }
+
+ if ( maxd2 > toler2 )
+ {
+ /* The tolerance has been exceeded, push this floater onto the
+ stack, and reset float point to the max distance point. */
+ stkptr = stkptr + 1;
+ if ( stkptr > MXVRT )
+ {
+ xvt_note ("Reduc2: stack blew up" );
+ }
+ stack[stkptr-1] = fptr;
+ fptr = maxptr;
+ }
+ else
+ {
+ /* The tolerance has been met. Output the current anchor point. */
+
+ *nout = *nout + 1;
+ out[*nout - 1].x = in[aptr].x;
+ out[*nout - 1].y = in[aptr].y;
+
+ if ( stkptr == 0 )
+ {
+ /* Output the final float point and exit. */
+ if ( (*nout > 1) || ((pow(in[0].x - in[fptr].x, 2.E0) +
+ pow(in[0].y - in[fptr].y, 2.E0)) > toler2) )
+ {
+ *nout = *nout + 1;
+ out[*nout - 1].x = in[fptr].x;
+ out[*nout - 1].y = in[fptr].y;
+ }
+ /* Free the stack */
+ if (stack)
+ xvt_free ((char*)stack);
+ return;
+ }
+
+ else
+ {
+ /* Change the current float point into the new anchor point. */
+ aptr = fptr;
+ /* Pop the stack to get the next floater. */
+ fptr = stack[stkptr-1];
+ stkptr = stkptr - 1;
+ }
+ }
+
+ } /* End while */
+
+} /* end of function */
+
+#if 0
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*-*
+ UNIT NAME: Xcheck
+
+ FUNCTIONAL DESCRIPTION: Post processing QC/Repair for polyline reduction.
+ Takes precaution against creating a self or mutual
+ crossing condition in the output polyline(s).
+ Plane geometry is used to detect intersections. !?
+ Repair is done by replacing as many points from
+ original polyline as reqd to eliminate crossings.
+
+ INPUT FILES/PARAMETERS: xr,yr,nr - Reduced polyline.
+ xo,yo,no - Original unreduced version of xr,yr
+ xc,yc,nc - Polyline to be checked for crossings.
+ (may be a copy of xr,yr)
+
+ OUTPUT FILES/PARAMETERS: xr,yr,nr - Reduced polyline (crossings removed)
+ ierror - Reports a failed correction.
+ (may have had crossing in original)
+
+ SUBROUTINES CALLED: plnint - Counts line-polyline intersections.
+
+ PROGRAMMER: DATE OF LAST CHANGE REASON FOR CHANGE
+ Tom Wescott NOSC March 92 Original entry
+ Jim Bellenger SC/WGEA Dec 92 Cleaned up the FORTRAN
+ conversion
+
+-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*-*/
+#define BIG 1.0E99
+
+void Xcheck(int32 *idr,
+ double *xr, double *yr, int32 *nr,
+ double *xo, double *yo, int32 *no,
+ int32 *idc,
+ double *xc, double *yc, int32 *nc,
+ int32 *ierror)
+{
+
+ int32 i, j, k, iend, istep,
+ istr, ivrt, lcross, len, line, loop,
+ lstart, m, maxints, maxlin, n, ncross, ndelet, nints, nreplc;
+ int32 _d_l, _d_m, _do4, _do5;
+ double tx[MXVRT], ty[MXVRT], x1, x2, xcmax, xcmin, xmax, xmin, xrmax,
+ xrmin, y1, y2, ycmax, ycmin, ymax, ymin, yrmax, yrmin;
+ void Plnint();
+ char string[256];
+
+ *ierror = 0;
+ loop = 0;
+ if ( (*nr >= 2) && (*nc > 2) )
+ {
+ /* Use minimax test to screen cases where intersection is impossible. */
+ xrmin = BIG;
+ yrmin = BIG;
+ xrmax = -BIG;
+ yrmax = -BIG;
+ for (i=0; i<*nr; i++ )
+ {
+ xrmin = MIN( xmin, xr[i] );
+ yrmin = MIN( ymin, yr[i] );
+ xrmax = MAX( xmax, xr[i] );
+ yrmax = MAX( ymax, yr[i] );
+ }
+
+ xcmin = BIG;
+ ycmin = BIG;
+ xcmax = -BIG;
+ ycmax = -BIG;
+ for (i=0; i<*nc; i++)
+ {
+ xcmin = MIN( xmin, xc[i] );
+ ycmin = MIN( ymin, yc[i] );
+ xcmax = MAX( xmax, xc[i] );
+ ycmax = MAX( ymax, yc[i] );
+ }
+
+ if ( (((xrmax > xcmin) && (xrmin < xcmax)) && (yrmax > ycmin)) &&
+ (yrmin < ycmax) )
+ {
+
+ while (1)
+ {
+
+ /* Exhaustive check from first line segment begins here. */
+ lstart = 1;
+ ncross = 0;
+
+ while (1)
+ {
+ /* Check from next unrepaired segment begins here. */
+
+ loop = loop + 1;
+
+ /* Find the line segment with the most crossings. */
+
+ maxints = 0;
+ maxlin = 0;
+ lcross = 0;
+ for ( line = lstart; line < *nr-1; line++ )
+ {
+ x1 = xr[line];
+ y1 = yr[line];
+ x2 = xr[line + 1];
+ y2 = yr[line + 1];
+
+ if ( *idr != *idc )
+ Plnint( &x1, &y1, &x2, &y2, xc, yc, nc, &nints );
+ else
+ Plnint( &x1, &y1, &x2, &y2, xr, yr, nr, &nints );
+
+ if ( nints > 0 )
+ lcross = lcross + 1;
+
+ if ( nints > maxints )
+ {
+ maxints = nints;
+ n = line;
+ }
+ }
+
+ if ( maxints > 0 )
+ {
+ /* Repair bad line segment with the most crossings. */
+ x1 = xr[n - 1];
+ y1 = yr[n - 1];
+ x2 = xr[n];
+ y2 = yr[n];
+
+ if ( *idr != *idc )
+ Plnint( &x1, &y1, &x2, &y2, xc, yc, nc, &nints );
+ else
+ Plnint( &x1, &y1, &x2, &y2, xr, yr, nr, &nints );
+
+ ncross = ncross + nints;
+ if ( nints > 0 )
+ {
+ xvt_note (" SID %d Reduced line%d crosses%d lines in SID %d loop# %d \n",
+ *idr, n, nints, *idc, loop );
+
+ /* Find ends of bad segment in input polyline. */
+
+ istr = MXVRT;
+ for ( j=0; j < *no; j++)
+ {
+ if ( istr == MXVRT )
+ {
+ if ( (x1 == xo[j]) && (y1 == yo[j]) )
+ istr = j;
+ }
+ else
+ {
+ if ( (x2 == xo[j]) && (y2 == yo[j]) )
+ iend = j;
+ }
+ }
+
+ ndelet = iend - istr - 1;
+ xvt_note (" Repairing segment,str,end = %d %d %d SID = %d \n",
+ n, istr, iend, *idr );
+
+ /* Generate a more accurate replacement for the bad segment.
+ Inserting a single central input point in the segment on
+ each iteration results in near minimum length
+ polylines. */
+
+ istep = MAX( 1, (iend - istr)/2 );
+
+ len = 0;
+ for ( ivrt = istr, _do4=DOCNT(istr,iend,_do5=istep); _do4 > 0; ivrt += _do5, _do4-- )
+ {
+ len = len + 1;
+ tx[len - 1] = xo[ivrt];
+ ty[len - 1] = yo[ivrt];
+ }
+ nreplc = len - 2;
+
+ if ( nreplc > 0 )
+ {
+ /* Push rest of polyline down its buffer and
+ replace deletes. */
+
+ for ( j = *nr; j >= n+1; j-- )
+ {
+ xr[j + nreplc] = xr[j];
+ yr[j + nreplc] = yr[j];
+ }
+
+ for ( k=0; k < nreplc; k++ )
+ {
+ xr[n + k] = tx[1 + k];
+ yr[n + k] = ty[1 + k];
+ xvt_note (" Replaced input pt %d (x,y) = %g %g \n",
+ istr + k*istep, xr[n + k], yr[n + k] );
+ }
+ *nr = *nr + nreplc;
+ xvt_note (" Number of points in,out = %d %d SID = %d \n",
+ *no, *nr, *idr );
+
+ /* Polyline modified. Repeat crossing check
+ from beginning. */
+
+ if ( loop <= (*nr - 1) )
+ break;
+ }
+
+ else
+ {
+ /* No modification. Continue crossing check from
+ next line. */
+ lstart = n + 1;
+ if ( loop <= (*nr - 1) )
+ continue;
+ }
+ }
+ }
+
+ if ( ncross != 0 )
+ {
+ m = m + 1;
+ sprintf (string," **** Error # %d SID = %d \n", m, *idr );
+ note (string);
+ *ierror = 2;
+ }
+ }
+ }
+ }
+ }
+
+ return;
+} /* end of function */
+
+/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*-*
+ UNIT NAME: PLNINT
+
+ FUNCTIONAL DESCRIPTION: Counts crossings of a line segment by a polyline.
+
+ INPUT FILES/PARAMETERS: x1,y1, x2,y2 - Line segment.
+ x(n),y(n),len - Polyline arrays.
+
+ LOCAL VARIABLES: xi,yi - Current point in input polyline.
+ xprv,yprv - Previous point.
+ s1, s2 - Sign of sN tells half plane.
+ dX, dY, D - Coefficients of test line in
+ form: dY*x - dX*y + D = 0
+ ddx,ddy,dd - Coefs of polyline segment.
+
+ OUTPUT: nint - Number of crossings.
+
+ PROGRAMMER: DATE OF LAST CHANGE REASON FOR CHANGE
+ Tom Wescott (NOSC) Jan 89 Original code
+ Jim Bellenger SC/WGEA Dec 92 Cleaned up the FORTRAN
+ conversion
+
+-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|*-*-*- */
+
+void Plnint (double *x1, double *y1,
+ double *x2, double *y2,
+ double *x, double *y,
+ int32 *len, int32 *nints)
+
+{
+ int32 inptr;
+ double s1, s2, s3, s4;
+ double ax, ay, bx, by, d, dd, ddx, ddy, dx, dy, xi, xprv, yi, yprv;
+
+ /* NOTE: This test requires high precision arithmetic when applied to
+ short segmented polylines. */
+
+ *nints = 0;
+ ax = *x1;
+ ay = *y1;
+ bx = *x2;
+ by = *y2;
+
+ /* Compute vector (also half plane) general form coefficients
+ from directed line segment (ax,ay) to (bx,by). */
+
+ dy = ay - by;
+ dx = ax - bx;
+ d = ax*by - ay*bx;
+
+ /* Initialize counters, and set up loop with previous point. */
+
+ inptr = 0;
+ xprv = x[inptr];
+ yprv = y[inptr];
+ s1 = dy*xprv - dx*yprv + d;
+
+ /* Count intersections of directed segment and polyline.
+ While (verts remain) do. */
+
+ while (1)
+ {
+ inptr = inptr + 1;
+ if ( inptr >= *len )
+ break;
+
+ xi = x[inptr];
+ yi = y[inptr];
+ s2 = dy*xi - dx*yi + d;
+
+ /* Perform initial screen to insure polyline segment crosses line segmemt. */
+ if ( (s1 <= 0.E0) && (s2 <= 0.E0) )
+ {
+ /* Do nothing. */
+ }
+ else if( (s1 >= 0.E0) && (s2 >= 0.E0) )
+ {
+ /* Do nothing. */
+ }
+ else
+ {
+ /* Secondary screen to insure line segment crosses polyline segment. */
+
+ ddx = xprv - xi;
+ ddy = yprv - yi;
+ dd = xprv*yi - yprv*xi;
+ s3 = ddy*ax - ddx*ay + dd;
+ s4 = ddy*bx - ddx*by + dd;
+ if ( (s3 >= 0.E0) && (s4 >= 0.E0) )
+ {
+ /* No cross. */
+ }
+ else if ( (s3 <= 0.E0) && (s4 <= 0.E0) )
+ {
+ /* No cross */
+ }
+ else
+ {
+ *nints = *nints + 1;
+ }
+ }
+
+ if ( s2 != 0.E0 )
+ s1 = s2;
+
+ xprv = xi;
+ yprv = yi;
+
+ } /* End while. */
+
+ return;
+
+} /* end of function */
+#endif /* if 0 */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/set.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/set.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/set.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1066 @@
+/*************************************************************************
+ *
+ *N Module SET.C
+ * Purpose:
+ * This module contains functions that make up an abstract data type
+ * "set". The data structures and algorithms herein allow programs
+ * to perform basic manipulations defined in the mathematics of set
+ * theory. These operations are fundamental to relational database
+ * theory, as well.
+ *
+ * Sets are initialized with a user-defined size, and elements in
+ * the set may be accessed from 0 up to and including the given
+ * set size. All sets passed into functions in this module are
+ * expected to have been initialized with set_init().
+ * Parameters:
+ * N/A
+ * External Variables:
+ * None
+ * Functions Called:
+ * set_type set_init( int32 n );
+ * int set_empty( set_type set );
+ * void set_insert( int32 element, set_type set );
+ * void set_delete( int32 element, set_type set );
+ * int set_member( int32 element, set_type set );
+ * int32 set_min( set_type set );
+ * int32 set_max( set_type set );
+ * int num_in_set( set_type set );
+ * void set_on( set_type set );
+ * void set_off( set_type set );
+ * int set_equal( set_type a, set_type b );
+ * void set_assign( set_type *a, set_type b );
+ * set_type set_union( set_type a, set_type b );
+ * set_type set_intersection( set_type a, set_type b );
+ * set_type set_difference( set_type a, set_type b );
+ * void set_nuke( set_type *set );
+ *************************************************************************/
+
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+#ifdef _MSDOS
+#ifndef _WINDOWS
+#include <alloc.h>
+#include <mem.h>
+#include <dos.h>
+#include <malloc.h>
+#endif
+#else
+#include <memory.h>
+#endif
+
+#include <float.h>
+#include <stdlib.h>
+
+#ifndef __SET_H__
+#include "set.h"
+#endif
+
+#include <stdio.h>
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+static unsigned char checkmask[] = {254,253,251,247,239,223,191,127};
+static unsigned char setmask[] = {1,2,4,8,16,32,64,128};
+
+#define BITSET(bit,byte) ((byte | checkmask[bit]) ^ checkmask[bit])
+
+#define SET_BIT(bit,byte) (byte | setmask[bit])
+
+/* Warning: UNSET_BIT should only be called if the bit is not
+ already set. If it is already set, this macro may actually
+ turn the bit on. */
+#define UNSET_BIT(bit,byte) (byte ^ setmask[bit])
+
+/* The number of bytes in the set. The byte buffer should
+ only access bytes 0 through (NBYTES(set)-1). */
+#define NBYTES(set) ((set.size>>3L) + 1L)
+
+#ifndef max
+#define max(a,b) ( (a > b) ? a : b )
+#endif
+
+/* #define BOUNDSCHECK 1 */
+
+#ifdef PROTO
+ static char set_byte (int32 nbyte, set_type set)
+#else
+ static char set_byte (nbyte, set)
+ int32 nbyte;
+ set_type set;
+#endif
+ {
+ if ( (nbyte < 0) || (nbyte >= NBYTES(set)) ) return 0;
+ return set.buf[nbyte];
+ }
+
+#define SET_BYTE( nbyte, set, byte ) \
+ if ( (nbyte < 0) || (nbyte >= NBYTES(set)) ) \
+ byte = 0; \
+ else \
+ byte = set.buf[nbyte];
+
+
+/*************************************************************************
+ * set_off
+ * Purpose:
+ * Parameters:
+ * set <inout> == (set_type) set to be acted upon.
+ * External Variables:
+ * Functions Called:
+ * None
+ *************************************************************************/
+#ifdef PROTO
+ void set_off (set_type set)
+#else
+ void set_off (set)
+ set_type set;
+#endif
+
+ {
+#if 0
+ memset(set.buf,0,NBYTES(set));
+#endif
+ gmemset (set.buf, 0, NBYTES (set));
+ }
+
+/*************************************************************************
+ *
+ *N set_on
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Turns each element in the set 'on'.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * set <inout> == (set_type) set to be acted upon.
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+*************************************************************************/
+#ifdef PROTO
+ void set_on (set_type set)
+#else
+ void set_on (set)
+ set_type set;
+#endif
+
+{
+ register int32 i;
+ unsigned char byte=255;
+
+ /* Turn on all bits up through set.size. */
+ /* All but the last byte. */
+#if 0
+ memset(set.buf,byte,(set.size>>3L));
+#endif
+ gmemset (set.buf, byte, (set.size>>3L));
+
+ /* The valid bits of the last byte. */
+ for (i=(set.size>>3L)*8L;i<=set.size;i++)
+ set_insert(i,set);
+}
+
+
+
+/*************************************************************************
+ *
+ *N set_init
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Initialize the set for 'n' elements.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * n <input> == (int32) maximum number of elements in the set.
+ * return <output> == (set_type) initialized set.
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ *************************************************************************/
+#ifdef PROTO
+ set_type set_init (int32 n)
+#else
+ set_type set_init (n)
+ int32 n;
+#endif
+
+{
+ set_type s;
+ int32 nbytes;
+
+ s.size = n;
+ nbytes = NBYTES(s);
+#if 1 /* Passe passe a thomas !!! LAS inc.*/
+ s.buf = (char*)xvt_zmalloc (nbytes+1L);
+ s.buf_handle = s.buf;
+#else
+
+ s.buf_handle = galloc (nbytes+1L);
+ s.buf = glock (s.buf_handle);
+#endif
+
+ if (s.buf == (char*)NULL)
+ {
+ xvt_error ("SET_INIT: Out of Memory!");
+ }
+
+ set_off(s);
+
+ return s;
+}
+
+/*************************************************************************
+ *
+ *N set_empty
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns TRUE if the given set is empty; else it
+ * returns FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * set <input> == (set_type) set.
+ * return <output> == (int) TRUE[1] or FALSE[0].
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *************************************************************************/
+#ifdef PROTO
+ int set_empty (set_type set)
+#else
+ int set_empty (set)
+ set_type set;
+#endif
+
+{
+ register int32 i, nbytes;
+
+ nbytes = NBYTES(set);
+ for (i=0;i<nbytes;i++) {
+ if (set_byte(i,set)) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/*************************************************************************
+ *
+ * set_insert
+ * Purpose:
+ * This function inserts the given element into the specified set.
+ * Parameters:
+ * element <input> == (int32) element to insert into the set.
+ * set <inout> == (set_type) set.
+ * External Variables:
+ * None
+ * Functions Called:
+ * None
+ *************************************************************************/
+#ifdef PROTO
+ void set_insert (int32 element, set_type set)
+#else
+ void set_insert (element, set)
+ int32 element;
+ set_type set;
+#endif
+
+ {
+ int32 nbyte,bit;
+ unsigned char byte;
+
+ if ((element < 0) || (element > set.size))
+ {
+ return;
+ }
+ nbyte = element >> 3L; /* element/8 */
+ bit = element % 8L;
+ SET_BYTE (nbyte, set, byte);
+ byte = SET_BIT (bit, byte);
+ set.buf[nbyte] = byte;
+ }
+
+/*************************************************************************
+ *
+ *N set_delete
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function deletes the given element from the specified set.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * element <input> == (int32) element to delete from the set.
+ * set <inout> == (set_type) set.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void unset_bit() BITSTUFF.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ void set_delete (int32 element, set_type set)
+#else
+ void set_delete (element, set)
+ int32 element;
+ set_type set;
+#endif
+
+{
+ int32 nbyte,bit;
+ unsigned char byte;
+
+ if ((element<0)||(element>set.size)) {
+#ifdef BOUNDSCHECK
+ fprintf(stderr,"Invalid call to set_delete!\n");
+ exit(1);
+#endif
+ return;
+ }
+ nbyte = element>>3L; /* element/8 */
+ bit = element%8L;
+ SET_BYTE(nbyte,set,byte);
+ if (!BITSET(bit,byte)) return;
+ byte = UNSET_BIT(bit,byte);
+ set.buf[nbyte] = byte;
+}
+
+/*************************************************************************
+ *
+ *N set_member
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function determines whether a given element is a member of
+ * the specified set. It returns either TRUE or FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * element <input> == (int32) element to check in the set.
+ * set <input> == (set_type) set.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void bitset() BITSTUFF.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int set_member (int32 element, set_type set)
+#else
+ int set_member (element, set)
+ int32 element;
+ set_type set;
+#endif
+
+{
+ int32 nbyte,bit;
+ unsigned char byte;
+
+ if ((element < 0)||(element > set.size)) return FALSE;
+ nbyte = element>>3L; /* element/8L */
+ bit = element%8L;
+ SET_BYTE(nbyte,set,byte);
+ return BITSET(bit,byte);
+}
+
+/*************************************************************************
+ *
+ *N set_min
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the minimum element in the given set.
+ * If the set is empty, the return value is MAXLONG.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * set <input> == (set_type) set.
+ * return <output> == (int32) minimum element in the set.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void bitset() BITSTUFF.C
+ * int set_empty( set_type set ) SET.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 set_min (set_type set)
+#else
+ int32 set_min (set)
+ set_type set;
+#endif
+
+{
+ register int32 nbyte, bit, element, nbytes;
+ unsigned char byte = ' ';
+
+ if (!set.size) return (int32) MAXLONG;
+
+ /* Find the first byte with a bit set */
+ nbytes = NBYTES(set);
+
+ for (nbyte=0;nbyte<nbytes;nbyte++)
+ if (set.buf[nbyte]) {
+ byte = set.buf[nbyte];
+ break;
+ }
+
+ /* Now find the first bit set in the byte */
+ element = nbyte*8L;
+ for (bit=0; bit<8; bit++,element++) {
+ if (element > set.size) return (int32) MAXLONG;
+ if (BITSET(bit,byte)) return element;
+ }
+ return (int32) MAXLONG;
+}
+
+/*************************************************************************
+ *
+ *N set_max
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the maximum element in the given set.
+ * If the set is empty, the return value is -MAXLONG.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * set <input> == (set_type) set.
+ * return <output> == (int32) maximum element in the set.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ * Brian Glover Nov 1992 MDB upgrade
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 set_max (set_type set)
+#else
+ int32 set_max (set)
+ set_type set;
+#endif
+
+{
+ register int32 bytenum, bit, nbytes;
+ unsigned char byte;
+
+ if (!set.size) return (int32) -MAXLONG;
+
+ /* Find the last byte with a bit set */
+ nbytes = NBYTES(set);
+ bytenum = nbytes;
+
+ for (bytenum=bytenum-1;bytenum>=0;bytenum--) {
+ if (set.buf[bytenum]) {
+ byte = set.buf[bytenum];
+ break;
+ }
+ }
+
+ if (bytenum < 0) return (int32) -MAXLONG;
+
+ for (bit=7;bit>=0;bit--) {
+ if (BITSET(bit,byte)) {
+ return ((bytenum*8L)+bit);
+ }
+ }
+
+ return (int32) -MAXLONG;
+}
+
+/*************************************************************************
+ *
+ *N num_in_set
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the number of elements in the given set.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * set <input> == (set_type) set.
+ * return <output> == (int32) number of elements in the set.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void bitset() BITSTUFF.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 num_in_set (set_type set)
+#else
+ int32 num_in_set (set)
+ set_type set;
+#endif
+
+{
+ register int32 nbyte,bit,n=0L, nbytes;
+ unsigned char byte;
+
+ if (set.size == 0) return n;
+ nbytes = NBYTES(set);
+ for (nbyte=0;nbyte<nbytes;nbyte++) {
+ byte = set_byte(nbyte,set);
+ if (byte) {
+ for (bit=0;bit<8;bit++)
+ if (BITSET(bit,byte)) n++;
+ }
+ }
+ return n;
+}
+
+
+/*************************************************************************
+ *
+ *N set_equal
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function determines whether two sets are equal to each other.
+ * It returns TRUE or FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * a <input> == (set_type) first set to compare.
+ * b <input> == (set_type) second set to compare.
+ * return <output> == (int) TRUE if (a==b) or FALSE if (a!=b).
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int set_equal (set_type a, set_type b)
+#else
+ int set_equal (a, b)
+ set_type a, b;
+#endif
+
+{
+
+ if (a.size != b.size) return FALSE;
+ if (memcmp(a.buf,b.buf,NBYTES(a))==0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+
+/*************************************************************************
+ *
+ *N set_assign
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function assigns set a to be equal to set b. If a and b are
+ * different sizes, the function will reallocate a to match b.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * a <input> == (set_type *) set to be assigned.
+ * b <input> == (set_type) set to assign to a.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ void set_assign (set_type *a, set_type b)
+#else
+ void set_assign (a, b)
+ set_type *a, b;
+#endif
+
+{
+ register int32 nbytes;
+
+ nbytes = NBYTES(b);
+
+ if (a->size == b.size) {
+ memcpy(a->buf,b.buf,nbytes);
+ } else { /* a and b are different sizes */
+ a->buf = (char *)xvt_realloc(a->buf,nbytes+1L);
+ if (!a->buf) {
+ fprintf(stderr,"Memory reallocation error in set_assign\n");
+ exit(1);
+ }
+ memcpy(a->buf,b.buf,nbytes);
+ a->size = b.size;
+ }
+}
+
+/*************************************************************************
+ *
+ *N set_union
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Return the set C such that C = (A U B). C is initialized within
+ * this function, and should be nuked when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * a <input> == (set_type) set to be unioned.
+ * b <input> == (set_type) set to be unioned.
+ * return <output> == (set_type) (A U B).
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * set_type set_init() SET.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ set_type set_union (set_type a, set_type b)
+#else
+ set_type set_union (a, b)
+ set_type a, b;
+#endif
+
+{
+ register int32 i, nbytes;
+ set_type c;
+
+ c = set_init( (int32)max(a.size,b.size) );
+
+ nbytes = NBYTES(c);
+
+ for (i=0;i<nbytes;i++)
+ c.buf[i] = set_byte(i,a) | set_byte(i,b);
+
+ return c;
+}
+
+
+/*************************************************************************
+ *
+ *N set_intersection
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Return the set C such that C = (A o B). C is initialized within
+ * this function, and should be nuked when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * a <input> == (set_type) set to be intersectioned.
+ * b <input> == (set_type) set to be intersectioned.
+ * return <output> == (set_type) (A o B).
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * set_type set_init() SET.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ set_type set_intersection (set_type a, set_type b)
+#else
+ set_type set_intersection (a, b)
+ set_type a, b;
+#endif
+
+{
+ register int32 i, nbytes;
+ set_type c;
+
+ c = set_init( (int32)max(a.size,b.size) );
+
+ nbytes = NBYTES(c);
+ for (i=0;i<nbytes;i++)
+ c.buf[i] = set_byte(i,a) & set_byte(i,b);
+
+
+ return c;
+}
+
+/*************************************************************************
+ *
+ *N set_difference
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Return the set C such that C = (A - B). C is initialized within
+ * this function, and should be nuked when no longer needed.
+ *
+ * NOTE: This function can be sped up, if necessary, by direct
+ * manipulation of the bytes and bits rather than the abstract
+ * set function calls used presently.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * a <input> == (set_type) set to subtract from.
+ * b <input> == (set_type) set to be subtracted.
+ * return <output> == (set_type) (A - B).
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * set_type set_init() SET.C
+ * int set_member() SET.C
+ * void set_insert() SET.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ set_type set_difference (set_type a, set_type b)
+#else
+ set_type set_deffenence (a, b)
+ set_type a, b;
+#endif
+
+{
+ register int32 i;
+ set_type c;
+
+ c = set_init( a.size );
+
+ for (i=0;i<=a.size;i++) {
+ if ( i > b.size ) {
+ if (set_member(i,a)) set_insert( i, c );
+ } else {
+ if ((set_member(i,a)) && (!set_member(i,b))) set_insert(i,c);
+ }
+ }
+
+ return c;
+}
+
+
+/*************************************************************************
+ *
+ *N set_nuke
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Nucleate a set from existence.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * set <inout> == (set_type *) set to be nuked.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels July 1990 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This function conforms to ANSI C standards.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ void set_nuke (set_type *set)
+#else
+ void set_nuke (set)
+ set_type *set;
+#endif
+
+ {
+ if (set->buf)
+#if 0
+ xvt_free (set->buf);
+#endif
+ {
+// gunlock (set->buf_handle);
+ gfree (set->buf_handle);
+ }
+ set->size = -1;
+ }
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/set.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/set.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/set.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,66 @@
+/* =====================================================================
+
+ Environmental Systems Research Institute (ESRI) Applications Programming
+
+ Project: VPF display software
+ Original Coding: Barry Micheals November 1990 PC version
+ Modifications: David Flinn October 1991 UNIX
+
+ ================================================================= */
+
+#ifndef __SET_H__
+#define __SET_H__
+
+#include "xvt.h"
+
+#include "machine.h"
+
+/* A set is represented as an array of characters with each character */
+/* holding 8 bits of the set. */
+typedef struct
+ {
+ int32 size;
+ char /*huge*/ *buf;
+ GHANDLE buf_handle;
+ } set_type;
+
+
+/* Functions: */
+#ifdef PROTO
+ set_type set_init (int32 n);
+ int set_empty (set_type set);
+ void set_insert (int32 element, set_type set);
+ void set_delete (int32 element, set_type set);
+ int set_member (int32 element, set_type set);
+ int32 set_min (set_type set);
+ int32 set_max (set_type set);
+ int32 num_in_set (set_type set);
+ void set_on (set_type set);
+ void set_off (set_type set);
+ int set_equal (set_type a, set_type b);
+ void set_assign (set_type *a, set_type b);
+ set_type set_union (set_type a, set_type b);
+ set_type set_intersection (set_type a, set_type b);
+ set_type set_difference (set_type a, set_type b);
+ void set_nuke (set_type *set);
+#else
+ set_type set_init ();
+ int set_empty ();
+ void set_insert ();
+ void set_delete ();
+ int set_member ();
+ int32 set_min ();
+ int32 set_max ();
+ int32 num_in_set ();
+ void set_on ();
+ void set_off ();
+ int set_equal ();
+ void set_assign ();
+ set_type set_union ();
+ set_type set_intersection ();
+ set_type set_difference ();
+ void set_nuke ();
+#endif /* If PROTO */
+
+#endif /* ifdef __SET_H__ */
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/strfunc.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/strfunc.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/strfunc.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,320 @@
+
+/*****************************************************************************/
+/* STRFUNC */
+/* */
+/* Purpose: */
+/* This module contains functions some additional character string */
+/* handling functions beyond the standard C string libraries. */
+/* The strings passed in to each of these functions is actually */
+/* modified and an identical string is returned. */
+/* Contents: */
+/* strupr */
+/* strlwr */
+/* strreverse */
+/* leftjust */
+/* rightjust */
+/* justify */
+/* Mstrcmpi */
+/* Mstrncmpi */
+/*****************************************************************************/
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+
+#ifdef _UNIX
+#include <strings.h>
+#endif
+
+#ifndef __STRFUNC_H__
+#include "strfunc.h"
+#endif
+
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+
+/*****************************************************************************/
+/* strupr */
+/* */
+/* Purpose: */
+/* This function changes all lowercase characters in a string to */
+/* uppercase. */
+/* */
+/* Parameters: */
+/* string <inout> == (char *) string to be made uppercase. */
+/* strupr <output> == (char *) pointer to string. */
+/* */
+/*****************************************************************************/
+#ifdef PROTO
+ char *strupr (char *string)
+#else
+ char *strupr (string)
+ char *string;
+#endif
+
+ {
+ size_t i;
+
+ if (!string)
+ return string;
+
+ for (i=0; i<strlen (string); i++)
+ string[i] = (char)toupper (string[i]);
+ return string;
+ }
+
+/*****************************************************************************/
+/* strlwr */
+/* */
+/* Purpose: */
+/* This function changes all lowercase characters in a string to */
+/* uppercase. */
+/* */
+/* Parameters: */
+/* string <inout> == (char *) string to be made uppercase. */
+/* strupr <output> == (char *) pointer to string. */
+/* */
+/*****************************************************************************/
+
+#ifdef PROTO
+ char *strlwr (char *string)
+#else
+ char *strlwr (string)
+ char *string;
+#endif
+
+ {
+ size_t i;
+
+ if (!string)
+ return string;
+
+ for (i=0; i<strlen (string); i++)
+ string[i] = (char)tolower (string[i]);
+ return string;
+ }
+
+
+/*************************************************************************
+*
+*N strreverse
+*
+*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+*
+* Purpose:
+*P
+* This function reverses the characters in a string.
+*E
+*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+*
+* Parameters:
+*A
+* string <inout> == (char *) string to be reversed.
+* strreverse <output> == (char *) pointer to string.
+*E
+*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+*
+* History:
+*H
+* Brian Glover April 1992 Rewrite of non-ANSI function
+*E
+*************************************************************************/
+#ifdef PROTO
+ char *strreverse (char *str)
+#else
+ char *strreverse (str)
+ char *str;
+#endif
+
+{
+ size_t i, len;
+ char *copy;
+
+ len = strlen (str);
+ copy = (char*)xvt_malloc (sizeof(char) * (len+1));
+ strcpy (copy, str);
+
+ for (i=0; i<len; i++)
+ str[i] = copy[(len-1)-i];
+ xvt_free (copy);
+
+ return str;
+}
+
+/*****************************************************************************/
+/* leftjust */
+/* */
+/* Purpose: */
+/* This function left justifies a string by removing all leading */
+/* whitespace. */
+/* */
+/* Parameters: */
+/* string <inout> == (char *) string to be left justified. */
+/* leftjust <output> == (char *) pointer to string. */
+/*****************************************************************************/
+
+#ifdef PROTO
+ char *leftjust (char *str)
+#else
+ char *leftjust (str)
+ char *str;
+#endif
+
+ {
+ register char * eol;
+ const char *post_white;
+
+ if (!str)
+ return str;
+
+ post_white = str + strspn(str, " \t\n\b");
+ if( post_white != str )
+ {
+ memmove( str, post_white, strlen(post_white)+1 );
+ }
+
+ if ((eol = strchr (str, '\n')) != NULL)
+ *eol = 0;
+
+ return str;
+ }
+
+
+/*****************************************************************************/
+/* rightjust */
+/* */
+/* Purpose: */
+/* This function right justifies a string by removing all trailing */
+/* whitespace. */
+/* */
+/* Parameters: */
+/* string <inout> == (char *) string to be right justified. */
+/* rightjust <output> == (char *) pointer to string. */
+/*****************************************************************************/
+
+#ifdef PROTO
+ char *rightjust (char *str)
+#else
+ char *rightjust (str)
+ char *str;
+#endif
+
+ {
+ size_t len, i;
+
+ len = strlen (str);
+ i = len - 1;
+ while ((i>0) && ((str[i]==0) || (str[i]==' '))) i--;
+ if (i < (len-1))
+ str[i+1] = '\0';
+ for (i=0; i<strlen (str); i++)
+ {
+ if (str[i]=='\n') /* Newline char */
+ str[i] = '\0';
+ else if (str[i] == '\t') /* Tab char */
+ str[i] = '\0';
+ else if (str[i] == '\b') /* Backspace char */
+ str[i] = '\0';
+ }
+ return str;
+ }
+
+#ifdef _MAC
+int strncmpi (char *str1, char *str2, size_t len)
+ {
+
+ char *string1, *string2;
+ int retvalue;
+
+ string1 = (char*)xvt_zmalloc (len + 1L);
+ string2 = (char*)xvt_zmalloc (len + 1L);
+ strncpy(string1, str1, len);
+ strncpy(string2, str2, len);
+ retvalue = strcmpi ((char*)string1, (char*)string2);
+ xvt_free (string1);
+ xvt_free (string2);
+ return (retvalue);
+ }
+#endif
+
+/*****************************************************************************/
+/* justify */
+/* */
+/* Purpose: */
+/* This function justifies a string by removing all leading and trailing */
+/* whitespace. */
+/* */
+/* Parameters: */
+/* string <inout> == (char*) string to be left justified. */
+/* justify <output> == (char*) pointer to string. */
+/*****************************************************************************/
+
+#ifdef PROTO
+ char *justify (char *str)
+#else
+ char *justify (str)
+ char *str;
+#endif
+
+ {
+ str = leftjust (str);
+ str = rightjust (str);
+ return (str);
+ }
+
+
+/*****************************************************************************/
+/* Mstrcmpi */
+/* MUSE platform independent form of a case insensitive string compare */
+/*****************************************************************************/
+#ifdef PROTO
+ int Mstrcmpi (const char* string1, const char *string2)
+#else
+ int Mstrcmpi (string1, string2)
+ const char *string1;
+ const char *string2;
+#endif
+
+ {
+ int value;
+
+#ifdef _MAC
+ value = strcmpi ((char*)string1, (char*)string2);
+#elif defined(_HPUX_SOURCE) || defined(_UNIX)
+ value = strcasecmp (string1, string2);
+#else
+ value = stricmp (string1, string2);
+#endif
+
+ return (value);
+ }
+
+
+/*****************************************************************************/
+/* Mstrncmpi */
+/* MUSE platform independent form of a function to compare a portion of */
+/* two strings without regard to case. */
+/*****************************************************************************/
+#ifdef PROTO
+ int Mstrncmpi (const char* string1, const char *string2, size_t size)
+#else
+ int Mstrncmpi (string1, string2, size)
+ const char *string1;
+ const char *string2;
+ size_t size;
+#endif
+
+ {
+ int value;
+
+#ifdef _MAC
+ value = strncmpi ((char*)string1, (char*)string2, size);
+#elif defined(_WINDOWS)
+ value = strnicmp (string1, string2, size);
+#else
+ value = strncasecmp (string1, string2, size);
+#endif
+
+ return (value);
+ }
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/strfunc.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/strfunc.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/strfunc.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,50 @@
+#ifndef __STRFUNC_H__
+#define __STRFUNC_H__
+
+#include "stdio.h"
+#include <string.h>
+
+#define VPF_SEPARATOR '\\'
+#define VPF_SEPARATOR_STRING "\\"
+
+#ifdef _MSDOS
+#define OS_SEPARATOR '\\'
+#define OS_SEPARATOR_STRING "\\"
+#define DIR_SEPARATOR '\\'
+#endif
+
+#ifdef _UNIX
+#define OS_SEPARATOR '/'
+#define OS_SEPARATOR_STRING "/"
+#define DIR_SEPARATOR '/'
+#endif
+
+#ifdef _MAC
+#define OS_SEPARATOR ':'
+#define OS_SEPARATOR_STRING ":"
+#define DIR_SEPARATOR ':'
+#endif
+
+
+
+/* Functions: */
+#ifdef PROTO
+ char *strupr( char *str);
+ char *strlwr( char *str);
+ char *leftjust( char *str);
+ char *rightjust( char *str);
+ char *justify (char *str);
+ int Mstrcmpi (const char *string1, const char *string2);
+ int Mstrncmpi (const char *string1, const char *string2, size_t size);
+#else
+
+ char *strupr ();
+ char *strlwr ();
+ char *leftjust ();
+ char *rightjust ();
+ char *justify ();
+ int Mstrcmpi ();
+ int Mstrncmpi ();
+#endif
+
+#endif /* ifdef __STRFUNC_H__ */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vec_d.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vec_d.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vec_d.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,240 @@
+#ifndef H_VEC_D
+#define H_VEC_D
+
+
+#ifndef H_MUSE1
+#include "muse1.h"
+#endif
+#ifndef H_VIEW_DEF
+#include "view_d.h"
+#endif
+
+#ifndef _WINDOWS
+#ifndef H_PHIGS_D
+#include "phigs_d.h"
+#endif
+#endif
+
+#ifndef __VPF_H__
+/* VPF feature types */
+typedef enum { LINE=1, AREA, ANNO, POINTS, COMPLEX=6 } vpf_feature_type;
+#endif
+
+
+#define MAGIC_VEC2_DATA 120000002L
+
+
+#define MAXPOINTS 16000
+#define MAXLINES 16000
+#define MAXAREAS 16000
+#define MAXTEXT 16000
+#define MAXRINGS 5000
+#define MAXSEGS 5000
+#define MAXCOORDS 5000
+#define MAXSTRING 80
+
+#define SZ_VEC 60
+#define SZ_VEC_EXTENTS 32
+#define SZ_VEC_LINES 4
+#define SZ_VEC_TEXT 4
+#define SZ_VEC_POINTS 4
+#define SZ_VEC_AREAS 4
+#define SZ_VEC_SYMBOLOGY 16
+#define SZ_VEC_INFO 8
+#define SZ_SYMB_LINES 20
+#define SZ_SYMB_TEXT 16
+#define SZ_SYMB_POINTS 16
+#define SZ_SYMB_AREAS 10
+#define SZ_COORDINATE 16
+
+#define SZ_LONG 4
+#define SZ_DOUBLE 8
+
+
+/***************************************************************
+@ FEATURE_EDIT_FLAGS
+****************************************************************
+A set of flags used in feature editing.
+*/
+typedef struct
+{
+ BOOLEAN selected; /*TRUE if selected*/
+ BOOLEAN deleted; /*TRUE if flagged for deletion*/
+ BOOLEAN modified; /*TRUE if recently modified*/
+} FEATURE_EDIT_FLAGS;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ COORDINATE
+****************************************************************
+Geospatial coordinate pair.
+*/
+typedef struct
+ {
+ float x;
+ float y;
+ } COORDINATE;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ SEGMENT
+****************************************************************
+Line/edge segment.
+*/
+typedef struct
+ {
+ int32 id;
+ int32 nr_coords;
+ COORDINATE *coords;
+ } SEGMENT;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ POINT_FEATURE
+****************************************************************
+Point Feature structure.
+*/
+typedef struct
+ {
+ int32 id;
+ COORDINATE *coord;
+ FEATURE_EDIT_FLAGS flags;
+ } POINT_FEATURE;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ LINE_FEATURE
+****************************************************************
+Line Feature structure.
+*/
+typedef struct
+ {
+ int32 id;
+ int32 nr_segs;
+ SEGMENT **segs;
+ FEATURE_EDIT_FLAGS flags;
+ } LINE_FEATURE;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ RING
+****************************************************************
+Ring structure.
+*/
+typedef struct
+ {
+ int32 id;
+ int32 nr_segs;
+ SEGMENT **segs;
+ } RING;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ AREA_FEATURE
+****************************************************************
+Area Feature structure.
+*/
+typedef struct
+ {
+ int32 id;
+ int32 nr_rings;
+ RING **rings;
+ FEATURE_EDIT_FLAGS flags;
+ } AREA_FEATURE;
+/*
+Description:
+
+*/
+
+/***************************************************************
+@ TEXT_FEATURE
+****************************************************************
+Text Feature structure.
+*/
+typedef struct
+ {
+ int32 id;
+ char *string;
+ int32 nr_coords;
+ COORDINATE *coords;
+ FEATURE_EDIT_FLAGS flags;
+ } TEXT_FEATURE;
+/*
+Description:
+
+*/
+
+/****************************************************************************
+@ VEC_EXTENT
+*****************************************************************************
+Spatial extents of the data-set.
+*/
+typedef struct
+{
+ double xmin;
+ double ymin;
+ double xmax;
+ double ymax;
+} VEC_EXTENT;
+/*
+Description:
+
+*/
+
+/****************************************************************************
+@ VEC_INFO
+*****************************************************************************
+Spatial extents of the data-set.
+*/
+typedef struct
+{
+ char *type;
+ char *info;
+} VEC_INFO;
+
+
+/***********************************************************************
+@ VEC
+************************************************************************
+A MUSE structure to hold vector overlay data.
+*/
+typedef struct
+ {
+ int32 magic;
+ vpf_feature_type feature_type;
+ int32 nr_features;
+ int32 nr_lines;
+ int32 nr_text;
+ int32 nr_points;
+ int32 nr_areas;
+ VEC_EXTENT *extents;
+ VEC_INFO *info;
+ LINE_FEATURE **lines;
+ TEXT_FEATURE **text;
+ POINT_FEATURE **points;
+ AREA_FEATURE **areas;
+ } VEC;
+/*
+Description:
+
+*/
+
+#endif /* H_VEC_DEF */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,75 @@
+/* VPF.H */
+
+#ifndef __VPF_H__
+#define __VPF_H__ 1
+
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+/* Define some standard VPF-related data types and structures */
+
+
+/* Currently supported VPF versions */
+typedef enum { VPF_0_7, VPF_0_8, VPF_0_9, VPF_1_0 } vpf_version_type;
+
+
+/* VPF feature types */
+typedef enum { LINE=1, AREA, ANNO, VPFPOINTS, VPFCOMPLEX=6 } vpf_feature_type;
+
+/* VPF primitive types */
+typedef enum { EDGE=1, FACE, TEXT, ENTITY_NODE, CONNECTED_NODE }
+ vpf_primitive_type;
+
+typedef struct {
+ unsigned char edge;
+ unsigned char face;
+ unsigned char text;
+ unsigned char entity_node;
+ unsigned char connected_node;
+} primitive_class_type;
+
+
+typedef enum { UNKNOWN_SECURITY, UNCLASSIFIED, RESTRICTED, CONFIDENTIAL,
+ SECRET, TOP_SECRET } security_type;
+
+
+/* Units of measure */
+typedef enum { UNKNOWN_UNITS, METERS, FEET, INCHES,
+ KILOMETERS, OTHER_UNITS, DEC_DEGREES } vpf_units_type;
+
+
+/* Map coordinate projection definitions */
+
+typedef enum {
+ DDS, /* Decimal Degrees */
+ AC, /* Albers Equal Area */
+ AK, /* Azimuthal Equal Area */
+ AL, /* Azimuthal Equal Distance */
+ GN, /* Gnomonic */
+ LE, /* Lambert Conformal Conic */
+ LJ, /* Lambert (Cylindrical) Equal Area */
+ MC, /* Mercator */
+ OC, /* Oblique Mercator */
+ OD, /* Orthographic */
+ PG, /* Polar Stereographic */
+ TC, /* Transverse Mercator */
+ UT, /* UTM */
+ PC /* Plate-Carree */
+} vpf_projection_code;
+
+
+typedef struct
+ {
+ vpf_projection_code code;
+ double parm1, parm2, parm3, parm4;
+ vpf_units_type units;
+ double false_easting, false_northing;
+ int32 (*forward_proj)();
+ int32 (*inverse_proj)();
+ char name[21];
+ } vpf_projection_type;
+
+typedef unsigned char boolean;
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf2vec.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf2vec.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf2vec.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1637 @@
+/**************************************************************************/
+/* VPF2VEC.C */
+/* */
+/* Contents: */
+/* vpf2vec.c */
+/* get_features */
+/* get_selected_tile_primitives */
+/* primitives_within_extent */
+/* get_tile_set */
+/* bit_fix */
+/* */
+/**************************************************************************/
+
+#include "xvt.h"
+#include "vpf.h"
+#include "vpfview.h"
+#include "vpfrelat.h"
+#include "vpfspx.h"
+#include "vpfprim.h"
+#include "vpfproj.h"
+#include "vpfquery.h"
+#include "vpfselec.h"
+#include "get_feat.h"
+#include "params.h"
+#include "vec_d.h"
+#include "musedir.h"
+#include "vpf2vec.h"
+#include "strfunc.h"
+#include "i_stat.h"
+
+/* Prototype */
+set_type spatial_index_search( char *fname,float x1, float y1, float x2, float y2 );
+
+/**************************************************************************/
+/* VPF2VEC */
+/**************************************************************************/
+
+#ifdef PROTO
+ void vpf2vec (USER_PARAMS *params, VEC *vec)
+#else
+ void vpf2vec (params, vec)
+ USER_PARAMS *params;
+ VEC *vec;
+#endif
+ {
+ view_type view;
+ map_environment_type mapenv;
+ char StatusMessage[40], string[40];
+ static char sep[2] = {DIR_SEPARATOR,'\0'};
+
+ /* Create the Status Window */
+ strcpy (StatusMessage, "INITIALIZING!");
+ strcpy (string, "Please be patient");
+ if (iCreateStatus (StatusMessage, string) != TRUE)
+ {
+ xvt_note ("VPF2VEC: Cannot create Status Window.");
+ return;
+ }
+
+ /* Allocate space for view, database, & library structures */
+ view.path = (char*)xvt_malloc (PATHSIZE);
+ if (view.path == (char*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ strcpy (view.name, "MUSE");
+ view.ndb = 1L;
+ view.nthemes = 1L;
+
+ view.database = (database_type*) xvt_zmalloc (sizeof (database_type));
+ if (view.database == (database_type*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ view.database->path = (char*)xvt_zmalloc (PATHSIZE);
+ view.database->nlibraries = 1;
+
+ view.database->library = (library_type*)xvt_zmalloc (sizeof (library_type));
+ if (view.database->library == (library_type*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ view.database->library->viewable = TRUE;
+ view.database->library->path = (char*)xvt_zmalloc (PATHSIZE);
+ if (view.database->library->path == (char*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ strcpy (view.database->path, params->db_path);
+ strcat (view.database->path, sep);
+ strcpy (view.database->name, params->db_name);
+ strcpy (view.database->library->name, params->lib_name);
+
+ /* Set Spatial Extents */
+ mapenv.mapextent.x1 = params->x_min;
+ mapenv.mapextent.x2 = params->x_max;
+ mapenv.mapextent.y1 = params->y_min;
+ mapenv.mapextent.y2 = params->y_max;
+
+ /* Accomidate crossing the 180 meridian */
+ if (mapenv.mapextent.x1 > mapenv.mapextent.x2)
+ mapenv.mapextent.x2 += 360.E0;
+
+ strcpy (view.database->library->path, view.database->path);
+ strcat (view.database->library->path, view.database->name);
+ strcat (view.database->library->path, sep);
+ strcat (view.database->library->path, view.database->library->name);
+ strcat (view.database->library->path, sep);
+
+ view.database->library->projection = DDS;
+ view.database->library->units = DDS;
+
+ strcpy (view.path, view.database->path);
+ strcat (view.path, view.database->name);
+
+
+ /* THEMES */
+ view.theme = (theme_type*)xvt_malloc (sizeof (theme_type));
+ if (view.theme == NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ view.nthemes = 1;
+
+ /* Set Theme parameters */
+ view.theme->database = (char*)xvt_malloc (SZ_FNAME);
+ if (view.theme->database == (char*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ strcpy (view.theme->database, view.database->path);
+ view.theme->database = strcat
+ (view.theme->database, view.database->name);
+
+ view.theme->library = (char*)xvt_malloc (SZ_FNAME);
+ if (view.theme->library == NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ strcpy (view.theme->library, view.database->library->name);
+
+ view.theme->coverage = (char*)xvt_malloc (SZ_FNAME);
+ if (view.theme->coverage == (char*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ strcpy (view.theme->coverage, params->cov_name);
+
+ view.theme->expression = (char*)xvt_malloc (80 * sizeof (char));
+ if (view.theme->expression == (char*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ strcpy (view.theme->expression, params->expression);
+
+ view.theme->fc = (char*)xvt_malloc (SZ_FNAME);
+ if (view.theme->fc == (char*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ strcpy (view.theme->fc, params->fclass);
+
+ /* Feature Table Path */
+ view.theme->ftable = (char*)xvt_malloc (SZ_FNAME);
+ if (view.theme->ftable == (char*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ strcpy (view.theme->ftable, view.theme->database);
+ strcat (view.theme->ftable, sep);
+ strcat (view.theme->ftable, view.theme->library);
+ strcat (view.theme->ftable, sep);
+ strcat (view.theme->ftable, view.theme->coverage);
+ strcat (view.theme->ftable, sep);
+ strcat (view.theme->ftable, view.theme->fc);
+
+ /* Allocate space for vec structure */
+ vec->magic = MAGIC_VEC2_DATA;
+
+ vec->extents = (VEC_EXTENT*)xvt_zmalloc (sizeof (VEC_EXTENT));
+ if (vec->extents == (VEC_EXTENT*)NULL)
+ {
+ xvt_note ("VPF2VEC: Out of memory!");
+ clean_up (view);
+ return;
+ }
+
+ vec->extents->xmin = params->x_min;
+ vec->extents->xmax = params->x_max;
+ vec->extents->ymin = params->y_min;
+ vec->extents->ymax = params->y_max;
+
+ /* Accomidate crossing the 180 meridian */
+ if (vec->extents->xmin > vec->extents->xmax)
+ vec->extents->xmax += 360.E0;
+
+
+ vec->feature_type = params->feature_type;
+
+ switch (params->feature_type)
+ {
+ case LINE:
+ {
+ strcat (view.theme->ftable, ".lft");
+ break;
+ }
+ case AREA:
+ {
+ strcat (view.theme->ftable, ".aft");
+ break;
+ }
+ case ANNO:
+ {
+ strcat (view.theme->ftable, ".tft");
+ break;
+ }
+ case VPFPOINTS:
+ {
+ strcat (view.theme->ftable, ".pft");
+ break;
+ }
+ case COMPLEX:
+ break;
+ default:
+ {
+ xvt_note ("VPF_SS: Invalid feature type.");
+ return;
+ }
+ }
+
+
+ get_features (vec, &view, &mapenv);
+
+ clean_up (view);
+
+ return;
+ }
+
+/*********************************************************************/
+/* CLEAN_UP */
+/*********************************************************************/
+#ifdef PROTO
+ void clean_up (view_type view)
+#else
+ void clean_up (view)
+ view_type view;
+#endif
+
+ {
+ /* Free allocated memory */
+ if (view.path)
+ xvt_free (view.path);
+ if (view.theme)
+ {
+ if (view.theme->database)
+ xvt_free (view.theme->database);
+ if (view.theme->library)
+ xvt_free (view.theme->library);
+ if (view.theme->fc)
+ xvt_free (view.theme->fc);
+ if (view.theme->ftable)
+ xvt_free (view.theme->ftable);
+ xvt_free ((char*)view.theme);
+ }
+ if (view.database)
+ {
+ if (view.database->library)
+ {
+ if (view.database->library->path)
+ xvt_free (view.database->library->path);
+ if (view.database->library->tile_set.buf)
+ set_nuke (&view.database->library->tile_set);
+ xvt_free ((char*)view.database->library);
+ }
+ if (view.database->path)
+ xvt_free (view.database->path);
+ xvt_free ((char*)view.database);
+ }
+
+ /* Destroy Status Window */
+ iDestroyStatus ();
+
+ return;
+ }
+
+
+
+/*****************************************************************************/
+/* GET_FEATURES */
+/* */
+/* Purpose: */
+/* This function retreives the selected features from a specified */
+/* feature class based upon a selection expression. */
+/* Parameters: */
+/* view <input> == (view_type*) view structure. */
+/* mapenv <input> == (map_environment_type*) map environment structure. */
+/* return <output> == (int32) completion status: */
+/* 1 if completed successfully, */
+/* 0 if an error occurred. */
+/*****************************************************************************/
+#ifdef PROTO
+ int32 get_features (VEC *vec, view_type *view, map_environment_type *mapenv)
+#else
+ int32 get_features (vec, view, mapenv)
+ VEC *vec;
+ view_type *view;
+ map_environment_type *mapenv;
+#endif
+
+ {
+ int32 status, finished=1, tilecover, TILEPATH_=0, prim;
+ int32 number_relate_paths, relpathnum;
+ vpf_table_type rngtable,edgtable,fbrtable, tile_table, fcs;
+ vpf_table_type fca, ft;
+ int32 fit=0L, fc_id;
+ row_type row;
+ char ptype[4], StatusMessage[40], string[40];
+ int32 i, j, n=0L, tile, tileid;
+ int32 pclass;
+ int32 starttile, endtile, startprim, endprim;
+ int32 count, nr, TABLE_NAME_, PRIM_TYPE_;
+ char path[255], libpath[255], covpath[255], tiledir[255], ftable[255];
+ char *buf, *primtype;
+ static char sep[2] = {DIR_SEPARATOR,'\0'};
+ set_type sprims, primitives, feature_rows;
+ fcrel_type fcrel;
+ int32 nr_features;
+ LINE_FEATURE **temp_lines;
+ AREA_FEATURE **temp_areas;
+ TEXT_FEATURE **temp_text;
+ POINT_FEATURE **temp_points;
+ BOOLEAN stop_processing = FALSE;
+
+
+
+ strcpy (libpath, view->theme->database);
+ strcat (libpath, sep);
+ strcat (libpath, view->theme->library);
+ strcat (libpath, sep);
+
+ strcpy (covpath, libpath);
+ strcat (covpath, view->theme->coverage);
+ strcat (covpath, sep);
+
+
+
+
+
+ /* Look for feature class entry in FCA */
+ strcpy (path, covpath);
+ strcat (path, "fca");
+
+ if (muse_access (path, 0) == 0)
+ {
+ fca = vpf_open_table (path, disk, "rb", NULL);
+ j = table_pos ("FCLASS",fca);
+
+ for (i=1; i<=fca.nrows; i++)
+ {
+ row = read_next_row (fca);
+ buf = (char*)get_table_element (j, row, fca, NULL, &count);
+ rightjust (buf);
+
+ if (Mstrcmpi (buf, view->theme->fc) == 0)
+ {
+ fc_id = (int32)i;
+ i = fca.nrows + 2;
+ }
+ xvt_free (buf);
+ free_row (row, fca);
+ }
+ vpf_close_table(&fca);
+ }
+
+ /* Get the set of Feature_IDs that satisfy the thematic expression */
+ strcpy (path, view->theme->ftable);
+ ft = vpf_open_table (path, disk, "rb", NULL);
+
+ feature_rows = query_table (view->theme->expression, ft);
+ vpf_close_table (&ft);
+ nr_features = num_in_set (feature_rows);
+
+ /* Return if no features were found */
+ if (nr_features == 0)
+ return (-1);
+
+ /* Set Primitive Class type and */
+ /* allocate memory for array of feature pointes */
+ switch (vec->feature_type)
+ {
+ case LINE:
+ {
+ vec->lines = (LINE_FEATURE**)xvt_zmalloc
+ (MAXLINES * sizeof (LINE_FEATURE*));
+ if (vec->lines == NULL)
+ {
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+ return (-1);
+ }
+ strcpy (ptype, "EDG");
+ pclass = 1;
+ break;
+ }
+ case AREA:
+ {
+ vec->areas = (AREA_FEATURE**)xvt_zmalloc
+ (MAXAREAS * sizeof (AREA_FEATURE*));
+ if (vec->areas == NULL)
+ {
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+ return (-1);
+ }
+ strcpy (ptype, "FAC");
+ pclass = 2;
+ break;
+ }
+ case ANNO:
+ {
+ vec->text = (TEXT_FEATURE**)xvt_zmalloc
+ (MAXTEXT * sizeof (TEXT_FEATURE*));
+ if (vec->text == NULL)
+ {
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+ return (-1);
+ }
+ strcpy (ptype, "TXT");
+ pclass = 3;
+ break;
+ }
+ case VPFPOINTS:
+ {
+ vec->points = (POINT_FEATURE**)xvt_zmalloc
+ (MAXPOINTS * sizeof (POINT_FEATURE*));
+ if (vec->points == NULL)
+ {
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+ return (-1);
+ }
+ /* Determine if points are Entity Nodes "END" or */
+ /* Connected Nodes "CND". */
+ strcpy (string, view->theme->fc);
+ strcat (string, ".PFT");
+
+ /* Open Feature Class Schema table "FCS" */
+ strcpy (path, covpath);
+ strcat (path, "fcs");
+ fcs= vpf_open_table (path, disk, "rb", NULL);
+
+ /* Find the column that contains the feature table name */
+ TABLE_NAME_ = table_pos ("TABLE1", fcs);
+ PRIM_TYPE_ = table_pos ("TABLE2", fcs);
+
+ /* Find the correct row for the feature table */
+ for (i=0; i<fcs.nrows; i++)
+ {
+ row = read_next_row (fcs);
+ buf = (char*)get_table_element(TABLE_NAME_, row, fcs, NULL, &n);
+ buf = leftjust (buf);
+ buf = rightjust (buf);
+ if (strcmpi (string, buf) == 0)
+ {
+ /* Get the primitive type */
+ primtype = (char*)get_table_element (PRIM_TYPE_, row, fcs, NULL, &n);
+ primtype = leftjust (primtype);
+ primtype = rightjust (primtype);
+ free_row (row, fcs);
+ xvt_free (buf);
+ break;
+ }
+ free_row (row, fcs);
+ xvt_free (buf);
+ }
+ vpf_close_table (&fcs);
+ strcpy (ptype, primtype);
+ xvt_free (primtype);
+ pclass = 4;
+ n = 0;
+ break;
+ }
+ case COMPLEX:
+ break;
+ }
+
+
+ /*** Look for Feature Index Table (FIT) ***/
+ strcpy (path, covpath);
+ strcat (path, ptype);
+ strcat (path,".FIT");
+ fit = (muse_access (path, 0) == 0);
+
+ /* Set up the feature class table relate chain. */
+ /* The feature table is fcrel.table[0]. */
+ /* The primitive table is the last table in the chain: */
+ /* fcrel.table[ fcrel.nchain-1 ]. */
+
+ if (fit)
+ {
+ number_relate_paths = 1;
+ }
+ else
+ {
+ strcpy (path, covpath);
+ strcat (path, "FCS");
+ fcs = vpf_open_table (path, disk, "rb", NULL);
+ number_relate_paths = num_relate_paths (ptype,
+ view->theme->fc, fcs);
+ vpf_close_table (&fcs);
+ }
+
+
+ /* Look for the primitive table at the coverage level */
+ /* to determine if the coverage is tiled. */
+ strcpy (path, covpath);
+ strcat (path, ptype);
+ if (muse_access (path, 0) == 0)
+ {
+ tilecover = FALSE;
+ starttile = 1;
+ endtile = 1;
+ }
+ else
+ {
+ view->database->library->tile_set = get_tile_set
+ (libpath, mapenv->mapextent, &stop_processing);
+
+ if (stop_processing)
+ return (-1);
+
+ /* The coverage is tiled, open the TILEREF.AFT table */
+ strcpy (path, libpath);
+ strcat (path, "tileref");
+ strcat (path, sep);
+ strcat (path, "tileref.aft");
+ if ((muse_access (path, 0)) == 0)
+ {
+ tilecover = TRUE;
+ starttile = set_min (view->database->library->tile_set);
+ endtile = set_max (view->database->library->tile_set);
+ tile_table = vpf_open_table (path, disk, "rb", NULL);
+ TILEPATH_ = (int32)table_pos ("TILE_NAME", tile_table);
+ }
+ else
+ {
+ /* No primitive table found & no tileref table found */
+ /* This is a problem. */
+ xvt_error ("GET_FEATURES: Can't find primitive table.");
+ return (-1);
+ }
+ }
+
+
+
+ /**** RELATIVE PATH LOOP ***************************************/
+
+ for (relpathnum=0; relpathnum<number_relate_paths; relpathnum++)
+ {
+ if (stop_processing)
+ break;
+
+ if (fit)
+ {
+ /* Only need the primitive table */
+ fcrel.table = (vpf_table_type*)xvt_zmalloc (sizeof (vpf_table_type));
+ if (fcrel.table == NULL)
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+
+ fcrel.relate_list = NULL;
+ fcrel.nchain = 1;
+ }
+ else
+ {
+ /* Initialize the feature class relates */
+ j = strlen (view->theme->ftable) - 1;
+ while (view->theme->ftable[j] != DIR_SEPARATOR && j>0)
+ j--;
+ if (view->theme->ftable[j] == DIR_SEPARATOR)
+ strcpy (ftable, &view->theme->ftable[j+1]);
+ else
+ strcpy (ftable, view->theme->ftable);
+ rightjust (ftable);
+ fcrel = select_feature_class_relate (covpath,
+ view->theme->fc, ptype, ftable, relpathnum);
+ }
+ prim = 0;
+
+ /* Open the Feature_Table */
+ ft = vpf_open_table (view->theme->ftable, disk, "rb", NULL);
+
+
+
+
+ /**** Tile Loop ********************************************/
+ /* If the coverage is untiled still go thru the loop once. */
+ /* That is, treat an untiled coverage as a single tile. */
+ /***********************************************************/
+ for (tile = starttile; tile <= endtile; tile++)
+ {
+ if (stop_processing)
+ break;
+
+ /* Update Status Window */
+ sprintf (StatusMessage, "Retrieve Features");
+ sprintf (string, "Searching Tile Nr. %ld", tile);
+ if (iUpdateStatus (StatusMessage, string) != TRUE)
+ xvt_note ("VPF2vec: Update Status failed.");
+ if (iCheckCancel() != TRUE)
+ return (-1);
+
+ if (tilecover)
+ {
+ if (!set_member(tile,view->database->library->tile_set))
+ continue;
+ row = get_row (tile, tile_table);
+ buf = (char*)get_table_element (TILEPATH_, row, tile_table,
+ NULL, &count);
+ free_row (row, tile_table);
+ /* Convert uppercase chars to lowercase */
+ buf = strlwr (buf);
+ strcpy (tiledir, buf);
+ rightjust (tiledir);
+ /* Filter path for system specific file separators */
+ muse_check_path (tiledir);
+ strcat (tiledir, sep);
+ xvt_free (buf);
+ tileid = tile;
+ }
+ else
+ {
+ strcpy (tiledir, "");
+ tileid = 0;
+ }
+ finished = TRUE;
+
+ strcpy (path, covpath);
+ strcat (path, tiledir);
+ strcat (path, ptype);
+
+ /* Check for primitive table within the current tile */
+ if (muse_access (path, 0) != 0)
+ continue;
+ fcrel.table[prim] = vpf_open_table (path, disk, "rb", NULL);
+
+ wait_cursor ();
+
+ if (fit)
+ {
+ /* Get set of primitives that meet spatial constraints */
+ sprims = primitives_within_extent (mapenv->mapextent, covpath,
+ tiledir, pclass, fcrel.table[prim].nrows);
+ nr = num_in_set (sprims);
+
+ /* Get set of primitives that meet both spatial and */
+ /* thematic constraints. */
+ primitives = get_fit_primitives (covpath, pclass,
+ feature_rows, sprims, tileid, fc_id,
+ fcrel.table[prim].nrows, &stop_processing);
+ nr = num_in_set (primitives);
+ set_nuke (&sprims);
+ }
+ else
+ {
+ primitives = get_selected_tile_primitives (covpath, fcrel,
+ pclass, feature_rows, mapenv, tileid, tiledir,
+ &status);
+ }
+
+ if (primitives.size < 1)
+ {
+ vpf_close_table (&fcrel.table[prim]);
+ continue;
+ }
+
+ if (set_empty (primitives))
+ {
+ set_nuke (&primitives);
+ vpf_close_table (&fcrel.table[prim]);
+ continue;
+ }
+
+ finished = 1;
+
+ startprim = set_min (primitives);
+ endprim = set_max (primitives);
+
+ /* It turns out to be MUCH faster off of a CD-ROM to */
+ /* read each row and discard unwanted ones than to */
+ /* forward seek past them. It's about the same off */
+ /* of a hard disk. */
+
+ fseek (fcrel.table[prim].fp,
+ index_pos (startprim, fcrel.table[prim]), SEEK_SET);
+
+ /* Load the primitives into the vec structure */
+ switch (pclass)
+ {
+ case EDGE:
+ {
+ for (i=startprim; i<endprim; i++)
+ {
+ if (stop_processing)
+ break;
+ row = read_next_row (fcrel.table[prim]);
+ if (set_member (i, primitives))
+ {
+ vec->lines[n] = (LINE_FEATURE*)xvt_zmalloc (sizeof (LINE_FEATURE));
+ if (vec->lines[n] == NULL)
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+ vec->lines[n]->id = i;
+ get_line_feature (vec->lines[n], row, fcrel.table[prim]);
+ vec->nr_lines += 1;
+ n++;
+
+ sprintf (string, "%ld Found", vec->nr_lines);
+ if (iUpdateStatus (StatusMessage, string) != TRUE)
+ xvt_note ("VPF2vec: Update Status failed.");
+ if (iCheckCancel() != TRUE)
+ stop_processing = TRUE;
+
+ if (vec->nr_lines == MAXLINES)
+ {
+ xvt_note ("Line feature limit reached (MAXLINES)");
+ stop_processing = TRUE;
+ }
+ }
+ free_row (row, fcrel.table[prim]);
+ }
+ break;
+ }
+ case ENTITY_NODE:
+ case CONNECTED_NODE:
+ {
+ for (i=startprim; i<endprim; i++)
+ {
+ if (stop_processing)
+ break;
+ row = read_next_row (fcrel.table[prim]);
+ if (set_member (i, primitives))
+ {
+ vec->points[n] = (POINT_FEATURE*)xvt_zmalloc (sizeof (POINT_FEATURE));
+ if (vec->points[n] == NULL)
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+
+ get_point_feature (vec->points[n], row, fcrel.table[prim]);
+ vec->nr_points += 1;
+ n++;
+
+ sprintf (string, "%ld Found", vec->nr_points);
+ if (iUpdateStatus (StatusMessage, string) != TRUE)
+ xvt_note ("VPF2vec: Update Status failed.");
+ if (iCheckCancel() != TRUE)
+ stop_processing = TRUE;
+
+ if (vec->nr_points == MAXPOINTS)
+ {
+ xvt_note ("Point feature limit reached (MAXPOINTS)");
+ stop_processing = TRUE;
+ }
+ }
+ free_row (row, fcrel.table[prim]);
+ }
+ break;
+ }
+ case FACE:
+ {
+ /* Must also open RNG, EDG, and FBR for drawing faces. */
+ strcpy (path, covpath);
+ strcat (path, tiledir);
+ strcat (path, "rng");
+ rngtable = vpf_open_table (path, disk, "rb", NULL);
+
+ strcpy (path, covpath);
+ strcat (path, tiledir);
+ strcat (path, "edg");
+ edgtable = vpf_open_table (path, disk, "rb", NULL);
+
+ strcpy (path, covpath);
+ strcat (path, tiledir);
+ strcat (path, "fbr");
+ fbrtable = vpf_open_table (path, disk, "rb", NULL);
+
+ /* startprim should never be 1 i.e. face_id=1 which is the */
+ /* universal face. DCW shows face_id=1 to be a valid feature */
+ /* which is incorrect. */
+
+ if (startprim == 1)
+ startprim = 2;
+
+
+ for (i=startprim; i<=endprim; i++)
+ {
+ if (stop_processing)
+ break;
+ row = read_next_row (fcrel.table[prim]);
+ if (set_member (i, primitives))
+ {
+ vec->areas[n] = (AREA_FEATURE*)xvt_zmalloc (sizeof (AREA_FEATURE));
+ if (vec->areas[n] == NULL)
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+
+ vec->areas[n]->id = n+1;
+ get_area_feature (vec->areas[n], i, fcrel.table[prim],
+ rngtable, edgtable);
+
+ vec->nr_areas += 1;
+ n++;
+
+ sprintf (string, "%ld Found", vec->nr_areas);
+ if (iUpdateStatus (StatusMessage, string) != TRUE)
+ xvt_note ("VPF2vec: Update Status failed.");
+ if (iCheckCancel() != TRUE)
+ stop_processing = TRUE;
+
+ if (vec->nr_areas == MAXAREAS)
+ {
+ xvt_note ("Area feature limit reached (MAXAREAS)");
+ stop_processing = TRUE;
+ }
+ }
+ free_row (row, fcrel.table[prim]);
+ }
+ vpf_close_table (&rngtable);
+ vpf_close_table (&edgtable);
+ vpf_close_table (&fbrtable);
+ break;
+ }
+ case TEXT:
+ {
+ for (i=startprim; i<endprim; i++)
+ {
+ if (stop_processing)
+ break;
+ row = read_next_row (fcrel.table[prim]);
+ if (set_member (i, primitives))
+ {
+ vec->text[n] = (TEXT_FEATURE*)xvt_zmalloc (sizeof (TEXT_FEATURE));
+ if (vec->text[n] == NULL)
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+
+ get_text_feature (vec->text[n], row, fcrel.table[prim]);
+ vec->nr_text += 1;
+ n ++;
+
+ sprintf (string, "%ld Found", vec->nr_text);
+ if (iUpdateStatus (StatusMessage, string) != TRUE)
+ xvt_note ("VPF2vec: Update Status failed.");
+ if (iCheckCancel() != TRUE)
+ stop_processing = TRUE;
+
+ if (vec->nr_text == MAXTEXT)
+ {
+ xvt_note ("Text feature limit reached (MAXTEXT)");
+ stop_processing = TRUE;
+ }
+ }
+ free_row (row, fcrel.table[prim]);
+ }
+ break;
+ }
+ } /* switch (pclass) */
+
+ vpf_close_table (&fcrel.table[prim]);
+ set_nuke (&primitives);
+ } /* Tile Loop */
+
+ if (!finished)
+ {
+ status = 0;
+ deselect_feature_class_relate (&fcrel);
+ break;
+ }
+ status = 1;
+ deselect_feature_class_relate (&fcrel);
+ } /* relpathnum loop */
+
+
+ /* Finished getting the features, now clean up */
+
+ /* Close the Feature Table if open */
+ vpf_close_table (&ft);
+
+ if (tilecover)
+ {
+ vpf_close_table (&tile_table);
+ }
+
+ set_nuke (&feature_rows);
+
+
+ /* Reallocate space for feature pointer addresses */
+ switch (pclass)
+ {
+ case EDGE:
+ {
+ temp_lines = (LINE_FEATURE**)xvt_zmalloc
+ (vec->nr_lines * sizeof (LINE_FEATURE*));
+ if (temp_lines == (LINE_FEATURE**)NULL)
+ {
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+ return (-1);
+ }
+ else
+ {
+ memcpy (temp_lines, vec->lines, (vec->nr_lines * sizeof (LINE_FEATURE*)));
+ xvt_free ((char*)vec->lines);
+ vec->lines = temp_lines;
+ vec->nr_features = vec->nr_lines;
+ }
+ break;
+ }
+ case ENTITY_NODE:
+ case CONNECTED_NODE:
+ {
+ temp_points = (POINT_FEATURE**)xvt_zmalloc
+ (vec->nr_points * sizeof (POINT_FEATURE*));
+ if (temp_points == (POINT_FEATURE**)NULL)
+ {
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+ return (-1);
+ }
+ else
+ {
+ memcpy (temp_points, vec->points, (vec->nr_points * sizeof (POINT_FEATURE*)));
+ xvt_free ((char*)vec->points);
+ vec->points = temp_points;
+ vec->nr_features = vec->nr_points;
+ }
+ break;
+ }
+ case FACE:
+ {
+ temp_areas = (AREA_FEATURE**)xvt_zmalloc
+ (vec->nr_areas * sizeof (AREA_FEATURE*));
+ if (temp_areas == (AREA_FEATURE**)NULL)
+ {
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+ return (-1);
+ }
+ else
+ {
+ memcpy (temp_areas, vec->areas, (vec->nr_areas * sizeof (AREA_FEATURE*)));
+ xvt_free ((char*)vec->areas);
+ vec->areas = temp_areas;
+ vec->nr_features = vec->nr_areas;
+ }
+ break;
+ }
+ case TEXT:
+ {
+ temp_text = (TEXT_FEATURE**)xvt_zmalloc
+ (vec->nr_text * sizeof (TEXT_FEATURE*));
+ if (temp_text == (TEXT_FEATURE**)NULL)
+ {
+ xvt_fatal ("GET_FEATURES: Out of memory!");
+ return (-1);
+ }
+ else
+ {
+ memcpy (temp_text, vec->text, (vec->nr_text * sizeof (TEXT_FEATURE*)));
+ xvt_free ((char*)vec->text);
+ vec->text = temp_text;
+ vec->nr_features = vec->nr_text;
+ }
+ break;
+ }
+ } /* switch(pclass) */
+
+
+ /* Destroy the Status Window */
+ iDestroyStatus();
+
+ return (0);
+ }
+
+
+
+/*****************************************************************************/
+/* GET_SELECTED_TILE_PRIMITIVES */
+/* */
+/* Purpose: */
+/* This function determines all of the selected primitive rows from */
+/* the selected features of a given tile. */
+/* */
+/* This function expects a feature class relationship structure that */
+/* has been successfully created with select_feature_class_relate() */
+/* from the feature table to the primitive. The primitive table in */
+/* the feature class relate structure must have been successfully */
+/* opened for the given tile. */
+/* Parameters: */
+/* covpath <input> == (char*) path th the VPF coverage. */
+/* fclass <input> == (char*) feature class. */
+/* fcrel <input> == (fcrel_type) feature class relate structure.*/
+/* primclass <input> == (int32) primitive class to select. */
+/* feature_rows <input> == (set_type) set of selected features. */
+/* mapenv <input> == (map_environment_type *) map environment. */
+/* tile <input> == (int32) tile number. */
+/* tiledir <input> == (char*) path to the tile directory. */
+/* status <output> == (int32*) status of the function: */
+/* 1 if completed, 0 if user escape. */
+/* return <output> == (set_type) set of primitives for the */
+/* features. */
+/*****************************************************************************/
+#ifdef PROTO
+ set_type get_selected_tile_primitives (char *covpath,
+ fcrel_type fcrel,
+ int32 primclass,
+ set_type feature_rows,
+ map_environment_type *mapenv,
+ int32 tile,
+ char *tiledir,
+ int32 *status)
+
+#else
+ set_type get_selected_tile_primitives (covpath, fcrel, primclass,
+ feature_rows, mapenv, tile,
+ tiledir, status)
+ char *covpath;
+ fcrel_type fcrel;
+ int32 primclass;
+ set_type feature_rows;
+ map_environment_type *mapenv;
+ int32 tile;
+ char *tiledir;
+ int32 *status;
+#endif
+
+ {
+ int32 feature, prim;
+ row_type row;
+ set_type primitive_rows;
+ set_type primitives;
+ int32 feature_rownum;
+ register int32 i, start,end;
+ linked_list_type feature_list;
+ position_type p;
+ extent_type pextent;
+
+ prim = 0;
+ feature = fcrel.nchain-1;
+
+ /* Assume that fcrel.table[prim] has been opened */
+
+ primitives.size = 0;
+ primitives.buf = NULL;
+
+ primitives = set_init(fcrel.table[prim].nrows+1);
+
+ /* All VPF products produced so far are in Decimal Degrees */
+ /* so no calls to mapextent is needed */
+ pextent = mapenv->mapextent; /*DGM*/
+
+ /* Get the set of primitive rows within the map extent */
+ primitive_rows = primitives_within_extent (pextent, covpath, tiledir,
+ primclass,
+ fcrel.table[prim].nrows);
+
+ if (set_empty (primitive_rows))
+ {
+ set_nuke (&primitive_rows);
+ return primitives;
+ }
+
+ end = set_max (primitive_rows);
+ start = set_min (primitive_rows);
+ if (end>0 && start<1)
+ start=1;
+ if (end>fcrel.table[prim].nrows)
+ end = fcrel.table[prim].nrows;
+
+
+ /* It turns out to be MUCH faster off of a CD-ROM to */
+ /* read each row and discard unwanted ones than to */
+ /* forward seek past them. It's about the same off */
+ /* of a hard disk. */
+
+ fseek(fcrel.table[prim].fp,index_pos(start,fcrel.table[prim]),
+ SEEK_SET);
+
+ for (i=start; i<=end; i++)
+ {
+ if (i>fcrel.table[prim].nrows)
+ break;
+
+ row = read_next_row (fcrel.table[prim]);
+ if (!row)
+ break;
+
+ if (!set_member (i, primitive_rows))
+ {
+ free_row (row, fcrel.table[prim]);
+ continue;
+ }
+
+ feature_list = fc_row_numbers (row, fcrel, tile);
+
+ free_row (row, fcrel.table[prim]);
+
+ if (!ll_empty(feature_list))
+ {
+ p = ll_first(feature_list);
+ while (!ll_end(p))
+ {
+ ll_element(p,&feature_rownum);
+ if ((feature_rownum < 1) ||
+ (feature_rownum > fcrel.table[feature].nrows))
+ {
+ p = ll_next(p);
+ continue;
+ }
+ if (set_member (feature_rownum, feature_rows))
+ {
+ set_insert (i, primitives);
+ break;
+ }
+ p = ll_next (p);
+ }
+ }
+ if (feature_list) ll_reset (feature_list);
+ }
+ set_nuke(&primitive_rows);
+
+ *status = 1;
+ return primitives;
+ }
+
+
+
+/******************************************************************************/
+/* PRIMITIVES_WITHIN_EXTENT */
+/* */
+/* Spatially select all of the primitives for a primitive class in a */
+/* specified tile that are contained within the specified map extent. */
+/* The map extent must be specified in decimal degrees. */
+/* Parameters: */
+/* extent <input> == (extent_type) spatial extent in decimal degrees. */
+/* covpath <input> == (char*) directory path to a VPF coverage. */
+/* tiledir <input> == (char*) tile directory from the tileref.aft. */
+/* primclass<input> == (int) primitive class identifier. Must be */
+/* EDGE, FACE, ENTITY_NODE, CONNECTED_NODE, or TEXT. */
+/* numprims <input> == (int32) number of rows in the associated */
+/* primitive table. */
+/* return <output> == (set_type) set of selected primitives. */
+/******************************************************************************/
+#ifdef PROTO
+ set_type primitives_within_extent (extent_type mapextent, char *covpath,
+ char *tiledir, int32 primclass,
+ int32 numprims)
+
+#else
+ set_type primitives_within_extent (mapextent, covpath, tiledir, primclass,
+ numprims)
+ extent_type mapextent;
+ char *covpath;
+ char *tiledir;
+ int32 primclass;
+ int32 numprims;
+#endif
+
+ {
+ char path[255];
+ BOOLEAN index_exists = FALSE;
+ set_type primitive_rows;
+ static char *spxname[] = {"","ESI","FSI","TSI","NSI","CSI"};
+ static char *brname[] = {"","EBR","FBR","TBR","NBR","CBR"};
+
+
+ primitive_rows.size = 0;
+ primitive_rows.buf = (char *)NULL;
+
+ /* 20 is a fairly arbitrary cutoff of the number of */
+ /* primitives that make a spatial index search worth while. */
+ if (numprims > 20)
+ {
+ strcpy (path, covpath);
+ strcat (path, tiledir);
+ strcat (path, spxname[primclass]);
+ if (muse_access (path, 0) == 0)
+ {
+ index_exists = TRUE;
+ primitive_rows = spatial_index_search (path,
+ (float)mapextent.x1, (float)mapextent.y1,
+ (float)mapextent.x2, (float)mapextent.y2);
+ }
+ }
+
+ if ((numprims <= 20) || (index_exists == FALSE))
+ {
+ /* Next best thing - bounding rectangle table */
+ strcpy (path, covpath);
+ strcat (path, tiledir);
+ strcat (path, brname[primclass]);
+ if ((muse_access (path,0) == 0) && (numprims > 20))
+ primitive_rows = bounding_select (path, mapextent, NOPROJ);
+ }
+
+ /* if the spatial index or bounding rectangle table were found then */
+ /* just turn on the entire set. */
+ if (primitive_rows.size == 0)
+ {
+ primitive_rows = set_init (numprims+1L);
+ set_on (primitive_rows);
+ }
+
+ return (primitive_rows);
+ }
+
+
+
+/******************************************************************************/
+/* bitfix */
+/******************************************************************************/
+#ifdef PROTO
+ static float bitfix (float f)
+#else
+ static float bitfix (f)
+ float f;
+#endif
+
+ {
+ int32 machine_byte_order = MACHINE_BYTE_ORDER;
+ union
+ {
+ float f;
+ unsigned char c[4];
+ } fltchr;
+
+ fltchr.f = f;
+
+ if (machine_byte_order == LEAST_SIGNIFICANT)
+ fltchr.c[0] = ((fltchr.c[0] >> 3) << 3);
+ else
+ fltchr.c[3] = ((fltchr.c[3] >> 3) << 3);
+
+ return (fltchr.f);
+ }
+
+
+/******************************************************************************/
+/* GET_TILE_SET */
+/******************************************************************************/
+#ifdef PROTO
+set_type get_tile_set (char* lib_path, extent_type extent, BOOLEAN *cancel_process)
+#else
+set_type get_tile_set (lib_path, extent, cancel_process)
+char* lib_path;
+extent_type extent;
+BOOLEAN *cancel_process;
+#endif
+ {
+ char path[255], StatusMessage[40], string[40];
+ int32 XMIN_, YMIN_, XMAX_, YMAX_, FAC_ID_;
+ float delta, retval;
+ int32 i, n, face_id, nr_tiles=0L;
+ static char sep[2] = {DIR_SEPARATOR,'\0'};
+ row_type row;
+ vpf_table_type fbr, aft;
+ fextent_type tile_extent, area_extent;
+ set_type tile_set;
+
+ /* Convert the double area extents to float */
+ area_extent.x1 = (float)extent.x1;
+ area_extent.y1 = (float)extent.y1;
+ area_extent.x2 = (float)extent.x2;
+ area_extent.y2 = (float)extent.y2;
+
+ /* Initialize the set to contain 0 elements */
+ tile_set = set_init (0L);
+
+ if (area_extent.y2 > 90.0)
+ {
+ delta = (area_extent.y2 - 90.0);
+ area_extent.y2 = 90.0;
+ area_extent.y1 -= delta;
+ }
+
+/* Open the tileref.fbr table */
+ strcpy (path, lib_path);
+ strcat (path, "tileref");
+ strcat (path, sep);
+ strcat (path, "fbr");
+ if (muse_access (path,0)!=0)
+ return (tile_set);
+
+ fbr = vpf_open_table (path, disk, "rb", NULL);
+ if (!fbr.fp)
+ {
+ vpf_close_table (&fbr);
+ return (tile_set);
+ }
+ XMIN_ = table_pos("XMIN",fbr);
+ YMIN_ = table_pos("YMIN",fbr);
+ XMAX_ = table_pos("XMAX",fbr);
+ YMAX_ = table_pos("YMAX",fbr);
+
+ /* Check for invalid fbr */
+ if (XMIN_ < 0 || YMIN_ < 0 || XMAX_ < 0 || YMAX_ < 0)
+ {
+ vpf_close_table(&fbr);
+ *cancel_process = TRUE;
+ return (tile_set);
+ }
+
+ /* Initialize tile_set */
+ tile_set = set_init (fbr.nrows);
+
+
+ /* Open the Tileref.aft table */
+ strcpy (path, lib_path);
+ strcat (path, "tileref");
+ strcat (path, sep);
+ strcat (path, "tileref.aft");
+ aft = vpf_open_table (path, disk, "rb", NULL);
+ if (!aft.fp)
+ {
+ vpf_close_table (&fbr);
+ vpf_close_table (&aft);
+ return (tile_set);
+ }
+
+ FAC_ID_ = table_pos ("FAC_ID", aft);
+
+ for (i=1; i<=aft.nrows; i++)
+ {
+ if (FAC_ID_ >= 0)
+ {
+ /* Uses the MIL-STD-2407 (26 May 1993) style of
+ the tile reference coverage with a FAC_ID */
+ row = read_next_row (aft);
+ get_table_element (FAC_ID_, row, aft, &face_id, &n);
+ free_row (row, aft);
+ }
+ else
+ {
+ /* Assume the library use the MIL-STD-600006
+ (before 26 May 1993) style of the tile reference
+ coverage, which assumes a 1:1 relationship between
+ the TILEREF.AFT and the FAC table, and discards
+ the universe face 1. */
+ face_id = i;
+ }
+
+ /* Ignore the Universal Face (face_id = 1) */
+ if (face_id == 1)
+ continue;
+
+ row = read_row (face_id, fbr);
+
+ get_table_element (XMIN_, row, fbr, &retval, &n);
+ tile_extent.x1 = bitfix (retval);
+ get_table_element (YMIN_, row, fbr, &retval, &n);
+ tile_extent.y1 = retval;
+ get_table_element (XMAX_, row, fbr, &retval, &n);
+ tile_extent.x2 = retval;
+ get_table_element (YMAX_, row, fbr, &retval, &n);
+ tile_extent.y2 = retval;
+
+ free_row (row, fbr);
+
+ if (geo_intersect (area_extent, tile_extent))
+ {
+ set_insert (i, tile_set);
+ nr_tiles++;
+ }
+
+ /* Update Status Window */
+ sprintf (StatusMessage, "TILE SEARCH");
+ sprintf (string, "%ld Found", nr_tiles);
+ if (iUpdateStatus (StatusMessage, string) != TRUE)
+ xvt_note ("VPF2vec: Update Status failed.");
+ if (iCheckCancel() != TRUE)
+ {
+ set_nuke (&tile_set);
+ vpf_close_table (&fbr);
+ vpf_close_table (&aft);
+ *cancel_process = TRUE;
+ return (tile_set);
+ }
+
+ }
+ vpf_close_table (&fbr);
+ vpf_close_table (&aft);
+
+ return (tile_set);
+ }
+
+
+/*****************************************************************************/
+/* get_fit_primitives */
+/* */
+/* Purpose: */
+/* Get the set of primitives in the given tile for the selected features */
+/* in the given feature class. Use the Feature Index Table instead of */
+/* the schema relationships. */
+/* Parameters: */
+/* covpath <input>==(char*) path to the VPF coverage. */
+/* primclass <input>==(int) primitive class to select. */
+/* fset <input> == (set_type*) set of feature IDs that meet the */
+/* thematic conditions. */
+/* sprims <input> == (set_type*) set of primitive IDs that meet */
+/* the spatial conditions. */
+/* tile <input>==(int32) tile number. */
+/* fca_id <input>==(int) Feature Class Attribute table id of the */
+/* selected feature class. */
+/* numprims <input>==(int) number of rows in the specified tile's */
+/* primitive table for the specified primitive */
+/* class. */
+/* status <output>==(int *) status of the function: */
+/* 1 if completed, 0 if user escape. */
+/* return <output>==(set_type) set of primitives for the features */
+/* */
+/* Modified 21 June 94 DGM */
+/*****************************************************************************/
+#ifdef PROTO
+ set_type get_fit_primitives (char *covpath, int32 primclass, set_type fset,
+ set_type sprims, int32 tile, int32 fca_id,
+ int32 numprims, BOOLEAN *stop_processing)
+#else
+ set_type get_fit_primitives (covpath, primclass, fset, sprims, tile,
+ fca_id, numprims, stop_processing)
+ char *covpath;
+ int32 primclass;
+ set_type fset;
+ set_type sprims;
+ int32 tile, fca_id, numprims;
+ BOOLEAN *stop_processing;
+#endif
+
+ {
+ set_type primitives, tileset, fcset, selset;
+ int32 i, start, end, prim_id, tile_id, fc_id, feature_id, count;
+ short short_tile_id;
+ int32 PRIM_ID_, TILE_ID_, FC_ID_, FEATURE_ID_;
+ vpf_table_type fit;
+ row_type row;
+ char path[255], StatusMessage[40], string[40];
+ static char *ptable[] = {"","EDG","FAC","TXT","END","CND"};
+
+ /* Initialize sets */
+ primitives = set_init (numprims+1);
+
+ /* Open the FIT */
+ strcpy (path, covpath);
+ strcat (path, ptable[primclass]);
+ strcat (path, ".FIT");
+ muse_check_path (path);
+
+ if (muse_access (path,0) != 0)
+ return primitives;
+
+ fit = vpf_open_table (path, disk, "rb", NULL);
+ if (!fit.fp)
+ return primitives;
+
+ /* Get the column positions of tile_id, primitive_id, feature_class_id, */
+ /* feature_id. */
+ TILE_ID_ = table_pos ("TILE_ID", fit);
+ PRIM_ID_ = table_pos ("PRIM_ID", fit);
+ FC_ID_ = table_pos ("FC_ID", fit);
+ if (FC_ID_ < 0)
+ FC_ID_ = table_pos ("FCA_ID", fit);
+ FEATURE_ID_ = table_pos ("FEATURE_ID", fit);
+
+ if ((TILE_ID_ < 0 && tile) || PRIM_ID_ < 0 ||
+ FC_ID_ < 0 || FEATURE_ID_ < 0)
+ {
+ vpf_close_table (&fit);
+ return primitives;
+ }
+
+ /* Look for TILE_ID thematic index */
+ tileset.size = 0;
+ if (tile)
+ {
+ if (fit.header[TILE_ID_].tdx)
+ {
+ strcpy (path, covpath);
+ strcat (path, fit.header[TILE_ID_].tdx);
+ muse_check_path (path);
+ if (muse_access (path,0) == 0)
+ {
+ if (fit.header[TILE_ID_].type == 'I')
+ {
+ tile_id = (int32)tile;
+ tileset = read_thematic_index (path, (char*)&tile_id);
+ }
+ else if (fit.header[TILE_ID_].type == 'S')
+ {
+ short_tile_id = tile;
+ tileset = read_thematic_index(path,(char *)&short_tile_id);
+ }
+ } /* if muse_access */
+ } /* if tile_id.tdx */
+ } /* if tile */
+
+ if (!tileset.size)
+ {
+ tileset = set_init (fit.nrows+1);
+ set_on (tileset);
+ set_delete (0, tileset);
+ }
+
+
+ /* Look for FC_ID thematic index */
+ fcset.size = 0;
+ if (fit.header[FC_ID_].tdx)
+ {
+ strcpy (path, covpath);
+ strcat (path, fit.header[FC_ID_].tdx);
+ muse_check_path (path);
+ if (muse_access (path, 0) == 0)
+ {
+ fc_id = (int32)fca_id;
+ fcset = read_thematic_index (path, (char*)&fc_id);
+ }
+ } /* if fc_id.tdx */
+
+ if (!fcset.size)
+ {
+ fcset = set_init (fit.nrows+1);
+ set_on (fcset);
+ set_delete (0, fcset);
+ }
+
+
+ /* Get the set of all FIT rows in the search tile that match the */
+ /* search fca_id. */
+ selset = set_intersection (tileset, fcset);
+ set_nuke (&tileset);
+ set_nuke (&fcset);
+
+ if (set_empty (selset))
+ {
+ vpf_close_table (&fit);
+ set_nuke (&selset);
+ return (primitives);
+ }
+
+ /* Now loop through the FIT and get the matching primitive ids */
+ start = set_min (selset);
+ end = set_max (selset);
+
+ /* Set file pointer to start record */
+ fseek (fit.fp, index_pos (start, fit), SEEK_SET);
+ for (i=start; i<=end; i++)
+ {
+
+ if ((i % 10) == 0)
+ {
+ /* Update Status Window */
+ sprintf (StatusMessage, "Retrieve Features");
+ sprintf (string, "Searching Tile Nr. %ld", tile);
+ if (iUpdateStatus (StatusMessage, string) != TRUE)
+ xvt_note ("GET_FIT_PRIMITIVES: Update Status failed.");
+ if (iCheckCancel() != TRUE)
+ {
+ vpf_close_table (&fit);
+ set_nuke (&selset);
+ *stop_processing = TRUE;
+ return (primitives);
+ }
+ }
+
+ /* Read each row of the fit starting at "start". If the row is a member */
+ /* of selset then get the tile_id. */
+ row = read_next_row (fit);
+ if (set_member (i, selset))
+ {
+
+ /* i is a member of selset so now we must test it to see if it */
+ /* meets the conditions of the thematic expression */
+ get_table_element(PRIM_ID_,row,fit,&prim_id,&count);
+ get_table_element(FC_ID_,row,fit,&fc_id,&count);
+ get_table_element(FEATURE_ID_,row,fit,&feature_id,&count);
+ tile_id = 0;
+ if (tile)
+ {
+ if (fit.header[TILE_ID_].type == 'I')
+ {
+ get_table_element (TILE_ID_, row, fit, &tile_id, &count);
+ }
+ else if (fit.header[TILE_ID_].type == 'S')
+ {
+ get_table_element(TILE_ID_, row, fit, &short_tile_id, &count);
+ tile_id = short_tile_id;
+ }
+ } /* if tile */
+
+
+ if (tile_id == tile && fc_id == fca_id &&
+ set_member (prim_id, sprims) && set_member (feature_id, fset))
+ {
+ set_insert (prim_id, primitives);
+ }
+ } /* if set_member */
+ free_row (row, fit);
+ } /* for i */
+
+ vpf_close_table (&fit);
+ set_nuke (&selset);
+
+ return (primitives);
+ }
+
+
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf2vec.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf2vec.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpf2vec.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,79 @@
+/**********************************************************************/
+/* VPF2VEC.H */
+/* Dan Maddux, DMASC/WGEA, 12 March 1993 */
+/**********************************************************************/
+#ifndef VPF2VEC_H
+#define VPF2VEC_H
+
+#ifndef __VPFVIEW_H__
+#include "vpfview.h"
+#endif
+#ifndef __VPFRELAT_H__
+#include "vpfrelat.h"
+#endif
+#ifndef PARAMS_H
+#include "params.h"
+#endif
+#ifndef H_VEC_D
+#include "vec_d.h"
+#endif
+
+/* Copied from grpim.h */
+#ifndef NoLine
+#define NoLine -1
+#endif
+
+#define PATHSIZE 255
+
+#if 0
+typedef struct
+ {
+ char *description;
+ int32 value;
+ double relem;
+ } DATA;
+typedef struct
+ {
+ double x;
+ double y;
+ } DATA_AREA;
+#endif
+
+/* Global Declarations */
+vpf_projection_type NOPROJ = {DDS, 0.0, 0.0, 0.0, 0.0, 0, 0.0, 0.0,
+ NULL, NULL, "Decimal Degrees "};
+
+
+
+/* Prototype Definitions */
+#ifdef PROTO
+ void vpf2vec (USER_PARAMS *params, VEC *vec);
+ set_type query_table (char *expression, vpf_table_type table);
+ int32 get_features (VEC*, view_type*, map_environment_type*);
+ set_type get_selected_tile_primitives (char *covpath, fcrel_type fcrel, int32 primclass,
+ set_type feature_rows, map_environment_type *mapenv,
+ int32 tile, char *tiledir, int32 *status);
+ set_type primitives_within_extent (extent_type mapextent, char *covpath, char *tiledir,
+ int32 primclass, int32 numprims);
+ set_type get_tile_set (char*, extent_type, BOOLEAN*);
+ void clean_up (view_type);
+ set_type get_fit_primitives (char *covpath, int32 primclass, set_type fset,
+ set_type sprims, int32 tile, int32 fca_id,
+ int32 numprims, BOOLEAN *stop_processing);
+ set_type get_prim_set (char *covpath, int32 primclass, char *expression,
+ vpf_table_type ft, set_type sprims,
+ int32 tile, int32 numprims);
+
+#else
+ void vpf2vec ();
+ set_type query_table ();
+ int32 get_features ();
+ set_type get_selected_tile_primitives ();
+ set_type primitives_within_extent ();
+ set_type get_tile_set ();
+ void clean_up ();
+ set_type get_fit_primitives ();
+ set_type get_prim_set ();
+#endif
+
+#endif /* VPF2VEC_H */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfbrows.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfbrows.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfbrows.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1068 @@
+/* VPFBROWS.C */
+
+#include "xvt.h"
+#include "musedir.h"
+#include "vpftable.h"
+#include "vpfbrows.h"
+#include "ibrowse.h"
+
+
+#define MAXLINES 10000
+#define MAXLENGTH 255
+
+static int32 maxlength;
+
+
+#ifdef PROTO
+ void vpf_browse (BROWSE *browse)
+#else
+ void vpf_browse (browse)
+ BROWSE *browse;
+#endif
+
+ {
+ SLIST slist;
+ SLIST_ELT elt;
+ char *string;
+
+ /* Display results in Browse Window */
+ wait_cursor ();
+
+ if (browse->string_length < MAXLENGTH)
+ maxlength = browse->string_length;
+ else
+ maxlength = MAXLENGTH;
+
+/*********************** QUIKFIX ****************************/
+/* Allowing the user to select the stringlength is causing */
+/* too many problems to correct at this time so force */
+/* maxlength to always = 255. dgm */
+/************************************************************/
+ maxlength = MAXLENGTH;
+
+ slist = table_to_slist (browse);
+ elt = slist_first (slist);
+ string = slist_get (slist, elt, 0L);
+ ibrowse_slist (string, slist);
+ return;
+ }
+
+
+#ifdef PROTO
+ SLIST table_to_slist (BROWSE *browse)
+#else
+ SLIST table_to_slist (browse)
+ BROWSE browse;
+#endif
+
+ {
+ SLIST browse_list;
+ vpf_table_type table;
+ date_type dval, *dptr;
+ id_triplet_type kval, *kptr;
+ coordinate_type cval, *cptr;
+ tri_coordinate_type zval, *zptr;
+ row_type row;
+ int32 i, j, k, n;
+ int ival, *iptr;
+ int32 lval, *lptr;
+ float fval, *fptr;
+ char *buf, ch, date[40];
+ char *string, *temp, index[4];
+
+
+ /* Initialize string count to 0 */
+ str2list (NULL, NULL);
+
+ memset (&table, '\0', sizeof (vpf_table_type));
+ memset (&index, '\0', sizeof (index));
+ string = xvt_zmalloc (maxlength);
+ temp = xvt_zmalloc (maxlength);
+ browse_list = slist_new();
+
+
+
+ /* Add the table path and name as the first string on the list */
+ strcpy (string, browse->path);
+ str2list (browse_list, string);
+
+ strcpy (string, " ");
+ str2list (browse_list, string);
+
+
+ /* Determine if the file to be browsed is an INDEX */
+ if ((strncmp (&browse->path[(strlen (browse->path) - 1)], "x", 1) == 0) ||
+ (strncmp (&browse->path[(strlen (browse->path) - 1)], "X", 1) == 0) ||
+ (strncmp (&browse->path[(strlen (browse->path) - 3)], "fcz", 3) == 0))
+ {
+ browse_list = idx_to_str (browse, browse_list);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ else if ((strncmp (&browse->path[(strlen (browse->path) - 2)], "si", 2) == 0) ||
+ (strncmp (&browse->path[(strlen (browse->path) - 2)], "SI", 2) == 0))
+ {
+ browse_list = si_to_str (browse, browse_list);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ else if ((strncmp (&browse->path[(strlen (browse->path) - 2)], "ti", 2) == 0) ||
+ (strncmp (&browse->path[(strlen (browse->path) - 2)], "TI", 2) == 0))
+ {
+ browse_list = ti_to_str (browse, browse_list);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+
+ table = vpf_open_table (browse->path, DISK, "rb", NULL);
+
+ if (browse->hdr_data)
+ {
+ /* Dump Table Header Info */
+ strcpy (string, "****** TABLE HEADER DATA ******");
+ str2list (browse_list, string);
+
+ sprintf (string, "NAME: %s", table.name);
+ str2list (browse_list, string);
+
+ strcpy (string, "DESCRIPTION: ");
+ if (table.description)
+ strcat (string, table.description);
+ else
+ strcat (string, "NULL");
+ str2list (browse_list, string);
+
+ strcpy (string, "NARRATIVE TABLE: ");
+ if (table.narrative)
+ strcat (string, table.narrative);
+ else
+ strcat (string, "NULL");
+ str2list (browse_list, string);
+
+ sprintf (string, "BYTE ORDER: %c", table.byte_order);
+ str2list (browse_list, string);
+
+ sprintf (string, "HEADER LENGTH: %ld", table.ddlen);
+ str2list (browse_list, string);
+
+ sprintf (string, "RECORD LENGTH: %ld", table.reclen);
+ str2list (browse_list, string);
+
+ sprintf (string, "NR RECORDS: %ld", table.nrows);
+ str2list (browse_list, string);
+
+ sprintf (string, "NR FIELDS: %ld", table.nfields);
+ str2list (browse_list, string);
+
+ strcpy (string, " ");
+ str2list (browse_list, string);
+ }
+
+
+ if (browse->field_desc)
+ {
+ strcpy (string, "****** FIELD DESCRIPTORS ******");
+ str2list (browse_list, string);
+
+ for (i=0; i<table.nfields; i++)
+ {
+ sprintf (string, "%ld", (i+1));
+ sprintf (&string[ strlen (string)], " <%s>", table.header[i].name);
+ sprintf (&string[ strlen (string)], "<%c>", table.header[i].type);
+ sprintf (&string[ strlen (string)], "<%ld>", table.header[i].count);
+ sprintf (&string[ strlen (string)], "<%c>", table.header[i].keytype);
+ sprintf (&string[ strlen (string)], "<%s>", table.header[i].description);
+ sprintf (&string[ strlen (string)], "<%s>", table.header[i].vdt);
+ sprintf (&string[ strlen (string)], "<%s>", table.header[i].tdx);
+ sprintf (&string[ strlen (string)], "<%s>", table.header[i].narrative);
+ str2list (browse_list, string);
+ }
+
+ strcpy (string, " ");
+ str2list (browse_list, string);
+ }
+
+ strcpy (string, "****** TABLE RECORD DATA ******");
+ str2list (browse_list, string);
+
+ if (browse->start_record < 1)
+ browse->start_record = 1;
+ if (browse->end_record > table.nrows)
+ browse->end_record = table.nrows;
+
+ for (i=browse->start_record; i<=browse->end_record; i++)
+ {
+ row = get_row (i, table);
+ memset (string, '\0', maxlength);
+ sprintf (string, "%ld: ", i);
+ for (j=0; j<table.nfields; j++)
+ {
+ switch (table.header[j].type)
+ {
+ case 'T': /* Text */
+ if ((int)table.header[j].count==1) /* String is one char */
+ {
+ get_table_element (j, row, table, &ch, &n);
+ sprintf (temp, "<%c>", ch);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ else /* String is greater than one char int32 */
+ {
+ buf = (char*)get_table_element (j, row, table, NULL, &n);
+ n = strlen (buf);
+ /* Filter out carriage control characters */
+ for (k=0; k<n; k++)
+ if (buf[k] == '\n' || buf[k] == '\r')
+ buf[k] = ' ';
+ sprintf (temp, "<%s>", buf);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ xvt_free (buf);
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ xvt_free (buf);
+ }
+ break;
+ case 'I': /* Int32 Integer */
+ if ((int)table.header[j].count==1)
+ {
+ get_table_element (j, row, table, &lval, &n);
+ sprintf (temp, "<%ld>", lval);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ else
+ {
+ lptr = (int32*)get_table_element (j, row, table, NULL, &n);
+ for (k=0; k<n; k++)
+ {
+ sprintf (temp, "<%ld>",lptr[k]);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ xvt_free ((char*)lptr);
+ }
+ break;
+ case 'S': /* Short */
+ if ((int)table.header[j].count==1)
+ {
+ get_table_element (j, row, table, &ival, &n);
+ sprintf (temp, "<%d>", ival);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ else
+ {
+ iptr = (int*)get_table_element (j, row, table, NULL, &n);
+ for (k=0; k<n; k++)
+ {
+ sprintf (temp, "<%d>",iptr[k]);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ xvt_free ((char*)iptr);
+ }
+ break;
+ case 'F': /* Float */
+ if ((int)table.header[j].count==1)
+ {
+ get_table_element (j, row, table, &fval, &n);
+ sprintf (temp, "<%f>", fval);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ else
+ {
+ fptr = (float*)get_table_element (j, row, table, NULL, &n);
+ for (k=0; k<n; k++)
+ {
+ sprintf (temp, "<%f>", fptr[k]);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ xvt_free ((char*)fptr);
+ }
+ break;
+ case 'C': /* Coordinate pair */
+ if ((int)table.header[j].count==1)
+ {
+ get_table_element (j, row, table, &cval, &n);
+ sprintf (temp,"<%lf,%lf>", cval.x, cval.y);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ else
+ {
+ cptr = (coordinate_type*)get_table_element
+ (j, row, table, NULL, &n);
+#if 0
+ for (k=0; k<n; k++)
+ {
+ sprintf (temp, "<%lf,%lf>", cptr[k].x, cptr[k].y);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+#endif
+ if (str2list (browse_list, string) != TRUE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ for (k=0; k<n; k++)
+ {
+ sprintf (string, " %lf, %lf", cptr[k].x, cptr[k].y);
+ if (str2list (browse_list, string) != TRUE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ xvt_free ((char*)cptr);
+ }
+ break;
+ case 'K':
+ if ((int)table.header[j].count==1)
+ {
+ get_table_element (j, row, table, &kval, &n);
+ sprintf (temp, "<%ld,%ld,%ld>",
+ kval.id, kval.tile, kval.exid);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ else
+ {
+ kptr = get_table_element (j, row, table, NULL, &n);
+ for (k=0; k<n; k++)
+ {
+ sprintf (temp, "<%ld,%ld,%ld>",
+ kptr[k].id, kptr[k].tile, kptr[k].exid);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ xvt_free ((char*)kptr);
+ }
+ break;
+ case 'D': /* Date */
+ if ((int)table.header[j].count==1)
+ {
+ get_table_element (j, row, table, &dval, &n);
+ format_date (dval, date);
+ sprintf (temp, "<%s>", date);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ else
+ {
+ dptr = get_table_element (j, row, table, NULL, &n);
+ for (k=0; k<n; k++)
+ {
+ format_date (dptr[k], date);
+ sprintf (temp, "<%s>", date);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ xvt_free ((char*)dptr);
+ }
+ break;
+ case 'Z': /* 3D Coordinates */
+ if ((int)table.header[j].count==1)
+ {
+ get_table_element (j, row, table, &zval, &n);
+ sprintf (temp, "<%f,%f,%f>", zval.x, zval.y, zval.z);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ else
+ {
+ zptr = (tri_coordinate_type*)get_table_element
+ (j, row, table, NULL, &n);
+ for (k=1; k<n; k++)
+ {
+ sprintf (temp, "<%f,%f,%f>",
+ zptr[k].x, zptr[k].y, zptr[k].z);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ }
+ xvt_free ((char*)zptr);
+ }
+ break;
+ default:
+ break;
+ } /* switch */
+ }
+ if (str2list (browse_list, string) == FALSE)
+ {
+ free_row (row, table);
+ vpf_close_table (&table);
+ xvt_free (string);
+ xvt_free (temp);
+ return (browse_list);
+ }
+ free_row (row, table);
+ }
+ strcpy (string, "END_OF_TABLE");
+ slist_add (browse_list, NULL, string, 0L);
+ vpf_close_table (&table);
+ if (string)
+ xvt_free (string);
+ if (temp)
+ xvt_free (temp);
+ return (browse_list);
+ }
+
+
+
+/**************************************************************************/
+/* IDX_TO_STR */
+/**************************************************************************/
+#ifdef PROTO
+ SLIST idx_to_str (BROWSE *browse, SLIST browse_list)
+#else
+ SLIST idx_to_str (browse, browse_list)
+ BROWSE *browse;
+ SLIST browse_list;
+#endif
+
+ {
+ FILE *file;
+ char *string;
+ int32 entries, size, offset, length, i;
+
+ /* Initialize string count to 0 */
+ str2list (NULL, NULL);
+
+ file = muse_file_open (browse->path, "rb");
+ string = xvt_zmalloc(sizeof (char) * maxlength);
+
+ VpfRead (&entries, VpfInteger, 1, file);
+
+ VpfRead (&size, VpfInteger, 1, file);
+
+ /* Print Header Data */
+ if (browse->hdr_data)
+ {
+ strcpy (string, "****** VARIABLE LENGTH INDEX HEADER DATA ******");
+ str2list (browse_list, string);
+
+ sprintf (string, "Entries: %ld", entries);
+ str2list (browse_list, string);
+
+ sprintf (string, "Size: %ld", size);
+ str2list (browse_list, string);
+
+ strcpy (string, " ");
+ str2list (browse_list, string);
+ }
+
+
+ strcpy (string, "***** RECORD DATA *****");
+ str2list (browse_list, string);
+
+ if (browse->start_record < 1)
+ browse->start_record = 1;
+ if (browse->end_record > entries)
+ browse->end_record = entries;
+
+ for (i = browse->start_record; i <= browse->end_record; i++)
+ {
+ VpfRead (&offset, VpfInteger, 1, file);
+ VpfRead (&length, VpfInteger, 1, file);
+ sprintf (string, "%ld: %ld, %ld", i, offset, length);
+ if (str2list (browse_list, string) == FALSE)
+ {
+ fclose (file);
+ xvt_free (string);
+ return (browse_list);
+ }
+ }
+ fclose (file);
+ strcpy (string, "END_OF_TABLE");
+ slist_add (browse_list, NULL, string, 0L);
+ xvt_free (string);
+ return (browse_list);
+ } /* END IDX_TO_STR */
+
+
+
+/**************************************************************************/
+/* SI_TO_STR */
+/**************************************************************************/
+#ifdef PROTO
+ SLIST si_to_str (BROWSE *browse, SLIST browse_list)
+#else
+ SLIST si_to_str (browse, browse_list)
+ BROWSE *browse;
+ SLIST browse_list;
+#endif
+
+ {
+ FILE *file;
+ char *string;
+ unsigned char x1, y1, x2, y2;
+ int32 numprim, nnode, id, offset, count, i;
+ float xmin, ymin, xmax, ymax;
+
+ /* Initialize string count to 0 */
+ str2list (NULL, NULL);
+
+ file = muse_file_open (browse->path, "rb");
+ string = xvt_zmalloc(sizeof (char) * maxlength);
+
+ /* Header Info */
+ VpfRead (&numprim, VpfInteger, 1, file);
+ VpfRead (&xmin, VpfFloat, 1, file);
+ VpfRead (&ymin, VpfFloat, 1, file);
+ VpfRead (&xmax, VpfFloat, 1, file);
+ VpfRead (&ymax, VpfFloat, 1, file);
+ VpfRead (&nnode, VpfInteger, 1, file);
+
+ if (browse->hdr_data)
+ {
+ strcpy (string, "****** SPATIAL INDEX HEADER DATA ******");
+ str2list (browse_list, string);
+
+ sprintf (string, "Number of Primitives: %ld", numprim);
+ str2list (browse_list, string);
+
+ sprintf (string, "Xmin: %f", xmin);
+ str2list (browse_list, string);
+
+ sprintf (string, "Ymin: %f", ymin);
+ str2list (browse_list, string);
+
+ sprintf (string, "Xmax: %f", xmax);
+ str2list (browse_list, string);
+
+ sprintf (string, "Ymax: %f", ymax);
+ str2list (browse_list, string);
+
+ sprintf (string, "Number of Nodes: %ld", nnode);
+ str2list (browse_list, string);
+ }
+
+ strcpy (string, "****** SPATIAL INDEX BIN ARRAY RECORDS ******");
+ str2list (browse_list, string);
+
+ if (browse->start_record < 1)
+ browse->start_record = 1;
+ if (browse->end_record > nnode)
+ browse->end_record = nnode;
+
+ for (i=browse->start_record; i<=browse->end_record; i++)
+ {
+ VpfRead (&offset, VpfInteger, 1, file);
+ VpfRead (&count, VpfInteger, 1, file);
+ sprintf (string, "Node: %ld, Offset: %ld, Count: %ld",
+ i, offset, count);
+ if (str2list (browse_list, string) == FALSE)
+ {
+ if (file)
+ fclose (file);
+ xvt_free (string);
+ return (browse_list);
+ }
+ }
+ strcpy (string, " ");
+ str2list (browse_list, string);
+
+ /* Position the file pointer to the beginning of the Bin Data Records */
+ /* if not there already. */
+ if (browse->end_record != nnode)
+ {
+ while (i<=nnode)
+ {
+ VpfRead (&offset, VpfInteger, 1, file);
+ VpfRead (&count, VpfInteger, 1, file);
+ i++;
+ }
+ }
+
+
+ strcpy (string, "****** SPATIAL INDEX BIN DATA RECORDS ******");
+ str2list (browse_list, string);
+
+ if (browse->start_record < 1)
+ browse->start_record = 1;
+ if (browse->end_record > numprim)
+ browse->end_record = numprim;
+
+ for (i=browse->start_record; i<=browse->end_record; i++)
+ {
+ VpfRead (&x1, VpfChar, 1, file);
+ VpfRead (&y1, VpfChar, 1, file);
+ VpfRead (&x2, VpfChar, 1, file);
+ VpfRead (&y2, VpfChar, 1, file);
+ VpfRead (&id, VpfInteger, 1, file);
+ sprintf (string, "X1: %3d, Y1: %3d, X2: %3d, Y2: %3d, ID: %d",
+ x1, y1, x2, y2, id);
+ if (str2list (browse_list, string) == FALSE)
+ {
+ xvt_free (string);
+ if (file)
+ fclose (file);
+ return (browse_list);
+ }
+ }
+ if (file)
+ fclose (file);
+ strcpy (string, "END_OF_TABLE");
+ slist_add (browse_list, NULL, string, 0L);
+ xvt_free (string);
+ return (browse_list);
+ }
+
+
+
+/**************************************************************************/
+/* TI_TO_STR */
+/**************************************************************************/
+#ifdef PROTO
+ SLIST ti_to_str (BROWSE *browse, SLIST browse_list)
+#else
+ SLIST ti_to_str (browse, browse_list)
+ BROWSE *browse;
+ SLIST browse_list;
+#endif
+
+ {
+ size_t nr_elts, nr_entries, i, maxlines;
+ int32 length, nr_rows, *count;
+ char indx_type, data_type, index_data_type;
+ char *string, *temp, name[13], col[26], unused[5];
+ int32 offset, nr_records;
+ char *t_elt;
+ int32 i_elt;
+ short s_elt;
+ float f_elt;
+ double r_elt;
+ FILE *file;
+
+ /* Initialize string count to 0 */
+ str2list (NULL, NULL);
+
+ file = muse_file_open (browse->path, "rb");
+ string = (char*)xvt_zmalloc (sizeof (char) * maxlength);
+ temp = (char*)xvt_zmalloc (sizeof (char) * maxlength);
+ memset (name, '\0', sizeof(name));
+ memset (col, '\0', sizeof(col));
+
+ VpfRead (&length, VpfInteger, 1, file);
+ VpfRead (&nr_entries, VpfInteger, 1, file);
+ VpfRead (&nr_rows, VpfInteger, 1, file);
+ VpfRead (&indx_type, VpfChar, 1, file);
+ VpfRead (&data_type, VpfChar, 1, file);
+ VpfRead (&nr_elts, VpfInteger, 1, file);
+ VpfRead (&index_data_type, VpfChar, 1, file);
+ VpfRead (&name, VpfChar, 12, file);
+ VpfRead (&col, VpfChar, 25, file);
+ VpfRead (&unused, VpfChar, 4, file);
+
+ if (browse->hdr_data)
+ {
+ strcpy (string, "***** THEMATIC INDEX HEADER DATA *****");
+ str2list (browse_list, string);
+
+ sprintf (string, "Header_size: %ld", length);
+ str2list (browse_list, string);
+
+ sprintf (string, "Nr_entries: %ld", (int32)nr_entries);
+ str2list (browse_list, string);
+
+ sprintf (string, "Nr_rows: %ld", nr_rows);
+ str2list (browse_list, string);
+
+ sprintf (string, "Index_type: %c", indx_type);
+ str2list (browse_list, string);
+
+ sprintf (string, "Data_type: %c", data_type);
+ str2list (browse_list, string);
+
+ sprintf (string, "Nr_elements: %ld", (int32)nr_elts);
+ str2list (browse_list, string);
+
+ sprintf (string, "Index_data_type: %c", index_data_type);
+ str2list (browse_list, string);
+
+ sprintf (string, "Table_name: %s", name);
+ str2list (browse_list, string);
+
+ sprintf (string, "Column_name: %s", col);
+ str2list (browse_list, string);
+
+ sprintf (string, "Unused_field: %s", unused);
+ str2list (browse_list, string);
+ }
+ strcpy (string, " ");
+ str2list (browse_list, string);
+
+
+ count = (int32*)xvt_zmalloc (sizeof(int32) * nr_entries);
+
+ /* Divide the remaining allowable text lines between the Index Directory */
+ /* records and the Index Data records */
+ maxlines = MAXLINES / 2;
+
+ strcpy (string, "***** INDEX DIRECTORY RECORDS *****");
+ str2list (browse_list, string);
+
+ /* Read Index Directory Records */
+ switch (data_type)
+ {
+ case 'T': /* Character String */
+ t_elt = (char*) xvt_zmalloc ((size_t) nr_elts);
+ for (i=0; i<nr_entries; i++)
+ {
+ VpfRead (t_elt, VpfChar, nr_elts, file);
+ VpfRead (&offset, VpfInteger, 1, file);
+ VpfRead (&nr_records, VpfInteger, 1, file);
+ count[i] = nr_records;
+ sprintf (string, "Elt: %s Offset: %ld Nr_records: %ld",
+ t_elt, offset, nr_records);
+ if ((str2list (browse_list, string) == FALSE) || (i == maxlines))
+ {
+ xvt_free (t_elt);
+ break;
+ }
+ }
+ xvt_free (t_elt);
+ break;
+ case 'S': /* Short Integer */
+ for (i=0; i<nr_entries; i++)
+ {
+ VpfRead (&s_elt, VpfShort, nr_elts, file);
+ VpfRead (&offset, VpfInteger, 1, file);
+ VpfRead (&nr_records, VpfInteger, 1, file);
+ count[i] = nr_records;
+ sprintf (string, "Elt: %d Offset: %ld Nr_records: %ld",
+ s_elt, offset, nr_records);
+ if ((str2list (browse_list, string) == FALSE) || (i == maxlines))
+ break;
+ }
+ break;
+ case 'I': /* Int32 Integer */
+ for (i=0; i<nr_entries; i++)
+ {
+ VpfRead (&i_elt, VpfInteger, nr_elts, file);
+ VpfRead (&offset, VpfInteger, 1, file);
+ VpfRead (&nr_records, VpfInteger, 1, file);
+ count[i] = nr_records;
+ sprintf (string, "Elt: %ld Offset: %ld Nr_records: %ld",
+ i_elt, offset, nr_records);
+ if ((str2list (browse_list, string) == FALSE) || (i == maxlines))
+ break;
+ }
+ break;
+ case 'F': /* 4 Byte Float */
+ for (i=0; i<nr_entries; i++)
+ {
+ VpfRead (&f_elt, VpfFloat, nr_elts, file);
+ VpfRead (&offset, VpfInteger, 1, file);
+ VpfRead (&nr_records, VpfInteger, 1, file);
+ count[i] = nr_records;
+ sprintf (string, "Elt: %f Offset: %ld Nr_records: %ld",
+ f_elt, offset, nr_records);
+ if ((str2list (browse_list, string) == FALSE) || (i == maxlines))
+ break;
+ }
+ break;
+ case 'R': /* 8 Byte Float */
+ for (i=0; i<nr_entries; i++)
+ {
+ VpfRead (&r_elt, VpfDouble, nr_elts, file);
+ VpfRead (&offset, VpfInteger, 1, file);
+ VpfRead (&nr_records, VpfInteger, 1, file);
+ count[i] = nr_records;
+ sprintf (string, "Elt: %f Offset: %ld Nr_records: %ld",
+ r_elt, offset, nr_records);
+ if ((str2list (browse_list, string) == FALSE) || (i == maxlines))
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ strcpy (string, " ");
+ str2list (browse_list, string);
+
+
+ /* Reset maxlines to the defined value */
+ maxlines = MAXLINES;
+
+ strcpy (string, "***** INDEX DATA RECORDS *****");
+ str2list (browse_list, string);
+
+ /* Read Index Data Records */
+ if ((indx_type == 'I') || (indx_type == 'T'))
+ {
+ switch (index_data_type)
+ {
+ case 'S': /* Short Integer */
+ {
+ short *row_nrs;
+ int32 j;
+
+ for (i=0; i<nr_entries; i++)
+ {
+ row_nrs = (short*)xvt_zmalloc (sizeof(short) * (size_t)count[i]);
+ VpfRead (row_nrs, VpfShort, (size_t)count[i], file);
+ sprintf (string, "%d Count: %ld %s: ", (i+1), count[i], col);
+ for (j=0; j<count[i]; j++)
+ {
+ sprintf (temp, "<%hd>",row_nrs[j]);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ xvt_free ((char*)row_nrs);
+ xvt_free ((char*)count);
+ xvt_free (temp);
+ xvt_free (string);
+ return (browse_list);
+ }
+ }
+ xvt_free ((char*)row_nrs);
+ }
+ break;
+ } /* case S */
+ case 'I': /* Int32 Integer */
+ {
+ int32 j, *row_nrs;
+
+ for (i=0; i<nr_entries; i++)
+ {
+ row_nrs = (int32*)xvt_zmalloc (sizeof(int32) * (size_t)count[i]);
+ VpfRead (row_nrs, VpfInteger, (size_t)count[i], file);
+ sprintf (string, "%d Count: %ld %s: ", (i+1), count[i], col);
+ for (j=0; j<count[i]; j++)
+ {
+ sprintf (temp, "<%ld>",row_nrs[j]);
+ if (add_string (browse_list, string, temp) == FALSE)
+ {
+ xvt_free ((char*)row_nrs);
+ xvt_free ((char*)count);
+ xvt_free (temp);
+ xvt_free (string);
+ return (browse_list);
+ }
+ }
+ xvt_free ((char*)row_nrs);
+ }
+ break;
+ } /* case I */
+ } /* switch */
+ } /* if */
+
+ strcpy (string, "END_OF_TABLE");
+ slist_add (browse_list, NULL, string, 0L);
+ xvt_free (string);
+ xvt_free (temp);
+ if (count)
+ xvt_free ((char*)count);
+ fclose (file);
+ return (browse_list);
+ }
+
+
+
+/***************************************************************************/
+/* ADD_STRING */
+/***************************************************************************/
+
+#ifdef PROTO
+ BOOLEAN add_string (SLIST list, char *string, char* temp)
+#else
+ BOOLEAN add_string (list, string, temp)
+ SLIST list;
+ char *string;
+ char *temp;
+#endif
+
+
+ {
+ size_t l1, l2;
+
+
+ /* See if the string has enough room left to cat temp */
+ l1 = strlen (temp);
+ l2 = strlen (string);
+
+ if ((l1 + l2) > maxlength)
+ {
+ /* Not enough room left in string so add string to slist and start fresh */
+ if (str2list (list, string) != TRUE)
+ {
+ /* MAXLINES reached */
+ return (FALSE);
+ }
+ strcpy (string, temp);
+ return (TRUE);
+ }
+ /* See if temp will fit into string */
+ if (l1 < (maxlength - l2))
+ {
+ /* Copy contents of temp to string */
+ strcat (string, temp);
+ }
+ else /* Temp is too big to fit into one string so break it up */
+ {
+ short start, end = 0;
+ BOOLEAN done = FALSE;
+
+ while (!done)
+ {
+ start = end;
+ end += maxlength - 1;
+ strncpy (string, &temp[start], end);
+ if (str2list (list, string) != TRUE)
+ {
+ /* MAXLINES reached */
+ return (FALSE);
+ }
+ if (end >= l1)
+ done = TRUE;
+ }
+ }
+ return (TRUE);
+ }
+
+
+/***************************************************************************/
+/* STR2LIST */
+/***************************************************************************/
+
+#ifdef PROTO
+ BOOLEAN str2list (SLIST list, char* string)
+#else
+ BOOLEAN str2list (list, string)
+ SLIST list;
+ char *string;
+#endif
+
+ {
+ static int32 nr_lines;
+
+ /* Use a Null string to initialize nr_lines */
+ if (string == (char*)NULL)
+ {
+ nr_lines = 0L;
+ return (TRUE);
+ }
+
+ slist_add (list, NULL, string, 0L);
+ nr_lines++;
+
+ /* Check nr_lines for MAXLINES */
+ if (nr_lines >= MAXLINES)
+ {
+ /* Close up shop */
+ strcpy (string, "MAXLINES REACHED");
+ slist_add (list, NULL, string, 0L);
+ return (FALSE);
+ }
+ else
+ /* Start a new string */
+ memset (string, '\0', maxlength);
+
+ return (TRUE);
+ }
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfbrows.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfbrows.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfbrows.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,45 @@
+/* VPF_BROWSE.H */
+#ifndef vpf_browse_h
+#define vpf_browse_h
+
+#include "xvt.h"
+#include "vpftable.h"
+
+#ifndef BOOLEAN
+typedef short BOOLEAN;
+#endif
+
+/* Browse Data Structure Definition */
+typedef struct
+ {
+ char *path;
+ BOOLEAN hdr_data;
+ BOOLEAN field_desc;
+ BOOLEAN field_labels;
+ BOOLEAN cancel;
+ int32 nr_fields;
+ int32 start_record;
+ int32 end_record;
+ int32 string_length;
+ } BROWSE;
+
+/* Prototype Declaration */
+#ifdef PROTO
+ void vpf_browse (BROWSE*);
+ SLIST table_to_slist (BROWSE*);
+ SLIST idx_to_str (BROWSE*, SLIST);
+ SLIST si_to_str (BROWSE*, SLIST);
+ SLIST ti_to_str (BROWSE*, SLIST);
+ BOOLEAN add_string (SLIST, char*, char*);
+ BOOLEAN str2list (SLIST, char*);
+#else
+ void vpf_browse ();
+ SLIST table_to_slist ();
+ SLIST idx_to_str ();
+ SLIST si_to_str ();
+ SLIST ti_to_str ();
+ BOOLEAN add_string ();
+ BOOLEAN str2list ();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfdproj.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfdproj.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfdproj.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,446 @@
+/* Vpfdproj dummy routines */
+
+#ifndef __VPFPROJ_H__
+#include "vpfproj.h"
+#endif
+#ifndef NOREF
+#define NOREF(a) a = a
+#endif
+
+#ifdef PROTO
+ int32 plate_carree_fwd (double *x, double *y)
+#else
+ int32 plate_carree_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return(0);
+ }
+
+#ifdef PROTO
+ int32 plate_carree_inv (double *x, double *y)
+#else
+ int32 plate_carree_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return(0);
+ }
+
+#ifdef PROTO
+ void set_vpf_forward_projection (vpf_projection_type proj)
+#else
+void set_vpf_forward_projection (proj)
+vpf_projection_type proj;
+#endif
+
+ {
+ NOREF (proj);
+ return;
+ }
+
+#ifdef PROTO
+ void set_vpf_inverse_projection (vpf_projection_type proj)
+#else
+ void set_vpf_inverse_projection (proj)
+ vpf_projection_type proj;
+#endif
+
+ {
+ NOREF (proj);
+ return;
+ }
+
+#ifdef PROTO
+ vpf_projection_type set_vpf_projection_parms (vpf_projection_code code,
+ extent_type extent)
+#else
+ vpf_projection_type set_vpf_projection_parms (code, extent)
+ vpf_projection_code code;
+ extent_type extent;
+#endif
+
+ {
+ vpf_projection_type dummy;
+ NOREF (code);
+ NOREF (extent);
+ return (dummy);
+ }
+
+#ifdef PROTO
+ vpf_projection_type get_vpf_forward_projection()
+#else
+ vpf_projection_type get_vpf_forward_projection ()
+#endif
+
+ {
+ vpf_projection_type dummy;
+ return (dummy);
+ }
+
+#ifdef PROTO
+ vpf_projection_type get_vpf_inverse_projection()
+#else
+ vpf_projection_type get_vpf_inverse_projection ()
+#endif
+
+ {
+ vpf_projection_type dummy;
+ return (dummy);
+ }
+
+#ifdef PROTO
+ int32 albers_equal_area_fwd (double *x, double *y)
+#else
+ int32 albers_equal_area_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 albers_equal_area_inv( double *x, double *y )
+#else
+ int32 albers_equal_area_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 azimuthal_equal_area_fwd( double *x, double *y )
+#else
+ int32 azimuthal_equal_area_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 azimuthal_equal_area_inv (double *x, double *y )
+#else
+ int32 azimuthal_equal_area_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 azimuthal_equal_distance_fwd (double *x, double *y )
+#else
+ int32 azimuthal_equal_distance_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 azimuthal_equal_distance_inv (double *x, double *y )
+#else
+ int32 azimuthal_equal_distance_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 gnomonic_fwd (double *x, double *y )
+#else
+ int32 gnomonic_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 gnomonic_inv (double *x, double *y )
+#else
+ int32 gnomonic_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 lambert_conformal_conic_fwd ( double *x, double *y )
+#else
+ int32 lambert_conformal_conic_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 lambert_conformal_conic_inv (double *x, double *y )
+#else
+ int32 lambert_conformal_conic_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 lambert_equal_area_fwd( double *x, double *y )
+#else
+ int32 lambert_equal_area_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 lambert_equal_area_inv (double *x, double *y )
+#else
+ int32 lambert_equal_area_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 mercator_fwd( double *x, double *y )
+#else
+ int32 mercator_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 mercator_inv (double *x, double *y )
+#else
+ int32 mercator_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 oblique_mercator_fwd( double *x, double *y )
+#else
+ int32 oblique_mercator_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 oblique_mercator_inv ( double *x, double *y )
+#else
+ int32 oblique_mercator_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 orthographic_fwd ( double *x, double *y )
+#else
+ int32 orthographic_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 orthographic_inv ( double *x, double *y )
+#else
+ int32 orthographic_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 polar_stereographic_fwd (double *x, double *y)
+#else
+ int32 polar_stereographic_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 polar_stereographic_inv( double *x, double *y )
+#else
+ int32 polar_stereographic_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 transverse_mercator_fwd( double *x, double *y )
+#else
+ int32 transverse_mercator_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 transverse_mercator_inv ( double *x, double *y )
+#else
+ int32 transverse_mercataor_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 UTM_fwd( double *x, double *y )
+#else
+ int32 UTM_fwd (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 UTM_inv( double *x, double *y )
+#else
+ int32 UTM_inv (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 forward_project( double *x, double *y )
+#else
+ int32 forward_project (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+#ifdef PROTO
+ int32 inverse_project( double *x, double *y )
+#else
+ int32 inverse_project (x, y)
+ double *x, *y;
+#endif
+
+ {
+ NOREF (x);
+ NOREF (y);
+ return (0);
+ }
+
+
+#ifdef PROTO
+ void set_vpf_coordinate_projection( vpf_projection_type proj )
+#else
+ void set_vpf_coordinate_projection (proj)
+ vpf_projection_type proj;
+#endif
+ {
+ NOREF (proj);
+ return;
+ }
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfio.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfio.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfio.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,129 @@
+/* char VPFIO_H_ID[] = "@(#) vpfio.h 2.3 11/9/91 ESRI Applications Programming" ; */
+/* ========================================================================
+
+ Environmental Systems Research Institute (ESRI) Applications Programming
+
+ Project: Conversion from ARC/INFO to VPF
+ Original Coding: David Flinn July 1991
+ Modifications:
+
+ ======================================================================== */
+
+#ifndef _VPF_IO_
+#define _VPF_IO_
+
+#include <stdio.h>
+
+/* These are all the metacharacters used to parse out input text files */
+
+#define COMPONENT_SEPERATOR ';'
+#define LINE_CONTINUE '\\'
+#define SPACE ' '
+#define TEXT_NULL "-"
+#define COMMENT_CHAR '"'
+#define FIELD_COUNT '='
+#define FIELD_SEPERATOR ','
+#define END_OF_FIELD ':'
+#define FIELD_PARTITION '^'
+#define NEXT_ELEMENT '|'
+#define COMMENT '#'
+#define NEW_LINE '\n'
+#define VARIABLE_COUNT '*'
+#define TAB '\t'
+
+/* Set up the macros to read in data from disk and to write */
+
+#ifndef _MSDOS
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+
+/* types */
+typedef enum {
+ VpfNull,
+ VpfChar,
+ VpfShort,
+ VpfInteger,
+ VpfFloat,
+ VpfDouble,
+ VpfDate,
+ VpfKey,
+ VpfCoordinate,
+ VpfTriCoordinate,
+ VpfDoubleCoordinate,
+ VpfDoubleTriCoordinate,
+ VpfUndefined
+} VpfDataType ;
+
+#define Read_Vpf_Char(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfChar,count,fromfile)
+
+#define Read_Vpf_Short(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfShort,count,fromfile)
+
+#define Read_Vpf_Int(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfInteger,count,fromfile)
+
+#define Read_Vpf_Float(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfFloat,count,fromfile)
+
+#define Read_Vpf_Double(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfDouble,count,fromfile)
+
+#define Read_Vpf_Date(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfDate,count,fromfile)
+
+#define Read_Vpf_Coordinate(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfCoordinate,count,fromfile)
+
+#define Read_Vpf_CoordinateZ(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfTriCoordinate,count,fromfile)
+
+#define Read_Vpf_DoubleCoordinate(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfDoubleCoordinate,count,fromfile)
+
+#define Read_Vpf_DoubleCoordinateZ(tobuffer,fromfile,count) \
+ VpfRead(tobuffer,VpfDoubleTriCoordinate,count,fromfile)
+
+#define Write_Vpf_Char(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfChar,count,fromfile)
+
+#define Write_Vpf_Short(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfShort,count,fromfile)
+
+#define Write_Vpf_Int(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfInteger,count,fromfile)
+
+#define Write_Vpf_Float(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfFloat,count,fromfile)
+
+#define Write_Vpf_Double(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfDouble,count,fromfile)
+
+#define Write_Vpf_Date(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfDate,count,fromfile)
+
+#define Write_Vpf_Coordinate(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfCoordinate,count,fromfile)
+
+#define Write_Vpf_CoordinateZ(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfTriCoordinate,count,fromfile)
+
+#define Write_Vpf_DoubleCoordinate(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfDoubleCoordinate,count,fromfile)
+
+#define Write_Vpf_DoubleCoordinateZ(tobuffer,fromfile,count) \
+ VpfWrite(tobuffer,VpfDoubleTriCoordinate,count,fromfile)
+
+/* subroutines */
+#ifdef PROTO
+ int32 VpfRead (void *to, VpfDataType type, int32 count, FILE *from);
+ int32 VpfWrite (void *from, VpfDataType type, int32 count, FILE *to);
+#else
+ int32 VpfRead ();
+ int32 VpfWrite ();
+#endif
+
+#endif /* ifndef _VPF_IO_ */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprim.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprim.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprim.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1584 @@
+/***********************************************************************
+ *
+ *N Module VPFPRIM - VPF Primitives
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This module contains functions for reading VPF primitives
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * N/A
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+
+#ifdef _MSDOS
+#include <io.h>
+#include <dos.h>
+#else
+#include <float.h>
+#endif
+
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __VPFPROJ_H__
+#include "vpfproj.h"
+#endif
+#ifndef __COORGEOM_H__
+#include "coorgeom.h"
+#endif
+#ifndef __VPFPRIM_H__
+#include "vpfprim.h"
+#endif
+#ifndef H_MUSEDIR
+#include "musedir.h"
+#endif
+
+
+/***********************************************************************
+ *
+ *N create_edge_rec
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function creates an edge record internal structure from a
+ * row of a VPF edge table. NOTE: This function allocates memory
+ * for "edge_rec.coord". This array should be freed when no longer
+ * needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * row <input> == (row_type) VPF table row.
+ * edge_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (edge_rec_type) returned edge record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ edge_rec_type create_edge_rec (row_type row,
+ vpf_table_type edge_table, int32 (*projfunc)())
+#else
+ edge_rec_type create_edge_rec (row, edge_table, projfunc)
+ row_type row;
+ vpf_table_type edge_table;
+ int32 (*projfunc)();
+#endif
+
+ {
+ edge_rec_type edge;
+ int32 rowid, start, end, right_face, left_face, right_edge, left_edge;
+ int32 coord, count, i;
+ id_triplet_type key;
+ coordinate_type *Ccoord;
+ tri_coordinate_type *Zcoord;
+ double_tri_coordinate_type *Ycoord;
+
+ if (!row) {
+ edge.id = -1;
+ edge.npts = 0;
+ return edge;
+ }
+
+ rowid = table_pos( "ID", edge_table );
+ start = table_pos( "START_NODE", edge_table );
+ end = table_pos( "END_NODE", edge_table );
+ right_face = table_pos( "RIGHT_FACE", edge_table );
+ left_face = table_pos( "LEFT_FACE", edge_table );
+ right_edge = table_pos( "RIGHT_EDGE", edge_table );
+ left_edge = table_pos( "LEFT_EDGE", edge_table );
+ coord = table_pos( "COORDINATES", edge_table );
+
+ get_table_element( rowid, row, edge_table, &(edge.id), &count );
+
+ if (start >= 0)
+ get_table_element( start, row, edge_table, &(edge.start_node), &count );
+ else
+ edge.start_node = 0;
+
+ if (end >= 0)
+ get_table_element( end, row, edge_table, &(edge.end_node), &count );
+ else
+ edge.end_node = 0;
+
+ if (right_face >= 0) {
+ if (edge_table.header[right_face].type=='K') {
+ get_table_element( right_face, row, edge_table, &key, &count );
+ edge.right_face = key.id;
+ } else if (edge_table.header[right_face].type=='I') {
+ get_table_element( right_face, row, edge_table, &(edge.right_face),
+ &count );
+ } else {
+ edge.right_face=1;
+ }
+ } else {
+ edge.right_face = 1;
+ }
+
+ if (left_face >= 0) {
+ if (edge_table.header[right_face].type=='K') {
+ get_table_element( left_face, row, edge_table, &key, &count );
+ edge.left_face = key.id;
+ } else if (edge_table.header[left_face].type=='I') {
+ get_table_element( left_face, row, edge_table, &(edge.left_face),
+ &count );
+ } else {
+ edge.left_face=1;
+ }
+ } else {
+ edge.left_face = 1;
+ }
+
+ if (edge_table.header[right_edge].type=='K') {
+ get_table_element( right_edge, row, edge_table, &key, &count );
+ edge.right_edge = key.id;
+ } else if (edge_table.header[right_edge].type=='I') {
+ get_table_element( right_edge, row, edge_table, &(edge.right_edge),
+ &count );
+ } else {
+ edge.right_edge=0;
+ }
+
+ if (edge_table.header[left_edge].type=='K') {
+ get_table_element( left_edge, row, edge_table, &key, &count );
+ edge.left_edge = key.id;
+ } else if (edge_table.header[left_edge].type=='I') {
+ get_table_element( left_edge, row, edge_table, &(edge.left_edge),
+ &count );
+ } else {
+ edge.left_edge=0;
+ }
+
+ switch (edge_table.header[coord].type) {
+ case 'C':
+ Ccoord = (coordinate_type *)get_table_element( coord,
+ row, edge_table,
+ NULL, &count );
+ edge.coords = (double_coordinate_type*)xvt_malloc((size_t)count *
+ sizeof(double_coordinate_type));
+ if (edge.coords) {
+ for (i=0;i<count;i++) {
+ edge.coords[i].x = (double) Ccoord[i].x;
+ edge.coords[i].y = (double) Ccoord[i].y;
+ }
+ }
+ xvt_free((char*)Ccoord);
+ break;
+ case 'Z':
+ Zcoord = (tri_coordinate_type *)get_table_element( coord,
+ row, edge_table,
+ NULL, &count );
+ edge.coords = (double_coordinate_type*)xvt_malloc((size_t)count *
+ sizeof(double_coordinate_type));
+ if (edge.coords) {
+ for (i=0;i<count;i++) {
+ edge.coords[i].x = (double) Zcoord[i].x;
+ edge.coords[i].y = (double) Zcoord[i].y;
+ }
+ }
+ xvt_free((char*)Zcoord);
+ break;
+ case 'B':
+ edge.coords = (double_coordinate_type *)get_table_element( coord,
+ row, edge_table,
+ NULL, &count );
+ break;
+ case 'Y':
+ Ycoord = (double_tri_coordinate_type *)get_table_element( coord,
+ row, edge_table,
+ NULL, &count );
+ edge.coords = (double_coordinate_type*)xvt_malloc((size_t)count *
+ sizeof(double_coordinate_type));
+ if (edge.coords) {
+ for (i=0;i<count;i++) {
+ edge.coords[i].x = Ycoord[i].x;
+ edge.coords[i].y = Ycoord[i].y;
+ }
+ }
+ xvt_free((char*)Ycoord);
+ break;
+ default:
+ xvt_note ("Invalid coordinate type: %c\n",
+ edge_table.header[coord].type);
+ count = 0;
+ break;
+ }
+ edge.coord_type = edge_table.header[coord].type;
+ edge.npts = count;
+
+ edge.fp = NULL;
+ if (!edge.coords) {
+ edge.fp = edge_table.fp;
+ edge.startpos = index_pos (edge.id,edge_table) +
+ row_offset ((int32)coord, row, edge_table) +
+ (int32)sizeof (int32);
+ edge.pos = -1;
+ }
+
+ edge.current_coordinate = -1;
+
+ edge.dir = ' ';
+
+ if (projfunc != NULL) {
+ for (i=0;i<count;i++) {
+ projfunc( &(edge.coords[i].x), &(edge.coords[i].y) );
+ }
+ }
+
+ return edge;
+}
+
+
+/***********************************************************************
+ *
+ *N read_edge
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads a VPF edge record from the input VPF table.
+ * It performs a search for the specified line number, and, if found,
+ * allocates, reads, and returns the edge record. NOTE: This function
+ * allocates memory for "edge_rec.coord". This array should be freed
+ * when no longer needed. If an invalid row id is passed in, this
+ * function will have unpredictable results.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * id <input> == (int32) edge id number.
+ * edge_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (edge_rec_type) returned edge record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ edge_rec_type read_edge( int32 id, vpf_table_type edge_table,
+ int32 (*projfunc)() )
+#else
+ edge_rec_type read_edge (id, edge_table, projfunc)
+ int32 id;
+ vpf_table_type edge_table;
+ int32 (*projfunc)();
+#endif
+
+ {
+ edge_rec_type edge;
+ row_type row;
+
+ row = get_row( id, edge_table );
+ edge = create_edge_rec( row, edge_table, projfunc );
+ free_row( row, edge_table );
+ return edge;
+}
+
+
+
+
+/***********************************************************************
+ *
+ *N read_next_edge
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads the next VPF edge record from the input VPF table.
+ * NOTE: This function allocates memory for "edge_rec.coord".
+ * This array should be freed when no longer needed.
+ * Must have called vpf_open_table with DISK as the storage type,
+ * since this function accesses the disk to read the next row.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * edge_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (edge_rec_type) returned edge record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ edge_rec_type read_next_edge (vpf_table_type edge_table, int32 (*projfunc)() )
+#else
+ edge_rec_type read_next_edge (edge_table, projfunc)
+ vpf_table_type edge_table;
+ int32 (*projfunc)();
+#endif
+
+ {
+ edge_rec_type edge;
+ row_type row;
+
+ row = read_next_row( edge_table );
+ edge = create_edge_rec( row, edge_table, projfunc );
+ free_row( row, edge_table );
+
+ return edge;
+}
+
+/***********************************************************************
+ *
+ *N first_edge_coordinate
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the first coordinate of the given VPF edge
+ * record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * edge_rec <inout> == (edge_rec_type *) VPF edge record structure.
+ * return <output> == (double_coordinate_type) first coordinate
+ * in the edge record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ double_coordinate_type first_edge_coordinate (edge_rec_type *edge_rec)
+#else
+ double_coordinate_type first_edge_coordinate (edge_rec)
+ edge_rec_type *edge_rec;
+#endif
+
+ {
+ coordinate_type coord;
+ tri_coordinate_type Zcoord;
+ double_coordinate_type Bcoord;
+ double_tri_coordinate_type Ycoord;
+ int32 size;
+
+ edge_rec->current_coordinate = 0;
+
+ if (edge_rec->coords) {
+ /* Coordinate array is in memory */
+ return edge_rec->coords[0];
+ }
+
+ /* Read coordinate from table */
+ fseek(edge_rec->fp,edge_rec->startpos,SEEK_SET);
+ switch (edge_rec->coord_type) {
+ case 'C':
+ ogdi_fread(&coord,sizeof(coord),1,edge_rec->fp);
+ Bcoord.x = (double) coord.x;
+ Bcoord.y = (double) coord.y;
+ size = sizeof(coord);
+ break;
+ case 'Z':
+ ogdi_fread(&Zcoord,sizeof(Zcoord),1,edge_rec->fp);
+ Bcoord.x = (double) Zcoord.x;
+ Bcoord.y = (double) Zcoord.y;
+ size = sizeof(Zcoord);
+ break;
+ case 'B':
+ ogdi_fread(&Bcoord,sizeof(Bcoord),1,edge_rec->fp);
+ size = sizeof(Bcoord);
+ break;
+ case 'Y':
+ ogdi_fread(&Ycoord,sizeof(Ycoord),1,edge_rec->fp);
+ Bcoord.x = Ycoord.x;
+ Bcoord.y = Ycoord.y;
+ size = sizeof(Ycoord);
+ break;
+ default:
+ Bcoord.x = (double) NULLINT;
+ Bcoord.y = (double) NULLINT;
+ size = 0;
+ break;
+ }
+
+ edge_rec->pos = edge_rec->startpos + size;
+
+ return Bcoord;
+}
+
+/***********************************************************************
+ *
+ *N next_edge_coordinate
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the next coordinate of the given VPF edge
+ * record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * edge_rec <inout> == (edge_rec_type *) VPF edge record structure.
+ * return <output> == (double_coordinate_type) next coordinate
+ * in the edge record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ double_coordinate_type next_edge_coordinate (edge_rec_type *edge_rec)
+#else
+ double_coordinate_type next_edge_coordinate (edge_rec)
+ edge_rec_type *edge_rec;
+#endif
+
+ {
+ coordinate_type coord;
+ tri_coordinate_type Zcoord;
+ double_coordinate_type Bcoord;
+ double_tri_coordinate_type Ycoord;
+ int32 size;
+
+ if (edge_rec->current_coordinate < 0)
+ return first_edge_coordinate(edge_rec);
+
+ edge_rec->current_coordinate++;
+
+ if (edge_rec->current_coordinate >= edge_rec->npts) {
+ edge_rec->current_coordinate = edge_rec->npts-1L;
+ if (!edge_rec->coords)
+ fseek(edge_rec->fp,edge_rec->startpos +
+ (edge_rec->npts-1L)*sizeof(coord),
+ SEEK_SET);
+ }
+
+ if (edge_rec->coords) {
+ /* Coordinate array is in memory */
+ return edge_rec->coords[edge_rec->current_coordinate];
+ }
+
+ /* Read coordinate from table */
+ switch (edge_rec->coord_type) {
+ case 'C':
+ ogdi_fread(&coord,sizeof(coord),1,edge_rec->fp);
+ Bcoord.x = (double) coord.x;
+ Bcoord.y = (double) coord.y;
+ size = sizeof(coord);
+ break;
+ case 'Z':
+ ogdi_fread(&Zcoord,sizeof(Zcoord),1,edge_rec->fp);
+ Bcoord.x = (double) Zcoord.x;
+ Bcoord.y = (double) Zcoord.y;
+ size = sizeof(Zcoord);
+ break;
+ case 'B':
+ ogdi_fread(&Bcoord,sizeof(Bcoord),1,edge_rec->fp);
+ size = sizeof(Bcoord);
+ break;
+ case 'Y':
+ ogdi_fread(&Ycoord,sizeof(Ycoord),1,edge_rec->fp);
+ Bcoord.x = Ycoord.x;
+ Bcoord.y = Ycoord.y;
+ size = sizeof(Ycoord);
+ break;
+ default:
+ Bcoord.x = (double) NULLINT;
+ Bcoord.y = (double) NULLINT;
+ size = 0;
+ break;
+ }
+ edge_rec->pos = edge_rec->startpos + size;
+
+ return Bcoord;
+}
+
+/***********************************************************************
+ *
+ *N get_edge_coordinate
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the specified coordinate of the given VPF edge
+ * record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * edge_rec <inout> == (edge_rec_type *) VPF edge record structure.
+ * n <input> == (int32) coordinate array number.
+ * return <output> == (double_coordinate_type) next coordinate
+ * in the edge record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ double_coordinate_type get_edge_coordinate (int32 n, edge_rec_type *edge_rec)
+#else
+ double_coordinate_type get_edge_coordinate (n, edge_rec)
+ int32 n;
+ edge_rec_type *edge_rec;
+#endif
+
+ {
+ coordinate_type coord;
+ tri_coordinate_type Zcoord;
+ double_coordinate_type Bcoord;
+ double_tri_coordinate_type Ycoord;
+ int32 size;
+
+ if (n < 0)
+ return first_edge_coordinate(edge_rec);
+
+ if (n >= edge_rec->npts) n = edge_rec->npts-1L;
+
+ edge_rec->current_coordinate = n;
+
+ if (edge_rec->coords) {
+ /* Coordinate array is in memory */
+ return edge_rec->coords[n];
+ }
+
+ /* Read coordinate from table */
+ switch (edge_rec->coord_type) {
+ case 'C':
+ size = sizeof(coord);
+ break;
+ case 'Z':
+ size = sizeof(Zcoord);
+ break;
+ case 'B':
+ size = sizeof(Bcoord);
+ break;
+ case 'Y':
+ size = sizeof(Ycoord);
+ break;
+ default:
+ size = 0;
+ break;
+ }
+ edge_rec->pos = edge_rec->startpos + (n*size);
+ fseek(edge_rec->fp,edge_rec->pos,SEEK_SET);
+ switch (edge_rec->coord_type) {
+ case 'C':
+ ogdi_fread(&coord,sizeof(coord),1,edge_rec->fp);
+ Bcoord.x = (double) coord.x;
+ Bcoord.y = (double) coord.y;
+ break;
+ case 'Z':
+ ogdi_fread(&Zcoord,sizeof(Zcoord),1,edge_rec->fp);
+ Bcoord.x = (double) Zcoord.x;
+ Bcoord.y = (double) Zcoord.y;
+ break;
+ case 'B':
+ ogdi_fread(&Bcoord,sizeof(Bcoord),1,edge_rec->fp);
+ break;
+ case 'Y':
+ ogdi_fread(&Ycoord,sizeof(Ycoord),1,edge_rec->fp);
+ Bcoord.x = Ycoord.x;
+ Bcoord.y = Ycoord.y;
+ break;
+ default:
+ Bcoord.x = (double)NULLINT;
+ Bcoord.y = (double)NULLINT;
+ break;
+ }
+
+ return Bcoord;
+}
+
+
+
+
+/***********************************************************************
+ *
+ *N read_face
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads a VPF face record from the input VPF table.
+ * It performs a search for the specified face number, and, if found,
+ * reads and returns the face record. If id is out of range,
+ * either the lowest or highest id numbered face record type will be
+ * returned.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * id <input> == (int32) face id number.
+ * face_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (face_rec_type) returned face record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ face_rec_type read_face (int32 id, vpf_table_type face_table)
+#else
+ face_rec_type read_face (id, face_table)
+ int32 id;
+ vpf_table_type face_table;
+#endif
+
+ {
+ face_rec_type face;
+ int32 count, rowid, ring;
+ row_type row;
+
+ rowid = table_pos( "ID", face_table );
+ ring = table_pos( "RING_PTR", face_table );
+
+ row = get_row( id, face_table );
+
+ get_table_element( rowid, row, face_table, &(face.id), &count );
+
+ get_table_element( ring, row, face_table, &(face.ring), &count );
+
+ free_row( row, face_table );
+
+ return face;
+}
+
+
+
+
+
+/***********************************************************************
+ *
+ *N read_next_face
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+ * Purpose:
+ *P
+ * This function reads the next VPF face record from the input VPF
+ * table. Must have used vpf_open_table with DISK as the storage type.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * face_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (face_rec_type) returned face record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ face_rec_type read_next_face( vpf_table_type face_table )
+#else
+ face_rec_type read_next_face (face_table)
+ vpf_table_type face_table;
+#endif
+
+ {
+ face_rec_type face;
+ int32 count, rowid, ring;
+ row_type row;
+
+ rowid = table_pos( "ID", face_table );
+ ring = table_pos( "RING_PTR", face_table );
+
+ row = read_next_row( face_table );
+
+ get_table_element( rowid, row, face_table, &(face.id), &count );
+
+ get_table_element( ring, row, face_table, &(face.ring), &count );
+
+ free_row( row, face_table );
+
+ return face;
+}
+
+
+
+
+
+/***********************************************************************
+ *
+ *N read_ring
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads a VPF ring record from the input VPF table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * id <input> == (int32) ring id number.
+ * ring_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (ring_rec_type) returned ring record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ ring_rec_type read_ring (int32 id, vpf_table_type ring_table)
+#else
+ ring_rec_type read_ring (id, ring_table)
+ int32 id;
+ vpf_table_type ring_table;
+#endif
+
+ {
+ ring_rec_type ring;
+ int32 count, rowid, face, edge;
+ row_type row;
+
+ rowid = table_pos( "ID", ring_table );
+ face = table_pos( "FACE_ID", ring_table );
+ edge = table_pos( "START_EDGE", ring_table );
+
+ row = get_row( id, ring_table );
+
+ get_table_element( rowid, row, ring_table, &(ring.id), &count );
+
+ get_table_element( face, row, ring_table, &(ring.face), &count );
+
+ get_table_element( edge, row, ring_table, &(ring.edge), &count );
+
+ free_row( row, ring_table );
+
+ return ring;
+}
+
+
+
+
+/***********************************************************************
+ *
+ *N read_next_ring
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads the next VPF ring record from the input VPF table.
+ * If read_next_ring goes past the end of the vpftable, ring_rec_type
+ * id will be a garbage number. The programmer must ensure that this
+ * does NOT happen. Must have called vpf_open_table with DISK as the
+ * storage type.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * ring_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (ring_rec_type) returned ring record.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ ring_rec_type read_next_ring (vpf_table_type ring_table )
+#else
+ ring_rec_type read_next_ring (ring_table)
+ vpf_table_type ring_table;
+#endif
+
+ {
+ ring_rec_type ring;
+ int32 count, rowid, face, edge;
+ row_type row;
+
+ rowid = table_pos( "ID", ring_table );
+ face = table_pos( "FACE_ID", ring_table );
+ edge = table_pos( "START_EDGE", ring_table );
+
+ row = read_next_row( ring_table );
+
+ get_table_element( rowid, row, ring_table, &(ring.id), &count );
+
+ get_table_element( face, row, ring_table, &(ring.face), &count );
+
+ get_table_element( edge, row, ring_table, &(ring.edge), &count );
+
+ free_row( row, ring_table );
+
+ return ring;
+}
+
+
+
+/***********************************************************************
+ *
+ *N read_node
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads a VPF node record from the input VPF table.
+ * It performs a search for the specified node number, and, if found,
+ * reads and returns the node record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * id <input> == (int32) node id number.
+ * node_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (node_rec_type) returned node record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ node_rec_type read_node (int32 id, vpf_table_type node_table, int32 (*projfunc)() )
+#else
+ node_rec_type read_node (id, node_table, projfunc)
+ int32 id;
+ vpf_table_type node_table;
+ int32 (*projfunc)();
+#endif
+
+
+ {
+ node_rec_type node;
+ int32 count, rowid, face, first_edge, coord;
+ coordinate_type c;
+ tri_coordinate_type Zcoord;
+ double_coordinate_type Bcoord;
+ double_tri_coordinate_type Ycoord;
+ row_type row;
+
+ rowid = table_pos( "ID", node_table );
+ face = table_pos( "CONTAINING_FACE", node_table );
+ first_edge = table_pos( "FIRST_EDGE", node_table );
+ coord = table_pos( "COORDINATE", node_table );
+
+ row = get_row( id, node_table );
+
+ get_table_element( rowid, row, node_table, &(node.id), &count );
+
+ if (face>0)
+ get_table_element( face, row, node_table, &(node.face), &count );
+ else
+ node.face = 0;
+
+ if (first_edge>0)
+ get_table_element( first_edge, row, node_table, &(node.first_edge),
+ &count );
+ else
+ node.first_edge = 0;
+
+ switch (node_table.header[coord].type) {
+ case 'C':
+ get_table_element( coord, row, node_table, &c, &count );
+ node.x = (double) c.x;
+ node.y = (double) c.y;
+ break;
+ case 'Z':
+ get_table_element( coord, row, node_table, &Zcoord, &count );
+ node.x = (double) Zcoord.x;
+ node.y = (double) Zcoord.y;
+ break;
+ case 'B':
+ get_table_element( coord, row, node_table, &Bcoord, &count );
+ node.x = Bcoord.x;
+ node.y = Bcoord.y;
+ break;
+ case 'Y':
+ get_table_element( coord, row, node_table, &Ycoord, &count );
+ node.x = Ycoord.x;
+ node.y = Ycoord.y;
+ break;
+ default:
+ node.x = (double)NULLINT;
+ node.y = (double)NULLINT;
+ break;
+ }
+
+ free_row( row, node_table );
+
+ if (projfunc != NULL) {
+ projfunc( &(node.x), &(node.y) );
+ }
+
+ return node;
+}
+
+
+
+
+/***********************************************************************
+ *
+ *N read_next_node
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads the next VPF node record from the input
+ * VPF table. Must have called vpf_open_table with DISK as the
+ * storage type.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * node_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (node_rec_type) returned node record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ *********************************************************************/
+#ifdef PROTO
+ node_rec_type read_next_node (vpf_table_type node_table, int32 (*projfunc)())
+#else
+ node_rec_type read_next_node (node_table, projfunc)
+ vpf_table_type node_table;
+ int32 (*projfunc)();
+#endif
+
+ {
+ node_rec_type node;
+ int32 count, rowid, face, first_edge, coord;
+ coordinate_type c;
+ tri_coordinate_type Zcoord;
+ double_coordinate_type Bcoord;
+ double_tri_coordinate_type Ycoord;
+ row_type row;
+
+ rowid = table_pos( "ID", node_table );
+ face = table_pos( "CONTAINING_FACE", node_table );
+ first_edge = table_pos( "FIRST_EDGE", node_table );
+ coord = table_pos( "COORDINATE", node_table );
+
+ row = read_next_row( node_table );
+
+ get_table_element( rowid, row, node_table, &(node.id), &count );
+
+ if (face>0)
+ get_table_element( face, row, node_table, &(node.face), &count );
+ else
+ node.face = 0;
+
+ if (first_edge>0)
+ get_table_element( first_edge, row, node_table, &(node.first_edge),
+ &count );
+ else
+ node.first_edge = 0;
+
+ switch (node_table.header[coord].type) {
+ case 'C':
+ get_table_element( coord, row, node_table, &c, &count );
+ node.x = (double) c.x;
+ node.y = (double) c.y;
+ break;
+ case 'Z':
+ get_table_element( coord, row, node_table, &Zcoord, &count );
+ node.x = (double) Zcoord.x;
+ node.y = (double) Zcoord.y;
+ break;
+ case 'B':
+ get_table_element( coord, row, node_table, &Bcoord, &count );
+ node.x = Bcoord.x;
+ node.y = Bcoord.y;
+ break;
+ case 'Y':
+ get_table_element( coord, row, node_table, &Ycoord, &count );
+ node.x = Ycoord.x;
+ node.y = Ycoord.y;
+ break;
+ default:
+ node.x = (double)NULLINT;
+ node.y = (double)NULLINT;
+ break;
+ }
+
+ free_row( row, node_table );
+
+ if (projfunc != NULL) {
+ projfunc( &(node.x), &(node.y) );
+ }
+
+ return node;
+}
+
+
+
+
+
+
+/***********************************************************************
+ *
+ *N read_text
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads a VPF annotation record from the input VPF table.
+ * It performs a search for the specified annotation id, and, if
+ * found, reads and returns the annotation record. NOTE: This function
+ * allocates memory for "txt.text". This must be freed when no
+ * longer needed.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * id <input> == (int32) annotation id.
+ * text_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (text_rec_type) returned annotation record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ text_rec_type read_text (int32 id, vpf_table_type text_table, int32 (*projfunc)())
+#else
+ text_rec_type read_text (id, text_table, projfunc)
+ int32 id;
+ vpf_table_type text_table;
+ int32 (*projfunc)();
+#endif
+
+ {
+ text_rec_type txt;
+ int32 count, rowid, text, coord;
+ coordinate_type *c;
+ tri_coordinate_type *Zcoord;
+ double_coordinate_type *Bcoord;
+ double_tri_coordinate_type *Ycoord;
+ row_type row;
+
+ rowid = table_pos( "ID", text_table );
+ text = table_pos( "STRING", text_table );
+ coord = table_pos( "SHAPE_LINE", text_table );
+
+ row = get_row( id, text_table );
+
+ get_table_element( rowid, row, text_table, &(txt.id), &count );
+
+ txt.text = get_table_element( text, row, text_table, NULL, &count );
+
+ switch (text_table.header[coord].type) {
+ case 'C':
+ c = (coordinate_type *)get_table_element( coord, row,
+ text_table, NULL, &count );
+ txt.x = (double) c[0].x;
+ txt.y = (double) c[0].y;
+ xvt_free((char*)c);
+ break;
+ case 'Z':
+ Zcoord = (tri_coordinate_type *)get_table_element( coord, row,
+ text_table, NULL, &count );
+ txt.x = (double) Zcoord[0].x;
+ txt.y = (double) Zcoord[0].y;
+ xvt_free((char*)Zcoord);
+ break;
+ case 'B':
+ Bcoord = (double_coordinate_type *)get_table_element( coord, row,
+ text_table, NULL, &count );
+ txt.x = Bcoord[0].x;
+ txt.y = Bcoord[0].y;
+ xvt_free((char*)Bcoord);
+ break;
+ case 'Y':
+ Ycoord = (double_tri_coordinate_type *)get_table_element( coord,
+ row, text_table, NULL, &count );
+ txt.x = Ycoord[0].x;
+ txt.y = Ycoord[0].y;
+ xvt_free ((char*)Ycoord);
+ break;
+ default:
+ txt.x = (double)NULLINT;
+ txt.y = (double)NULLINT;
+ break;
+ }
+
+ free_row( row, text_table );
+
+ if (projfunc != NULL) {
+ projfunc( &(txt.x), &(txt.y) );
+ }
+
+ return txt;
+}
+
+
+
+
+/***********************************************************************
+ *
+ *N read_next_text
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads the next VPF annotation record from the input
+ * VPF table. Must have called vpf_open_table with DISK as the storage
+ * type. NOTE: This function allocates memory for "txt.text". This
+ * must be freed when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * text_table <input> == (vpf_table_type) opened VPF table to read.
+ * return <output> == (text_rec_type) returned annotation record.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ text_rec_type read_next_text( vpf_table_type text_table, int32 (*projfunc)())
+#else
+ text_rec_type read_next_text (text_table, projfunc)
+ vpf_table_type text_table;
+ int32 (*projfunc)();
+#endif
+
+ {
+ text_rec_type txt;
+ int32 count, rowid, text, coord;
+ coordinate_type *c;
+ tri_coordinate_type *Zcoord;
+ double_coordinate_type *Bcoord;
+ double_tri_coordinate_type *Ycoord;
+ row_type row;
+
+ rowid = table_pos( "ID", text_table );
+ text = table_pos( "STRING", text_table );
+ coord = table_pos( "SHAPE_LINE", text_table );
+
+ row = read_next_row( text_table );
+
+ get_table_element( rowid, row, text_table, &(txt.id), &count );
+
+ txt.text = get_table_element( text, row, text_table, NULL, &count );
+
+ switch (text_table.header[coord].type) {
+ case 'C':
+ c = (coordinate_type *)get_table_element( coord, row,
+ text_table, NULL, &count );
+ txt.x = (double) c[0].x;
+ txt.y = (double) c[0].y;
+ xvt_free ((char*)c);
+ break;
+ case 'Z':
+ Zcoord = (tri_coordinate_type *)get_table_element( coord, row,
+ text_table, NULL, &count );
+ txt.x = (double) Zcoord[0].x;
+ txt.y = (double) Zcoord[0].y;
+ xvt_free ((char*)Zcoord);
+ break;
+ case 'B':
+ Bcoord = (double_coordinate_type *)get_table_element( coord, row,
+ text_table, NULL, &count );
+ txt.x = Bcoord[0].x;
+ txt.y = Bcoord[0].y;
+ xvt_free ((char*)Bcoord);
+ break;
+ case 'Y':
+ Ycoord = (double_tri_coordinate_type *)get_table_element( coord,
+ row, text_table, NULL, &count );
+ txt.x = Ycoord[0].x;
+ txt.y = Ycoord[0].y;
+ xvt_free ((char*)Ycoord);
+ break;
+ default:
+ txt.x = (double)NULLINT;
+ txt.y = (double)NULLINT;
+ break;
+ }
+
+ free_row( row, text_table );
+
+ if (projfunc != NULL) {
+ projfunc( &(txt.x), &(txt.y) );
+ }
+
+ return txt;
+}
+
+
+/***********************************************************************
+ *
+ *N bounding_select
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads the bounding rectangle table to weed out the
+ * local primitives.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * brpath <input> == (char *) path to the bounding rectangle table.
+ * mapextent <input> == (extent_type) map extent to compare.
+ * dec_degrees <input> == (int32) flag to indicate if data is in decimal
+ * degrees.
+ * projfunc <input> == (int32 *)() inverse projection function.
+ * bounding_select <output> == (set_type) set of bounding rectangle ids.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ set_type bounding_select( char *brpath, extent_type extent,
+ vpf_projection_type invproj )
+#else
+ set_type bounding_select (brpath, extent, invproj)
+ char *brpath;
+ extent_type extent;
+ vpf_projection_type invproj;
+#endif
+
+ {
+ vpf_table_type table;
+ row_type row;
+ set_type set;
+ int32 count, id;
+ int32 XMIN_, YMIN_, XMAX_, YMAX_;
+ extent_type box, pextent;
+ float fx1,fy1,fx2,fy2;
+ double x1,y1,x2,y2;
+ vpf_projection_type pcproj, prevproj;
+
+ prevproj = get_vpf_forward_projection();
+
+ /* Project all extents to plate-carree for cartesian comparisons */
+ /* (decimal degree coordinate systems) */
+
+ x1 = extent.x1; y1 = extent.y1;
+ x2 = extent.x2; y2 = extent.y2;
+ pcproj = set_vpf_projection_parms(PC,extent);
+ set_vpf_forward_projection(pcproj);
+ plate_carree_fwd(&x1,&y1);
+ plate_carree_fwd(&x2,&y2);
+ pextent.x1 = x1; pextent.y1 = y1;
+ pextent.x2 = x2; pextent.y2 = y2;
+
+ table = vpf_open_table(brpath,disk,"rb",NULL);
+ XMIN_ = table_pos("XMIN",table);
+ YMIN_ = table_pos("YMIN",table);
+ XMAX_ = table_pos("XMAX",table);
+ YMAX_ = table_pos("YMAX",table);
+ set = set_init(table.nrows+1);
+ for (id=1;id<=table.nrows;id++) {
+ row = read_next_row( table );
+ get_table_element(XMIN_,row,table,&fx1,&count);
+ get_table_element(YMIN_,row,table,&fy1,&count);
+ get_table_element(XMAX_,row,table,&fx2,&count);
+ get_table_element(YMAX_,row,table,&fy2,&count);
+ free_row(row,table);
+ box.x1 = (double)fx1;
+ box.y1 = (double)fy1;
+ box.x2 = (double)fx2;
+ box.y2 = (double)fy2;
+
+ if (invproj.inverse_proj != NULL) {
+ set_vpf_inverse_projection(invproj);
+ invproj.inverse_proj( &(box.x1), &(box.y1) );
+ invproj.inverse_proj( &(box.x2), &(box.y2) );
+ }
+
+ x1 = box.x1; y1 = box.y1;
+ x2 = box.x2; y2 = box.y2;
+ set_vpf_forward_projection(pcproj);
+ plate_carree_fwd(&x1,&y1);
+ plate_carree_fwd(&x2,&y2);
+ box.x1 = x1; box.y1 = y1;
+ box.x2 = x2; box.y2 = y2;
+
+ if ( contained(box,pextent) || contained(pextent,box) ) {
+ set_insert(id,set);
+ }
+ }
+ vpf_close_table(&table);
+
+ set_vpf_forward_projection(prevproj);
+
+ return set;
+}
+
+
+
+/***********************************************************************
+ *
+ *N open_bounding_rect
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function opens the bounding rectangle table for the specified
+ * primitmive class.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * covpath <input> == (char *) path to coverage directory.
+ * tiledir <input> == (char *) directory name of tile directory.
+ * pclass <input> == (int32) primitive class for bounding rectangle.
+ * open_bounding_rect <output> == (vpf_table_type) bounding rectangle table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Sept 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ vpf_table_type open_bounding_rect (char *covpath, char *tiledir, int32 pclass)
+#else
+ vpf_table_type open_bounding_rect (covpath, tiledir, pclass)
+ char *covpath;
+ char *tiledir;
+ int32 pclass;
+#endif
+
+ {
+ vpf_table_type brtable;
+ char path[256];
+ static char *brname[] = {"","ebr","fbr","tbr","nbr","cbr"};
+
+ strcpy( path, covpath );
+ strcat (path, tiledir);
+ strcat (path, brname[pclass]);
+
+ if (muse_access(path,0)==0) {
+ brtable = vpf_open_table( path, disk, "rb", NULL );
+ } else {
+ brtable.fp = NULL;
+ brtable.status = CLOSED;
+ }
+ return brtable;
+}
+
+
+/***********************************************************************
+ *
+ *N read_bounding_rect
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Reads the specified extent from the opened bounding rectangle table.
+ * If the given projection function is not NULL, the bounding
+ * rectangle coordinates are projected through the specified function
+ * before being returned.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * row <input> == (int32) table row.
+ * brtable <input> == (vpf_table_type) bounding rectangle table.
+ * projfunc <input> == (int32 *)() inverse projection function.
+ * read_bounding_rect <output> == (extent_type) spatial extent.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Sept 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ extent_type read_bounding_rect (int32 row, vpf_table_type brtable,
+ int32 (*projfunc)() )
+#else
+ extent_type read_bounding_rect (row, brtable, projfunc)
+ int32 row;
+ vpf_table_type brtable;
+ int32 (*projfunc)();
+#endif
+
+ {
+ int32 count;
+ extent_type extent;
+ float x1,y1,x2,y2;
+ row_type tablerow;
+ int32 XMIN_,YMIN_,XMAX_,YMAX_;
+
+ XMIN_ = table_pos("XMIN",brtable);
+ YMIN_ = table_pos("YMIN",brtable);
+ XMAX_ = table_pos("XMAX",brtable);
+ YMAX_ = table_pos("YMAX",brtable);
+
+ tablerow = read_row(row,brtable);
+ get_table_element(XMIN_,tablerow,brtable,&x1,&count);
+ get_table_element(YMIN_,tablerow,brtable,&y1,&count);
+ get_table_element(XMAX_,tablerow,brtable,&x2,&count);
+ get_table_element(YMAX_,tablerow,brtable,&y2,&count);
+ free_row(tablerow,brtable);
+
+ extent.x1 = (double) x1;
+ extent.y1 = (double) y1;
+ extent.x2 = (double) x2;
+ extent.y2 = (double) y2;
+
+ if (projfunc != NULL) {
+ projfunc( &(extent.x1), &(extent.y1) );
+ projfunc( &(extent.x2), &(extent.y2) );
+ }
+
+ return extent;
+}
+
+
+/***********************************************************************
+ *
+ *N read_next_bounding_rect
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Reads the next extent from the opened bounding rectangle table.
+ * If the given projection function is not NULL, the bounding
+ * rectangle coordinates are projected through the specified function
+ * before being returned.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * row <input> == (int32) table row.
+ * brtable <input> == (vpf_table_type) bounding rectangle table.
+ * projfunc <input> == (int32 *)() inverse projection function.
+ * read_bounding_rect <output> == (extent_type) spatial extent.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Sept 1991 DOS Turbo C
+ *E
+ **********************************************************************/
+#ifdef PROTO
+ extent_type read_next_bounding_rect( vpf_table_type brtable,
+ int32 (*projfunc)() )
+#else
+ extent_type read_next_bounding_rect (brtable, projfunc)
+ vpf_table_type brtable;
+ int32 (*projfunc)();
+#endif
+
+ {
+ int32 count;
+ extent_type extent;
+ float x1,y1,x2,y2;
+ row_type tablerow;
+ int32 XMIN_,YMIN_,XMAX_,YMAX_;
+
+ XMIN_ = table_pos("XMIN",brtable);
+ YMIN_ = table_pos("YMIN",brtable);
+ XMAX_ = table_pos("XMAX",brtable);
+ YMAX_ = table_pos("YMAX",brtable);
+
+ tablerow = read_next_row(brtable);
+ get_table_element(XMIN_,tablerow,brtable,&x1,&count);
+ get_table_element(YMIN_,tablerow,brtable,&y1,&count);
+ get_table_element(XMAX_,tablerow,brtable,&x2,&count);
+ get_table_element(YMAX_,tablerow,brtable,&y2,&count);
+ free_row(tablerow,brtable);
+
+ extent.x1 = (double) x1;
+ extent.y1 = (double) y1;
+ extent.x2 = (double) x2;
+ extent.y2 = (double) y2;
+
+ if (projfunc != NULL) {
+ projfunc( &(extent.x1), &(extent.y1) );
+ projfunc( &(extent.x2), &(extent.y2) );
+ }
+
+ return extent;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprim.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprim.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprim.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,142 @@
+
+#ifndef __VPFPRIM_H__
+#define __VPFPRIM_H__ 1
+
+#ifndef __COORGEOM_H__
+#include "coorgeom.h"
+#endif
+#ifndef __SET_H__
+#include "set.h"
+#endif
+#ifndef _VPF_TABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __VPF_H__
+#include "vpf.h"
+#endif
+
+/* VPF edge record internal structure */
+typedef struct {
+ int32 id;
+ int32 start_node;
+ int32 end_node;
+ int32 right_face;
+ int32 left_face;
+ int32 right_edge;
+ int32 left_edge;
+ char dir;
+ int32 npts;
+ double_coordinate_type *coords;
+ /* For coordinate arrays too large for memory (DOS support) */
+ FILE *fp;
+ int32 startpos, pos, current_coordinate;
+ char coord_type;
+ int32 (*projfunc)();
+} edge_rec_type;
+
+
+/* "static" part of the edge record (non-variable) */
+typedef struct {
+ int32 id;
+ int32 start_node;
+ int32 end_node;
+ int32 right_face;
+ int32 left_face;
+ int32 right_edge;
+ int32 left_edge;
+ char dir;
+ int32 npts;
+} edge_static_type;
+
+
+/* VPF face record structure */
+typedef struct {
+ int32 id;
+ int32 ring;
+} face_rec_type;
+
+
+/* VPF ring record structure */
+typedef struct {
+ int32 id;
+ int32 face;
+ int32 edge;
+} ring_rec_type;
+
+
+/* VPF entity node record internal structure */
+typedef struct {
+ int32 id;
+ int32 face;
+ int32 first_edge;
+ double x;
+ double y;
+} node_rec_type;
+
+
+/* VPF text record internal structure */
+typedef struct {
+ int32 id;
+ char *text;
+ double x;
+ double y;
+} text_rec_type;
+
+
+#ifdef PROTO
+ edge_rec_type create_edge_rec( row_type row, vpf_table_type edge_table,
+ int32 (*projfunc)() );
+ edge_rec_type read_edge( int32 id,
+ vpf_table_type edge_table,
+ int32 (*projfunc)() );
+ edge_rec_type read_next_edge( vpf_table_type edge_table,
+ int32 (*projfunc)() );
+ double_coordinate_type first_edge_coordinate( edge_rec_type *edge_rec );
+ double_coordinate_type next_edge_coordinate( edge_rec_type *edge_rec );
+ double_coordinate_type get_edge_coordinate( int32 n,
+ edge_rec_type *edge_rec );
+ face_rec_type read_face( int32 id,
+ vpf_table_type face_table );
+ face_rec_type read_next_face( vpf_table_type face_table );
+ ring_rec_type read_ring( int32 id,
+ vpf_table_type ring_table );
+ ring_rec_type read_next_ring( vpf_table_type ring_table );
+ node_rec_type read_node( int32 id,
+ vpf_table_type node_table,
+ int32 (*projfunc)() );
+ node_rec_type read_next_node( vpf_table_type node_table, int32 (*projfunc)() );
+ text_rec_type read_text( int32 id,
+ vpf_table_type text_table,
+ int32 (*projfunc)() );
+ text_rec_type read_next_text( vpf_table_type text_table,
+ int32 (*projfunc)() );
+ set_type bounding_select( char *brpath, extent_type extent,
+ vpf_projection_type invproj );
+ vpf_table_type open_bounding_rect( char *covpath, char *tiledir,
+ int32 pclass );
+ extent_type read_bounding_rect( int32 row, vpf_table_type brtable,
+ int32 (*projfunc)() );
+ extent_type read_next_bounding_rect( vpf_table_type brtable,
+ int32 (*projfunc)() );
+#else
+ edge_rec_type create_edge_rec ();
+ edge_rec_type read_edge ();
+ edge_rec_type read_next_edge ();
+ double_coordinate_type first_edge_coordinate ();
+ double_coordinate_type next_edge_coordinate ();
+ double_coordinate_type get_edge_coordinate ();
+ face_rec_type read_face ();
+ face_rec_type read_next_face ();
+ ring_rec_type read_ring ();
+ ring_rec_type read_next_ring ();
+ node_rec_type read_node ();
+ node_rec_type read_next_node ();
+ text_rec_type read_text ();
+ text_rec_type read_next_text ();
+ set_type bounding_select ();
+ vpf_table_type open_bounding_rect ();
+ extent_type read_bounding_rect ();
+ extent_type read_next_bounding_rect ();
+#endif /* If PROTO */
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfproj.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfproj.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfproj.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,86 @@
+
+#ifndef __VPFPROJ_H__
+#define __VPFPROJ_H__ 1
+
+#ifndef __COORGEOM_H__
+#include "coorgeom.h"
+#endif
+#ifndef __VPF_H__
+#include "vpf.h"
+#endif
+
+#ifdef PROTO
+ vpf_projection_type set_vpf_projection_parms (vpf_projection_code code,
+ extent_type extent);
+ void set_vpf_forward_projection( vpf_projection_type proj );
+ void set_vpf_inverse_projection( vpf_projection_type proj );
+ vpf_projection_type get_vpf_forward_projection();
+ vpf_projection_type get_vpf_inverse_projection();
+ double central_meridian( double minlon, double maxlon );
+ int32 plate_carree_fwd( double *x, double *y );
+ int32 plate_carree_inv( double *x, double *y );
+ int32 albers_equal_area_fwd( double *x, double *y );
+ int32 albers_equal_area_inv( double *x, double *y );
+ int32 azimuthal_equal_area_fwd( double *x, double *y );
+ int32 azimuthal_equal_area_inv( double *x, double *y );
+ int32 azimuthal_equal_distance_fwd( double *x, double *y );
+ int32 azimuthal_equal_distance_inv( double *x, double *y );
+ int32 gnomonic_fwd( double *x, double *y );
+ int32 gnomonic_inv( double *x, double *y );
+ int32 lambert_conformal_conic_fwd( double *x, double *y );
+ int32 lambert_conformal_conic_inv( double *x, double *y );
+ int32 lambert_equal_area_fwd( double *x, double *y );
+ int32 lambert_equal_area_inv( double *x, double *y );
+ int32 mercator_fwd( double *x, double *y );
+ int32 mercator_inv( double *x, double *y );
+ int32 oblique_mercator_fwd( double *x, double *y );
+ int32 oblique_mercator_inv( double *x, double *y );
+ int32 orthographic_fwd( double *x, double *y );
+ int32 orthographic_inv( double *x, double *y );
+ int32 polar_stereographic_fwd( double *x, double *y );
+ int32 polar_stereographic_inv( double *x, double *y );
+ int32 transverse_mercator_fwd( double *x, double *y );
+ int32 transverse_mercator_inv( double *x, double *y );
+ int32 UTM_fwd( double *x, double *y );
+ int32 UTM_inv( double *x, double *y );
+ int32 forward_project( double *x, double *y );
+ int32 inverse_project( double *x, double *y );
+ void set_vpf_coordinate_projection( vpf_projection_type proj );
+#else
+ vpf_projection_type set_vpf_projection_parms ();
+ void set_vpf_forward_projection();
+ void set_vpf_inverse_projection();
+ vpf_projection_type get_vpf_forward_projection();
+ vpf_projection_type get_vpf_inverse_projection();
+ double central_meridian();
+ int32 plate_carree_fwd();
+ int32 plate_carree_inv();
+ int32 albers_equal_area_fwd();
+ int32 albers_equal_area_inv();
+ int32 azimuthal_equal_area_fwd();
+ int32 azimuthal_equal_area_inv();
+ int32 azimuthal_equal_distance_fwd();
+ int32 azimuthal_equal_distance_inv();
+ int32 gnomonic_fwd();
+ int32 gnomonic_inv();
+ int32 lambert_conformal_conic_fwd();
+ int32 lambert_conformal_conic_inv();
+ int32 lambert_equal_area_fwd();
+ int32 lambert_equal_area_inv();
+ int32 mercator_fwd();
+ int32 mercator_inv();
+ int32 oblique_mercator_fwd();
+ int32 oblique_mercator_inv();
+ int32 orthographic_fwd();
+ int32 orthographic_inv();
+ int32 polar_stereographic_fwd();
+ int32 polar_stereographic_inv();
+ int32 transverse_mercator_fwd();
+ int32 transverse_mercator_inv();
+ int32 UTM_fwd();
+ int32 UTM_inv();
+ int32 forward_project();
+ int32 inverse_project();
+ void set_vpf_coordinate_projection();
+#endif
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprop.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprop.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprop.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,2679 @@
+
+/*************************************************************************
+ *
+ *N Module VPFPROP - VPF Properties Module
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This module contains functions for returning various standard
+ * properties of VPF entities such as databases, libraries, coverages,
+ * and feature classes.
+ *
+ * All of the functions take character strings as arguments to
+ * identify VPF tables and directories. These character strings
+ * must not be passed NULL value parameters.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * N/A
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+
+#ifndef __VPF_H__
+#include "vpf.h"
+#endif
+#ifndef __VPFPROJ_H__
+#include "vpfproj.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __STRFUNC_H__
+#include "strfunc.h"
+#endif
+#ifndef H_MUSEDIR
+#include "musedir.h"
+#endif
+#ifndef __VPFPROP_H__
+#include "vpfprop.h"
+#endif
+
+#ifndef MAXINT
+#define MAXINT SHRT_MAX
+#endif
+
+/* Global Variables */
+char *projection_names[] = {"Decimal Degrees",
+ "Albers Equal Area",
+ "Azimuthal Equal Area",
+ "Azimuthal Equal Distance",
+ "Gnomonic",
+ "Lambert Conformal Conic",
+ "Lambert Equal Area",
+ "Mercator",
+ "Oblique Mercator",
+ "Orthographic",
+ "Polar Stereographic",
+ "Transverse Mercator",
+ "UTM",
+ "Plate-Carree"};
+extern void *vpf_forward_projection;
+extern void *vpf_inverse_projection;
+
+
+/*
+Check the directory path separators against the operating system separators.
+*/
+#ifdef PROTO
+ void vpf_check_os_path( char *path )
+#else
+ void vpf_check_os_path (path)
+ char *path;
+#endif
+
+{
+ char *p, vpf_separator, os_separator;
+
+ vpf_separator = VPF_SEPARATOR;
+ os_separator = OS_SEPARATOR;
+
+ if (vpf_separator == os_separator) return;
+ p = &path[0];
+ while (*p) {
+ if (*p == VPF_SEPARATOR) *p = OS_SEPARATOR;
+ p++;
+ }
+}
+
+/*
+Set the case of the filename for the current operating system.
+*/
+#ifdef PROTO
+ char *os_case( char *filename )
+#else
+ char *os_case (filename)
+ char *filename;
+#endif
+
+{
+ char str[255];
+
+ strcpy(str,filename);
+
+#ifdef _MSDOS
+ return strupr(str);
+#else
+ return strlwr(str);
+#endif
+}
+
+
+/* The following function is a modification of file_exists using "access" */
+/* rather that "stat" to make it more portable DGM */
+#ifdef PROTO
+ int32 file_exists( char *filepath )
+#else
+ int32 file_exists (filepath)
+ char *filepath;
+#endif
+
+{
+ char *copy;
+ int32 found;
+
+ if (muse_access (filepath, 00) == 0) return 1;
+
+ found = 0;
+ /* filepath not found - try a '.' extension */
+ copy = (char *)xvt_malloc(strlen(filepath)+2);
+ if (!copy) {
+ xvt_note ("memory allocation error in vpfprop::file_exists()\n");
+ return 0;
+ }
+ strcpy(copy,filepath);
+ strcat(copy,".");
+ if (muse_access(copy, 00)==0) found = 1;
+ xvt_free(copy);
+
+ return found;
+}
+
+/*************************************************************************
+ *
+ *N database_library_names
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns an array of the library names in a specified VPF database.
+ * The number of library names in the array is returned in nlibs.
+ * The array of strings is dynamically allocated and each array element
+ * as well as the array itself should be freed when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * dbpath <input>==(char *) path the the VPF database.
+ * nlibs <output>==(int *) the number of libraries in the database.
+ * return <output>==(char **) array of library names in the database.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char **database_library_names( char *dbpath, int32 *nlibs )
+#else
+ char **database_library_name (dbpath, nlibs)
+ char *dbpath;
+ int32 *nlibs;
+#endif
+
+{
+ vpf_table_type table;
+ row_type row;
+ int32 LIB_, n, i;
+ char **libname, path[255];
+
+ *nlibs = 0;
+
+ strcpy(path,dbpath);
+ vpf_check_os_path(path);
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("LAT"));
+ if (!file_exists(path)) return (char **)NULL;
+
+ table = vpf_open_table( path, disk, "rb", NULL );
+ if (!table.fp) return (char **)NULL;
+
+ LIB_ = table_pos("LIBRARY_NAME",table);
+ if (LIB_ < 0) {
+ xvt_note ("vpfprop::database_library_names: ");
+ xvt_note ("Invalid LAT (%s) - missing LIBRARY_NAME field\n",
+ dbpath);
+ vpf_close_table(&table);
+ return (char **)NULL;
+ }
+
+ libname = (char**)xvt_zmalloc ((size_t)table.nrows * sizeof(char*));
+ if (!libname) {
+ vpf_close_table(&table);
+ return (char **)NULL;
+ }
+
+ *nlibs = (int32)table.nrows;
+
+ for (i=0;i<table.nrows;i++) {
+ row = read_next_row(table);
+ libname[i] = (char *)get_table_element(LIB_,row,table,NULL,&n);
+ free_row(row,table);
+ }
+
+ vpf_close_table(&table);
+
+ return libname;
+}
+
+
+/*************************************************************************
+ *
+ *N database_producer
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the name of the VPF database producer.
+ * The character string is dynamically allocated and should be freed
+ * when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * dbpath <input>==(char *) path the the VPF database.
+ * return <output>==(char *) database producer.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char *database_producer( char *dbpath )
+#else
+ char *database_producer (dbpath)
+ char *dbpath;
+#endif
+
+{
+ char path[255], *producer=(char *)NULL;
+ int32 PROD_,n;
+ row_type row;
+ vpf_table_type table;
+
+ strcpy(path,dbpath);
+ vpf_check_os_path(path);
+ rightjust(path);
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("DHT"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::database_producer: %s not found\n",path);
+ return producer;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::database_producer: Error opening %s\n",path);
+ return producer;
+ }
+
+ PROD_ = table_pos("ORIGINATOR",table);
+ if (PROD_ < 0) {
+ xvt_note ("vpfprop::database_producer: Invalid DHT (%s) - missing ORIGINATOR field\n",
+ path);
+ vpf_close_table(&table);
+ return producer;
+ }
+
+ row = read_next_row(table);
+ producer = (char *)get_table_element(PROD_,row,table,NULL,&n);
+ free_row(row,table);
+ vpf_close_table(&table);
+
+ return producer;
+}
+
+/*************************************************************************
+ *
+ *N library_description
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the text description of the specified VPF library in the
+ * specified database.
+ * The character string is dynamically allocated and should be freed
+ * when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * database_path <input>==(char *) path the the VPF database.
+ * library <input>==(char *) library name.
+ * return <output>==(char *) description of the library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char *library_description( char *database_path, char *library )
+#else
+ char *library_description (database_path, library)
+ char *database_path;
+ char *library;
+#endif
+
+{
+ char path[255],lib[16], *description=(char *)NULL;
+ int32 DESC_,n;
+ vpf_table_type table;
+ row_type row;
+
+ strcpy(path,database_path);
+ vpf_check_os_path(path);
+ rightjust(path);
+ strcat(path,OS_SEPARATOR_STRING);
+ strcpy(lib,library);
+ rightjust(lib);
+ strcat(path,os_case(lib));
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("LHT"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::library_description: %s not found\n",path);
+ return description;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::library_description: Error opening %s\n",path);
+ return description;
+ }
+
+ DESC_ = table_pos("DESCRIPTION",table);
+ if (DESC_ < 0) {
+ xvt_note ("vpfprop::library_description: Invalid LHT (%s) - missing DESCRIPTION field\n",
+ path);
+ vpf_close_table(&table);
+ return description;
+ }
+
+ row = read_next_row(table);
+ description = (char *)get_table_element(DESC_,row,table,NULL,&n);
+ free_row(row,table);
+ vpf_close_table(&table);
+
+ return description;
+}
+
+/*************************************************************************
+ *
+ *N library_extent
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the geographic extent of the specified VPF library in the
+ * coordinate system for the library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * database_path <input>==(char *) path the the VPF database.
+ * library <input>==(char *) library name.
+ * return <output>==(extent_type) geographic extent of the library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ extent_type library_extent( char *database_path, char *library )
+#else
+ extent_type library_extent (database_path, library)
+ char *database_path, *library;
+#endif
+
+{
+ static extent_type extent = {0.0,0.0,0.0,0.0};
+ char path[255], *lib, found;
+ int32 LIB_, XMIN_, YMIN_, XMAX_, YMAX_, i, n;
+ float x1, y1, x2, y2;
+ vpf_table_type table;
+ row_type row;
+
+ strcpy(path,database_path);
+ vpf_check_os_path(path);
+ rightjust(path);
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("LAT"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::library_extent: %s not found\n",path);
+ return extent;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::library_extent: Error opening %s\n",path);
+ return extent;
+ }
+
+ LIB_ = table_pos("LIBRARY_NAME",table);
+ if (LIB_ < 0) {
+ xvt_note ("vpfprop::library_extent: Invalid LAT (%s) - missing LIBRARY_NAME field\n",
+ path);
+ vpf_close_table(&table);
+ return extent;
+ }
+
+ XMIN_ = table_pos("XMIN",table);
+ if (XMIN_ < 0) {
+ xvt_note ("vpfprop::library_extent: Invalid LAT (%s) - missing XMIN field\n",
+ path);
+ vpf_close_table(&table);
+ return extent;
+ }
+
+ YMIN_ = table_pos("YMIN",table);
+ if (YMIN_ < 0) {
+ xvt_note ("vpfprop::library_extent: Invalid LAT (%s) - missing YMIN field\n",
+ path);
+ vpf_close_table(&table);
+ return extent;
+ }
+
+ XMAX_ = table_pos("XMAX",table);
+ if (XMAX_ < 0) {
+ xvt_note ("vpfprop::library_extent: Invalid LAT (%s) - missing XMAX field\n",
+ path);
+ vpf_close_table(&table);
+ return extent;
+ }
+
+ YMAX_ = table_pos("YMAX",table);
+ if (YMAX_ < 0) {
+ xvt_note ("vpfprop::library_extent: Invalid LAT (%s) - missing YMAX field\n",
+ path);
+ vpf_close_table(&table);
+ return extent;
+ }
+
+ found = 0;
+ for (i=0;i<table.nrows;i++) {
+ row = read_next_row(table);
+ lib = (char *)get_table_element(LIB_,row,table,NULL,&n);
+ rightjust(lib);
+ if (Mstrcmpi (lib,library)==0)
+ {
+ found = 1;
+ /* get extent */
+ get_table_element(XMIN_,row,table,&x1,&n);
+ get_table_element(YMIN_,row,table,&y1,&n);
+ get_table_element(XMAX_,row,table,&x2,&n);
+ get_table_element(YMAX_,row,table,&y2,&n);
+ extent.x1 = x1;
+ extent.y1 = y1;
+ extent.x2 = x2;
+ extent.y2 = y2;
+ }
+ xvt_free(lib);
+ free_row(row,table);
+ if (found) break;
+ }
+ vpf_close_table(&table);
+
+ if (!found)
+ xvt_note (
+ "vpfprop::library_extent: Library %s not found for database %s\n",
+ library, database_path);
+
+ return extent;
+}
+
+/*************************************************************************
+ *
+ *N library_security
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the security classification of the VPF library at the
+ * specified directory path.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * return <output>==(security_type) security classification
+ * of the library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ security_type library_security( char *library_path )
+#else
+ security_type library_security (library_path)
+ char *library_path;
+#endif
+
+{
+ char path[255],sec;
+ int32 SEC_,n;
+ security_type security=UNKNOWN_SECURITY;
+ vpf_table_type table;
+ row_type row;
+
+ if (!library_path) {
+ xvt_note ("vpfprop::library_security: no path specified\n");
+ return security;
+ }
+
+ strcpy(path,library_path);
+ vpf_check_os_path(path);
+ rightjust(path);
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("LHT"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::library_security: %s not found\n",path);
+ return security;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::library_security: Error opening %s\n",path);
+ return security;
+ }
+
+ SEC_ = table_pos("SECURITY_CLASS",table);
+ if (SEC_ < 0) {
+ xvt_note ("vpfprop::library_security: Invalid LHT (%s) - missing SECURITY_CLASS field\n",
+ path);
+ vpf_close_table(&table);
+ return security;
+ }
+
+ row = read_next_row(table);
+ get_table_element(SEC_,row,table,&sec,&n);
+ free_row(row,table);
+ vpf_close_table(&table);
+
+ switch (sec) {
+ case 'U':
+ security = UNCLASSIFIED;
+ break;
+ case 'R':
+ security = RESTRICTED;
+ break;
+ case 'C':
+ security = CONFIDENTIAL;
+ break;
+ case 'S':
+ security = SECRET;
+ break;
+ case 'T':
+ security = TOP_SECRET;
+ break;
+ }
+
+ return security;
+}
+
+
+/*************************************************************************
+ *
+ *N library_coverage_names
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns an array of coverage names present in the specified library.
+ * The number of coverages is returned in ncov. The array of strings
+ * is dynamically allocated and each array element as well as the
+ * array itself should be freed when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * ncov <output>==(int32 *) number of coverages in the library.
+ * return <output>==(char **) array of coverage names in the
+ * library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char **library_coverage_names( char *library_path, int32 *ncov )
+#else
+ char **library_coverage_names (library_path, ncov)
+ char *library_path, *ncov;
+#endif
+
+{
+ char **covname = (char **)NULL;
+ char path[255];
+ vpf_table_type table;
+ row_type row;
+ int32 i,n;
+ int32 COV_;
+
+ *ncov = 0;
+
+ strcpy(path,library_path);
+ rightjust(path);
+ if (path[strlen(path)-1] != OS_SEPARATOR)
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("CAT"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::library_coverage_names: ");
+ xvt_note ("Invalid VPF library (%s) - CAT missing\n",library_path);
+ return covname;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::library_coverage_names: ");
+ xvt_note ("Error opening %s\n",path);
+ return covname;
+ }
+
+ COV_ = table_pos("COVERAGE_NAME",table);
+ if (COV_ < 0) {
+ xvt_note ("vpfprop::library_coverage_names: ");
+ xvt_note ("%s - Invalid CAT - missing COVERAGE_NAME field\n",
+ library_path);
+ vpf_close_table(&table);
+ return covname;
+ }
+
+ covname = (char **)xvt_malloc ((size_t)table.nrows * sizeof (char*));
+ if (!covname) {
+ xvt_note ("vpfprop::library_coverage_names: ");
+ xvt_note ("Memory allocation error\n");
+ vpf_close_table(&table);
+ return covname;
+ }
+
+ for (i=0;i<table.nrows;i++) {
+ row = read_next_row(table);
+ covname[i] = (char *)get_table_element(COV_,row,table,NULL,&n);
+ free_row(row,table);
+ }
+
+ *ncov = (int32)table.nrows;
+
+ vpf_close_table(&table);
+
+ return covname;
+}
+
+/*************************************************************************
+ *
+ *N library_coverage_descriptions
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns an array of coverage descriptions present in the specified
+ * library. The number of coverages is returned in ncov. The array of
+ * strings is dynamically allocated and each array element as well
+ * as the array itself should be freed when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * ncov <output>==(int32 *) number of coverages in the library.
+ * return <output>==(char **) array of coverage descriptions in
+ * the library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char **library_coverage_descriptions( char *library_path, int32 *ncov )
+#else
+ char **library_coverage_descriptions (library_path, ncov)
+ char *library_path, *ncov;
+#endif
+
+{
+ char **covdesc = (char **)NULL;
+ char path[255];
+ vpf_table_type table;
+ row_type row;
+ int32 i,n;
+ int32 DESC_;
+
+ *ncov = 0;
+
+ strcpy(path,library_path);
+ rightjust(path);
+ if (path[strlen(path)-1] != OS_SEPARATOR)
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("CAT"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::library_coverage_descriptions: ");
+ xvt_note ("Invalid VPF library (%s) - CAT missing\n",
+ library_path);
+ return covdesc;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::library_coverage_descriptions: ");
+ xvt_note ("Error opening %s\n",path);
+ return covdesc;
+ }
+
+ DESC_ = table_pos("DESCRIPTION",table);
+ if (DESC_ < 0) {
+ xvt_note ("vpfprop::library_coverage_descriptions: ");
+ xvt_note ("%s - Invalid CAT - missing DESCRIPTION field\n",
+ library_path);
+ vpf_close_table(&table);
+ return covdesc;
+ }
+
+ covdesc = (char**)xvt_malloc ((size_t)table.nrows * sizeof(char*));
+ if (!covdesc) {
+ xvt_note ("vpfprop::library_coverage_descriptions: ");
+ xvt_note ("Memory allocation error\n");
+ vpf_close_table(&table);
+ return covdesc;
+ }
+
+ for (i=0;i<table.nrows;i++) {
+ row = read_next_row(table);
+ covdesc[i] = (char *)get_table_element(DESC_,row,table,NULL,&n);
+ free_row(row,table);
+ }
+
+ *ncov = (int32)table.nrows;
+
+ vpf_close_table(&table);
+
+ return covdesc;
+}
+
+
+
+
+/*************************************************************************
+ *
+ *N library_feature_class_names
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns an array of all of the feature classes in an entire library.
+ * The strings will be of the form "<cov>\<fcname>" where <cov> is the
+ * name of the coverage and <fcname> is the name of the feature class.
+ * The number of feature classes is returned in nfc. The array of
+ * strings is dynamically allocated and each array element as well
+ * as the array itself should be freed when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * nfc <output>==(long *) number of feature classes in the
+ * library.
+ * return <output>==(char **) array of coverage name\feature
+ * class name pairs in the library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char **library_feature_class_names( char *library_path, int32 *nfc )
+#else
+ char **library_feature_class_names (library_path, nfc)
+ char *library_path;
+ int32 *nfc;
+#endif
+
+{
+ int32 ncov,i,j,k,n;
+ char path[255];
+ char **ptr, **coverages, **subset, **fcnames=(char **)NULL;
+
+ *nfc=0;
+
+ strcpy(path,library_path);
+ vpf_check_os_path(path);
+ rightjust(path);
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::library_feature_class_names: %s not found\n",
+ path);
+ return fcnames;
+ }
+
+ coverages = library_coverage_names( path, &ncov );
+ if (ncov == 0) {
+ xvt_note ("vpfprop::library_feature_class_names: No coverages in library %s\n",
+ path);
+ return fcnames;
+ }
+
+ for (i=0;i<ncov;i++) {
+ rightjust(coverages[i]);
+ }
+
+ fcnames = (char **)xvt_malloc(sizeof(char *));
+ if (!fcnames) {
+ xvt_note ("vpfprop::library_feature_class_names: Memory allocation error\n");
+ return fcnames;
+ }
+
+ for (i=0;i<ncov;i++) {
+ subset = coverage_feature_class_names(path,coverages[i],&n);
+ if (!subset) continue;
+ for (j=0;j<n;j++) {
+ rightjust(subset[j]);
+ }
+ *nfc += n;
+ ptr = (char**)realloc (fcnames, (size_t)(sizeof (char*) * (*nfc)));
+ if (!ptr) {
+ xvt_note ("vpfprop::library_feature_class_names: ");
+ xvt_note ("Memory allocation error\n");
+ for (j=0;j<(*nfc)-n;j++) {
+ xvt_free(fcnames[j]);
+ }
+ xvt_free ((char*)fcnames);
+ *nfc = 0;
+ for (j=0;j<n;j++) {
+ xvt_free(subset[j]);
+ }
+ xvt_free ((char*)subset);
+ return (char **)NULL;
+ }
+ fcnames = ptr;
+ for (j=(*nfc)-n;j<(*nfc);j++) {
+ fcnames[j] = (char *)xvt_malloc(sizeof(char)*(strlen(coverages[i])+
+ strlen(subset[j-((*nfc)-n)])+
+ 2));
+ if (!fcnames[j]) {
+ for (k=0;k<j;k++) {
+ xvt_free(fcnames[k]);
+ }
+ xvt_free ((char*)fcnames);
+ for (k=0;k<ncov;k++) {
+ xvt_free(coverages[k]);
+ }
+ xvt_free ((char*)coverages);
+ for (k=0;k<n;k++) {
+ xvt_free(subset[k]);
+ }
+ xvt_free ((char*)subset);
+ xvt_note (
+ "vpfprop::library_feature_class_names: Memory allocation error\n");
+ return (char **)NULL;
+ }
+ sprintf (fcnames[j], "%s%c%s",
+ coverages[i],VPF_SEPARATOR,subset[j-((*nfc)-n)]);
+ }
+
+ for (j=0;j<n;j++) {
+ xvt_free(subset[j]);
+ }
+ xvt_free ((char*)subset);
+ }
+
+ for (i=0;i<ncov;i++) {
+ xvt_free(coverages[i]);
+ }
+ xvt_free ((char*)coverages);
+
+ return fcnames;
+}
+
+/*************************************************************************
+ *
+ *N library_tile_height
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the minimum tile height in the specified library.
+ * The tile height is returned in the stored coordinate system
+ * for the library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * return <output>==(double) minimum tile height in the library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ double library_tile_height( char *library_path )
+#else
+ double library_tile_height (library_path)
+ char *library_path;
+#endif
+
+{
+ double tileheight=0.0;
+ vpf_table_type table;
+ row_type row;
+ char path[255], dbpath[255],*libname;
+ int32 i, n;
+ int32 YMIN_, YMAX_, XMIN_, XMAX_;
+ double x1, y1, x2, y2;
+ extent_type libextent;
+ /* for dec degrees */
+ vpf_projection_type libproj;
+ void (*invproj)()=NULL;
+
+ libproj = library_projection(library_path);
+ set_vpf_forward_projection(libproj);
+ set_vpf_inverse_projection(libproj);
+#if 0
+ if (libproj.code > DDS) {
+ invproj = vpf_inverse_projection[libproj.code];
+ }
+#endif
+
+ strcpy(path,library_path);
+ vpf_check_os_path(path);
+ rightjust(path);
+ if (path[strlen(path)-1] != OS_SEPARATOR)
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("TILEREF"));
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("FBR"));
+ if (!file_exists(path)) {
+ strcpy(dbpath,library_path);
+ rightjust(dbpath);
+ if (dbpath[strlen(dbpath)-1] == DIR_SEPARATOR)
+ dbpath[strlen(dbpath)-1] = '\0';
+ i = strlen(dbpath)-1;
+ while (dbpath[i] != DIR_SEPARATOR && i>= 0) i--;
+ if (dbpath[i] == DIR_SEPARATOR) {
+ libname = &dbpath[i+1];
+ dbpath[i] = '\0';
+ } else {
+ libname = library_path;
+ strcpy(dbpath,"");
+ }
+ libextent = library_extent(dbpath,libname);
+ if (libproj.code > DDS) {
+ invproj(&libextent.x1,&libextent.y1);
+ invproj(&libextent.x2,&libextent.y2);
+ }
+ tileheight = (libextent.y2 - libextent.y1);
+ return tileheight;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::library_tile_height - ");
+ xvt_note ("Error opening %s\n",path);
+ return tileheight;
+ }
+
+ YMIN_ = table_pos("YMIN",table);
+ if (YMIN_ < 0) {
+ xvt_note ("vpfprop:library_tile_height: ");
+ xvt_note ("Invalid FBR (%s) - missing YMIN field\n",
+ path);
+ vpf_close_table(&table);
+ return tileheight;
+ }
+
+ YMAX_ = table_pos("YMAX",table);
+ if (YMAX_ < 0) {
+ xvt_note ("vpfprop:library_tile_height: ");
+ xvt_note ("Invalid FBR (%s) - missing YMAX field\n",
+ path);
+ vpf_close_table(&table);
+ return tileheight;
+ }
+
+ XMIN_ = table_pos("XMIN",table);
+ if (XMIN_ < 0) {
+ xvt_note ("vpfprop:library_tile_height: ");
+ xvt_note ("Invalid FBR (%s) - missing XMIN field\n",
+ path);
+ vpf_close_table(&table);
+ return tileheight;
+ }
+
+ XMAX_ = table_pos("XMAX",table);
+ if (XMAX_ < 0) {
+ xvt_note ("vpfprop:library_tile_height: ");
+ xvt_note ("Invalid FBR (%s) - missing XMAX field\n",
+ path);
+ vpf_close_table(&table);
+ return tileheight;
+ }
+
+ tileheight = (float)MAXINT;
+ for (i=1;i<=table.nrows;i++) {
+ row = read_next_row(table);
+ get_table_element(YMIN_,row,table,&y1,&n);
+ get_table_element(YMAX_,row,table,&y2,&n);
+ if (libproj.code > DDS) {
+ get_table_element(XMIN_,row,table,&x1,&n);
+ get_table_element(XMAX_,row,table,&x2,&n);
+ libextent.x1 = x1;
+ libextent.y1 = y1;
+ libextent.x2 = x2;
+ libextent.y2 = y2;
+ invproj(&libextent.x1,&libextent.y1);
+ invproj(&libextent.x2,&libextent.y2);
+ x1 = libextent.x1;
+ y1 = libextent.y1;
+ x2 = libextent.x2;
+ y2 = libextent.y2;
+ }
+ if ((y2-y1) < tileheight) tileheight = (y2-y1);
+ free_row(row,table);
+ }
+
+ vpf_close_table(&table);
+
+ return tileheight;
+}
+
+/*************************************************************************
+ *
+ *N library_projection
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the projection information for the stored coordinates in the
+ * specified VPF library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * return <output>==(vpf_projection_type) projection information
+ * for the library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ vpf_projection_type library_projection( char *library_path )
+#else
+ vpf_projection_type library_projection (library_path)
+ char *library_path;
+#endif
+
+{
+ vpf_projection_type proj;
+ char path[255], *buf;
+ vpf_table_type table;
+ row_type row;
+ int32 n, col;
+ float num;
+
+ proj.code = 0;
+ strcpy(proj.name,"");
+ proj.parm1 = 0.0;
+ proj.parm2 = 0.0;
+ proj.parm3 = 0.0;
+ proj.parm4 = 0.0;
+ proj.units = 0;
+ proj.false_easting = 0.0;
+ proj.false_northing = 0.0;
+ proj.forward_proj = NULL;
+ proj.inverse_proj = NULL;
+
+ strcpy(path,library_path);
+ rightjust(path);
+ vpf_check_os_path(path);
+ if (path[strlen(path)-1] != OS_SEPARATOR)
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("GRT"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("%s not found\n",path);
+ return proj;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::library_projection: Error opening %s\n",path);
+ return proj;
+ }
+
+ row = read_next_row(table);
+
+ col = table_pos("UNITS",table);
+ if (col < 0) {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("Invalid GRT (%s)- No UNITS field\n",path);
+ proj.units = UNKNOWN_UNITS;
+ } else {
+ buf = (char *)get_table_element(col,row,table,NULL,&n);
+ rightjust(buf);
+ if (strcmp(buf,"000")==0)
+ proj.units = UNKNOWN_UNITS;
+ else if (strcmp(buf,"001")==0)
+ proj.units = METERS;
+ else if (strcmp(buf,"014")==0)
+ proj.units = FEET;
+ else if (strcmp(buf,"019")==0)
+ proj.units = DEC_DEGREES;
+ else if (strcmp(buf,"021")==0)
+ proj.units = INCHES;
+ else if (strcmp(buf,"022")==0)
+ proj.units = KILOMETERS;
+ else if (strcmp(buf,"999")==0)
+ proj.units = OTHER_UNITS;
+ else {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("%s - Unknown UNITS code (%s)\n",path,buf);
+ proj.units = UNKNOWN_UNITS;
+ }
+ xvt_free(buf);
+ }
+
+ col = table_pos("PROJECTION_CODE",table);
+ if (col < 0) {
+ proj.code = DDS;
+ if (proj.units == UNKNOWN_UNITS) proj.units = DEC_DEGREES;
+ } else {
+ buf = (char *)get_table_element(col,row,table,NULL,&n);
+ strupr(buf);
+ if (n>2) buf[2] = '\0';
+ if (strcmp(buf,"AC")==0)
+ proj.code = AC;
+ else if (strcmp(buf,"AK")==0)
+ proj.code = AK;
+ else if (strcmp(buf,"AL")==0)
+ proj.code = AL;
+ else if (strcmp(buf,"GN")==0)
+ proj.code = GN;
+ else if (strcmp(buf,"LE")==0)
+ proj.code = LE;
+ else if (strcmp(buf,"LJ")==0)
+ proj.code = LJ;
+ else if (strcmp(buf,"MC")==0)
+ proj.code = MC;
+ else if (strcmp(buf,"OC")==0)
+ proj.code = OC;
+ else if (strcmp(buf,"OD")==0)
+ proj.code = OD;
+ else if (strcmp(buf,"PG")==0)
+ proj.code = PG;
+ else if (strcmp(buf,"TC")==0)
+ proj.code = TC;
+ else if (strcmp(buf,"UT")==0)
+ proj.code = UT;
+ else if (strcmp(buf," ")==0)
+ proj.code = DDS;
+ else {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("%s - Unknown projection code (%s)\n",
+ path, buf);
+ proj.code = -1;
+ }
+ xvt_free(buf);
+ }
+ if (proj.code < 0)
+ strcpy(proj.name,"Unknown");
+ else
+ strcpy ((char*) proj.name, (char*)projection_names[proj.code]);
+
+#if 0
+ proj.forward_proj = vpf_forward_projection[proj.code];
+ proj.inverse_proj = vpf_inverse_projection[proj.code];
+#endif
+
+ if (proj.code == DDS) {
+ free_row(row,table);
+ vpf_close_table(&table);
+ return proj;
+ }
+
+ /* parm1, parm2, parm3, parm4 */
+ col = table_pos("PARAMETER1",table);
+ if (col < 0) {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("Invalid GRT (%s)- No PARAMETER1 field\n",path);
+ } else {
+ get_table_element(col,row,table,&num,&n);
+ proj.parm1 = num;
+ }
+ col = table_pos("PARAMETER2",table);
+ if (col < 0) {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("Invalid GRT (%s)- No PARAMETER2 field\n",path);
+ } else {
+ get_table_element(col,row,table,&num,&n);
+ proj.parm2 = num;
+ }
+ col = table_pos("PARAMETER3",table);
+ if (col < 0) {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("Invalid GRT (%s)- No PARAMETER3 field\n",path);
+ } else {
+ get_table_element(col,row,table,&num,&n);
+ proj.parm3 = num;
+ }
+ col = table_pos("PARAMETER4",table);
+ if (col < 0) {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("Invalid GRT (%s)- No PARAMETER4 field\n",path);
+ } else {
+ get_table_element(col,row,table,&num,&n);
+ proj.parm4 = num;
+ }
+
+ col = table_pos("FALSE_ORIGIN_X",table);
+ if (col < 0) {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("Invalid GRT (%s)- No FALSE_ORIGIN_X field\n",path);
+ } else {
+ get_table_element(col,row,table,&num,&n);
+ proj.false_easting = num;
+ }
+ col = table_pos("FALSE_ORIGIN_Y",table);
+ if (col < 0) {
+ xvt_note ("vpfprop::library_projection: ");
+ xvt_note ("Invalid GRT (%s)- No FALSE_ORIGIN_Y field\n",path);
+ } else {
+ get_table_element(col,row,table,&num,&n);
+ proj.false_northing = num;
+ }
+
+ free_row(row,table);
+ vpf_close_table(&table);
+
+ return proj;
+}
+
+/*************************************************************************
+ *
+ *N coverage_description
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the description of the specified coverage in the specified
+ * VPF library. The description string is dynamically allocated and
+ * should be freed when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * coverage <input>==(char *) coverage name.
+ * return <output>==(char *) description of the coverage.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char *coverage_description( char *library_path, char *coverage )
+#else
+ char *coverage_description (library_path, coverage)
+ char *library_path, *coverage;
+#endif
+
+{
+ char path[255],*cov,*description=(char *)NULL;
+ vpf_table_type table;
+ row_type row;
+ int32 COV_, DESC_, n;
+ int32 found,i;
+
+ strcpy(path,library_path);
+ vpf_check_os_path(path);
+ rightjust(path);
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("CAT"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::coverage_description: %s not found\n",path);
+ return description;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::coverage_description: Error opening %s\n",path);
+ return description;
+ }
+
+ COV_ = table_pos("COVERAGE_NAME",table);
+ if (COV_ < 0) {
+ xvt_note ("vpfprop::coverage_description: Invalid CAT (%s) - missing COVERAGE_NAME field\n",
+ path);
+ vpf_close_table(&table);
+ return description;
+ }
+
+ DESC_ = table_pos("DESCRIPTION",table);
+ if (DESC_ < 0) {
+ xvt_note ("vpfprop::coverage_description: Invalid CAT (%s) - missing DESCRIPTION field\n",
+ path);
+ vpf_close_table(&table);
+ return description;
+ }
+
+ found = 0;
+ for (i=0;i<table.nrows;i++) {
+ row = read_next_row(table);
+ cov = (char *) get_table_element(COV_,row,table,NULL,&n);
+ rightjust(cov);
+
+ if (Mstrcmpi (cov, coverage) == 0)
+ {
+ found = 1;
+ description = (char *)get_table_element(DESC_,row,table,NULL,&n);
+ }
+
+ xvt_free(cov);
+ free_row(row,table);
+ if (found) break;
+ }
+
+ vpf_close_table(&table);
+
+ if (!found) {
+ xvt_note (
+ "vpfprop::coverage_description: Coverage %s not found for library %s\n",
+ coverage, library_path);
+ }
+ return description;
+}
+
+
+/*************************************************************************
+ *
+ *N coverage_feature_class_names
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns an array of the feature classes present in the specified
+ * coverage of the specified library. The number of feature classes
+ * is returned in nfc. The array of strings is dynamically allocated
+ * and each array element as well as the array itself should be freed
+ * when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * nfc <output>==(int32 *) number of feature classes in the
+ * coverage.
+ * return <output>==(char **) array of feature class names in
+ * the coverage.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char **coverage_feature_class_names( char *library_path, char *coverage,
+ int32 *nfc )
+#else
+ char **coverage_feature_class_names (library_path, coverage, nfc)
+ char *library_path, coverage;
+ int32 *nfc;
+#endif
+
+{
+ char **fcnames = (char **)NULL, path[255], covpath[255];
+ char *fc,**ptr;
+ vpf_table_type table;
+ row_type row;
+ int32 FC_, i, j, k, n;
+ int32 found;
+
+ *nfc = 0;
+
+ fcnames = (char **)xvt_malloc(sizeof(char *));
+ if (!fcnames) {
+ xvt_note (
+ "vpfprop::coverage_feature_class_names: Memory allocation error\n");
+ return (char **)NULL;
+ }
+
+ strcpy(covpath,library_path);
+ rightjust(covpath);
+ if (covpath[strlen(covpath)-1] != OS_SEPARATOR)
+ strcat(covpath,OS_SEPARATOR_STRING);
+ strcat(covpath,os_case(coverage));
+ rightjust(covpath);
+ strcat(covpath,OS_SEPARATOR_STRING);
+ vpf_check_os_path(covpath);
+
+ strcpy(path,covpath);
+ strcat(path,os_case("FCS"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::coverage_feature_class_names: ");
+ xvt_note ("Invalid VPF coverage (%s) - missing FCS\n",covpath);
+ xvt_free ((char*)fcnames);
+ return (char **)NULL;
+ }
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::coverage_feature_class_names: Error opening %s\n",
+ path);
+ xvt_free ((char*)fcnames);
+ return (char **)NULL;
+ }
+ FC_ = table_pos("FEATURE_CLASS",table);
+ if (FC_ < 0) {
+ xvt_note ("vpfprop::coverage_feature_class_names: ");
+ xvt_note ("Invalid FCS (%s) - missing FEATURE_CLASS field\n",
+ path);
+ vpf_close_table(&table);
+ xvt_free ((char*)fcnames);
+ return (char **)NULL;
+ }
+
+ j = 0;
+ row = read_next_row(table);
+ fcnames[j] = (char *)get_table_element(FC_,row,table,NULL,&n);
+ rightjust(fcnames[j]);
+ free_row(row,table);
+
+ for (i=2;i<=table.nrows;i++) {
+ row = read_next_row(table);
+ fc = (char *)get_table_element(FC_,row,table,NULL,&n);
+ rightjust(fc);
+ free_row(row,table);
+ found = 0;
+ for (k=j;k>=0;k--) {
+
+ if (Mstrcmpi (fc, fcnames[k]) == 0)
+ {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ j++;
+ ptr = (char**)realloc ((void*)fcnames, (size_t)(j+1) *
+ sizeof(char*));
+ if (!ptr) {
+ xvt_note ("vpfprop::coverage_feature_class_names: ");
+ xvt_note ("Memory allocation error\n");
+ for (k=(j-1);k>=0;k--) {
+ xvt_free(fcnames[k]);
+ }
+ xvt_free ((char*)fcnames);
+ vpf_close_table(&table);
+ return (char **)NULL;
+ }
+ fcnames = ptr;
+ fcnames[j] = (char *)xvt_malloc(strlen(fc)+1);
+ if (!fcnames[j]) {
+ xvt_note ("vpfprop::coverage_feature_class_names: ");
+ xvt_note ("Memory allocation error\n");
+ for (k=0;k<j;k++) xvt_free(fcnames[k]);
+ xvt_free ((char*)fcnames);
+ vpf_close_table(&table);
+ return (char **)NULL;
+ }
+ strcpy(fcnames[j],fc);
+ }
+ xvt_free(fc);
+ }
+ vpf_close_table(&table);
+
+ *nfc = (int32)j+1;
+
+ return fcnames;
+}
+
+/*************************************************************************
+ *
+ *N coverage_topology_level
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the topology level for the specified coverage in the
+ * specified VPF library.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * coverage <input>==(char *) coverage name.
+ * return <output>==(int32) topology level of the coverage.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 coverage_topology_level( char *library_path, char *coverage )
+#else
+ int32 coverage_topology_level (library_path, coverage)
+ char *library_path, *coverage;
+#endif
+
+{
+ char path[255],*cov;
+ int32 level=0, found,i;
+ vpf_table_type table;
+ row_type row;
+ int32 COV_,LVL_,n;
+
+ strcpy(path,library_path);
+ vpf_check_os_path(path);
+ rightjust(path);
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case("CAT"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::coverage_topology_level: %s not found\n",path);
+ return level;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::coverage_topology_level: Error opening %s\n",path);
+ return level;
+ }
+
+ COV_ = table_pos("COVERAGE_NAME",table);
+ if (COV_ < 0) {
+ xvt_note ("vpfprop::coverage_topology_level: Invalid CAT (%s) - missing COVERAGE_NAME field\n",
+ path);
+ vpf_close_table(&table);
+ return level;
+ }
+
+ LVL_ = table_pos("LEVEL",table);
+ if (LVL_ < 0) {
+ xvt_note ("vpfprop::coverage_topology_level: Invalid CAT (%s) - missing LEVEL field\n",
+ path);
+ vpf_close_table(&table);
+ return level;
+ }
+
+ found = 0;
+ for (i=0;i<table.nrows;i++) {
+ row = read_next_row(table);
+ cov = (char *) get_table_element(COV_,row,table,NULL,&n);
+ rightjust(cov);
+
+ if (Mstrcmpi (cov, coverage) == 0)
+ {
+ found = 1;
+ get_table_element(LVL_,row,table,&level,&n);
+ }
+
+ xvt_free(cov);
+ free_row(row,table);
+ if (found) break;
+ }
+
+ vpf_close_table(&table);
+
+ if (!found) {
+ xvt_note (
+ "vpfprop::coverage_topology_level: Coverage %s not found for library %s\n",
+ coverage, library_path);
+ }
+
+ return level;
+}
+
+
+
+/*************************************************************************
+ *
+ *N feature_class_description
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the text description for the specified VPF feature class.
+ * The description string is dynamically allocated and should be freed
+ * when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * coverage <input>==(char *) coverage name.
+ * feature_class <input>==(char *) feature class name.
+ * return <output>==(char *) feature class description string.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char *feature_class_description( char *library_path, char *coverage,
+ char *feature_class )
+#else
+ char *feature_class_description (library_path, coverage, feature_class)
+ char *library_path, *coverage, *feature_class;
+#endif
+
+{
+ char *desc = (char *)NULL, path[255], *fctable, *fc;
+ vpf_table_type table;
+ row_type row;
+ int32 FC_, DESC_, i, n;
+ int32 found;
+
+ /* First, see if an FCA table exists in the coverage */
+ strcpy(path,library_path);
+ rightjust(path);
+ if (path[strlen(path)-1] != OS_SEPARATOR)
+ strcat(path,OS_SEPARATOR_STRING);
+ strcat(path,os_case(coverage));
+ rightjust(path);
+ strcat(path,OS_SEPARATOR_STRING);
+ vpf_check_os_path(path);
+
+ strcat(path,os_case("FCA"));
+ if (file_exists(path)) {
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::feature_class_description: Error opening %s\n",
+ path);
+ return (char *)NULL;
+ }
+
+ FC_ = table_pos("FCLASS",table);
+ if (FC_ < 0) {
+ xvt_note ("vpfprop::feature_class_description: ");
+ xvt_note ("Invalid FCA (%s) - missing FCLASS field\n",
+ path);
+ vpf_close_table(&table);
+ return (char *)NULL;
+ }
+
+ DESC_ = table_pos("DESCRIPTION",table);
+ if (DESC_ < 0) DESC_ = table_pos("DESCR",table);
+ if (DESC_ < 0) {
+ xvt_note ("vpfprop::feature_class_description: ");
+ xvt_note ("Invalid FCA (%s) - missing DESCRIPTION field\n",
+ path);
+ vpf_close_table(&table);
+ return (char *)NULL;
+ }
+
+ found = 0;
+ for (i=1;i<=table.nrows;i++) {
+ row = read_next_row(table);
+ fc = (char *)get_table_element(FC_,row,table,NULL,&n);
+ rightjust(fc);
+
+ if (Mstrcmpi (fc, feature_class) == 0)
+ {
+ found = 1;
+ desc = (char *)get_table_element(DESC_,row,table,NULL,&n);
+ }
+ xvt_free(fc);
+ free_row(row,table);
+ if (found) break;
+ }
+
+ vpf_close_table(&table);
+
+ if (!found) {
+ xvt_note ("vpfprop::feature_class_description: ");
+ xvt_note ("Feature class (%s) not found in FCA (%s)\n",
+ feature_class,path);
+ }
+
+ } else {
+
+ /* Get description from feature class table */
+ fctable = feature_class_table( library_path, coverage, feature_class );
+ if (!fctable) {
+ xvt_note ("vpfprop::feature_class_description: ");
+ xvt_note ("Invalid feature class (%s) in coverage (%s %s)\n",
+ feature_class, library_path,coverage);
+ return (char *)NULL;
+ }
+ if (!file_exists(fctable)) {
+ xvt_note ("vpfprop::feature_class_description: ");
+ xvt_note ("%s not found\n",fctable);
+ xvt_free(fctable);
+ return (char *)NULL;
+ }
+
+ table = vpf_open_table(fctable,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::feature_class_description: ");
+ xvt_note ("Error opening %s\n",fctable);
+ xvt_free(fctable);
+ return (char *)NULL;
+ }
+
+ xvt_free(fctable);
+
+ desc = (char *)xvt_malloc(strlen(table.description)+1);
+ if (!desc) {
+ xvt_note ("vpfprop::feature_class_description: ");
+ xvt_note ("Memory allocation error\n");
+ return (char *)NULL;
+ }
+
+ strcpy(desc,table.description);
+
+ vpf_close_table(&table);
+
+ }
+
+ return desc;
+}
+
+/*************************************************************************
+ *
+ *N feature_class_table_description
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the text description for the specified feature class table.
+ * The description string is dynamically allocated and should be freed
+ * when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * fctable <input>==(char *) path to the feature class table.
+ * return <output>==(char *) feature class table description.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char *feature_class_table_description( char *fctable )
+#else
+ char *feature_class_table_description (fctable)
+ char *fctable;
+#endif
+
+{
+ char path[255],*description=(char *)NULL;
+ vpf_table_type table;
+
+ strcpy(path,fctable);
+ vpf_check_os_path(path);
+ rightjust(path);
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::feature_class_table_description: %s not found\n",
+ path);
+ return description;
+ }
+
+ if (!is_vpf_table(path)) {
+ xvt_note (
+ "vpfprop::feature_class_table_description: %s not a VPF table.\n",
+ path);
+ return description;
+ }
+
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::feature_class_table_description: Error opening %s\n",
+ path);
+ return description;
+ }
+
+ description = (char*)xvt_malloc (strlen (table.description)+1);
+ strcpy (description, table.description);
+
+ vpf_close_table(&table);
+
+ return description;
+}
+
+/*************************************************************************
+ *
+ *N feature_class_table
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the feature table path for the specified VPF feature class.
+ * The description string is dynamically allocated and should be freed
+ * when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * coverage <input>==(char *) coverage name.
+ * feature_class <input>==(char *) feature class name.
+ * return <output>==(char *) feature class table path.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ char *feature_class_table( char *library_path, char *coverage,
+ char *feature_class )
+#else
+ char *feature_class_table (library_path, coverage, feature_class)
+ char *library_path, *coverage, *feature_class;
+#endif
+
+{
+ char *fctable = (char *)NULL, path[255], covpath[255];
+ char *fc, *table1;
+ vpf_table_type table;
+ row_type row;
+ int32 TABLE1_, FC_, i,n;
+ int32 fcfound, ftfound;
+
+ fctable = (char *)xvt_malloc(255);
+ if (!fctable) {
+ xvt_note (
+ "vpfprop::feature_class_table: Memory allocation error\n");
+ return (char *)NULL;
+ }
+
+ strcpy(covpath,library_path);
+ rightjust(covpath);
+ if (covpath[strlen(covpath)-1] != OS_SEPARATOR)
+ strcat(covpath,OS_SEPARATOR_STRING);
+ strcat(covpath,os_case(coverage));
+ rightjust(covpath);
+ strcat(covpath,OS_SEPARATOR_STRING);
+ vpf_check_os_path(covpath);
+
+ strcpy(fctable,covpath);
+
+ strcpy(path,covpath);
+ strcat(path,os_case("FCS"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::feature_class_table: ");
+ xvt_note ("Invalid VPF coverage (%s) - missing FCS\n",covpath);
+ xvt_free(fctable);
+ return (char *)NULL;
+ }
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::feature_class_table: Error opening %s\n",
+ path);
+ xvt_free(fctable);
+ return (char *)NULL;
+ }
+ FC_ = table_pos("FEATURE_CLASS",table);
+ if (FC_ < 0) {
+ xvt_note ("vpfprop::feature_class_table: ");
+ xvt_note ("Invalid FCS (%s) - missing FEATURE_CLASS field\n",
+ path);
+ vpf_close_table(&table);
+ xvt_free(fctable);
+ return (char *)NULL;
+ }
+ TABLE1_ = table_pos("TABLE1",table);
+ if (TABLE1_ < 0) {
+ xvt_note ("vpfprop::feature_class_table: ");
+ xvt_note ("Invalid FCS (%s) - missing TABLE1 field\n",
+ path);
+ vpf_close_table(&table);
+ xvt_free(fctable);
+ return (char *)NULL;
+ }
+ fcfound = 0;
+ ftfound = 0;
+ for (i=1;i<=table.nrows;i++) {
+ row = read_next_row(table);
+ fc = (char *)get_table_element(FC_,row,table,NULL,&n);
+ rightjust(fc);
+
+ if (Mstrcmpi (fc, feature_class) == 0)
+ {
+ fcfound = 1;
+ table1 = (char*)get_table_element (TABLE1_, row, table, NULL, &n);
+ rightjust (table1);
+ if (is_feature (table1))
+ {
+ ftfound = 1;
+ if (is_feature (fctable))
+ {
+ if (is_complex_feature (table1))
+ {
+ strcpy (fctable, covpath);
+ strcat (fctable, os_case (table1));
+ }
+ }
+ else
+ {
+ strcat (fctable, os_case (table1));
+ }
+ }
+ xvt_free (table1);
+ }
+ free_row(row,table);
+ xvt_free(fc);
+ }
+ vpf_close_table(&table);
+
+ if (!fcfound) {
+ xvt_note ("vpfprop::feature_class_table: ");
+ xvt_note ("Feature class (%s) not found in FCS (%s)\n",
+ feature_class,path);
+ xvt_free(fctable);
+ fctable = (char *)NULL;
+ }
+
+ if (!ftfound) {
+ xvt_note ("vpfprop::feature_class_table: ");
+ xvt_note ("(%s) - No feature table found for feature class %s\n",
+ path,feature_class);
+ xvt_free(fctable);
+ fctable = (char *)NULL;
+ }
+
+ return fctable;
+}
+
+
+
+/*************************************************************************
+ *
+ *N feature_class_primitive_type
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the type(s) of primitive(s) associated with the specified
+ * VPF feature class.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * library_path <input>==(char *) path the the VPF library.
+ * coverage <input>==(char *) coverage name.
+ * feature_class <input>==(char *) feature class name.
+ * return <output>==(primitive_class_type) primitive class
+ * structure for the feature class.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ primitive_class_type feature_class_primitive_type( char *library_path,
+ char *coverage,
+ char *feature_class )
+#else
+ primitive_class_type feature_class_primitive_type (library_path, coverage, feature_class)
+ char *library_path, *coverage, *feature_class;
+#endif
+
+{
+ static primitive_class_type pclass = {0,0,0,0,0};
+ char path[255], covpath[255];
+ char *fc, *table1, *table2;
+ vpf_table_type table;
+ row_type row;
+ int32 TABLE1_, TABLE2_, FC_, i,n;
+ int32 fcfound, pfound;
+
+ strcpy(covpath,library_path);
+ rightjust(covpath);
+ if (covpath[strlen(covpath)-1] != OS_SEPARATOR)
+ strcat(covpath,OS_SEPARATOR_STRING);
+ strcat(covpath,os_case(coverage));
+ rightjust(covpath);
+ strcat(covpath,OS_SEPARATOR_STRING);
+ vpf_check_os_path(covpath);
+
+ strcpy(path,covpath);
+ strcat(path,os_case("FCS"));
+ if (!file_exists(path)) {
+ xvt_note ("vpfprop::feature_class_primitive_type: ");
+ xvt_note ("Invalid VPF coverage (%s) - missing FCS\n",covpath);
+ return pclass;
+ }
+ table = vpf_open_table(path,disk,"rb",NULL);
+ if (!table.fp) {
+ xvt_note ("vpfprop::feature_class_primitive_type: ");
+ xvt_note ("Error opening %s\n",
+ path);
+ return pclass;
+ }
+ FC_ = table_pos("FEATURE_CLASS",table);
+ if (FC_ < 0) {
+ xvt_note ("vpfprop::feature_class_primitive_type: ");
+ xvt_note ("Invalid FCS (%s) - missing FEATURE_CLASS field\n",
+ path);
+ vpf_close_table(&table);
+ return pclass;
+ }
+
+ TABLE1_ = table_pos("TABLE1",table);
+ if (TABLE1_ < 0) {
+ xvt_note ("vpfprop::feature_class_primitive_type: ");
+ xvt_note ("Invalid FCS (%s) - missing TABLE1 field\n",
+ path);
+ vpf_close_table(&table);
+ return pclass;
+ }
+
+ TABLE2_ = table_pos("TABLE2",table);
+ if (TABLE2_ < 0) {
+ xvt_note ("vpfprop::feature_class_primitive_type: ");
+ xvt_note ("Invalid FCS (%s) - missing TABLE2 field\n",
+ path);
+ vpf_close_table(&table);
+ return pclass;
+ }
+
+ fcfound = 0;
+ pfound = 0;
+ for (i=1;i<=table.nrows;i++) {
+ row = read_next_row(table);
+ fc = (char *)get_table_element(FC_,row,table,NULL,&n);
+ rightjust(fc);
+
+ if (Mstrcmpi (fc, feature_class) == 0)
+ {
+ fcfound = 1;
+ table1 = (char*)get_table_element (TABLE1_, row, table, NULL, &n);
+ rightjust (table1);
+ if (is_primitive (table1))
+ {
+ pfound = 1;
+ switch (primitive_class (table1))
+ {
+ case EDGE:
+ pclass.edge = 1;
+ break;
+ case FACE:
+ pclass.face = 1;
+ break;
+ case TEXT:
+ pclass.text = 1;
+ break;
+ case ENTITY_NODE:
+ pclass.entity_node = 1;
+ break;
+ case CONNECTED_NODE:
+ pclass.connected_node = 1;
+ break;
+ }
+ }
+ xvt_free (table1);
+ table2 = (char*)get_table_element (TABLE2_, row, table, NULL, &n);
+ rightjust (table2);
+ if (is_primitive (table2))
+ {
+ pfound = 1;
+ switch (primitive_class (table2))
+ {
+ case EDGE:
+ pclass.edge = 1;
+ break;
+ case FACE:
+ pclass.face = 1;
+ break;
+ case TEXT:
+ pclass.text = 1;
+ break;
+ case ENTITY_NODE:
+ pclass.entity_node = 1;
+ break;
+ case CONNECTED_NODE:
+ pclass.connected_node = 1;
+ break;
+ }
+ }
+ xvt_free(table2);
+ }
+ free_row(row,table);
+ xvt_free(fc);
+ }
+ vpf_close_table(&table);
+
+ if (!fcfound) {
+ xvt_note ("vpfprop::feature_class_primitive_type: ");
+ xvt_note ("Feature class (%s) not found in FCS (%s)\n",
+ feature_class,path);
+ }
+
+ if (!pfound) {
+ xvt_note ("vpfprop::feature_class_primitive_type: ");
+ xvt_note ("(%s) - No primitive table found for feature class %s\n",
+ path,feature_class);
+ }
+
+ return pclass;
+}
+
+
+/*************************************************************************
+ *
+ *N is_primitive
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns TRUE if the given table name is that of a valid VPF
+ * primitive table; otherwise, returns FALSE. Determination is
+ * based solely upon the file name. The actual contents of the
+ * file are not checked for validity.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * tablename <input>==(char *) name of the VPF table to check.
+ * return <output>==(int32) TRUE if the table name specifies a VPF
+ * primitive; otherwise, returns FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 is_primitive( char *tablename )
+#else
+ int32 is_primitive (tablename)
+ char *tablename;
+#endif
+
+{
+ char *locname,*end;
+ int32 len, retval=0;
+
+ locname = (char*) xvt_zmalloc (strlen (tablename) * sizeof(char)+1);
+ if (locname == (char*)NULL)
+ {
+ xvt_note ("vpfprop::is_primitive: Memory allocation error");
+ return FALSE;
+ }
+
+ strcpy(locname,tablename);
+
+ vpf_check_os_path(locname);
+
+ /* if OS_SEPARATOR in string, delete through last OS_SEPARATOR */
+
+ end = strrchr(locname,OS_SEPARATOR);
+
+ if (end != NULL) {
+ end += sizeof(char);
+ strcpy(locname,end);
+ }
+
+ /* if trailing '.' remove */
+
+ len = strlen(locname);
+
+ if (locname[len-1]=='.') {
+ locname[len-1]='\0';
+ len--;
+ }
+
+ strupr(locname);
+
+ if (strcmp(locname,"END") == 0) retval = TRUE;
+ if (strcmp(locname,"CND") == 0) retval = TRUE;
+ if (strcmp(locname,"EDG") == 0) retval = TRUE;
+ if (strcmp(locname,"FAC") == 0) retval = TRUE;
+ if (strcmp(locname,"TXT") == 0) retval = TRUE;
+
+ xvt_free(locname);
+
+ return retval;
+}
+
+
+/*************************************************************************
+ *
+ *N is_simple_feature
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns TRUE if the given table name is that of a valid VPF
+ * simple feature table; otherwise, returns FALSE. Determination is
+ * based solely upon the file name. The actual contents of the
+ * file are not checked for validity.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * Parameters:
+ *A
+ * tablename <input>==(char *) name of the VPF table to check.
+ * return <output>==(int32) TRUE if the table name specifies a VPF
+ * simple feature; otherwise, returns FALSE.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 is_simple_feature( char *tablename )
+#else
+ int32 is_simple_feature (tablename)
+ char *tablename;
+#endif
+
+{
+ char *locname, *end;
+ int32 retval=0;
+
+ locname = (char*) xvt_zmalloc (strlen (tablename) * sizeof (char)+1);
+ if (locname == (char*)NULL)
+ {
+ xvt_note ("vpfprop:is_simple_feature: Memory allocation error");
+ return FALSE;
+ }
+
+ strcpy(locname,tablename);
+ rightjust(locname);
+
+ /* if '.' in string, delete through last . */
+
+ end = strrchr(locname,'.');
+
+ if (end != NULL) {
+ strcpy(locname,end);
+ }
+
+ strupr(locname);
+
+ if (strcmp(locname,".PFT")==0) retval = TRUE;
+ if (strcmp(locname,".LFT")==0) retval = TRUE;
+ if (strcmp(locname,".AFT")==0) retval = TRUE;
+ if (strcmp(locname,".TFT")==0) retval = TRUE;
+
+ xvt_free(locname);
+
+ return retval;
+}
+
+
+/*************************************************************************
+ *
+ *N is_complex_feature
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns TRUE if the given table name is that of a valid VPF
+ * complex feature table; otherwise, returns FALSE. Determination is
+ * based solely upon the file name. The actual contents of the
+ * file are not checked for validity.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * Parameters:
+ *A
+ * tablename <input>==(char *) name of the VPF table to check.
+ * return <output>==(int32) TRUE if the table name specifies a VPF
+ * complex feature; otherwise, returns FALSE.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 is_complex_feature( char *tablename )
+#else
+ int32 is_complex_feature (tablename)
+ char *tablename;
+#endif
+
+{
+ char *locname, *end;
+ int32 retval=0;
+
+ locname = (char*)xvt_zmalloc (strlen (tablename) * sizeof(char)+1);
+ if (locname == (char*)NULL)
+ {
+ xvt_note ("vpfprop:is_complex_feature: Memory allocation error");
+ return FALSE;
+ }
+
+ strcpy(locname,tablename);
+ rightjust(locname);
+
+ /* if '.' in string, delete through last . */
+
+ end = strrchr(locname,'.');
+
+ if (end != NULL) {
+ strcpy(locname,end);
+ }
+
+ strupr(locname);
+
+ if (strcmp(locname,".CFT")==0) retval = TRUE;
+
+ xvt_free(locname);
+
+ return retval;
+}
+
+
+/*************************************************************************
+ *
+ *N is_feature
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns TRUE if the given table name is that of a valid VPF
+ * feature table; otherwise, returns FALSE. Determination is
+ * based solely upon the file name. The actual contents of the
+ * file are not checked for validity.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * Parameters:
+ *A
+ * tablename <input>==(char *) name of the VPF table to check.
+ * return <output>==(int32) TRUE if the table name specifies a VPF
+ * feature; otherwise, returns FALSE.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 is_feature( char *tablename )
+#else
+ int32 is_feature (tablename)
+ char *tablename;
+#endif
+
+{
+ if (is_simple_feature(tablename)) return TRUE;
+ if (is_complex_feature(tablename)) return TRUE;
+ return FALSE;
+}
+
+
+/*************************************************************************
+ *
+ *N is_join
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns TRUE if the given table name is that of a valid VPF
+ * join table; otherwise, returns FALSE. Determination is
+ * based solely upon the file name. The actual contents of the
+ * file are not checked for validity.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * Parameters:
+ *A
+ * tablename <input>==(char *) name of the VPF table to check.
+ * return <output>==(int32) TRUE if the table name specifies a VPF
+ * join table; otherwise, returns FALSE.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 is_join( char *tablename )
+#else
+ int32 is_join (tablename)
+ char *tablename;
+#endif
+
+{
+ char *locname, *end;
+ int32 retval=0;
+
+ locname = (char*)xvt_zmalloc (strlen (tablename) * sizeof(char)+1);
+ if (locname == (char*)NULL)
+ {
+ xvt_note ("vpfprop:is_join: Memory allocation error");
+ return FALSE;
+ }
+
+ strcpy(locname,tablename);
+ rightjust(locname);
+
+ /* if '.' in string, delete through last . */
+
+ end = strrchr(locname,'.');
+
+ if (end != NULL) {
+ strcpy(locname,end);
+ }
+
+ strupr(locname);
+
+ if (strcmp(locname,".CJT")==0) retval = TRUE;
+ if (strcmp(locname,".PJT")==0) retval = TRUE;
+ if (strcmp(locname,".LJT")==0) retval = TRUE;
+ if (strcmp(locname,".AJT")==0) retval = TRUE;
+ if (strcmp(locname,".TJT")==0) retval = TRUE;
+
+ xvt_free(locname);
+
+ return retval;
+}
+
+
+/*************************************************************************
+ *
+ *N primitive_class
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the primitive class of the given VPF primitive table name.
+ * If the table name is not that of a valid VPF primitive table, 0 is
+ * returned. Determination is based solely upon the file name. The
+ * actual contents of the file are not checked for validity.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * Parameters:
+ *A
+ * tablename <input>==(char *) name of the VPF table to check.
+ * return <output>==(int32) primitive class of the table (EDGE, FACE,
+ * ENTITY_NODE, CONNECTED_NODE, TEXT, or 0
+ * (if tablename not a primitive)).
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 primitive_class( char *tablename )
+#else
+ int32 primitive_class (tablename)
+ char *tablename;
+#endif
+
+{
+ char *locname,*end;
+ int32 len, retval=0;
+
+ locname = (char*)xvt_zmalloc (strlen (tablename) * sizeof(char)+1);
+ if (locname == (char*)NULL)
+ {
+ xvt_note ("vpfprop:primitive_class: Memory allocation error");
+ return FALSE;
+ }
+
+ strcpy(locname,tablename);
+
+ vpf_check_os_path(locname);
+
+ /* if OS_SEPARATOR in string, delete through last OS_SEPARATOR */
+
+ end = strrchr(locname,OS_SEPARATOR);
+
+ if (end != NULL) {
+ end += sizeof(char);
+ strcpy(locname,end);
+ }
+
+ /* if trailing '.' remove */
+
+ len = strlen(locname);
+
+ if (locname[len-1]=='.') {
+ locname[len-1]='\0';
+ len--;
+ }
+
+ strupr(locname);
+
+ if (strcmp(locname,"END") == 0) retval = ENTITY_NODE;
+ if (strcmp(locname,"CND") == 0) retval = CONNECTED_NODE;
+ if (strcmp(locname,"EDG") == 0) retval = EDGE;
+ if (strcmp(locname,"FAC") == 0) retval = FACE;
+ if (strcmp(locname,"TXT") == 0) retval = TEXT;
+
+ xvt_free(locname);
+
+ return retval;
+}
+
+
+/*************************************************************************
+ *
+ *N feature_class_type
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Returns the VPF feature type for the given feature table name.
+ * If the table name is not that of a valid VPF feature table, 0 is
+ * returned. Determination is based solely upon the file name.
+ * The actual contents of the file are not checked for validity.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * Parameters:
+ *A
+ * table <input>==(char *) name of the VPF table to check.
+ * return <output>==(int32) VPF feature type of the table (LINE,
+ * AREA, ANNO, POINT, COMPLEX, or 0
+ * (if table is none of the above)).
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * History:
+ *H
+ * Barry Michaels Nov 1992 gcc
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ int32 feature_class_type( char *table )
+#else
+ int32 feature_class_type (table)
+ char *table;
+#endif
+
+{
+ char *locname, *end;
+ int32 retval=0;
+
+ locname = (char*)xvt_zmalloc (strlen (table) * sizeof (char)+1);
+ if (locname == (char*)NULL)
+ {
+ xvt_note ("vpfprop:feature_class_type: Memory allocation error");
+ return 0;
+ }
+
+ strcpy(locname,table);
+ rightjust(locname);
+
+ /* if '.' in string, delete through last . */
+
+ end = strrchr(locname,'.');
+
+ if (end != NULL) {
+ strcpy(locname,end);
+ }
+
+ strupr(locname);
+
+ if (strcmp(locname,".PFT")==0) retval = VPFPOINTS;
+ if (strcmp(locname,".LFT")==0) retval = LINE;
+ if (strcmp(locname,".AFT")==0) retval = AREA;
+ if (strcmp(locname,".TFT")==0) retval = ANNO;
+ if (strcmp(locname,".CFT")==0) retval = VPFCOMPLEX;
+
+ xvt_free(locname);
+
+ return retval;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprop.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprop.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfprop.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,69 @@
+
+#ifndef __VPFPROP_H__
+#define __VPFPROP_H__ 1
+
+#ifndef __COORGEOM_H__
+#include "coorgeom.h"
+#endif
+#ifndef __VPF_H__
+#include "vpf.h"
+#endif
+
+#ifdef PROTO
+ char **database_library_names( char *dbpath, int32 *nlibs );
+ char *database_producer( char *dbpath );
+ char *library_description( char *database_path, char *library );
+ extent_type library_extent( char *database_path, char *library );
+ security_type library_security( char *library_path );
+ char **library_coverage_names( char *library_path, int32 *ncov );
+ char **library_coverage_descriptions( char *library_path, int32 *ncov );
+ char **library_feature_class_names( char *library_path, int32 *nfc );
+ double library_tile_height( char *library_path );
+ vpf_projection_type library_projection( char *library_path );
+ char *coverage_description( char *library_path, char *coverage );
+ char **coverage_feature_class_names( char *library_path, char *coverage,
+ int32 *nfc );
+ int32 coverage_topology_level( char *library_path, char *coverage );
+ char *feature_class_description( char *library_path, char *coverage,
+ char *feature_class );
+ char *feature_class_table_description( char *fctable );
+ char *feature_class_table( char *library_path, char *coverage,
+ char *feature_class );
+ primitive_class_type feature_class_primitive_type( char *library_path,
+ char *coverage,
+ char *feature_class );
+ int32 is_primitive( char *tablename );
+ int32 is_simple_feature( char *tablename );
+ int32 is_complex_feature( char *tablename );
+ int32 is_feature( char *tablename );
+ int32 is_join( char *tablename );
+ int32 primitive_class( char *tablename );
+ int32 feature_class_type( char *table );
+#else
+ char **database_library_names();
+ char *database_producer();
+ char *library_description();
+ extent_type library_extent();
+ security_type library_security();
+ char **library_coverage_names();
+ char **library_coverage_descriptions();
+ char **library_feature_class_names();
+ double library_tile_height();
+ vpf_projection_type library_projection();
+ char *coverage_description();
+ char **coverage_feature_class_names();
+ int32 coverage_topology_level();
+ char *feature_class_description();
+ char *feature_class_table_description();
+ char *feature_class_table();
+ primitive_class_type feature_class_primitive_type();
+ int32 is_primitive();
+ int32 is_simple_feature();
+ int32 is_complex_feature();
+ int32 is_feature();
+ int32 is_join();
+ int32 primitive_class();
+ int32 feature_class_type();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfquery.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfquery.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfquery.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1268 @@
+
+/*************************************************************************
+ *
+ *N Module VPFQUERY
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This module contains functions for querying a VPF table with a
+ * selection expression. It has one main entry point - query_table().
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * N/A
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ * Dec 1992 UNIX mdb port
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions:
+ *F
+ * set_type query_table( char *expression, vpf_table_type table );
+ *E
+*************************************************************************/
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+#if 0
+#include <string.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <stdio.h>
+#endif
+
+#ifdef _MSDOS
+#include <conio.h>
+#endif
+#ifndef __LINKLIST_H__
+#include "linklist.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __SET_H__
+#include "set.h"
+#endif
+#ifndef __STRFUNC_H__
+#include "strfunc.h"
+#endif
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+
+/* Delimiter tokens */
+typedef enum { EQ, NE, LE, GE, LT, GT, AND, OR, QUOTE } delim_type;
+delim_type delim;
+
+/* Valid delimeter strings */
+char *delimstr[] = { "=", "<>", "<=", ">=", "<", ">", " AND ",
+ " OR ", "\"" };
+int32 ndelim = 9;
+
+char **fieldname;
+int32 *fieldcol;
+int32 nfields;
+
+/* Token types */
+#define DELIMETER 1
+#define FIELD 2
+#define VALUE 3
+#define QUOTE 4
+#define STRING 5
+#define EOL 6
+#define FINISHED 7
+#define LOP 8 /* Logical Operator */
+#define JOIN 9
+#define ERRORTOKEN 10
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+typedef struct
+ {
+ int32 field;
+ char op;
+ char value[255];
+ char join;
+ } expr_type;
+
+#ifdef PROTO
+void *memalloc (size_t size)
+#else
+void *memalloc (size)
+size_t size;
+#endif
+ {
+ void *ptr;
+
+ ptr = (void*)xvt_malloc (size);
+ if (!ptr)
+ {
+ xvt_note ("Memory allocation error in VPFQUERY\n");
+ exit(1);
+ }
+ return ptr;
+ }
+
+#ifdef PROTO
+int32 is_white( char c )
+#else
+int32 is_white( c )
+char c;
+#endif
+ {
+ if (c==' ' || c=='\t')
+ return 1;
+ return 0;
+ }
+
+
+/*************************************************************************
+ *
+ *N return_token
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the first token string found in the
+ * expression string.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * expr <input>==(char *) selection expression string.
+ * token <output>==(char *) first token in the string.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+*************************************************************************/
+#ifdef PROTO
+void return_token (char *expr, char *token)
+#else
+void return_token ( expr, token)
+char *expr;
+char *token;
+#endif
+
+ {
+ register int32 i, j, n, found=0, stopflag;
+
+ n = 0;
+ stopflag=0;
+ while (expr[0] == ' ')
+ {
+ for (i=0; i<ndelim; i++)
+#ifdef _MAC
+ if (strncmpi (expr, delimstr[i], strlen (delimstr[i])) == 0)
+#elif defined(_WINDOWS)
+ if (strnicmp (expr, delimstr[i], strlen (delimstr[i])) == 0)
+#else
+ if (strncasecmp (expr, delimstr[i], strlen (delimstr[i])) == 0)
+#endif
+ {
+ stopflag=1;
+ break;
+ }
+ if (stopflag)
+ break;
+ expr++;
+ }
+ strcpy (token, expr);
+ for (i=0; i< (int32)strlen(token); i++)
+ {
+ for (j=0; j<ndelim; j++)
+ {
+#ifdef _MAC
+ if (strncmpi (expr, delimstr[j], strlen (delimstr[j])) == 0)
+ {
+#elif defined(_WINDOWS)
+ if (strnicmp (expr, delimstr[j], strlen (delimstr[j])) == 0)
+ {
+#else
+ if (strncasecmp (expr, delimstr[j], strlen (delimstr[j])) == 0)
+ {
+#endif
+ if (n > 0)
+ token[i] = '\0';
+ else
+ token[strlen (delimstr[j])] = '\0';
+ found = 1;
+ break;
+ }
+ }
+ if ((found) || (!is_white(*expr)))
+ n++;
+ if ((!found) && (*expr))
+ expr++;
+ if (found)
+ break;
+ }
+ }
+
+
+
+/*************************************************************************
+ *
+ *N get_token
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function gets the first token, token type, and token value of
+ * the expression string, and then advances the expression string
+ * past the token.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * expression <input>==(char *) selection expression string.
+ * token <output>==(char *) first token in the string.
+ * token_type <output>==(int32 *) token type.
+ * token_value <output>==(int32 *) token_value.
+ * return <output>==(char *) new selection expression.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void return_token( char *expr, char *token ) VPFQUERY.C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+char *get_token (char *expression, char *token, int32 *token_type,
+ int32 *token_value)
+#else
+char *get_token ( expression, token, token_type, token_value)
+char *expression;
+char *token;
+int32 *token_type;
+int32 *token_value;
+#endif
+
+ {
+ register int32 i, stopflag;
+
+ *token_type = (int32)NULL;
+
+ /* Test for no expression (NULL) */
+ if (*expression == (int32)NULL)
+ {
+ *token_type = FINISHED;
+ *token_value = (int32)NULL;
+ return expression;
+ }
+
+ /* Test for "control/linefeed" (\r) delimiter */
+ if (*expression == '\r')
+ {
+ ++expression;
+ ++expression;
+ *token = '\r';
+ token[1] = '\n';
+ token[2] = 0;
+ *token_type = DELIMETER;
+ }
+
+ stopflag = 0;
+
+ while ((expression[0] == '\"') || (expression[0] == ' '))
+ {
+ /* Test for any of the expression delimiters */
+ for (i=0; i<ndelim; i++)
+
+ if (Mstrncmpi (expression, delimstr[i], strlen (delimstr[i])) == 0)
+ {
+ stopflag = 1;
+ break;
+ }
+ if (stopflag)
+ break;
+ expression++;
+ }
+
+ return_token (expression, token);
+ expression += strlen(token);
+
+ if (*token == (int32)NULL)
+ {
+ *token_type = FINISHED;
+ *expression = (int32)NULL;
+ return expression;
+ }
+
+ leftjust (token);
+ rightjust (token);
+
+ /* Test for logical operator "AND" */
+ if ((strcmp (token, "AND") == 0) || (strcmp (token, "and") == 0))
+ {
+ strupr (token);
+ *token_type = JOIN;
+ *token_value = AND;
+ while ((expression[0] == '\"') || (expression[0] == ' '))
+ expression++;
+ return expression;
+ }
+
+
+ /* Test for logical operator "OR" */
+ if ((strcmp (token, "OR") == 0) || (strcmp (token, "or") == 0))
+ {
+ strupr (token);
+ *token_type = JOIN;
+ *token_value = OR;
+ while ((expression[0] == '\"') || (expression[0] == ' '))
+ expression++;
+ return expression;
+ }
+
+
+ /* Test for quoted strings */
+ if (token[0] == '"')
+ {
+/*
+See http://sourceforge.net/bugs/?func=detailbug&bug_id=122597&group_id=11181
+
+ if (*expression)
+ expression++;
+*/
+
+ i = 0;
+ while (*expression != '"')
+ {
+ token[i] = *expression;
+ i++;
+ expression++;
+ if (*expression == (int32)NULL)
+ {
+ *token_type = ERRORTOKEN;
+ *token_value = ERRORTOKEN;
+ return expression;
+ }
+ }
+
+ while ((expression[0] == '\"') || (expression[0] == ' '))
+ expression++;
+ token[i] = '\0';
+ *token_type = STRING;
+ *token_value = strlen (token);
+ return expression;
+ }
+
+
+ /* Test for logical operators */
+ for (i=0; i<ndelim; i++)
+ {
+ if (Mstrcmpi (token, delimstr[i]) == 0)
+ {
+ *token_type = LOP;
+ *token_value = i;
+ return expression;
+ }
+ }
+
+ /* Test for matching fieldnames */
+ for (i=0; i<nfields; i++)
+ {
+ if (Mstrcmpi (token, fieldname[i]) == 0)
+ {
+ strupr(token);
+ *token_type = FIELD;
+ *token_value = i;
+ return expression;
+ }
+ }
+
+ *token_type = VALUE;
+ *token_value = (int32)NULL;
+
+ return expression;
+ }
+
+
+/*************************************************************************
+ *
+ *N parse_expression
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns a list of selection expression clause
+ * structures. This list forms the internal structure of the query
+ * expression.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * expression <input>==(char *) selection expression string.
+ * table <input>==(vpf_table_type) VPF table structure.
+ * return <output>==(linked_list_type) list of expression clauses.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * char *get_token( char *expression, char *token, int32 *token_type,
+ * int32 *token_value) VPFQUERY.C
+ * void display_message( char *input) USER DEFINED
+ * linked_list_type ll_init() LINKLIST.C
+ * void ll_reset( linked_list_type list ) LINKLIST.C
+ * void ll_insert( void *element, unsigned size,
+ * position_type position ) LINKLIST.C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+linked_list_type parse_expression (char *expression, vpf_table_type table)
+#else
+linked_list_type parse_expression (expression, table)
+char *expression;
+vpf_table_type table;
+#endif
+ {
+ linked_list_type exprlist;
+ position_type pos;
+ expr_type expr;
+ int32 i, token_type, token_value;
+ char token[260];
+ char *orig_expression;
+
+
+ orig_expression = (char*)xvt_zmalloc (strlen (expression) + 1);
+ strcpy (orig_expression, expression);
+
+ exprlist = ll_init();
+ pos = exprlist;
+
+ /* Set up globals */
+
+ nfields = (int32)table.nfields;
+
+ fieldname = (char**)memalloc ((size_t)(nfields+2) * sizeof (char*));
+ fieldcol = (int32*)memalloc ((size_t)(nfields+2) * sizeof(int32));
+
+ for (i=0; i<table.nfields; i++)
+ {
+ fieldname[i] = (char*)memalloc (40 * sizeof (char));
+ strcpy (fieldname[i], table.header[i].name);
+ fieldcol[i] = i;
+ }
+
+ /*****/
+ /* Find the "field" token to the left of the logical operator */
+ expression = get_token (expression, token, &token_type, &token_value);
+
+ while (token_type != FINISHED)
+ {
+ if (token_type != FIELD)
+ {
+ xvt_note ("Expression syntax error %s\n",orig_expression);
+ ll_reset(exprlist);
+ exprlist = NULL;
+ break;
+ }
+ expr.field = token_value;
+
+ /* Find the logical operator token in the expression */
+ expression = get_token (expression, token, &token_type, &token_value);
+ if (token_type != LOP)
+ {
+ xvt_note ("Expression syntax error %s\n",orig_expression);
+ ll_reset(exprlist);
+ exprlist = NULL;
+ break;
+ }
+ expr.op = (char)token_value;
+
+ /* Find the "value" token to the right of the logical operator in the expression */
+ expression = get_token (expression, token, &token_type, &token_value);
+ if (token_type == ERRORTOKEN)
+ {
+ xvt_note ("Expression syntax error %s\n",orig_expression);
+ ll_reset(exprlist);
+ exprlist = NULL;
+ break;
+ }
+ strcpy(expr.value,token);
+
+ /* Check for a "join" token to determine if the expression is a compound expression */
+ expression = get_token (expression, token, &token_type, &token_value);
+ if (token_type == JOIN)
+ {
+ expr.join = (char)token_value;
+ ll_insert (&expr, sizeof (expr), pos);
+ pos = pos->next;
+ expression = get_token (expression, token, &token_type,
+ &token_value);
+ }
+ else if (token_type == FINISHED)
+ {
+ expr.join = '\0';
+ ll_insert (&expr, sizeof(expr), pos);
+ }
+ else
+ {
+ xvt_note ("Expression syntax error %s\n",orig_expression);
+ ll_reset (exprlist);
+ exprlist = NULL;
+ break;
+ }
+ }
+
+ for (i=0; i<nfields; i++)
+ xvt_free(fieldname[i]);
+
+ xvt_free ((char*)fieldname);
+ xvt_free ((char*)fieldcol);
+ xvt_free(orig_expression);
+
+ return exprlist;
+ }
+
+
+
+/*************************************************************************
+ *
+ *N bufcomp
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function is a general comparison function for comparing two
+ * buffers. NOTE: This function compares the bytes of the buffers
+ * as unsigned characters. Numeric values > 255 should not be
+ * compared with this function.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * val1 <input>==(void *) first buffer to compare.
+ * val2 <input>==(void *) second buffer to compare.
+ * size <input>==(int32) number of bytes to compare.
+ * op <input>==(char) logical operator.
+ * return <output>==(int32) TRUE or FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 bufcomp( void *val1, void *val2, int32 size, char op )
+#else
+int32 bufcomp( val1, val2, size, op )
+void *val1;
+void *val2;
+int32 size;
+char op;
+#endif
+{
+ int32 result;
+
+ result = (int32)memcmp (val1, val2, (size_t)size);
+
+ switch (op) {
+ case EQ:
+ result = !result;
+ break;
+ case NE:
+ break;
+ case LT:
+ if (result < 0)
+ result = TRUE;
+ else
+ result = FALSE;
+ break;
+ case LE:
+ if (result <= 0)
+ result = TRUE;
+ else
+ result = FALSE;
+ break;
+ case GT:
+ if (result > 0)
+ result = TRUE;
+ else
+ result = FALSE;
+ break;
+ case GE:
+ if (result >= 0)
+ result = TRUE;
+ else
+ result = FALSE;
+ break;
+ default:
+ xvt_note ("Invalid logical operator (%d)\n",op);
+ result = FALSE;
+ break;
+ }
+ return result;
+}
+
+
+/*************************************************************************
+ *
+ *N strcompare
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function compares two strings with the given logical operator.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * val1 <input>==(char *) first buffer to compare.
+ * val2 <input>==(char *) second buffer to compare.
+ * op <input>==(char) logical operator.
+ * return <output>==(int32) TRUE or FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 strcompare( char *val1, char *val2, char op )
+#else
+int32 strcompare( val1, val2, op )
+char *val1;
+char *val2;
+char op;
+#endif
+{
+ int32 result;
+ char str1[300], str2[300];
+
+ strcpy(str1,val1);
+ rightjust(str1);
+ strcpy(str2,val2);
+ rightjust(val2);
+
+ result = Mstrcmpi (str1, str2);
+
+ switch (op) {
+ case EQ:
+ result = !result;
+ break;
+ case NE:
+ break;
+ case LT:
+ if (result < 0)
+ result = TRUE;
+ else
+ result = FALSE;
+ break;
+ case LE:
+ if (result <= 0)
+ result = TRUE;
+ else
+ result = FALSE;
+ break;
+ case GT:
+ if (result > 0)
+ result = TRUE;
+ else
+ result = FALSE;
+ break;
+ case GE:
+ if (result >= 0)
+ result = TRUE;
+ else
+ result = FALSE;
+ break;
+ default:
+ xvt_note ("Invalid logical operator (%d)\n",op);
+ result = FALSE;
+ break;
+ }
+ return result;
+}
+
+
+/*************************************************************************
+ *
+ *N icompare
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function compares two int32 integers with the given logical
+ * operator.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * val1 <input>==(int32 int) first buffer to compare.
+ * val2 <input>==(int32 int) second buffer to compare.
+ * op <input>==(char) logical operator.
+ * return <output>==(int32) TRUE or FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 icompare( int32 val1, int32 val2, char op )
+#else
+int32 icompare(val1, val2, op )
+int32 val1;
+int32 val2;
+char op;
+#endif
+{
+ int32 result;
+
+ switch (op) {
+ case EQ:
+ result = (val1 == val2);
+ break;
+ case NE:
+ result = (val1 != val2);
+ break;
+ case LT:
+ result = (val1 < val2);
+ break;
+ case LE:
+ result = (val1 <= val2);
+ break;
+ case GT:
+ result = (val1 > val2);
+ break;
+ case GE:
+ result = (val1 >= val2);
+ break;
+ default:
+ xvt_note ("Invalid logical operator (%d)\n",op);
+ result = FALSE;
+ break;
+ }
+ return result;
+}
+
+
+/*************************************************************************
+ *
+ *N fcompare
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function compares two floating point numbers with the given
+ * logical operator.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * val1 <input>==(int32) first buffer to compare.
+ * val2 <input>==(int32) second buffer to compare.
+ * op <input>==(char) logical operator.
+ * return <output>==(int32) TRUE or FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 fcompare( float val1, float val2, char op )
+#else
+int32 fcompare( val1, val2, op )
+float val1;
+float val2;
+char op;
+#endif
+{
+ int32 result;
+
+ switch (op) {
+ case EQ:
+ result = (val1 == val2);
+ break;
+ case NE:
+ result = (val1 != val2);
+ break;
+ case LT:
+ result = (val1 < val2);
+ break;
+ case LE:
+ result = (val1 <= val2);
+ break;
+ case GT:
+ result = (val1 > val2);
+ break;
+ case GE:
+ result = (val1 >= val2);
+ break;
+ default:
+ xvt_note ("Invalid logical operator (%d)\n",op);
+ result = FALSE;
+ break;
+ }
+ return result;
+}
+
+
+/*************************************************************************
+ *
+ *N query_table
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the set of selected rows of a VPF table
+ * based upon the evaluation of the given selection expression string.
+ *
+ * The expression is strictly evaluated left to right. No nesting
+ * is supported, so parentheses are not allowed. The expression
+ * must match the form:
+ * <field><log op><value> [ <join> <field><log op><value>]
+ * where,
+ * <field> is a valid field name of the table.
+ * <log op> is one of the following: =, <, >, <=, >=, <> (not equal).
+ * <value> is a valid value for the field.
+ * <join> is either " AND " or " OR ".
+ * Any number of clauses (<field><log op><value>) may be joined
+ * together with AND or OR to form the expression.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * expression <input>==(char *) selection expression string.
+ * table <input>==(vpf_table_type) VPF table structure.
+ * return <output>==(set_type) set of selected rows.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * set_type set_init (int32 n) SET.C
+ * void set_insert (int32 element, set_type set) SET.C
+ * linked_list_type parse_expression (char *expression,
+ * vpf_table_type table) VPFQUERY.C
+ * row_type read_next_row (vpf_table_type table) VPFREAD.C
+ * position_type ll_first (linked_list_type list) LINKLIST.C
+ * int32 ll_end (position_type position) LINKLIST.C
+ * void ll_element (position_type position, void *element) LINKLIST.C
+ * void *get_table_element (int32 field_number, row_type row,
+ * vpf_table_type table, void *value,
+ * int32 *count) VPFREAD.C
+ * void display_message (char *info) USER DEFINED
+ * int32 strcompare (char *val1, char *val2, char op) VPFQUERY.C
+ * int32 icompare (int32 val1, int32 val2, char op) VPFQUERY.C
+ * int32 fcompare (float val1, float val2, char op) VPFQUERY.C
+ * void ll_reset (linked_list_type list) LINKLIST.C
+ * void free_row (row_type row, vpf_table_type table) VPFREAD.C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+set_type query_table( char *expression, vpf_table_type table )
+#else
+set_type query_table( expression, table )
+char *expression;
+vpf_table_type table;
+#endif
+{
+ row_type row;
+ position_type pos;
+ expr_type expr;
+ register int32 i;
+ int32 boolval=FALSE, booltemp=FALSE, join = OR;
+ int32 lval, lval2, count;
+ short sval,sval2;
+ float fval, fval2;
+ char tval, tval2, *tptr;
+ linked_list_type exprlist;
+ set_type select_set;
+ int32 ipos;
+
+#if 0 /* DGM */
+ select_set = set_init(table.nrows+1);
+#endif
+ select_set = set_init (table.nrows);
+
+ /* If the expression is "*" then just turn on all members of select_set */
+ /* and return */
+ if (strcmp (expression, "*") == 0)
+ {
+ set_on(select_set);
+ return select_set;
+ }
+
+ exprlist = parse_expression( expression, table );
+
+ if (!exprlist) return select_set;
+
+ if (table.storage == DISK)
+ {
+ ipos = index_pos (1L, table);
+ fseek( table.fp, ipos, SEEK_SET );
+ }
+
+ for (i=1;i<=table.nrows;i++) {
+
+ if (table.storage == DISK)
+ row = read_next_row(table);
+ else
+ row = get_row( i, table );
+
+ pos = ll_first(exprlist);
+ while (!ll_end(pos)) {
+ ll_element( pos, &expr );
+ switch (table.header[expr.field].type) {
+ case 'I':
+ if (table.header[expr.field].count == 1) {
+ get_table_element( expr.field, row, table, &lval, &count );
+ lval2 = atol(expr.value);
+ booltemp = icompare( lval, lval2, expr.op );
+ } else {
+ xvt_note ("Selection may not be performed upon arrays");
+ }
+ break;
+ case 'S':
+ if (table.header[expr.field].count == 1) {
+ get_table_element( expr.field, row, table, &sval, &count );
+ sval2 = (short)atoi (expr.value);
+ booltemp = icompare( (int32)sval, (int32)sval2,
+ expr.op );
+ } else {
+ xvt_note ("Selection may not be performed upon arrays");
+ }
+ break;
+ case 'T':
+ if (table.header[expr.field].count == 1) {
+ get_table_element( expr.field, row, table, &tval, &count );
+ tval2 = expr.value[0];
+ booltemp = bufcomp( &tval, &tval2, sizeof(tval), expr.op );
+ } else {
+ tptr = (char *)get_table_element( expr.field, row, table,
+ NULL, &count );
+ booltemp = strcompare( tptr, expr.value, expr.op );
+ xvt_free(tptr);
+ }
+ break;
+ case 'F':
+ if (table.header[expr.field].count == 1) {
+ get_table_element( expr.field, row, table, &fval, &count );
+ fval2 = (float)atof (expr.value);
+ booltemp = fcompare( fval, fval2, expr.op );
+ } else {
+ xvt_note ("Selection may not be performed upon arrays");
+ }
+ break;
+ default:
+ xvt_note ("Field type not supported for query\n");
+ break;
+ }
+
+ if (join==OR)
+ boolval = boolval || booltemp;
+ else
+ boolval = boolval && booltemp;
+
+ join = expr.join;
+
+ pos = pos->next;
+ }
+ free_row( row, table );
+ if (boolval) set_insert(i,select_set);
+ boolval = FALSE;
+ join = OR;
+
+ }
+
+ ll_reset(exprlist);
+
+ return select_set;
+}
+
+/*************************************************************************
+ *
+ *N query_table_row
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns 1 if the given row matches
+ * the given selection expression string, 0 otherwise.
+ *
+ * The expression is strictly evaluated left to right. No nesting
+ * is supported, so parentheses are not allowed. The expression
+ * must match the form:
+ * <field><log op><value> [ <join> <field><log op><value>]
+ * where,
+ * <field> is a valid field name of the table.
+ * <log op> is one of the following: =, <, >, <=, >=, <> (not equal).
+ * <value> is a valid value for the field.
+ * <join> is either " AND " or " OR ".
+ * Any number of clauses (<field><log op><value>) may be joined
+ * together with AND or OR to form the expression.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * expression <input>==(char *) selection expression string.
+ * row <input>==(row_type) VPF row structure.
+ * return <output>==(int) 1 if row matches expression,
+ * 0 otherwise.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels June 1993 VPFVIEW DOS 1.1
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 query_table_row (char *expression, row_type row, vpf_table_type table)
+#else
+int32 query_table_row (expression, row, table)
+char *expression;
+row_type row;
+vpf_table_type table;
+#endif
+{
+ position_type pos;
+ expr_type expr;
+ int32 boolval=FALSE, booltemp=FALSE, join = OR;
+ int32 lval, lval2, count;
+ short sval, sval2;
+ float fval, fval2;
+ char tval, tval2, *tptr;
+ linked_list_type exprlist;
+
+ if (strcmp(expression,"*")==0) {
+ return 1;
+ }
+
+ exprlist = parse_expression( expression, table );
+
+ if (!exprlist) return 0;
+
+ pos = ll_first(exprlist);
+ while (!ll_end(pos)) {
+ ll_element( pos, &expr );
+ switch (table.header[expr.field].type) {
+ case 'I':
+ if (table.header[expr.field].count == 1)
+ {
+ get_table_element( expr.field, row, table, &lval, &count );
+ lval2 = atol(expr.value);
+ booltemp = icompare( lval, lval2, expr.op );
+ }
+ else
+ {
+ }
+ break;
+ case 'S':
+ if (table.header[expr.field].count == 1)
+ {
+ get_table_element( expr.field, row, table, &sval, &count );
+ sval2 = atoi(expr.value);
+ booltemp = icompare( (int32)sval, (int32)sval2, expr.op );
+ }
+ else
+ {
+ }
+ break;
+ case 'T':
+ if (table.header[expr.field].count == 1)
+ {
+ get_table_element( expr.field, row, table, &tval, &count );
+ tval2 = expr.value[0];
+ booltemp = bufcomp( &tval, &tval2, sizeof(tval), expr.op );
+ }
+ else
+ {
+ tptr = (char *)get_table_element( expr.field, row, table, NULL, &count );
+ booltemp = strcompare( tptr, expr.value, expr.op );
+ xvt_free(tptr);
+ }
+ break;
+ case 'F':
+ if (table.header[expr.field].count == 1)
+ {
+ get_table_element( expr.field, row, table, &fval, &count );
+ if (!is_vpf_null_float(fval))
+ {
+ fval2 = (float) atof(expr.value);
+ booltemp = fcompare( fval, fval2, expr.op );
+ }
+ else
+ booltemp = FALSE;
+ }
+ else
+ {
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (join==OR)
+ boolval = boolval || booltemp;
+ else
+ boolval = boolval && booltemp;
+
+ join = expr.join;
+
+ pos = pos->next;
+ }
+
+ ll_reset(exprlist);
+
+ return boolval;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfquery.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfquery.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfquery.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,23 @@
+#ifndef __VPFQUERY_H__
+#define __VPFQUERY_H__
+
+#ifndef __VPFVIEW_H__
+#include "vpfview.h"
+#endif
+#ifndef __SET_H__
+#include "set.h"
+#endif
+#ifndef __LIKLIST_H__
+#include "linklist.h"
+#endif
+
+/* Function Definitions */
+#ifdef PROTO
+ set_type query_table (char *expression, vpf_table_type table );
+ linked_list_type parse_expression (char *expression, vpf_table_type table);
+#else
+ set_type query_table ();
+ linked_list_type parse_expression ();
+#endif
+
+#endif /* ifdef __VPFQUERY_H__ */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfread.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfread.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfread.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1682 @@
+/*************************************************************************
+ *
+ *N Module VPFREAD.C
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This module contains functions for reading VPF tables. It, along
+ * with VPFTABLE.C and VPFWRITE.C (and VPFIO.C for UNIX), comprises a
+ * fairly extensive set of functions for handling VPF tables.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * N/A
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 Original Version DOS Turbo C
+ * David Flinn Jul 1991 Merged with Barry & Mody's code for UNIX
+ * Jim TenBrink Oct 1991 Split this module off from vpftable and
+ * merged converter and vpfview branches
+ * for the functions included here..
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible. It includes #ifdefs for
+ * all system dependencies, so that it will work efficiently with
+ * either Turbo C in DOS or (at least) GNU C in UNIX.
+ *E
+ *
+ *************************************************************************/
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+#if 0
+#include <malloc.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#endif
+
+#ifdef _MSDOS
+#include <io.h>
+#include <dos.h>
+#endif
+
+#ifdef _UNIX
+#include <sys/stat.h>
+#define SEEK_SET 0 /* Turbo C fseek value */
+#define SEEK_CUR 1
+#endif
+
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+
+extern int32 STORAGE_BYTE_ORDER;
+
+
+/*
+ * currently being used by the converter routines, not by the vpfview
+ * routines
+ */
+#ifdef PROTO
+char * get_line (FILE *fp)
+#else
+char * get_line (fp)
+FILE *fp;
+#endif
+{
+ int32 CurrentChar, /* This is an int because fgetc returns an int */
+ count ,
+ NextBlock = 256 ,
+ LineAllocation = 0 ;
+ char *CurrentLine = (char *) NULL ;
+
+/* This forever loop searches past all lines beginning with #,
+ indicating comments. */
+
+ for (;;) {
+ CurrentChar = fgetc(fp);
+ if ( CurrentChar == COMMENT ) /* skip past comment line */
+ for (;CurrentChar != NEW_LINE; ) {
+ if (CurrentChar == EOF) return (char *) NULL ;
+ CurrentChar = fgetc (fp) ;
+ }
+ else
+ break ;
+ } /* end of forever loop */
+
+ if (CurrentChar == EOF ) return (char *) NULL ;
+
+ for(count = 0; CurrentChar != EOF; CurrentChar = fgetc(fp), count++) {
+
+ /* Allocate space for output line, if needed */
+
+ if (! ( count < LineAllocation )) {
+ LineAllocation += NextBlock ;
+ if ( CurrentLine )
+ CurrentLine = (char*) xvt_realloc (CurrentLine, (size_t)LineAllocation );
+ else
+ CurrentLine = (char*) xvt_zmalloc ((size_t)LineAllocation);
+ if (!CurrentLine) {
+#if 0
+ printf("get_line: Out of Memory");
+#endif
+
+ return (char *) NULL ;
+ }
+ }
+ if ( ( CurrentChar == (int32) LINE_CONTINUE ) ) {
+ CurrentChar = fgetc(fp ) ; /* read character after backslash */
+ /* A newline will be ignored and thus skipped over */
+ if ( CurrentChar == (int32) SPACE ) /* Assume line continue error */
+ while ( fgetc (fp) != (int32) SPACE ) ;
+ else if (CurrentChar != (int32) NEW_LINE ) {
+ /* copy it if not new line */
+ CurrentLine[count++] = (char) LINE_CONTINUE ;
+ CurrentLine[count] = (char) CurrentChar ;
+ } else
+ count -- ; /* Decrement the counter on a newline character */
+ } else if (CurrentChar == (int32) NEW_LINE ) /* We're done */
+ break;
+ else
+ CurrentLine[count] = (char)CurrentChar;
+
+ } /* end of for count */
+
+ CurrentLine[count] = (char)('\0'); /* terminate string */
+ return CurrentLine ;
+
+}
+
+
+
+#ifdef PROTO
+int32 VpfRead ( void *to, VpfDataType type, int32 count, FILE *from )
+#else
+int32 VpfRead ( to, type, count, from )
+void *to;
+VpfDataType type;
+int32 count;
+FILE *from;
+#endif
+{
+ int32 retval=0, i ;
+
+ switch ( type ) {
+ case VpfChar:
+ retval = fread ( to, sizeof (char), (size_t)count, from ) ;
+ break ;
+ case VpfShort:
+ {
+ short int stemp ,
+ *sptr = (short *) to ;
+ for ( i=0; i < count; i++ ) {
+ retval = fread ( &stemp, sizeof (short), 1, from ) ;
+ if (STORAGE_BYTE_ORDER != MACHINE_BYTE_ORDER)
+ swap_two ( (char*)&stemp, (char*)sptr ) ;
+ else
+ *sptr = stemp;
+ sptr++ ;
+ }
+ }
+ break ;
+ case VpfInteger:
+ {
+ if (STORAGE_BYTE_ORDER != MACHINE_BYTE_ORDER) {
+ int32 itemp,
+ *iptr = (int32 *) to ;
+ for ( i=0; i < count; i++ ) {
+ retval = fread ( &itemp, sizeof (int32), 1, from ) ;
+ swap_four ((char*)&itemp, (char*)iptr ) ;
+ iptr++ ;
+ }
+ } else {
+ retval = fread ( to, sizeof (int32), (size_t)count, from ) ;
+ }
+ }
+ break ;
+ case VpfFloat:
+ {
+ float ftemp , *fptr = (float*)to;
+ for (i=0; i<count; i++)
+ {
+ retval = fread (&ftemp, sizeof (float), 1, from);
+ if (STORAGE_BYTE_ORDER != MACHINE_BYTE_ORDER)
+ swap_four ((char*)&ftemp, (char*)fptr);
+ else
+ *fptr = ftemp;
+ fptr++;
+ }
+ }
+ break;
+ case VpfDouble:
+ {
+ double dtemp ,
+ *dptr = (double *) to ;
+ for ( i=0; i < count; i++ ) {
+ retval = fread ( &dtemp, sizeof (double), 1, from ) ;
+ if (STORAGE_BYTE_ORDER != MACHINE_BYTE_ORDER)
+ swap_eight ((char*)&dtemp, (char*)dptr ) ;
+ else
+ *dptr = dtemp;
+ dptr++ ;
+ }
+ }
+ break ;
+ case VpfDate:
+ {
+ date_type *dp = (date_type *) to ;
+ retval = fread(dp, sizeof(date_type)-1, (size_t)count, from);
+ }
+ break ;
+ case VpfCoordinate:
+ {
+ if (STORAGE_BYTE_ORDER != MACHINE_BYTE_ORDER)
+ {
+ coordinate_type ctemp, *cptr = (coordinate_type*) to;
+ for (i=0; i<count; i++)
+ {
+ retval = fread ( &ctemp, sizeof (coordinate_type), 1, from ) ;
+ swap_four ((char*)&ctemp.x, (char*)&cptr->x ) ;
+ swap_four ((char*)&ctemp.y, (char*)&cptr->y ) ;
+ cptr++ ;
+ }
+ }
+ else
+ {
+ retval = fread (to, sizeof(coordinate_type), (size_t)count, from ) ;
+ }
+ }
+ break ;
+ case VpfDoubleCoordinate:
+ {
+ double_coordinate_type dctemp ,
+ *dcptr = (double_coordinate_type *) to ;
+ for (i=0; i<count; i++)
+ {
+ retval = fread ( &dctemp, sizeof (double_coordinate_type), 1, from ) ;
+ if (STORAGE_BYTE_ORDER != MACHINE_BYTE_ORDER)
+ {
+ swap_eight ((char*)&dctemp.x, (char*)&dcptr->x ) ;
+ swap_eight ((char*)&dctemp.y, (char*)&dcptr->y ) ;
+ }
+ else
+ {
+ dcptr->x = dctemp.x;
+ dcptr->y = dctemp.y;
+ }
+ dcptr++ ;
+ }
+ }
+ break ;
+ case VpfTriCoordinate:
+ {
+ if (STORAGE_BYTE_ORDER != MACHINE_BYTE_ORDER)
+ {
+ tri_coordinate_type temp, *ptr = (tri_coordinate_type*)to;
+ for (i=0; i<count; i++)
+ {
+ retval = fread (&temp, sizeof (tri_coordinate_type), 1, from);
+ swap_four ((char*)&temp.x, (char*)&ptr->x);
+ swap_four ((char*)&temp.y, (char*)&ptr->y);
+ swap_four ((char*)&temp.z, (char*)&ptr->z);
+ ptr++;
+ }
+ }
+ else
+ retval = fread (to, sizeof (tri_coordinate_type), (size_t)count, from);
+ }
+ break ;
+ case VpfDoubleTriCoordinate:
+ {
+ double_tri_coordinate_type dttemp ,
+ *dtptr = (double_tri_coordinate_type *) to ;
+ for ( i=0; i < count; i++ ) {
+ retval = fread ( &dttemp,sizeof (double_tri_coordinate_type), 1, from);
+ if (STORAGE_BYTE_ORDER != MACHINE_BYTE_ORDER) {
+ swap_eight ((char*)&dttemp.x, (char*)&dtptr->x ) ;
+ swap_eight ((char*)&dttemp.y, (char*)&dtptr->y ) ;
+ swap_eight ((char*)&dttemp.z, (char*)&dtptr->z ) ;
+ } else {
+ dtptr->x = dttemp.x;
+ dtptr->y = dttemp.y;
+ dtptr->z = dttemp.z;
+ }
+ dtptr++ ;
+ }
+ }
+ break ;
+ case VpfNull:
+ /* Do Nothing */
+ break ;
+ default:
+#if 0
+ printf ("\nVpfRead: error on data type , %s >", type);
+#endif
+
+ break ;
+ } /* end of switch */
+
+ return retval; /* whatever fread returns */
+ }
+
+/* #endif */
+
+
+
+/*************************************************************************
+ *
+ *N index_length
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the length of a specified row from the table
+ * index.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * row_number <input> == (int32) row number in the table.
+ * table <input> == (vpf_table_type) VPF table structure.
+ * return <output> == (int32) length of the table row or 0 on error.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 Original Version DOS Turbo C
+ * Dave Flinn July 1991 UNIX extensions
+ * JTB 10/91 removed aborts()
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 index_length( int32 row_number,
+ vpf_table_type table )
+#else
+int32 index_length( row_number, table )
+int32 row_number;
+vpf_table_type table;
+#endif
+{
+ int32 recsize,len=0;
+ uint32 ulen;
+ int32 pos;
+
+ STORAGE_BYTE_ORDER = table.byte_order;
+
+ if (row_number < 1) row_number = 1;
+ if (row_number > table.nrows) row_number = table.nrows;
+
+ switch (table.xstorage) {
+ case COMPUTE:
+ len = table.reclen;
+ break;
+ case DISK:
+ recsize = sizeof(index_cell);
+ fseek( table.xfp, (int32)(row_number*recsize), SEEK_SET );
+
+ if ( ! Read_Vpf_Int(&pos,table.xfp,1) ) {
+#if 0
+ printf ("\nindex_length: error reading index.") ;
+#endif
+
+ len = (int32)NULL ;
+ }
+
+ if ( ! Read_Vpf_Int(&ulen,table.xfp,1) ) {
+#if 0
+ printf ("\nindex_length: error reading index.");
+#endif
+ return (int32)NULL ;
+ }
+ len = ulen;
+ break;
+ case RAM:
+ len = table.index[row_number-1].length;
+ break;
+ default:
+ if ( table.mode == Write && table.nrows != row_number ) {
+ /* Just an error check, should never get here in writing */
+ xvt_note ("index_length: error trying to access row %d",
+ (int) row_number ) ;
+ len = (int32)NULL;
+ }
+ break;
+ }
+ return len;
+}
+
+/*************************************************************************
+ *
+ *N index_pos
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the position of a specified row from the table
+ * index.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * row_number <input> == (int32) row number in the table.
+ * table <input> == (vpf_table_type) VPF table structure.
+ * return <output> == (int32) position of the table row
+ * or zero on error.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 Original Version DOS Turbo C
+ * Dave Flinn July 1991 Updated for UNIX
+ * JTB 10/91 removed aborts()
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 index_pos (int32 row_number, vpf_table_type table)
+#else
+int32 index_pos (row_number, table)
+int32 row_number;
+vpf_table_type table;
+#endif
+{
+ int32 recsize;
+ uint32 pos = (uint32) NULL; /* Intergraph solution TR#GX323 */
+
+ STORAGE_BYTE_ORDER = table.byte_order;
+
+ if (row_number < 1) row_number = 1;
+ if (row_number > table.nrows) row_number = table.nrows;
+
+ switch (table.xstorage) {
+ case COMPUTE:
+ pos = table.ddlen + ((row_number-1) * table.reclen);
+ break;
+ case DISK:
+ recsize = sizeof(index_cell);
+ fseek( table.xfp, (int32)(row_number*recsize), SEEK_SET );
+ if ( ! Read_Vpf_Int(&pos,table.xfp,1) ) {
+#if 0
+ printf ("\nindex_length: error reading index.");
+#endif
+ pos = (int32)NULL ;
+ }
+ break;
+ case RAM:
+ pos = table.index[row_number-1].pos;
+ break;
+ default:
+ if ( table.mode == Write && table.nrows != row_number ) {
+ /* Just an error check, should never get here in writing */
+ xvt_note ("index_length: error trying to access row %d",
+ (int) row_number ) ;
+ pos = (int32)NULL;
+ }
+ break;
+ }
+ return pos;
+}
+
+
+/* Compute the offset from the start of the row to the given field */
+#ifdef PROTO
+int32 row_offset( int32 field, row_type row, vpf_table_type table)
+#else
+int32 row_offset( field, row, table)
+int32 field;
+row_type row;
+vpf_table_type table;
+#endif
+{
+ int32 offset,n,size;
+ int32 i;
+ id_triplet_type key;
+ static int32 keysize[] = {0,sizeof(char),sizeof(short int),sizeof(int32)};
+
+ if (field < 0 || field >= table.nfields) return -1;
+
+ offset = 0L;
+ for (i=0;i<field;i++) {
+ switch (table.header[i].type) {
+ case 'I':
+ offset += sizeof(int32)*row[i].count;
+ break;
+ case 'S':
+ offset += sizeof(short int)*row[i].count;
+ break;
+ case 'T':
+ offset += sizeof(char)*row[i].count;
+ break;
+ case 'F':
+ offset += sizeof(float)*row[i].count;
+ break;
+ case 'D':
+ offset += sizeof(date_type)*row[i].count;
+ break;
+ case 'K':
+ get_table_element(i,row,table,&key,&n);
+ size = sizeof(char) +
+ keysize[TYPE0(key.type)] +
+ keysize[TYPE1(key.type)] +
+ keysize[TYPE2(key.type)];
+ offset += size*row[i].count;
+ break;
+ case 'R':
+ offset += sizeof(double)*row[i].count;
+ break;
+ case 'C':
+ offset += sizeof(coordinate_type)*row[i].count;
+ break;
+ case 'B':
+ offset += sizeof(double_coordinate_type)*row[i].count;
+ break;
+ case 'Z':
+ offset += sizeof(tri_coordinate_type)*row[i].count;
+ break;
+ case 'Y':
+ offset += sizeof(double_tri_coordinate_type)*row[i].count;
+ break;
+ }
+ }
+ return offset;
+}
+
+/*************************************************************************
+ *
+ *N read_key
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads an id triplet key from a VPF table.
+ * The table must be open for read.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * table <input> == (vpf_table_type) VPF table.
+ * read_key <output> == (id_triplet_type) id triplet key.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 Original Version DOS Turbo C
+ * Dave Flinn July 1991 Updated for UNIX
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+id_triplet_type read_key( vpf_table_type table )
+#else
+id_triplet_type read_key( table )
+vpf_table_type table;
+#endif
+{
+ id_triplet_type key;
+ unsigned char ucval;
+ unsigned short int uival;
+
+ STORAGE_BYTE_ORDER = table.byte_order;
+
+ key.id = 0L;
+ key.tile = 0L;
+ key.exid = 0L;
+
+ /* just doing this to be consistent */
+ Read_Vpf_Char (&(key.type),table.fp,1);
+
+ switch (TYPE0(key.type)) {
+ case 0:
+ break;
+ case 1:
+
+ Read_Vpf_Char (&ucval, table.fp, 1 ) ;
+ key.id = (int32)ucval;
+ break;
+ case 2:
+
+ Read_Vpf_Short (&uival, table.fp, 1 ) ;
+ key.id = (int32)uival;
+ break;
+ case 3:
+
+ Read_Vpf_Int (&(key.id), table.fp, 1 ) ;
+ break;
+ }
+ switch (TYPE1(key.type)) {
+ case 0:
+ break;
+ case 1:
+ Read_Vpf_Char (&ucval, table.fp, 1 ) ;
+ key.tile = (int32)ucval;
+ break;
+ case 2:
+ Read_Vpf_Short (&uival, table.fp, 1 ) ;
+ key.tile = (int32)uival;
+ break;
+ case 3:
+ Read_Vpf_Int (&(key.tile), table.fp, 1 ) ;
+ break;
+ }
+
+ switch (TYPE2(key.type)) {
+ case 0:
+ break;
+ case 1:
+ Read_Vpf_Char (&ucval, table.fp, 1 ) ;
+ key.exid = (int32)ucval;
+ break;
+ case 2:
+ Read_Vpf_Short (&uival, table.fp, 1 ) ;
+ key.exid = (int32)uival;
+ break;
+ case 3:
+ Read_Vpf_Int (&(key.exid), table.fp, 1 ) ;
+ break;
+ }
+
+ return key;
+ }
+
+/*************************************************************************
+ *
+ *N read_next_row
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads the next row of the table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * table <input> == (vpf_table_type) vpf table structure.
+ * return <output> == (row_type) the next row in the table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 Original Version DOS Turbo C
+ * Dave Flinn July 1991 Updated for UNIX
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void *vpfmalloc()
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+row_type read_next_row( vpf_table_type table )
+#else
+row_type read_next_row( table )
+vpf_table_type table;
+#endif
+{
+ register int32 i,j;
+ int32 status;
+ char *tptr;
+ int32 size,count;
+ row_type row;
+ id_triplet_type * keys;
+ coordinate_type dummycoord;
+
+ if (feof(table.fp))
+ {
+ return NULL;
+ }
+
+ STORAGE_BYTE_ORDER = table.byte_order;
+
+ row = (row_type)xvt_zmalloc (((size_t)table.nfields+1) * sizeof(column_type));
+
+ for (i=0;i<table.nfields;i++) row[i].ptr = NULL;
+
+ for (i=0;i<table.nfields;i++)
+ {
+ if (table.header[i].count < 0)
+ {
+ /* Read the count subfield for variable length fields */
+ Read_Vpf_Int (&count, table.fp, 1);
+
+ if ((unsigned int) count > 2000000) {
+ free_row ( row, table ) ;
+ return (row_type) NULL;
+ }
+ }
+ else
+ {
+ count = table.header[i].count;
+ }
+ row[i].count = count;
+
+ status = 0;
+ switch (table.header[i].type) {
+ case 'T':
+ if (count == 1) {
+ row[i].ptr = (char *)xvt_zmalloc(sizeof(char));
+ Read_Vpf_Char(row[i].ptr, table.fp, 1) ;
+ } else {
+ size = count*sizeof(char);
+ row[i].ptr = (char*) xvt_zmalloc((size_t)size+2);
+ tptr = (char*)xvt_zmalloc ((size_t)size+2);
+ Read_Vpf_Char(tptr,table.fp,count) ;
+ tptr[count] = '\0';
+ strcpy(row[i].ptr,tptr);
+ if(tptr != (char *)NULL)
+ {xvt_free(tptr);tptr = (char *)NULL;}
+ }
+ break;
+ case 'I':
+ row[i].ptr = (int32*)xvt_zmalloc((size_t)count * sizeof (int32));
+ Read_Vpf_Int (row[i].ptr, table.fp, count ) ;
+ break;
+ case 'S':
+ row[i].ptr = (short*)xvt_zmalloc ((size_t)count * sizeof (short));
+ Read_Vpf_Short (row[i].ptr, table.fp, count ) ;
+ break;
+ case 'F':
+ row[i].ptr = (float*)xvt_zmalloc ((size_t)count * sizeof (float));
+ Read_Vpf_Float (row[i].ptr, table.fp, count ) ;
+ break;
+ case 'R':
+ row[i].ptr = (double*)xvt_zmalloc ((size_t)count * sizeof (double));
+ Read_Vpf_Double (row[i].ptr, table.fp, count ) ;
+ break;
+ case 'D':
+ row[i].ptr = (date_type*)xvt_zmalloc ((size_t)count *
+ sizeof (date_type));
+ Read_Vpf_Date (row[i].ptr, table.fp, count ) ;
+ break;
+ case 'C':
+ /* Coordinate strings may be quite large. */
+ /* Allow for null coordinate string pointer if */
+ /* not enough memory that can be handled one */
+ /* coordinate at a time in higher level functions. */
+ row[i].ptr = (coordinate_type*)xvt_zmalloc ((size_t)count *
+ sizeof(coordinate_type));
+ if (row[i].ptr)
+ Read_Vpf_Coordinate(row[i].ptr,table.fp,count);
+ else
+ for (j=0;j<count;j++)
+ Read_Vpf_Coordinate(&dummycoord,table.fp,1);
+ break;
+ case 'Z':
+ row[i].ptr = (tri_coordinate_type*)xvt_zmalloc ((size_t)count *
+ sizeof (tri_coordinate_type));
+ Read_Vpf_CoordinateZ(row[i].ptr,table.fp,count);
+ break;
+ case 'B':
+ row[i].ptr = (double_coordinate_type*)xvt_zmalloc ((size_t)count *
+ sizeof (double_coordinate_type));
+ Read_Vpf_DoubleCoordinate(row[i].ptr,table.fp,count);
+ break;
+ case 'Y':
+ row[i].ptr = (double_tri_coordinate_type*)xvt_zmalloc ((size_t)count *
+ sizeof (double_tri_coordinate_type));
+ Read_Vpf_DoubleCoordinateZ(row[i].ptr,table.fp,count);
+ break;
+ case 'K': /* ID Triplet */
+ row[i].ptr = (id_triplet_type*)xvt_zmalloc ((size_t)count *
+ sizeof (id_triplet_type));
+ keys = (id_triplet_type*)xvt_zmalloc ((size_t)count *
+ sizeof (id_triplet_type));
+ for (j=0;j<count;j++) {
+ keys[j] = read_key(table);
+ }
+ memcpy (row[i].ptr, keys, (size_t)count *
+ sizeof(id_triplet_type));
+ if(keys != (id_triplet_type*)NULL)
+ {xvt_free ((char*)keys);keys = (id_triplet_type*)NULL;}
+ break;
+ case 'X':
+ row[i].ptr = NULL;
+ break;
+ default:
+ xvt_note ("%s%s >>> read_next_row: no such type < %c >",
+ table.path,table.name,table.header[i].type ) ;
+ status = 1;
+ break ;
+ } /* end of switch */
+ if (status == 1) {
+ free_row ( row, table ) ;
+ return (row_type) NULL;
+ }
+ }
+ return row;
+}
+
+/*************************************************************************
+ *
+ *N rowcpy
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns a copy of the specified row.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * origrow <input> == (row_type) row to copy.
+ * table <input> == (vpf_table_type) vpf table structure.
+ * return <output> == (row_type) copy of the row.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void *vpfmalloc() VPFMISC.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+row_type rowcpy( row_type origrow,
+ vpf_table_type table )
+#else
+row_type rowcpy( origrow, table )
+row_type origrow;
+vpf_table_type table;
+#endif
+{
+ register int32 i;
+ int32 count;
+ int32 size;
+ row_type row;
+
+ row = (row_type)xvt_zmalloc ((size_t)table.nfields * sizeof (column_type));
+ for (i=0;i<table.nfields;i++) {
+ count = origrow[i].count;
+ row[i].count = count;
+ switch (table.header[i].type) {
+ case 'T':
+ if (count==1) {
+ row[i].ptr = (char *)xvt_zmalloc(1);
+ memcpy(row[i].ptr,origrow[i].ptr,sizeof(char));
+ } else {
+ size = count*sizeof(char);
+ row[i].ptr = (char*)xvt_zmalloc ((size_t)size + 1);
+ strcpy(row[i].ptr,origrow[i].ptr);
+ }
+ break;
+ case 'I':
+ size = count*sizeof(int32);
+ row[i].ptr = (int32*)xvt_zmalloc ((size_t)size);
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ break;
+ case 'S':
+ size = count*sizeof(short int);
+ row[i].ptr = (short*)xvt_zmalloc ((size_t)size);
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ break;
+ case 'F':
+ size = count*sizeof(float);
+ row[i].ptr = (float*)xvt_zmalloc ((size_t)size);
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ break;
+ case 'R':
+ size = count*sizeof(double);
+ row[i].ptr = (double*)xvt_zmalloc ((size_t)size);
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ break;
+ case 'C':
+ size = count*sizeof(coordinate_type);
+ row[i].ptr = (coordinate_type*)xvt_zmalloc ((size_t)size);
+ if (row[i].ptr && origrow[i].ptr)
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ else
+ row[i].ptr = NULL;
+ break;
+ case 'Z':
+ size = count*sizeof(tri_coordinate_type);
+ row[i].ptr = (tri_coordinate_type*)xvt_zmalloc ((size_t)size);
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ break;
+ case 'B':
+ size = count*sizeof(double_coordinate_type);
+ row[i].ptr = (double_coordinate_type*)xvt_zmalloc ((size_t)size);
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ break;
+ case 'Y':
+ size = count*sizeof(double_tri_coordinate_type);
+ row[i].ptr = (double_tri_coordinate_type*)xvt_zmalloc ((size_t)size);
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ break;
+ case 'D': /* Date */
+ size = count*sizeof(date_type);
+ row[i].ptr = (date_type*)xvt_zmalloc ((size_t)size);
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ break;
+ case 'K': /* ID Triplet */
+ size = count*sizeof(id_triplet_type);
+ row[i].ptr = (id_triplet_type*)xvt_zmalloc ((size_t)size);
+ memcpy (row[i].ptr, origrow[i].ptr, (size_t)size);
+ break;
+ case 'X':
+ row[i].ptr = NULL;
+ break;
+ default:
+ xvt_note ("row_cpy: error in data type < %c >",
+ table.header[i].type ) ;
+ abort () ;
+ break ;
+ } /* end of switch */
+ } /* end of table.nfields */
+ return row;
+}
+
+/*************************************************************************
+ *
+ *N read_row
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function reads a specified row from the table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * row_number <input> == (int32) row number.
+ * table <input> == (vpf_table_type) vpf table structure.
+ * return <output> == (row_type) row that was read in.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * int32 index_pos() VPFTABLE.C
+ * row_type read_next_row() VPFTABLE.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+row_type read_row( int32 row_number,
+ vpf_table_type table )
+#else
+row_type read_row( row_number, table )
+int32 row_number;
+vpf_table_type table;
+#endif
+{
+ int32 fpos;
+
+ /*
+ Intergraph solution DAP 12/10/97 TR323 Don't try to read
+ if table is empty.
+ */
+
+ if (table.fp != NULL) {
+ fpos = index_pos(row_number,table);
+ if ( fpos != (long)NULL) {
+ fseek(table.fp,fpos,SEEK_SET);
+ return read_next_row(table);
+ } else {
+ return NULL;
+ }
+ } else {
+ return NULL;
+ }
+}
+
+/*************************************************************************
+ *
+ *N free_row
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function frees the memory that was dynamically allocated for the
+ * specified row.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * row <input> == (row_type) row to be freed.
+ * table <input> == (vpf_table_type) vpf table structure.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void free_row (row_type row, vpf_table_type table)
+#else
+void free_row ( row, table)
+row_type row;
+vpf_table_type table;
+#endif
+ {
+ register int32 i;
+
+ if (!row)
+ return;
+ for (i=0; i<table.nfields; i++)
+ if (row[i].ptr != (void*)NULL)
+ {xvt_free (row[i].ptr);
+ row[i].ptr = (void*)NULL;
+ }
+ if (row != (row_type)NULL)
+ {
+ xvt_free ((char*)row);
+ row = (row_type)NULL;
+ }
+ }
+
+/*************************************************************************
+ *
+ *N get_row
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the specified row of the table. If the table
+ * is stored in memory, the row is copied from there. If it is on disk,
+ * it is read and returned.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * row_number <input> == (int32) row number in range [1 .. table.nrows].
+ * table <input> == (vpf_table_type) vpf table structure.
+ * return <output> == (row_type) returned row.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * row_type rowcpy VPFREAD.C
+ * row_type read_row VPFREAD.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+row_type get_row( int32 row_number,
+ vpf_table_type table )
+#else
+row_type get_row( row_number, table )
+int32 row_number;
+vpf_table_type table;
+#endif
+{
+ row_type row;
+
+ row_number = max(min(row_number, table.nrows), 1);
+
+ if (table.storage == RAM) {
+ row = rowcpy(table.row[row_number-1],table);
+ return row;
+ } else {
+ return read_row( row_number, table );
+ }
+}
+
+/*************************************************************************
+ *
+ *N table_pos
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the column offset of the specified field name
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * field_name <input> == (char *) field name.
+ * table <input> == (vpf_table_type) VPF table structure.
+ * table_pos <output> == (int32) returned column number.
+ * UNIX returns -1 if not exists
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 table_pos (char * field_name, vpf_table_type table)
+#else
+int32 table_pos (field_name, table)
+char * field_name;
+vpf_table_type table;
+#endif
+ {
+ register int32 i;
+ int32 col;
+
+ col = -1;
+ for (i=0; i<table.nfields; i++)
+ {
+#ifdef _WINDOWS
+ if (strcmpi (field_name, table.header[i].name) == 0)
+#else
+ if (strcasecmp (field_name, table.header[i].name) == 0)
+#endif /* mb */
+ {
+ col = i;
+ break;
+ }
+ }
+ return col;
+ }
+
+/*************************************************************************
+ *
+ *N get_table_element
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the element in the given row in the given
+ * column. If the element is a single element (count=1), the value
+ * is passed back via the void pointer *value; otherwise, an array
+ * is allocated and passed back as the return value.
+ * NOTE: If an array is allocated in this function, it should be freed
+ * when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * field_number <input> == (int32) field column number.
+ * row <input> == (row_type) vpf table row.
+ * table <input> == (vpf_table_type) VPF table structure.
+ * value <output> == (void *) pointer to a single element value.
+ * count <output> == (int32 *) pointer to the array size for a
+ * multiple element value.
+ * return <output> == (void *) returned multiple element value.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void *vpfmalloc()
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void *get_table_element( int32 field_number,
+ row_type row,
+ vpf_table_type table,
+ void *value,
+ int32 *count )
+#else
+void *get_table_element( field_number, row, table, value, count )
+int32 field_number;
+row_type row;
+vpf_table_type table;
+void *value;
+int32 *count;
+#endif
+{
+ int32 col;
+ char * tptr;
+ void * retvalue;
+
+ retvalue = NULL;
+ col = field_number;
+ if ((col < 0) || (col >= table.nfields)) {
+ xvt_note ("GET_TABLE_ELEMENT: Invalid field number %d\n",
+ (int) field_number);
+ return NULL;
+ }
+
+ if (!row) return NULL;
+
+ switch (table.header[col].type) {
+ case 'X':
+ retvalue = NULL;
+ break;
+ case 'T':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(char));
+ } else {
+ retvalue = (char*)xvt_zmalloc (((size_t)row[col].count + 1) *
+ sizeof (char));
+ tptr = (char*)xvt_zmalloc (((size_t)row[col].count + 1) *
+ sizeof (char));
+ memcpy (tptr, row[col].ptr, (size_t)row[col].count *
+ sizeof (char));
+ tptr[row[col].count] = '\0';
+ strcpy((char *)retvalue,tptr);
+ if(tptr != (char *)NULL)
+ {xvt_free(tptr);tptr = (char *)NULL;}
+ }
+ break;
+ case 'I':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(int32));
+ } else {
+ retvalue = (int32*)xvt_zmalloc ((size_t)row[col].count *
+ sizeof(int32));
+ memcpy (retvalue, row[col].ptr,(size_t) row[col].count *
+ sizeof(int32));
+ }
+ break;
+ case 'S':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(short int));
+ } else {
+ retvalue = (short*)xvt_zmalloc ((size_t)row[col].count *
+ sizeof(short int));
+ memcpy (retvalue, row[col].ptr, (size_t)row[col].count *
+ sizeof(short int));
+ }
+ break;
+ case 'F':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(float));
+ } else {
+ retvalue = (float*)xvt_zmalloc ((size_t)row[col].count *
+ sizeof(float));
+ memcpy (retvalue, row[col].ptr, (size_t)row[col].count *
+ sizeof(float));
+ }
+ break;
+ case 'R':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(double));
+ } else {
+ retvalue = (double*)xvt_zmalloc ((size_t)row[col].count *
+ sizeof (double));
+ memcpy (retvalue, row[col].ptr, (size_t)row[col].count *
+ sizeof(double));
+ }
+ break;
+ case 'C':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(coordinate_type));
+ } else {
+ if (row[col].ptr) {
+ retvalue = (coordinate_type*)xvt_zmalloc ((size_t)row[col].count *
+ sizeof (coordinate_type));
+ if (retvalue)
+ memcpy (retvalue, row[col].ptr, (size_t)row[col].count *
+ sizeof(coordinate_type));
+ } else {
+ retvalue = NULL;
+ }
+ }
+ break;
+ case 'Z':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(tri_coordinate_type));
+ } else {
+ retvalue = (tri_coordinate_type*)xvt_zmalloc ((size_t)row[col].count *
+ sizeof (tri_coordinate_type));
+ memcpy (retvalue, row[col].ptr, (size_t)row[col].count *
+ sizeof(tri_coordinate_type));
+ }
+ break;
+ case 'B':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(double_coordinate_type));
+ } else {
+ retvalue = (double_coordinate_type*)xvt_zmalloc
+ ((size_t)row[col].count * sizeof (double_coordinate_type));
+ memcpy (retvalue, row[col].ptr, (size_t)row[col].count *
+ sizeof(double_coordinate_type));
+ }
+ break;
+ case 'Y':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(double_tri_coordinate_type));
+ } else {
+ retvalue = (double_tri_coordinate_type*)xvt_zmalloc
+ ((size_t)row[col].count * sizeof (double_tri_coordinate_type));
+ memcpy (retvalue, row[col].ptr, (size_t)row[col].count *
+ sizeof(double_tri_coordinate_type));
+ }
+ break ;
+ case 'D':
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(date_type));
+ } else {
+ retvalue = (date_type*)xvt_zmalloc ((size_t)row[col].count *
+ sizeof (date_type));
+ memcpy (retvalue, row[col].ptr, (size_t)row[col].count *
+ sizeof(date_type));
+ }
+ break;
+ case 'K': /* ID Triplet */
+ if (table.header[col].count == 1) {
+ memcpy(value,row[col].ptr,sizeof(id_triplet_type));
+ } else {
+ retvalue = (id_triplet_type*)xvt_zmalloc ((size_t)row[col].count *
+ sizeof (id_triplet_type));
+ memcpy (retvalue, row[col].ptr, (size_t)row[col].count *
+ sizeof(id_triplet_type));
+ }
+ break;
+ }
+ *count = row[col].count;
+
+ return retvalue;
+}
+
+/*************************************************************************
+ *
+ *N named_table_element
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the element in the specified row in the column
+ * matching the given field name. If the element is a single element
+ * (count=1), the value is passed back via the void pointer *value;
+ * otherwise, an array is allocated and passed back as the return value.
+ * NOTE: If an array is allocated in this function, it should be freed
+ * when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * field_name <input> == (char *) field name.
+ * row_number <input> == (int32) row_number.
+ * table <input> == (vpf_table_type) VPF table structure.
+ * value <output> == (void *) pointer to a single element value.
+ * count <output> == (int32 *) pointer to the array size for a multiple
+ * element value.
+ * return <output> == (void *) returned multiple element value.
+ * or NULL if field_name could not be found
+ * as a column
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void *vpfmalloc() VPFREAD.C
+ * row_type get_row() VPFREAD.C
+ * void free_row() VPFREAD.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void *named_table_element( char * field_name,
+ int32 row_number,
+ vpf_table_type table,
+ void * value,
+ int32 * count )
+#else
+void *named_table_element( field_name, row_number, table, value, count )
+char * field_name;
+int32 row_number;
+vpf_table_type table;
+void * value;
+int32 * count;
+#endif
+{
+ int32 col;
+ row_type row;
+ void * retvalue;
+
+ col = table_pos(field_name, table);
+
+ if (col < 0) {
+ xvt_note ("%s: Invalid field name <%s>\n",table.name,field_name);
+ return NULL;
+ }
+ row = get_row(row_number,table);
+
+ retvalue = get_table_element( col, row, table, value, count );
+
+ free_row(row, table);
+
+ return retvalue;
+}
+
+/*************************************************************************
+ *
+ *N table_element
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function returns the element in the specified row in the column
+ * matching the given field number. If the element is a single element
+ * (count=1), the value is passed back via the void pointer *value;
+ * otherwise, an array is allocated and passed back as the return value.
+ * NOTE: If an array is allocated in this function, it should be freed
+ * when no longer needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * field_number <input> == (int32) field number (offset from
+ * first field in table).
+ * row_number <input> == (int32) row_number.
+ * table <input> == (vpf_table_type) VPF table structure.
+ * value <output> == (void *) pointer to a single element value.
+ * count <output> == (int32 *) pointer to the array size for a multiple
+ * element value.
+ * return <output> == (void *) returned multiple element value or
+ * NULL of the field number is invalid
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * row_type get_row() VPFREAD.C
+ * void free_row() VPFREAD.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void *table_element( int32 field_number,
+ int32 row_number,
+ vpf_table_type table,
+ void * value,
+ int32 * count )
+#else
+void *table_element( field_number, row_number, table, value, count )
+int32 field_number;
+int32 row_number;
+vpf_table_type table;
+void * value;
+int32 * count;
+#endif
+{
+ row_type row;
+ void * retvalue;
+
+ row = get_row(row_number, table);
+ retvalue = get_table_element(field_number, row, table, value, count);
+ free_row(row,table);
+
+ return retvalue;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfrelat.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfrelat.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfrelat.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1215 @@
+
+/***************************************************************************
+ *
+ * Module VPFRELAT.C
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *
+ * This module contains functions supporting relates between VPF
+ * feature classes and primitives (and vice versa). It relies
+ * upon the information provided by the Feature Class Schema table.
+ * This table is used to generate a feature class relationship (fcrel)
+ * data structure for a feature class. This structure contains all
+ * of the tables and their primary and foreign keys for the
+ * relationships between a feature table and its primitive, or
+ * from a primitive to its feature table (each relate chain is one way).
+ * This module tries to be as much of a black box as it can to
+ * enable a programmer to simply return the corresponding primitive
+ * row of a feature record, or the corresponding feature row of a
+ * primitive record.
+ *
+ * This is one of the most difficult modules required to support
+ * a truly 'generic' VPF application, since VPF allows so many
+ * variations of feature-primitive relationships. The final version
+ * of this module must support every allowed relationship.
+ **************************************************************************/
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+
+#ifndef __SET_H__
+#include "set.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __VPFVIEW_H__
+#include "vpfview.h"
+#endif
+#ifndef __VPFRELAT_H__
+#include "vpfrelat.h"
+#endif
+#ifndef __VPFTIDX_H__
+#include "vpftidx.h"
+#endif
+#ifndef __VPFQUERY_H__
+#include "vpfquery.h"
+#endif
+#ifndef __STRFUNC_H__
+#include "strfunc.h"
+#endif
+#ifndef __VPFPROP_H__
+#include "vpfprop.h"
+#endif
+#ifndef H_MUSEDIR
+#include "musedir.h"
+#endif
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+
+/* Determine if the given table name is in the given list of */
+/* vpf relate structures. */
+#ifdef PROTO
+ int32 table_in_list (char *tablename, linked_list_type rlist)
+#else
+ int32 table_in_list (tablename, rlist)
+ char *tablename;
+ linked_list_type rlist;
+#endif
+
+ {
+ position_type p;
+ vpf_relate_struct rcell;
+
+ p = ll_first (rlist);
+ while (!ll_end (p))
+ {
+ ll_element (p, &rcell);
+ if (strcmp(rcell.table1, tablename) == 0)
+ return 1;
+ p = ll_next (p);
+ }
+ return 0;
+ }
+
+
+/**************************************************************************
+ *
+ *N num_relate_paths
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Find the number of possible relate paths for the feature class
+ * from the start table. (Complex features can have several relates
+ * to a single primitive table.)
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * start_table <input> == (char *) table to start from.
+ * fcname <input> == (char *) feature class name.
+ * fcs <input> == (vpf_table_type) feature class schema table.
+ * num_relate_paths<output> == (int32) number of relate paths found.
+ *E
+*************************************************************************/
+#ifdef PROTO
+int32 num_relate_paths( char *start_table,
+ char *fcname,
+ vpf_table_type fcs )
+#else
+int32 num_relate_paths( start_table, fcname, fcs )
+char *start_table;
+char *fcname;
+vpf_table_type fcs;
+#endif
+{
+ set_type fcset;
+ int32 n;
+ char qstr[80];
+
+ sprintf(qstr,"FEATURE_CLASS = %s AND TABLE1 = %s",
+ fcname,start_table);
+ fcset = query_table(qstr,fcs);
+ n = (int32) num_in_set (fcset);
+ set_nuke(&fcset);
+ return n;
+}
+
+
+/**************************************************************************
+ *
+ *N fcs_relate_list
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Read the feature class schema table and create the list of
+ * tables to chain through.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * fcname <input> == (char *) feature class name.
+ * start_table <input> == (char *) table to start from.
+ * end_table <input> == (char *) table to end with.
+ * fcs <input> == (vpf_table_type) feature class schema table.
+ * npath <input> == (int32) relate path number.
+ * fcs_relate_list <output> == (linked_list_type) list of tables to
+ * chain through.
+ *************************************************************************/
+#ifdef PROTO
+linked_list_type fcs_relate_list( char *fcname, char *start_table,
+ char *end_table, vpf_table_type fcs,
+ int32 npath )
+#else
+linked_list_type fcs_relate_list( fcname, start_table, end_table, fcs, npath )
+char *fcname;
+char *start_table;
+char *end_table;
+vpf_table_type fcs;
+int32 npath;
+#endif
+{
+ linked_list_type rlist;
+ vpf_relate_struct rstruct;
+ set_type fcset;
+ char tablename[255], *buf, expr[255];
+ row_type row;
+ int32 i, rownum, n;
+ int32 TABLE1_, KEY1_, TABLE2_, KEY2_;
+ char prevstr[80];
+
+ rlist = ll_init();
+
+ sprintf(expr,"FEATURE_CLASS = %s AND TABLE1 = %s",fcname,start_table);
+
+ fcset = query_table(expr,fcs);
+
+ if (set_empty(fcset)) {
+ set_nuke(&fcset);
+ return rlist;
+ }
+
+ TABLE1_ = table_pos("TABLE1",fcs);
+ KEY1_ = table_pos("FOREIGN_KEY",fcs);
+ if (KEY1_ < 0) {
+ KEY1_ = table_pos("TABLE1_KEY",fcs);
+ }
+ TABLE2_ = table_pos("TABLE2",fcs);
+ KEY2_ = table_pos("PRIMARY_KEY",fcs);
+ if (KEY2_ < 0) {
+ KEY2_ = table_pos("TABLE2_KEY",fcs);
+ }
+
+ /* Get to the relate path number */
+ n = -1;
+ rownum = 0;
+ for (i=1; i<fcs.nrows; i++)
+ {
+ if (set_member (i, fcset))
+ {
+ rownum = i;
+ n++;
+ if (n>=npath) break;
+ }
+ }
+ if (n<npath) rownum = set_max(fcset);
+
+ set_nuke(&fcset);
+
+ row = get_row(rownum,fcs);
+
+ buf = (char *)get_table_element(TABLE1_,row,fcs,NULL,&n);
+ strcpy(rstruct.table1,buf);
+ rightjust(rstruct.table1);
+ xvt_free(buf);
+
+ buf = (char *)get_table_element(KEY1_,row,fcs,NULL,&n);
+ strcpy(rstruct.key1,buf);
+ rightjust(rstruct.key1);
+ xvt_free(buf);
+
+ buf = (char *)get_table_element(TABLE2_,row,fcs,NULL,&n);
+ strcpy(rstruct.table2,buf);
+ rightjust(rstruct.table2);
+ xvt_free(buf);
+
+ buf = (char*)get_table_element (KEY2_, row, fcs, NULL, &n);
+ strcpy (rstruct.key2,buf);
+ rightjust (rstruct.key2);
+ xvt_free (buf);
+
+ free_row( row, fcs );
+
+ ll_insert( &rstruct, sizeof(rstruct), ll_last(rlist) );
+
+ strcpy( tablename, rstruct.table2 );
+ strcpy( prevstr, rstruct.table1 );
+#ifdef _MAC /* REM */
+ while ( strcmpi(tablename,end_table) != 0) {
+#elif defined(_WINDOWS)
+ while ( stricmp(tablename,end_table) != 0) {
+#else
+ while (strcasecmp(tablename, end_table) != 0) {
+#endif
+ sprintf(expr,"FEATURE_CLASS = %s AND TABLE1 = %s AND TABLE2 <> %s",
+ fcname,tablename,prevstr);
+
+ fcset = query_table(expr,fcs);
+ if (set_empty(fcset)) {
+ set_nuke(&fcset);
+ return rlist;
+ }
+ rownum = set_min(fcset);
+
+ set_nuke(&fcset);
+
+ row = get_row(rownum,fcs);
+
+ buf = (char *)get_table_element(TABLE1_,row,fcs,NULL,&n);
+ strcpy(rstruct.table1,buf);
+ rightjust(rstruct.table1);
+ xvt_free(buf);
+
+ buf = (char *)get_table_element(KEY1_,row,fcs,NULL,&n);
+ strcpy(rstruct.key1,buf);
+ rightjust(rstruct.key1);
+ xvt_free(buf);
+
+ buf = (char *)get_table_element(TABLE2_,row,fcs,NULL,&n);
+ strcpy(rstruct.table2,buf);
+ rightjust(rstruct.table2);
+ xvt_free(buf);
+
+ buf = (char *)get_table_element(KEY2_,row,fcs,NULL,&n);
+ strcpy(rstruct.key2,buf);
+ rightjust(rstruct.key2);
+ xvt_free(buf);
+
+ free_row( row, fcs );
+
+ if (table_in_list(rstruct.table1, rlist)) break;
+
+ ll_insert( &rstruct, sizeof(rstruct), ll_last(rlist) );
+
+ strcpy( tablename, rstruct.table2 );
+ strcpy( prevstr, rstruct.table1 );
+ }
+
+ return rlist;
+}
+
+
+
+
+/**************************************************************************
+ *
+ *N related_row
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Return the related row of table2 based upon the value of table 1's key
+ * Table 2 must be the '1' side of an n:1 relationship -- If it isn't,
+ * use 'related_rows()'.
+ * Supported data types - I, S, K, and T<n>.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * keyval1 <input> == (void *) key value from table 1 in the relate.
+ * table2 <input> == (vpf_table_type) table 2 in the relate.
+ * key2 <input> == (char *) key column name in table 2.
+ * return <output> == (int32) first related row number in table 2.
+ * 0 is returned if no related rows are found.
+ *************************************************************************/
+#ifdef PROTO
+int32 related_row( void *keyval1,
+ vpf_table_type table2, char *key2,
+ int32 tile_id )
+#else
+int32 related_row( keyval1, table2, key2, tile_id )
+void *keyval1;
+vpf_table_type table2;
+char *key2;
+int32 tile_id;
+#endif
+{
+ int32 rowid, i, ival, n, tile, start,end;
+ short int sval;
+ row_type row;
+ int32 KEY2_,TILE_;
+ char cval, *tval, path[255], *keystring, dir_separator[2];
+ set_type idxset, tileset, searchset;
+ id_triplet_type idtrip;
+
+ dir_separator[0] = DIR_SEPARATOR;
+ dir_separator[1] = '\0';
+
+ if (strcmp(key2,"ID")==0) {
+ memcpy( &rowid, keyval1, sizeof(rowid) );
+ return rowid;
+ }
+
+ rowid = 0;
+
+ KEY2_ = table_pos(key2,table2);
+
+ if ((table2.header[KEY2_].type != 'I')&&
+ (table2.header[KEY2_].type != 'S')&&
+ (table2.header[KEY2_].type != 'K')&&
+ (table2.header[KEY2_].type != 'T')) return rowid;
+
+ if ((table2.header[KEY2_].type != 'T')&&
+ (table2.header[KEY2_].count != 1)) return rowid;
+
+ if (tile_id > 0)
+ TILE_ = table_pos("TILE_ID",table2);
+ else
+ TILE_ = -1;
+
+ idxset.size = 0;
+ if (table2.header[KEY2_].tdx)
+ {
+ strcpy (path, table2.path);
+ rightjust (path);
+ /* Remove the filename from the path */
+ i = strlen (path);
+ while (path[i] != DIR_SEPARATOR)
+ i--;
+ path[i+1] = '\0';
+ strcat (path, table2.header[KEY2_].tdx);
+
+ if (muse_access (path, 4) == 0)
+ {
+ idxset = read_thematic_index(path, (char*)keyval1);
+ if (TILE_ < 0)
+ {
+ /* Don't bother checking TILE_ID. */
+ /* Take the first value in the set. */
+ i = set_min (idxset);
+ if (i>table2.nrows || i<0)
+ i = 0;
+ set_nuke(&idxset);
+ return i;
+ }
+ }
+ }
+ if (idxset.size == 0)
+ {
+ idxset = set_init (table2.nrows);
+ set_on (idxset);
+ }
+
+ tileset.size = 0;
+ if (TILE_ >= 0)
+ {
+ if (table2.header[TILE_].tdx)
+ {
+ strcpy (path, table2.path);
+ rightjust (path);
+ /* Remove the filename from the path */
+ i = strlen (path);
+ while (path[i] != DIR_SEPARATOR)
+ i--;
+ path[i+1] = '\0';
+ strcat (path, table2.header[TILE_].tdx);
+
+ if (muse_access( path, 4) == 0)
+ {
+ tile = tile_id;
+ if (table2.header[TILE_].type == 'S')
+ {
+ sval = (short)tile;
+ tileset = read_thematic_index(path,(char *)&sval);
+ }
+ else if (table2.header[TILE_].type == 'I')
+ {
+ tileset = read_thematic_index (path, (char*)&tile);
+ }
+ }
+ }
+ }
+ if (tileset.size == 0)
+ {
+ tileset = set_init (table2.nrows);
+ set_on (tileset);
+ }
+
+ searchset = set_intersection (tileset, idxset);
+ set_nuke (&tileset);
+ set_nuke (&idxset);
+
+ if (table2.header[KEY2_].type == 'T')
+ {
+ keystring = (char*)xvt_malloc (strlen((char*)keyval1));
+ strcpy (keystring, (char*)keyval1);
+
+ rightjust(keystring);
+ }
+ else
+ {
+ keystring = NULL;
+ }
+
+ start = set_min(searchset);
+ end = set_max(searchset);
+ if (start < 1) start = 1;
+ if (end > table2.nrows) end = table2.nrows;
+
+ for (i=start;i<=end;i++) {
+ if (!set_member(i,searchset)) continue;
+ row = get_row(i,table2);
+
+ if (TILE_>0) {
+ tile = tile_id;
+ if (table2.header[TILE_].type == 'S') {
+ get_table_element(TILE_,row,table2,&sval,&n);
+ tile = sval;
+ } else if (table2.header[TILE_].type == 'I') {
+ get_table_element(TILE_,row,table2,&tile,&n);
+ }
+ if (tile != tile_id) {
+ free_row(row,table2);
+ continue;
+ }
+ }
+
+ if (table2.header[KEY2_].type == 'I') {
+ get_table_element(KEY2_,row,table2,&ival,&n);
+ if (memcmp(&ival,keyval1,sizeof(ival))==0) rowid = i;
+ } else if (table2.header[KEY2_].type == 'S') {
+ get_table_element(KEY2_,row,table2,&sval,&n);
+ ival = (int32)sval;
+ if (memcmp(&ival,keyval1,sizeof(ival))==0) rowid = i;
+ } else if (table2.header[KEY2_].type == 'K') {
+ get_table_element(KEY2_,row,table2,&idtrip,&n);
+ ival = (int32)idtrip.exid;
+ if (memcmp(&ival,keyval1,sizeof(ival))==0) rowid = i;
+ } else if (table2.header[KEY2_].type == 'T') {
+ if (table2.header[KEY2_].count==1) {
+ get_table_element(KEY2_,row,table2,&cval,&n);
+ if (memcmp(&cval,keyval1,sizeof(ival))==0) rowid = i;
+ } else {
+ tval = get_table_element(KEY2_,row,table2,NULL,&n);
+ rightjust(tval);
+#ifdef _MAC /*REM*/
+ if (strcmpi(tval,keystring)==0) rowid = i;
+#elif defined(_WINDOWS)
+ if (stricmp(tval,keystring)==0) rowid = i;
+#else
+ if (strcasecmp(tval,keystring)==0) rowid = i;
+#endif
+ }
+ }
+ free_row(row,table2);
+ if (rowid > 0) break;
+
+ }
+
+ set_nuke(&searchset);
+
+ if (keystring) xvt_free(keystring);
+
+ return rowid;
+}
+
+
+/**************************************************************************
+ *
+ *N related_rows
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Return the list of related rows of table2 based upon the value of
+ * table 1's key.
+ * Supported data types - I, S, K, and T<n>.
+ * Thematic index used, if present on key column.
+ * NOTE: A sequential search operation will search the entire
+ * table if no thematic index ...zzz...
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * keyval1 <input> == (void *) key value from table 1 in the relate.
+ * table2 <input> == (vpf_table_type) table 2 in the relate.
+ * key2 <input> == (char *) key column name in table 2.
+ * return <output> == (linked_list_type) list of (int32) related rows
+ * in table 2. If no related rows are found, the
+ * returned list is empty.
+ *************************************************************************/
+#ifdef PROTO
+ linked_list_type related_rows (void *keyval1, vpf_table_type table2, char *key2,
+ int32 tile_id)
+#else
+ linked_list_type related_rows (keyval1, table2, key2, tile_id)
+ void *keyval1;
+ vpf_table_type table2;
+ char *key2;
+ int32 tile_id;
+#endif
+
+ {
+ linked_list_type rowlist;
+ set_type idxset, tileset, searchset;
+ int32 rowid, i, ival, n, start,end, tile;
+ short short_tile, sval;
+ row_type row;
+ int32 KEY2_, TILE_;
+ char cval, *tval, path[255], *keystring, dir_separator[2];
+ id_triplet_type idtrip = {' ',0,0,0};
+
+ dir_separator[0] = DIR_SEPARATOR;
+ dir_separator[1] = '\0';
+
+ rowlist = ll_init ();
+
+ if (strcmp (key2, "ID") == 0)
+ {
+ memcpy (&rowid, keyval1, sizeof (rowid));
+ ll_insert (&rowid, sizeof (rowid), rowlist);
+ return rowlist;
+ }
+
+ KEY2_ = table_pos (key2, table2);
+
+ if ((table2.header[KEY2_].type != 'I') &&
+ (table2.header[KEY2_].type != 'S') &&
+ (table2.header[KEY2_].type != 'K') &&
+ (table2.header[KEY2_].type != 'T')) return rowlist;
+
+ if ((table2.header[KEY2_].type == 'I') &&
+ (table2.header[KEY2_].count != 1)) return rowlist;
+
+ if (tile_id > 0)
+ TILE_ = table_pos ("TILE_ID", table2);
+ else
+ TILE_ = -1;
+
+ idxset.size = 0;
+
+ /* Use thematic index for column KEY2_ if one exists */
+ if (table2.header[KEY2_].tdx)
+ {
+ strcpy (path, table2.path);
+ rightjust (path);
+
+ /* Remove the filename from the path */
+ i = strlen (path);
+ while (path[i] != DIR_SEPARATOR)
+ i--;
+ path[i+1] = '\0';
+
+ strcat (path, table2.header[KEY2_].tdx);
+
+ if (muse_access(path,4)==0)
+ {
+ idxset = read_thematic_index(path,(char *)keyval1);
+ if (TILE_ < 0)
+ {
+ /* don't bother to check TILE_ID for a match */
+ start = set_min(idxset);
+ end = set_max(idxset);
+ for (i=start;i<end;i++)
+ if (set_member(i,idxset))
+ ll_insert(&i,sizeof(i),ll_last(rowlist));
+ set_nuke(&idxset);
+ return rowlist;
+ }
+ }
+ }
+ if (idxset.size == 0)
+ {
+ idxset = set_init(table2.nrows);
+ set_on(idxset);
+ }
+
+ /* Tiled Data */
+ tileset.size = 0;
+ if (TILE_ >= 0)
+ {
+ /* Use thematic index for TILE_ column if it exists */
+ if (table2.header[TILE_].tdx)
+ {
+ strcpy(path,table2.path);
+ rightjust(path);
+
+ /* Remove the filename from the path */
+ i = strlen (path);
+ while (path[i] != DIR_SEPARATOR)
+ i--;
+ path[i+1] = '\0';
+ strcat (path, table2.header[TILE_].tdx);
+
+ if (muse_access(path,4)==0)
+ {
+ tile = tile_id;
+ if (table2.header[TILE_].type == 'S')
+ {
+ sval = (short int)tile;
+ tileset = read_thematic_index(path,(char *)&sval);
+ }
+ else if (table2.header[TILE_].type == 'I')
+ {
+ tileset = read_thematic_index(path,(char *)&tile);
+ }
+ }
+ }
+ }
+
+ if (tileset.size == 0)
+ {
+ tileset = set_init (table2.nrows);
+ set_on (tileset);
+ }
+
+ searchset = set_intersection (tileset, idxset);
+ set_nuke (&tileset);
+ set_nuke (&idxset);
+
+ if (table2.header[KEY2_].type == 'T')
+ {
+ keystring = (char*)xvt_malloc (strlen ((char*)keyval1));
+ strcpy (keystring, (char*)keyval1);
+
+ rightjust(keystring);
+ }
+ else
+ {
+ keystring = NULL;
+ }
+
+ start = set_min(searchset);
+ end = set_max(searchset);
+ if (start < 1) start = 1;
+ if (end > table2.nrows) end = table2.nrows;
+
+ for (i=start;i<=end;i++)
+ {
+ if (set_member(i,searchset))
+ {
+ row = get_row(i,table2);
+
+ if (TILE_>0)
+ {
+ tile = tile_id;
+ if (table2.header[TILE_].type == 'S')
+ {
+ get_table_element(TILE_,row,table2,&short_tile,&n);
+ tile = short_tile;
+ }
+ else if (table2.header[TILE_].type == 'I')
+ {
+ get_table_element(TILE_,row,table2,&tile,&n);
+ }
+ if (tile != tile_id)
+ {
+ free_row(row,table2);
+ continue;
+ }
+ }
+
+ if (table2.header[KEY2_].type == 'I')
+ {
+ get_table_element(KEY2_,row,table2,&ival,&n);
+ if (memcmp(&ival,keyval1,sizeof(ival))==0)
+ ll_insert(&i,sizeof(i),ll_last(rowlist));
+ }
+ else if (table2.header[KEY2_].type == 'S')
+ {
+ get_table_element(KEY2_,row,table2,&sval,&n);
+ if (memcmp(&sval,keyval1,sizeof(sval))==0)
+ ll_insert(&i,sizeof(i),ll_last(rowlist));
+ }
+ else if (table2.header[KEY2_].type == 'K')
+ {
+ get_table_element(KEY2_,row,table2,&sval,&n);
+ ival = idtrip.exid;
+ if (memcmp(&ival,keyval1,sizeof(ival))==0)
+ ll_insert(&i,sizeof(i),ll_last(rowlist));
+ }
+ else if (table2.header[KEY2_].type == 'T')
+ {
+ if (table2.header[KEY2_].count==1)
+ {
+ get_table_element(KEY2_,row,table2,&cval,&n);
+ if (memcmp(&cval,keyval1,sizeof(ival))==0)
+ ll_insert(&i,sizeof(i),ll_last(rowlist));
+ }
+ else
+ {
+ tval = get_table_element(KEY2_,row,table2,NULL,&n);
+ rightjust(tval);
+#ifdef _MAC /*REM*/
+ if (strcmpi(tval,keystring)==0)
+#elif defined(_WINDOWS)
+ if (stricmp(tval,keystring)==0)
+#else
+ if (strcasecmp(tval,keystring)==0)
+#endif
+ ll_insert(&i,sizeof(i),ll_last(rowlist));
+ }
+ }
+ free_row(row,table2);
+ }
+ }
+ set_nuke (&searchset);
+
+ return rowlist;
+ }
+
+
+/**************************************************************************
+ *
+ *N select_feature_class_relate
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Set up the relationships between features and primitives or between
+ * primitives and features (one way only) for a specified feature class.
+ *************************************************************************/
+#ifdef PROTO
+fcrel_type select_feature_class_relate( char *covpath, char *fcname,
+ char *start_table, char *end_table, int32 npath)
+#else
+fcrel_type select_feature_class_relate( covpath, fcname, start_table,
+ end_table, npath)
+char *covpath;
+char *fcname;
+char *start_table;
+char *end_table;
+int32 npath;
+#endif
+{
+ storage_type storage;
+ vpf_table_type fcs;
+ int32 i;
+ char *path;
+ position_type p;
+ vpf_relate_struct rcell;
+ fcrel_type fcrel;
+
+ path = (char*)xvt_zmalloc (255 * sizeof (char));
+ fcrel.nchain = 0;
+ fcrel.table = NULL;
+ fcrel.relate_list = NULL;
+
+ rightjust(covpath);
+ sprintf( path, "%sfcs", covpath );
+ /* Feature Class Schema table */
+ fcs = vpf_open_table (path, disk, "rb", NULL );
+ if (!fcs.fp)
+ {
+ xvt_note ("select_feature_class_relate: Error opening %s\n",path);
+ return fcrel;
+ }
+
+ fcrel.relate_list = fcs_relate_list (fcname, start_table, end_table,
+ fcs, npath);
+
+ if (ll_empty (fcrel.relate_list))
+ {
+ ll_reset (fcrel.relate_list);
+ xvt_note ("ERROR in feature class relationship!");
+ return fcrel;
+ }
+
+ /* Find the number of tables in the relate chain */
+ p = ll_first (fcrel.relate_list);
+ fcrel.nchain = 0;
+ while (!ll_end(p))
+ {
+ fcrel.nchain++;
+ p = ll_next (p);
+ }
+ /* Allow for last table2 */
+ fcrel.nchain++;
+
+ fcrel.table = (vpf_table_type*)
+ xvt_malloc((size_t)(fcrel.nchain + 1) * sizeof(vpf_table_type));
+ if (!fcrel.table)
+ {
+ xvt_note ("Out of memory in select_feature_class_relate\n");
+ exit(1);
+ }
+
+ for (i=0; i<fcrel.nchain+1; i++)
+ {
+ vpf_nullify_table (&(fcrel.table[i]));
+ }
+
+
+ p = ll_first (fcrel.relate_list);
+ for (i=0; i<fcrel.nchain-1; i++)
+ {
+ ll_element (p, &rcell);
+
+ /** Can't open primitive table - may be several under tile **/
+ /** directories. Open all others **/
+ if (!is_primitive (rcell.table1))
+ {
+ strcpy (path, covpath);
+ strcat (path, rcell.table1);
+
+ if (is_join(rcell.table1))
+ storage = ram;
+ else
+ storage = disk;
+
+
+ fcrel.table[i] = vpf_open_table (path, storage, "rb", (char*)NULL);
+ }
+ if (!ll_end(p))
+ p = ll_next(p);
+ }
+
+ /* End of relate chain */
+ i = fcrel.nchain-1;
+ if (!is_primitive (rcell.table2))
+ {
+ strcpy (path, covpath);
+ strcat (path, rcell.table2);
+ storage = disk;
+ fcrel.table[i] = vpf_open_table (path, storage, "rb", (char*)NULL);
+ }
+
+ vpf_close_table( &fcs );
+ if (path)
+ xvt_free (path);
+
+ return fcrel;
+}
+
+
+/**************************************************************************
+ *
+ *N fc_row_number
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Given the starting row of a feature class relationship, return the
+ * row number of the table at the end of the feature class relate
+ * chain.
+ * If your relate goes from the feature to the primitive, this will
+ * return the primitive id for the given feature row.
+ * If your relate goes from the primitive to the feature, this will
+ * return the feature id of the given primitive row.
+ *
+ * Currently only supports relates on 'I', 'S', or 'K' fields.
+ *************************************************************************/
+#ifdef PROTO
+int32 fc_row_number( row_type row, fcrel_type fcrel, int32 tile )
+#else
+int32 fc_row_number( row, fcrel, tile )
+row_type row;
+fcrel_type fcrel;
+int32 tile;
+#endif
+{
+ row_type relrow;
+ int32 count;
+ int32 i, rownum, keyval;
+ short int sval;
+ id_triplet_type triplet_keyval;
+ int32 KEY1_, KEY_;
+ position_type p;
+ vpf_relate_struct rcell;
+
+ p = ll_first(fcrel.relate_list);
+ ll_element(p,&rcell);
+ KEY1_ = table_pos(rcell.key1,fcrel.table[0]);
+
+ get_table_element(0,row,fcrel.table[0],&rownum,&count);
+
+ if (KEY1_ == 0) /* "ID" */
+ {
+ keyval = rownum;
+ }
+ else
+ {
+ switch (fcrel.table[0].header[KEY1_].type)
+ {
+ case 'I':
+ get_table_element(KEY1_,row,fcrel.table[0],&keyval,&count);
+ break;
+ case 'S':
+ get_table_element(KEY1_,row,fcrel.table[0],&sval,&count);
+ keyval = sval;
+ break;
+ case 'K':
+ get_table_element(KEY1_,row,fcrel.table[0],&triplet_keyval,
+ &count);
+ keyval = triplet_keyval.exid;
+ if (tile != triplet_keyval.tile)
+ {
+ return -2;
+ }
+ break;
+ default:
+ keyval = 0;
+ break;
+ }
+ }
+
+ p = ll_first(fcrel.relate_list);
+ for (i=1;i<(fcrel.nchain-1);i++) {
+ /* Relate through Join table(s) */
+ rownum = related_row (&keyval,fcrel.table[i],rcell.key2,tile);
+ if (rownum < 1) break;
+ relrow = get_row(rownum,fcrel.table[i]);
+
+ p = ll_next(p);
+ ll_element(p,&rcell);
+ KEY_ = table_pos(rcell.key1,fcrel.table[i]);
+
+ if (KEY_ == 0) { /* "ID" */
+ keyval = rownum;
+ } else {
+ switch (fcrel.table[i].header[KEY_].type) {
+ case 'I':
+ get_table_element(KEY_,relrow,fcrel.table[i],&keyval,&count);
+ break;
+ case 'S':
+ get_table_element(KEY_,relrow,fcrel.table[i],&sval,&count);
+ keyval = sval;
+ break;
+ case 'K':
+ get_table_element(KEY_,relrow,fcrel.table[i],&triplet_keyval,
+ &count);
+ keyval = triplet_keyval.exid;
+ if (tile != triplet_keyval.tile) {
+ return -2;
+ }
+ break;
+ default:
+ keyval = 0;
+ break;
+ }
+ }
+
+ free_row(relrow,fcrel.table[i]);
+ }
+
+ if (rownum < 1) return 0;
+
+ if (strcmp(rcell.key2,"ID")==0)
+ rownum = keyval;
+ else
+ rownum = related_row(&keyval,fcrel.table[i],rcell.key2,tile);
+
+ return rownum;
+}
+
+
+/**************************************************************************
+ *
+ *N fc_row_numbers
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Given the starting row of a feature class relationship, return the
+ * list of row numbers of the table at the end of the feature class
+ * relate chain.
+ * If your relate goes from the feature to the primitive, this will
+ * return the primitive ids for the given feature row.
+ * If your relate goes from the primitive to the feature, this will
+ * return the feature ids of the given primitive row.
+ *
+ * Currently only supports relates on 'I', 'S', or 'K' fields.
+ *************************************************************************/
+#ifdef PROTO
+linked_list_type fc_row_numbers (row_type row, fcrel_type fcrel,
+ int32 tile)
+#else
+linked_list_type fc_row_numbers (row, fcrel, tile)
+row_type row;
+fcrel_type fcrel;
+int32 tile;
+#endif
+ {
+ row_type relrow;
+ int32 count;
+ int32 n, rownum, keyval;
+ id_triplet_type triplet_keyval;
+ int32 KEY1_, KEY_;
+ position_type p, prow, pkey;
+ vpf_relate_struct rcell;
+ linked_list_type rowlist, keylist, templist;
+
+ p = ll_first (fcrel.relate_list);
+ ll_element (p,&rcell);
+ KEY1_ = table_pos (rcell.key1, fcrel.table[0]);
+
+ get_table_element (0L, row, fcrel.table[0], &rownum, &count);
+
+ if (KEY1_ == 0)
+ {
+ /* "ID" */
+ keyval = rownum;
+ }
+ else
+ {
+ switch (fcrel.table[0].header[KEY1_].type)
+ {
+ case 'I':
+ get_table_element (KEY1_, row, fcrel.table[0], &keyval, &count);
+ break;
+ case 'K':
+ get_table_element (KEY1_, row, fcrel.table[0], &triplet_keyval,
+ &count);
+ keyval = triplet_keyval.exid;
+ if (tile != triplet_keyval.tile)
+ {
+ keyval = -2;
+ }
+ break;
+ default:
+ keyval = 0;
+ break;
+ }
+ }
+
+ keylist = ll_init();
+ ll_insert (&keyval, sizeof (keyval), keylist);
+
+ n = 0;
+
+ p = ll_first (fcrel.relate_list);
+ for (n=1; n<(fcrel.nchain-1); n++)
+ {
+ /* Relate through Join table(s) */
+ rowlist = ll_init ();
+ pkey = ll_first (keylist);
+ while (!ll_end (pkey))
+ {
+ ll_element (pkey, &keyval);
+ templist = related_rows (&keyval, fcrel.table[n], rcell.key2, tile);
+ prow = ll_first (templist);
+ while (!ll_end (prow))
+ {
+ ll_element (prow, &rownum);
+ if (!ll_locate (&rownum, rowlist))
+ ll_insert (&rownum, sizeof (rownum), ll_last (rowlist));
+ prow = ll_next(prow);
+ }
+ ll_reset (templist);
+ pkey = ll_next (pkey);
+ }
+ ll_reset (keylist);
+
+ p = ll_next (p);
+ ll_element (p, &rcell);
+ KEY_ = table_pos (rcell.key1, fcrel.table[n]);
+
+ keylist = ll_init ();
+ if (ll_empty (rowlist))
+ break;
+ prow = ll_first (rowlist);
+ while (!ll_end (prow))
+ {
+ ll_element (prow, &rownum);
+ relrow = get_row (rownum, fcrel.table[n]);
+
+ if (KEY_ == 0)
+ {
+ /* "ID" */
+ keyval = rownum;
+ }
+ else
+ {
+ switch (fcrel.table[n].header[KEY_].type)
+ {
+ case 'I':
+ get_table_element(KEY_,relrow,fcrel.table[n],&keyval,&count);
+ break;
+ case 'K':
+ get_table_element(KEY_,relrow,fcrel.table[n],&triplet_keyval,
+ &count);
+ keyval = triplet_keyval.exid;
+ if (tile != triplet_keyval.tile)
+ {
+ keyval = -2;
+ }
+ break;
+ default:
+ keyval = 0;
+ break;
+ }
+ }
+ if (keyval > 0)
+ ll_insert(&keyval,sizeof(keyval),ll_last(keylist));
+ prow = ll_next(prow);
+ free_row(relrow,fcrel.table[n]);
+ }
+ ll_reset(rowlist);
+ }
+ rowlist = ll_init();
+ if (ll_empty(keylist))
+ return rowlist;
+ p = ll_first(keylist);
+ while (!ll_end(p))
+ {
+ ll_element(p,&keyval);
+ templist = related_rows(&keyval,fcrel.table[n],rcell.key2,tile);
+ prow = ll_first(templist);
+ while (!ll_end(prow))
+ {
+ ll_element(prow,&rownum);
+ if (!ll_locate(&rownum,rowlist))
+ ll_insert(&rownum,sizeof(rownum),ll_last(rowlist));
+ prow = ll_next(prow);
+ }
+ ll_reset(templist);
+ p = ll_next(p);
+ }
+ ll_reset(keylist);
+
+ return rowlist;
+ }
+
+
+/**************************************************************************
+ *
+ *N deselect_feature_class_relate
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Clear out a previously allocated feature class relate structure
+ * from memory.
+ *************************************************************************/
+#ifdef PROTO
+ void deselect_feature_class_relate (fcrel_type *fcrel)
+#else
+ void deselect_feature_class_relate (fcrel)
+ fcrel_type *fcrel;
+#endif
+
+ {
+ register int32 i;
+
+ if (fcrel->nchain > 0)
+ {
+ for (i=0; i<fcrel->nchain; i++)
+ {
+ if (fcrel->table[i].status == OPENED)
+ {
+ vpf_close_table (&(fcrel->table[i]));
+ }
+ }
+ xvt_free ((char*)fcrel->table);
+ ll_reset(fcrel->relate_list);
+ }
+ fcrel->nchain = 0;
+ }
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfrelat.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfrelat.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfrelat.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,57 @@
+
+#ifndef __VPFRELAT_H__
+#define __VPFRELAT_H__ 1
+
+#ifndef __LINKLIST_H__
+#include "linklist.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __VPFTIDX_H__
+#include "vpftidx.h"
+#endif
+
+typedef struct {
+ char table1[40];
+ char key1[40];
+ char table2[40];
+ char key2[40];
+} vpf_relate_struct;
+
+
+typedef struct {
+ int32 nchain;
+ vpf_table_type *table;
+ linked_list_type relate_list;
+} feature_class_relate_type, fcrel_type;
+
+
+#ifdef PROTO
+ int32 num_relate_paths( char *start_table, char *fcname, vpf_table_type fcs );
+ linked_list_type fcs_relate_list( char *fcname, char *start_table,
+ char *end_table, vpf_table_type fcs,
+ int32 npath );
+ int32 related_row( void *keyval, vpf_table_type table, char *keyfield,
+ int32 tile_id );
+ linked_list_type related_rows( void *keyval, vpf_table_type table,
+ char *keyfield, int32 tile_id );
+ fcrel_type select_feature_class_relate( char *covpath, char *fcname,
+ char *start_table, char *end_table,
+ int32 npath );
+ int32 fc_row_number( row_type row, fcrel_type fcrel, int32 tile );
+ linked_list_type fc_row_numbers( row_type row, fcrel_type fcrel,
+ int32 tile );
+ void deselect_feature_class_relate( fcrel_type *fcrel );
+#else
+ int32 num_relate_paths ();
+ linked_list_type fcs_relate_list ();
+ int32 related_row ();
+ linked_list_type related_rows ();
+ fcrel_type select_feature_class_relate ();
+ int32 fc_row_number ();
+ linked_list_type fc_row_numbers ();
+ void deselect_feature_class_relate ();
+#endif /* If PROTO */
+
+#endif /* VPFRELAT_H */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,261 @@
+
+/*************************************************************************
+ *
+ *N Module VPFSELEC - VPF SELECTED FEATURES
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This module contains functions for selecting VPF features and
+ * primitives.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * N/A
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Nov 1991 DOS Turbo C
+ * Feb 1992 - Optimized for CD-ROM performance.
+ *E
+ *************************************************************************/
+
+#ifndef __VPF_H__
+#include "vpf.h"
+#endif
+#ifndef H_MUSEDIR
+#include "musedir.h"
+#endif
+#ifndef __VPFQUERY_H__
+#include "vpfquery.h"
+#endif
+#ifndef __VPFTIDX_H__
+#include "vpftidx.h"
+#endif
+#ifndef __VPFSELEC_H__
+#include "vpfselec.h"
+#endif
+
+/*************************************************************************
+ *
+ *N get_fit_tile_primitives
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Get the set of primitives in the given tile for the selected features
+ * in the given feature class. Use the Feature Index Table instead of
+ * the schema relationships.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * covpath <input>==(char *) path th the VPF coverage.
+ * primclass <input>==(int) primitive class to select.
+ * expression<input>==(char *) expression to apply to the feature table.
+ * feature_table <input>==(vpf_table_type) feature table.
+ * tile <input>==(int32) tile number.
+ * fca_id <input>==(int) Feature Class Attribute table id of the
+ * selected feature class.
+ * numprims <input>==(int) number of rows in the specified tile's
+ * primitive table for the specified primitive
+ * class.
+ * status <output>==(int *) status of the function:
+ * 1 if completed, 0 if user escape.
+ * return <output>==(set_type) set of primitives for the features
+ * in the corresponding tile.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *************************************************************************/
+
+#ifdef PROTO
+int32 query_table_row (char *expression, row_type row, vpf_table_type table);
+#else
+int32 query_table_row (char *expression, row_type row, vpf_table_type table);
+#endif
+
+#ifdef PROTO
+ set_type get_fit_tile_primitives (char *covpath, int32 primclass, char *expression,
+ vpf_table_type feature_table, int32 tile, int32 fca_id,
+ int32 numprims, int32 *status)
+#else
+ set_type get_fit_tile_primitives (covpath, primclass, expression, feature_table, tile,
+ fca_id, numprims, status)
+ char *covpath;
+ int32 primclass;
+ char *expression;
+ vpf_table_type feature_table;
+ int32 tile, fca_id, numprims, *status;
+#endif
+
+ {
+ set_type primitives, tileset, fcset, selset;
+ int32 i, start, end, prim_id, tile_id, fc_id, feature_id, count;
+ short short_tile_id;
+ int32 PRIM_ID_, TILE_ID_, FC_ID_, FEATURE_ID_;
+ vpf_table_type fit;
+ row_type row, frow;
+ char path[255];
+ static char *ptable[] = {"","EDG","FAC","TXT","END","CND"};
+
+ primitives = set_init (numprims+1);
+
+ strcpy (path, covpath);
+ strcat (path, ptable[primclass]);
+ strcat (path, ".FIT");
+ muse_check_path (path);
+
+ if (muse_access (path,0) != 0)
+ return primitives;
+
+ fit = vpf_open_table (path, disk, "rb", NULL);
+ if (!fit.fp)
+ return primitives;
+
+ TILE_ID_ = table_pos ("TILE_ID", fit);
+ PRIM_ID_ = table_pos ("PRIM_ID", fit);
+ FC_ID_ = table_pos ("FC_ID", fit);
+ if (FC_ID_ < 0)
+ FC_ID_ = table_pos ("FCA_ID", fit);
+ FEATURE_ID_ = table_pos ("FEATURE_ID", fit);
+ if ((TILE_ID_ < 0 && tile) || PRIM_ID_ < 0 ||
+ FC_ID_ < 0 || FEATURE_ID_ < 0)
+ {
+ vpf_close_table (&fit);
+ *status = 0;
+ return primitives;
+ }
+
+ /* Look for TILE_ID thematic index */
+ tileset.size = 0;
+ if (tile)
+ {
+ if (fit.header[TILE_ID_].tdx)
+ {
+ strcpy (path, covpath);
+ strcat (path, fit.header[TILE_ID_].tdx);
+ muse_check_path (path);
+ if (muse_access (path,0) == 0)
+ {
+ if (fit.header[TILE_ID_].type == 'I')
+ {
+ tile_id = (int32)tile;
+ tileset = read_thematic_index (path, (char*)&tile_id);
+ }
+ else if (fit.header[TILE_ID_].type == 'S')
+ {
+ short_tile_id = tile;
+ tileset = read_thematic_index(path,(char *)&short_tile_id);
+ }
+ } /* if muse_access */
+ } /* if tile_id.tdx */
+ } /* if tile */
+
+ if (!tileset.size)
+ {
+ tileset = set_init (fit.nrows+1);
+ set_on (tileset);
+ set_delete (0, tileset);
+ }
+
+ /* Look for FC_ID thematic index */
+ fcset.size = 0;
+ if (fit.header[FC_ID_].tdx)
+ {
+ strcpy (path, covpath);
+ strcat (path, fit.header[FC_ID_].tdx);
+ muse_check_path (path);
+ if (muse_access (path, 0) == 0)
+ {
+ fc_id = (int32)fca_id;
+ fcset = read_thematic_index (path, (char*)&fc_id);
+ }
+ } /* if fc_id.tdx */
+
+ if (!fcset.size)
+ {
+ fcset = set_init (fit.nrows+1);
+ set_on (fcset);
+ set_delete (0, fcset);
+ }
+
+ /* Get the set of all FIT rows in the search tile that match the
+ search fca_id */
+ selset = set_intersection (tileset, fcset);
+ set_nuke (&tileset);
+ set_nuke (&fcset);
+
+ if (set_empty (selset))
+ {
+ vpf_close_table (&fit);
+ set_nuke (&selset);
+ *status = 1;
+ return primitives;
+ }
+
+
+ /* Now loop through the FIT and get the matching primitive ids */
+ start = set_min (selset);
+ end = set_max (selset);
+
+ /* Set file pointer to start record */
+ fseek (fit.fp, index_pos (start, fit), SEEK_SET);
+
+ for (i=start; i<=end; i++)
+ {
+ /* Read each row of the fit starting as start. IF the row is a member */
+ /* of selset then get the tile_id. */
+ row = read_next_row (fit);
+ if (set_member (i, selset))
+ {
+
+ /* i is a member of selset so now we must test it to see if it */
+ /* meets the conditions of the thematic expression */
+ get_table_element(PRIM_ID_,row,fit,&prim_id,&count);
+ get_table_element(FC_ID_,row,fit,&fc_id,&count);
+ get_table_element(FEATURE_ID_,row,fit,&feature_id,&count);
+ tile_id = 0;
+ if (tile)
+ {
+ if (fit.header[TILE_ID_].type == 'I')
+ {
+ get_table_element (TILE_ID_, row, fit, &tile_id, &count);
+ }
+ else if (fit.header[TILE_ID_].type == 'S')
+ {
+ get_table_element(TILE_ID_, row, fit, &short_tile_id, &count);
+ tile_id = short_tile_id;
+ }
+ } /* if tile */
+ free_row (row, fit);
+
+ if (tile_id != tile || fc_id != fca_id)
+ continue;
+ frow = get_row (feature_id, feature_table);
+ if (query_table_row (expression, frow, feature_table))
+ set_insert (prim_id, primitives);
+ free_row(frow,feature_table);
+ } /* if set_member */
+ free_row (row, fit);
+ } /* for i */
+
+ vpf_close_table (&fit);
+ set_nuke (&selset);
+
+ *status = 1;
+
+ return primitives;
+ }
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,25 @@
+/* VPFSELEC.H - SELECT VPF FEATURES */
+
+#ifndef __VPFSELEC_H__
+
+#define __VPFSELEC_H__ 1
+
+#ifndef __SET_H__
+#include "set.h"
+#endif
+#ifndef __VPFVIEW_H__
+#include "vpfview.h"
+#endif
+#ifndef __VPFRELAT_H__
+#include "vpfrelat.h"
+#endif
+
+#ifdef PROTO
+ set_type get_fit_tile_primitives (char *covpath, int32 primclass, char *expression,
+ vpf_table_type feature_table, int32 tile, int32 fca_id,
+ int32 numprims, int32 *status);
+#else
+ set_type get_fit_tile_primitives ();
+#endif
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.i
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.i 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfselec.i 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1761 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#pragma comment(exestr, "xpg4plus @(#) stdio.h 20.1 94/12/04 ")
+
+#pragma pack(4)
+
+
+typedef unsigned int size_t;
+
+typedef long fpos_t;
+
+typedef long wchar_t;
+
+typedef long wint_t;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+typedef struct _FILE_
+{
+ int __cnt;
+ unsigned char *__ptr;
+ unsigned char *__base;
+ unsigned char __flag;
+ unsigned char __file;
+ unsigned char __buf[2];
+} FILE;
+
+
+extern FILE __iob[];
+
+
+
+
+extern int remove(const char *);
+extern int rename(const char *, const char *);
+extern FILE *tmpfile(void);
+extern char *tmpnam(char *);
+extern int fclose(FILE *);
+extern int fflush(FILE *);
+extern FILE *fopen(const char *, const char *);
+extern FILE *freopen(const char *, const char *, FILE *);
+extern void setbuf(FILE *, char *);
+extern int setvbuf(FILE *, char *, int, size_t);
+
+extern int fprintf(FILE *, const char *, ...);
+
+extern int fscanf(FILE *, const char *, ...);
+
+extern int printf(const char *, ...);
+
+extern int scanf(const char *, ...);
+
+extern int sprintf(char *, const char *, ...);
+
+extern int sscanf(const char *, const char *, ...);
+extern int vfprintf(FILE *, const char *, char * ) ;
+extern int vprintf(const char *, char * ) ;
+extern int vsprintf(char *, const char *, char * ) ;
+extern int fgetc(FILE *);
+extern char *fgets(char *, int, FILE *);
+extern int fputc(int, FILE *);
+extern int fputs(const char *, FILE *);
+extern int getc(FILE *);
+extern int getchar(void);
+extern char *gets(char *);
+extern int putc(int, FILE *);
+extern int putchar(int);
+extern int puts(const char *);
+extern int ungetc(int, FILE *);
+extern size_t fread(void *, size_t, size_t, FILE *);
+#pragma int_to_unsigned fread
+extern size_t fwrite(const void *, size_t, size_t, FILE *);
+#pragma int_to_unsigned fwrite
+extern int fgetpos(FILE *, fpos_t *);
+extern int fseek(FILE *, long, int);
+extern int fsetpos(FILE *, const fpos_t *);
+extern long ftell(FILE *);
+extern void rewind(FILE *);
+extern void clearerr(FILE *);
+extern int feof(FILE *);
+extern int ferror(FILE *);
+extern void perror(const char *);
+
+extern int __filbuf(FILE *);
+extern int __flsbuf(int, FILE *);
+
+
+
+
+
+extern int (fileno)(FILE *);
+extern char *ctermid(char *);
+extern FILE *fdopen(int, const char *);
+
+extern FILE *popen(const char *, const char *);
+extern char *tempnam(const char *, const char *);
+extern int getw(FILE *);
+extern int putw(int, FILE *);
+extern int pclose(FILE *);
+
+
+
+extern char *optarg;
+extern int optind, opterr, optopt;
+extern char *cuserid(char *);
+extern int getopt(int, char *const*, const char *);
+
+
+
+extern int system(const char *);
+extern wint_t fgetwc(FILE *);
+extern wchar_t *fgetws(wchar_t *, int, FILE *);
+extern wint_t fputwc(wint_t, FILE *);
+extern int fputws(const wchar_t *, FILE *);
+extern wint_t getwc(FILE *);
+extern wint_t getwchar(void);
+extern wint_t putwc(wint_t, FILE *);
+extern wint_t putwchar(wint_t);
+extern wint_t ungetwc(wint_t, FILE *);
+
+extern int fwprintf(FILE *, const wchar_t *, ...);
+
+extern int fwscanf(FILE *, const wchar_t *, ...);
+
+extern int wprintf(const wchar_t *, ...);
+
+extern int wscanf(const wchar_t *, ...);
+
+extern int swprintf(wchar_t *, size_t, const wchar_t *, ...);
+
+extern int swscanf(const wchar_t *, const wchar_t *, ...);
+extern int vfwprintf(FILE *, const wchar_t *, char * ) ;
+extern int vfwscanf(FILE *, const wchar_t *, char * ) ;
+extern int vwprintf(const wchar_t *, char * ) ;
+extern int vwscanf(const wchar_t *, char * ) ;
+extern int vswprintf(wchar_t *, size_t, const wchar_t *, char * ) ;
+extern int vswscanf(const wchar_t *, const wchar_t *, char * ) ;
+extern void funflush(FILE *);
+
+extern int snprintf(char *, size_t, const char *, ...);
+extern int vsnprintf(char *, size_t, const char *, char * ) ;
+extern int vfscanf(FILE *, const char *, char * ) ;
+extern int vscanf(const char *, char * ) ;
+extern int vsscanf(const char *, const char *, char * ) ;
+
+
+
+extern int nl_fprintf(FILE *, const char *, ...);
+
+extern int nl_fscanf(FILE *, const char *, ...);
+
+extern int nl_printf(const char *, ...);
+
+extern int nl_scanf(const char *, ...);
+
+extern int nl_sprintf(char *, const char *, ...);
+
+extern int nl_sscanf(const char *, const char *, ...);
+
+
+
+
+#pragma pack()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#pragma comment(exestr, "xpg4plus @(#) stdlib.h 20.1 94/12/04 ")
+
+
+#pragma pack(4)
+
+typedef struct
+{
+ int quot;
+ int rem;
+} div_t;
+
+typedef struct
+{
+ long quot;
+ long rem;
+} ldiv_t;
+
+
+typedef int ssize_t;
+
+
+
+
+
+
+
+
+extern unsigned char __ctype[];
+
+
+extern double atof(const char *);
+extern int atoi(const char *);
+extern long atol(const char *);
+extern double strtod(const char *, char **);
+extern float strtof(const char *, char **);
+extern long strtol(const char *, char **, int);
+extern unsigned long strtoul(const char *, char **, int);
+
+extern int rand(void);
+extern void srand(unsigned int);
+
+extern void *calloc(size_t, size_t);
+extern void free(void *);
+extern void *malloc(size_t);
+extern void *realloc(void *, size_t);
+
+extern void abort(void);
+extern int atexit(void (*)(void));
+extern void exit(int);
+extern char *getenv(const char *);
+extern int system(const char *);
+
+extern void *bsearch(const void *, const void *, size_t, size_t,
+ int (*)(const void *, const void *));
+extern void qsort(void *, size_t, size_t,
+ int (*)(const void *, const void *));
+
+extern int (abs)(int);
+
+extern div_t div(int, int);
+extern long labs(long);
+extern ldiv_t ldiv(long, long);
+
+extern int mbtowc(wchar_t *, const char *, size_t);
+extern int mblen(const char *, size_t);
+extern int wctomb(char *, wchar_t);
+
+extern size_t mbstowcs(wchar_t *, const char *, size_t);
+extern size_t wcstombs(char *, const wchar_t *, size_t);
+
+
+extern long a64l(const char *);
+extern int dup2(int, int);
+extern char *ecvt(double, int, int *, int *);
+extern char *ecvtl(long double, int, int *, int *);
+extern char *fcvt(double, int, int *, int *);
+extern char *fcvtl(long double, int, int *, int *);
+extern char *getcwd(char *, size_t);
+extern char *getlogin(void);
+extern int getopt(int, char *const *, const char *);
+extern int getsubopt(char **, char *const *, char **);
+extern char *initstate(unsigned, char *, int);
+extern int grantpt(int);
+extern char *optarg;
+extern int optind, opterr, optopt;
+extern char *getpass(const char *);
+extern int getpw(int, char *);
+extern char *gcvt(double, int, char *);
+extern char *gcvtl(long double, int, char *);
+extern int isatty(int);
+extern void l3tol(long *, const char *, int);
+extern char *l64a(long);
+extern char *l64a_r(long, char *, size_t);
+extern void ltol3(char *, const long *, int);
+extern void *memalign(size_t, size_t);
+extern char *mktemp(char *);
+extern int mkstemp(char *);
+extern char *ptsname(int);
+extern long random(void);
+extern int rand_r(unsigned int *);
+extern char *realpath(const char *, char *);
+extern char *setstate(char *);
+extern void srandom(unsigned);
+extern long double strtold(const char *, char **);
+extern void swab(const void *, void *, ssize_t);
+extern char *ttyname(int);
+extern int ttyslot(void);
+extern int unlockpt(int);
+extern void *valloc(size_t);
+extern double wcstod(const wchar_t *, wchar_t **);
+extern float wcstof(const wchar_t *, wchar_t **);
+extern long wcstol(const wchar_t *, wchar_t **, int);
+extern long double wcstold(const wchar_t *, wchar_t **);
+extern unsigned long wcstoul(const wchar_t *, wchar_t **, int);
+
+
+
+extern double drand48(void);
+extern double erand48(unsigned short *);
+extern long jrand48(unsigned short *);
+extern void lcong48(unsigned short *);
+extern long lrand48(void);
+extern long mrand48(void);
+extern long nrand48(unsigned short *);
+extern int putenv(const char *);
+extern unsigned short *seed48(unsigned short *);
+extern void setkey(const char *);
+extern void srand48(long);
+
+
+
+
+
+#pragma pack()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#pragma comment(exestr, "xpg4plus @(#) string.h 20.1 94/12/04 ")
+
+
+
+
+
+
+extern void *memchr(const void *, int, size_t);
+extern void *memcpy(void *, const void *, size_t);
+extern void *memccpy(void *, const void *, int, size_t);
+extern void *memmove(void *, const void *, size_t);
+extern void *memset(void *, int, size_t);
+
+extern char *strchr(const char *, int);
+extern char *strcpy(char *, const char *);
+extern char *strncpy(char *, const char *, size_t);
+extern char *strcat(char *, const char *);
+extern char *strncat(char *, const char *, size_t);
+extern char *strpbrk(const char *, const char *);
+extern char *strrchr(const char *, int);
+extern char *strstr(const char *, const char *);
+extern char *strtok(char *, const char *);
+extern char *strtok_r(char *, const char *, char **);
+extern char *strerror(int);
+extern char *strlist(char *, const char *, ...);
+
+extern int memcmp(const void *, const void *, size_t);
+extern int strcmp(const char *, const char *);
+extern int strcoll(const char *, const char *);
+extern int strncmp(const char *, const char *, size_t);
+
+extern void perror(const char *);
+extern char *strdup(const char *);
+extern int strncoll(const char *, const char *, int);
+extern size_t strnxfrm(char *, const char *, size_t , int);
+
+extern size_t strxfrm(char *, const char *, size_t);
+extern size_t strcspn(const char *, const char *);
+extern size_t strspn(const char *, const char *);
+extern size_t strlen(const char *);
+
+#pragma int_to_unsigned strcspn
+#pragma int_to_unsigned strspn
+#pragma int_to_unsigned strlen
+
+
+
+
+extern int ffs(int);
+
+extern int nl_strcmp(char *, char *);
+extern int nl_strncmp(char *, char *, int n);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#pragma comment(exestr, "xpg4plus @(#) malloc.h 20.1 94/12/04 ")
+
+
+#pragma pack(4)
+
+
+
+struct mallinfo {
+ int arena;
+ int ordblks;
+ int smblks;
+ int hblks;
+ int hblkhd;
+ int usmblks;
+ int fsmblks;
+ int uordblks;
+ int fordblks;
+ int keepcost;
+};
+
+
+
+extern void *malloc(size_t);
+extern void free(void *);
+extern void *realloc(void *, size_t);
+extern int mallopt(int, int);
+extern struct mallinfo mallinfo(void);
+extern void *calloc(size_t, size_t);
+
+
+#pragma pack()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#pragma comment(exestr, "xpg4plus @(#) limits.h 20.2 94/12/15 ")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+extern long _sysconf(int);
+
+
+
+extern void G_warning (char *msg);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ short dir_create ( ) ;
+ short dir_pop ( ) ;
+ short dir_push ( ) ;
+ short dir_restore ( ) ;
+ short dir_save ( ) ;
+ short dir_current ( ) ;
+ short file_spec_to_string ( ) ;
+FILE *file_open ();
+int muse_access ();
+long muse_filelength ();
+void muse_check_path ();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+extern void G_warning (char *msg);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+typedef struct
+ {
+ long size;
+ char * buf ;
+ void * buf_handle ;
+ } set_type;
+
+
+
+ set_type set_init ();
+ int set_empty ();
+ void set_insert ();
+ void set_delete ();
+ int set_member ();
+ long set_min ();
+ long set_max ();
+ long num_in_set ();
+ void set_on ();
+ void set_off ();
+ int set_equal ();
+ void set_assign ();
+ set_type set_union ();
+ set_type set_intersection ();
+ set_type set_difference ();
+ void set_nuke ();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#pragma comment(exestr, "xpg4plus @(#) math.h 20.1 94/12/04 ")
+
+#pragma pack(4)
+
+
+
+struct exception
+{
+ int type;
+ char *name;
+ double arg1;
+ double arg2;
+ double retval;
+};
+
+extern int matherr(struct exception *);
+
+
+
+extern double acos(double);
+extern double asin(double);
+extern double atan(double);
+extern double atan2(double, double);
+extern double cos(double);
+extern double sin(double);
+extern double tan(double);
+
+extern double cosh(double);
+extern double sinh(double);
+extern double tanh(double);
+
+extern double exp(double);
+extern double frexp(double, int *);
+extern double ldexp(double, int);
+extern double log(double);
+extern double log10(double);
+extern double modf(double, double *);
+
+extern double pow(double, double);
+extern double sqrt(double);
+
+extern double ceil(double);
+extern double fabs(double);
+extern double floor(double);
+extern double fmod(double, double);
+
+extern const double __huge_val;
+
+
+extern double erf(double);
+extern double erfc(double);
+extern double gamma(double);
+extern double hypot(double, double);
+extern double j0(double);
+extern double j1(double);
+extern double jn(int, double);
+extern double y0(double);
+extern double y1(double);
+extern double yn(int, double);
+extern double lgamma(double);
+extern int isnan(double);
+
+
+
+
+
+
+
+extern long double frexpl(long double, int *);
+extern long double ldexpl(long double, int);
+extern long double modfl(long double, long double *);
+
+extern float acosf(float);
+extern float asinf(float);
+extern float atanf(float);
+extern float atan2f(float, float);
+extern float cosf(float);
+extern float sinf(float);
+extern float tanf(float);
+
+extern float coshf(float);
+extern float sinhf(float);
+extern float tanhf(float);
+
+extern float expf(float);
+extern float logf(float);
+extern float log10f(float);
+
+extern float powf(float, float);
+extern float sqrtf(float);
+
+extern float ceilf(float);
+extern float fabsf(float);
+extern float floorf(float);
+extern float fmodf(float, float);
+extern float modff(float, float *);
+
+
+
+extern double atof(const char *);
+extern double scalb(double, double);
+extern double logb(double);
+extern double log1p(double);
+extern double nextafter(double, double);
+extern double acosh(double);
+extern double asinh(double);
+extern double atanh(double);
+extern double cbrt(double);
+extern double copysign(double, double);
+extern double expm1(double);
+extern int ilogb(double);
+extern double remainder(double, double);
+extern double rint(double);
+extern int unordered(double, double);
+extern int finite(double);
+
+extern long double scalbl(long double, long double);
+extern long double logbl(long double);
+extern long double nextafterl(long double, long double);
+extern int unorderedl(long double, long double);
+extern int finitel(long double);
+
+
+
+
+extern int signgam;
+
+
+
+
+
+
+
+
+
+
+#pragma pack()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+extern void G_warning (char *msg);
+
+
+
+
+
+
+
+
+
+
+
+
+
+typedef struct
+{
+ long machine;
+ long input;
+ long output;
+} xBYTE_ORDER;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+typedef enum {
+ VpfNull,
+ VpfChar,
+ VpfShort,
+ VpfInteger,
+ VpfFloat,
+ VpfDouble,
+ VpfDate,
+ VpfKey,
+ VpfCoordinate,
+ VpfTriCoordinate,
+ VpfDoubleCoordinate,
+ VpfDoubleTriCoordinate,
+ VpfUndefined
+} VpfDataType ;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ long VpfRead ();
+ long VpfWrite ();
+
+
+
+
+
+
+
+
+typedef char date_type[21] ;
+
+
+typedef union
+ {
+ char *Char;
+ short int Short;
+ long int Int;
+ float Float;
+ double Double;
+ date_type Date;
+ char Other;
+ } null_field;
+
+
+typedef struct {
+ char *name;
+ char *tdx;
+ char *narrative;
+ long int count;
+ char description[81];
+ char keytype;
+ char vdt[13];
+ char type;
+ null_field nullval ;
+} header_cell, *header_type;
+
+typedef enum { ram, disk, either, compute } storage_type;
+
+typedef enum { Read, Write } file_mode ;
+
+
+
+
+typedef struct
+ {
+ long count;
+ void *ptr;
+ } column_type;
+
+
+typedef column_type *row_type;
+typedef column_type * ROW ;
+
+
+
+typedef struct {
+ unsigned long pos;
+ unsigned long length;
+} index_cell;
+
+typedef index_cell * index_type ;
+
+
+typedef struct {
+ char *path;
+ long nfields;
+ long nrows;
+ long reclen;
+ long ddlen;
+ FILE *fp;
+ FILE *xfp;
+ index_type index;
+ void * idx_handle ;
+ storage_type storage;
+ storage_type xstorage;
+ header_type header;
+ ROW *row;
+ void * row_handle ;
+ file_mode mode;
+ char *defstr ;
+ char name[13];
+ char description[81];
+ char narrative[13];
+ unsigned char status;
+ unsigned char byte_order;
+} vpf_table_type;
+
+typedef struct {
+ float x,y;
+} coordinate_type;
+
+typedef struct {
+ double x,y;
+} double_coordinate_type;
+
+typedef struct {
+ float x,y,z;
+} tri_coordinate_type;
+
+typedef struct {
+ double x,y, z;
+} double_tri_coordinate_type;
+
+
+typedef union {
+ unsigned char f1;
+ unsigned short f2;
+ unsigned long f3;
+} key_field;
+
+
+typedef struct {
+ unsigned char type;
+ long id, tile, exid;
+} id_triplet_type;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ double quiet_nan ();
+ void vpf_nullify_table ();
+ vpf_table_type vpf_open_table ();
+ void vpf_close_table ();
+ char *read_text_defstr ();
+ long index_length ();
+ long index_pos ();
+ id_triplet_type read_key ();
+ long row_offset ();
+ row_type read_next_row ();
+ row_type rowcpy ();
+ row_type read_row ();
+ void free_row ();
+ row_type get_row ();
+ long table_pos ();
+ void *get_table_element ();
+ void *named_table_element ();
+ void *table_element ();
+ long is_vpf_table ();
+ long is_vpf_null_float ();
+ long is_vpf_null_double ();
+ long parse_data_def ();
+
+
+ long int write_key ();
+ long int write_next_row ();
+ long int write_row ();
+ row_type create_row ();
+ void nullify_table_element ();
+ long put_table_element ();
+ void swap_two ();
+ void swap_four ();
+ void swap_eight ();
+ void format_date ();
+
+ extern FILE * errorfp;
+
+
+
+
+
+
+
+
+typedef struct linked_list_cell
+ {
+ void *element;
+ size_t element_size;
+ struct linked_list_cell *next;
+ } cell_type, *linked_list_type, *position_type;
+
+
+
+
+
+
+ linked_list_type ll_init ();
+ long ll_empty ();
+ position_type ll_first ();
+ position_type ll_last ();
+ position_type ll_next ();
+ position_type ll_previous ();
+ long ll_end ();
+ void ll_element ();
+ void ll_insert ();
+ void ll_delete ();
+ void ll_reset ();
+ position_type ll_locate ();
+ void ll_replace ();
+ size_t ll_element_size ();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+typedef enum { VPF_0_7, VPF_0_8, VPF_0_9, VPF_1_0 } vpf_version_type;
+
+
+
+typedef enum { LINE=1, AREA, ANNO, VPFPOINTS, VPFCOMPLEX=6 } vpf_feature_type;
+
+
+typedef enum { EDGE=1, FACE, TEXT, ENTITY_NODE, CONNECTED_NODE }
+ vpf_primitive_type;
+
+typedef struct {
+ unsigned char edge;
+ unsigned char face;
+ unsigned char text;
+ unsigned char entity_node;
+ unsigned char connected_node;
+} primitive_class_type;
+
+
+typedef enum { UNKNOWN_SECURITY, UNCLASSIFIED, RESTRICTED, CONFIDENTIAL,
+ SECRET, TOP_SECRET } security_type;
+
+
+
+typedef enum { UNKNOWN_UNITS, METERS, FEET, INCHES,
+ KILOMETERS, OTHER_UNITS, DEC_DEGREES } vpf_units_type;
+
+
+
+
+typedef enum {
+ DDS,
+ AC,
+ AK,
+ AL,
+ GN,
+ LE,
+ LJ,
+ MC,
+ OC,
+ OD,
+ PG,
+ TC,
+ UT,
+ PC
+} vpf_projection_code;
+
+
+typedef struct
+ {
+ vpf_projection_code code;
+ double parm1, parm2, parm3, parm4;
+ vpf_units_type units;
+ double false_easting, false_northing;
+ long (*forward_proj)();
+ long (*inverse_proj)();
+ char name[21];
+ } vpf_projection_type;
+
+typedef unsigned char boolean;
+
+
+
+
+
+
+typedef struct
+ {
+ double x1, y1, x2, y2;
+} extent_type, line_segment_type;
+
+
+typedef struct {
+ float x1, y1, x2, y2;
+} fextent_type;
+
+typedef enum {
+ Miles,
+ Meters,
+ Degrees,
+ Feet,
+ Inches,
+ Kilometers
+} coord_units_type;
+
+
+typedef struct {
+ long degrees;
+ long minutes;
+ float seconds;
+} dms_type;
+
+
+
+
+
+
+
+
+
+
+ double dms_to_float ();
+ double gc_distance ();
+ long contained ();
+ long geo_intersect ();
+ long completely_within ();
+ long fwithin ();
+ long intersect ();
+ long perpendicular_intersection ();
+ dms_type float_to_dms ();
+ double dms_to_float ();
+
+
+
+
+
+
+typedef struct {
+ char name[9];
+ boolean viewable;
+ char *path;
+ long int ntiles;
+ set_type tile_set;
+ vpf_projection_code projection;
+ vpf_units_type units;
+} library_type;
+
+
+typedef struct {
+ char name[9];
+ char *path;
+ library_type *library;
+ long nlibraries;
+} database_type;
+
+
+
+
+
+typedef struct {
+ long point_color;
+ long point;
+ long line_color;
+ long line;
+ long area_color;
+ long area;
+ long text_color;
+ long text;
+} theme_symbol_type;
+
+
+
+
+typedef struct {
+ char *description;
+ char *database;
+ char *library;
+ char *coverage;
+ char *fc;
+ char *ftable;
+ primitive_class_type primclass;
+ char *expression;
+} theme_type;
+
+
+
+
+typedef struct {
+ char name[9];
+ database_type *database;
+ long ndb;
+ char *path;
+ long nthemes;
+ theme_type *theme;
+ set_type selected;
+ set_type displayed;
+ linked_list_type sellist;
+ extent_type extent;
+ double tileheight;
+ char sympath[255];
+} view_type;
+
+
+
+typedef struct {
+ extent_type mapextent;
+ boolean mapchanged;
+ boolean mapdisplayed;
+ boolean user_escape;
+ boolean study_area_selected;
+ boolean latlongrid;
+ boolean scale_bar;
+ vpf_projection_type projection;
+ coord_units_type distance_unit;
+ coord_units_type scale_bar_unit;
+ vpf_units_type locator_unit;
+} map_environment_type;
+
+typedef struct {
+ extent_type mapextent;
+ boolean mapdisplayed;
+ boolean latlongrid;
+ boolean tilegrid;
+ boolean points;
+ boolean text;
+ vpf_units_type locator_unit;
+} libref_map_environment_type;
+
+
+
+
+
+
+
+
+
+
+
+
+
+ set_type query_table ();
+ linked_list_type parse_expression ();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+typedef struct {
+ long int nbytes ,
+ nbins ,
+ table_nrows ;
+ char index_type ,
+ column_type ;
+ long int type_count ;
+ char id_data_type ,
+ vpf_table_name[13] ,
+ vpf_column_name[25] ,
+ sort ,
+ padding[3] ;
+} ThematicIndexHeader ;
+
+
+
+
+typedef union
+ {
+ char cval , *strval;
+ long ival;
+ short sval;
+ float fval;
+ double dval;
+ } ThematicIndexValue;
+
+typedef struct {
+ ThematicIndexValue value;
+ long int binid,
+ start_offset ,
+ num_items ;
+} ThematicIndexDirectory ;
+
+typedef struct {
+ ThematicIndexHeader h;
+ ThematicIndexDirectory *d, *gid;
+ FILE *fp;
+} ThematicIndex;
+
+
+ long create_thematic_index ();
+ set_type read_thematic_index ();
+ ThematicIndex open_thematic_index ();
+ set_type search_thematic_index ();
+ void close_thematic_index ();
+ long create_gazetteer_index ();
+ set_type search_gazetteer_index ();
+ set_type read_gazetteer_index ();
+
+
+
+
+
+
+
+
+
+
+
+typedef struct {
+ char table1[40];
+ char key1[40];
+ char table2[40];
+ char key2[40];
+} vpf_relate_struct;
+
+
+typedef struct {
+ long nchain;
+ vpf_table_type *table;
+ linked_list_type relate_list;
+} feature_class_relate_type, fcrel_type;
+
+
+ long num_relate_paths ();
+ linked_list_type fcs_relate_list ();
+ long related_row ();
+ linked_list_type related_rows ();
+ fcrel_type select_feature_class_relate ();
+ long fc_row_number ();
+ linked_list_type fc_row_numbers ();
+ void deselect_feature_class_relate ();
+
+
+ set_type get_fit_tile_primitives ();
+
+
+
+ set_type get_fit_tile_primitives (covpath, primclass, expression, feature_table, tile,
+ fca_id, numprims, status)
+ char *covpath;
+ long primclass;
+ char *expression;
+ vpf_table_type feature_table;
+ long tile, fca_id, numprims, *status;
+
+ {
+ set_type primitives, tileset, fcset, selset;
+ long i, start, end, prim_id, tile_id, fc_id, feature_id, count;
+ short short_tile_id;
+ long PRIM_ID_, TILE_ID_, FC_ID_, FEATURE_ID_;
+ vpf_table_type fit;
+ row_type row, frow;
+ char path[255];
+ static char *ptable[] = {"","EDG","FAC","TXT","END","CND"};
+
+ primitives = set_init (numprims+1);
+
+ __std_hdr_strcpy ( path , covpath ) ;
+ strcat (path, ptable[primclass]);
+ strcat (path, ".FIT");
+ muse_check_path (path);
+
+ if (muse_access (path,0) != 0)
+ return primitives;
+
+ fit = vpf_open_table (path, disk, "rb", 0 ) ;
+ if (!fit.fp)
+ return primitives;
+
+ TILE_ID_ = table_pos ("TILE_ID", fit);
+ PRIM_ID_ = table_pos ("PRIM_ID", fit);
+ FC_ID_ = table_pos ("FC_ID", fit);
+ if (FC_ID_ < 0)
+ FC_ID_ = table_pos ("FCA_ID", fit);
+ FEATURE_ID_ = table_pos ("FEATURE_ID", fit);
+ if ((TILE_ID_ < 0 && tile) || PRIM_ID_ < 0 ||
+ FC_ID_ < 0 || FEATURE_ID_ < 0)
+ {
+ vpf_close_table (&fit);
+ *status = 0;
+ return primitives;
+ }
+
+
+ tileset.size = 0;
+ if (tile)
+ {
+ if (fit.header[TILE_ID_].tdx)
+ {
+ __std_hdr_strcpy ( path , covpath ) ;
+ strcat (path, fit.header[TILE_ID_].tdx);
+ muse_check_path (path);
+ if (muse_access (path,0) == 0)
+ {
+ if (fit.header[TILE_ID_].type == 'I')
+ {
+ tile_id = (long int)tile;
+ tileset = read_thematic_index (path, (char*)&tile_id);
+ }
+ else if (fit.header[TILE_ID_].type == 'S')
+ {
+ short_tile_id = tile;
+ tileset = read_thematic_index(path,(char *)&short_tile_id);
+ }
+ }
+ }
+ }
+
+ if (!tileset.size)
+ {
+ tileset = set_init (fit.nrows+1);
+ set_on (tileset);
+ set_delete (0, tileset);
+ }
+
+
+ fcset.size = 0;
+ if (fit.header[FC_ID_].tdx)
+ {
+ __std_hdr_strcpy ( path , covpath ) ;
+ strcat (path, fit.header[FC_ID_].tdx);
+ muse_check_path (path);
+ if (muse_access (path, 0) == 0)
+ {
+ fc_id = (long)fca_id;
+ fcset = read_thematic_index (path, (char*)&fc_id);
+ }
+ }
+
+ if (!fcset.size)
+ {
+ fcset = set_init (fit.nrows+1);
+ set_on (fcset);
+ set_delete (0, fcset);
+ }
+
+
+ selset = set_intersection (tileset, fcset);
+ set_nuke (&tileset);
+ set_nuke (&fcset);
+
+ if (set_empty (selset))
+ {
+ vpf_close_table (&fit);
+ set_nuke (&selset);
+ *status = 1;
+ return primitives;
+ }
+
+
+
+ start = set_min (selset);
+ end = set_max (selset);
+
+
+ fseek (fit.fp, index_pos (start, fit), 0 ) ;
+
+ for (i=start; i<=end; i++)
+ {
+
+
+ row = read_next_row (fit);
+ if (set_member (i, selset))
+ {
+
+
+
+ get_table_element(PRIM_ID_,row,fit,&prim_id,&count);
+ get_table_element(FC_ID_,row,fit,&fc_id,&count);
+ get_table_element(FEATURE_ID_,row,fit,&feature_id,&count);
+ tile_id = 0;
+ if (tile)
+ {
+ if (fit.header[TILE_ID_].type == 'I')
+ {
+ get_table_element (TILE_ID_, row, fit, &tile_id, &count);
+ }
+ else if (fit.header[TILE_ID_].type == 'S')
+ {
+ get_table_element(TILE_ID_, row, fit, &short_tile_id, &count);
+ tile_id = short_tile_id;
+ }
+ }
+ free_row (row, fit);
+
+ if (tile_id != tile || fc_id != fca_id)
+ continue;
+ frow = get_row (feature_id, feature_table);
+ if (query_table_row (expression, frow, feature_table))
+ set_insert (prim_id, primitives);
+ free_row(frow,feature_table);
+ }
+ free_row (row, fit);
+ }
+
+ vpf_close_table (&fit);
+ set_nuke (&selset);
+
+ *status = 1;
+
+ return primitives;
+ }
+
+#ident "acomp: Release 5.0.0a 16Mar95"
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfspx.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfspx.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfspx.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,436 @@
+
+/*****************************************************************************/
+/* VPFSPX.C */
+/* */
+/* Purpose: */
+/* This module contains functions for reading the VPF spatial index */
+/* file. A VPF spatial index is a modified quad-tree index with a */
+/* cross-over bin for features spanning more than one spatial cell. */
+/* There is one interface function in this module - */
+/* spatial_index_search(). The spatial index creation function is */
+/* not included. */
+/*****************************************************************************/
+#ifndef INCL_XVTH
+#include "xvt.h"
+#endif
+
+#include <string.h>
+#include <math.h>
+#include <stdio.h>
+#include <fcntl.h>
+#ifdef _UNIX
+#define O_BINARY 0
+#include <unistd.h>
+#include <memory.h>
+#include <malloc.h>
+#endif
+#ifdef _MSDOS
+#include <mem.h>
+#include <conio.h>
+#include <dos.h>
+#include <io.h>
+#include <alloc.h>
+#endif
+#ifdef _UNIX
+#include <sys/stat.h>
+#endif
+#include <stdlib.h>
+#ifndef H_MUSEDIR
+#include "musedir.h"
+#endif
+#ifndef __VPFSPX_H__
+#include "vpfspx.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+
+/******* cellmap definitions **/
+#define START 0
+#define NUMFEAT 1
+
+#define OUT 0
+#define IN 1
+
+#define ID 1
+#define BOUND 0
+
+#define TOTAL_NUMBER 0
+#define BOUND_START 1
+#define CELLMAP_SIZE 5
+
+#define XMIN 0
+#define YMIN 1
+#define XMAX 2
+#define YMAX 3
+
+typedef struct
+ {
+ int32 start, numfeat;
+ } cellmap_rec_type;
+
+typedef struct
+ {
+ int32 bound, id;
+ } spx_rec_type;
+
+typedef struct
+ {
+ FILE *fp; /* File pointer */
+ int32 maplen; /* Number of cells in the tree */
+ cellmap_rec_type *cellmap; /* The tree of cells */
+ int32 shift; /* Size of data before real cell records */
+ unsigned char box[4]; /* Search box */
+ } spx_type;
+
+
+/*************************************************************************
+ *
+ *N is_over
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Determine if two boxes overlap.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * box1 <input>==(unsigned char[4]) first box to check.
+ * box2 <input>==(unsigned char[4]) second box to check.
+ * return <output>==(int) 1 if the boxes overlap,
+ * 0 if the boxes do not.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Mody Buchbinder Jul 1991
+ *E
+ *************************************************************************/
+#ifdef PROTO
+static int is_over( unsigned char box1[4], unsigned char box2[4] )
+#else
+static int is_over( box1, box2 )
+unsigned char box1[4];
+unsigned char box2[4];
+#endif
+{
+ int xmin,xmax,ymin,ymax;
+
+ if(box2[XMIN] >= box1[XMIN] && box2[XMIN] <= box1[XMAX])
+ xmin = IN;
+ else
+ xmin = OUT;
+ if(box2[XMAX] >= box1[XMIN] && box2[XMAX] <= box1[XMAX])
+ xmax = IN;
+ else
+ xmax = OUT;
+ if(box2[YMIN] >= box1[YMIN] && box2[YMIN] <= box1[YMAX])
+ ymin = IN;
+ else
+ ymin = OUT;
+ if(box2[YMAX] >= box1[YMIN] && box2[YMAX] <= box1[YMAX])
+ ymax = IN;
+ else
+ ymax = OUT;
+ /* complete overlap */
+ if(xmin == OUT && xmax == OUT && box2[XMIN] <= box1[XMIN] &&
+ box2[XMAX] >= box1[XMAX])
+ xmin = IN;
+ if(ymin == OUT && ymax == OUT && box2[YMIN] <= box1[YMIN] &&
+ box2[YMAX] >= box1[YMAX])
+ ymin = IN;
+
+ if((xmin == IN || xmax == IN) && (ymin == IN || ymax == IN)) return 1;
+
+ return 0;
+}
+
+
+/*************************************************************************
+ *
+ *N get_record
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Read spatial index record 'num'. Insert the record into the search
+ * set if it falls within the search box.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * num <input>==(int32) record number.
+ * spx <input>==(spx_type *) spatial index record structure.
+ * set <output>==(set_type) search set to be updated.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Mody Buchbinder Jul 1991
+ *E
+ *************************************************************************/
+#ifdef PROTO
+static void get_record(int32 num, spx_type *spx, set_type set )
+#else
+static void get_record (num, spx, set )
+int32 num;
+spx_type *spx;
+set_type set;
+#endif
+{
+ int32 offset;
+ int32 i,j,index; /* DGM */
+ unsigned char box[4];
+ int32 ltmp;
+ spx_rec_type *rec;
+ int32 machine_byte_order = MACHINE_BYTE_ORDER; /* DGM */
+
+ index = num -1;
+ offset = spx->cellmap[index].start + spx->shift;
+ fseek(spx->fp,offset,SEEK_SET);
+ rec = (spx_rec_type *)xvt_zmalloc(spx->cellmap[index].numfeat*
+ sizeof(spx_rec_type));
+ ogdi_fread(rec,sizeof(spx_rec_type),spx->cellmap[index].numfeat,spx->fp);
+
+ if(machine_byte_order != LEAST_SIGNIFICANT) /* DGM */
+ for(i=0;i<spx->cellmap[index].numfeat;i++){
+ /* spx->buf[i][0] is a four byte buffer - don't swap */
+ /* spx->buf[i][ID] is an integer - swap */
+ ltmp = rec[i].id;
+ swap_four((char*)<mp,(char*)&rec[i].id);
+ }
+
+ for(j=0;j<spx->cellmap[index].numfeat;j++) {
+ memcpy(&box,&(rec[j].bound),4*sizeof(unsigned char));
+ if (is_over(box,spx->box)) {
+ set_insert(rec[j].id,set);
+ }
+ }
+
+ xvt_free((char*)rec);
+}
+
+
+/*************************************************************************
+ *
+ *N search_cell
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Search the current cell for local records and, if the box is in the
+ * search area, search the cell's children.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * record <input>==(int32) record number.
+ * level <input>==(int) level of the index tree.
+ * bnd <input>==(unsigned char[4]) bounding box.
+ * spx <input>==(spx_type *) spatial index record structure.
+ * set <output>==(set_type) search set to be updated.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Mody Buchbinder Jul 1991
+ *E
+ *************************************************************************/
+#ifdef PROTO
+static void search_cell( int32 record, int level, unsigned char bnd[4],
+ spx_type *spx, set_type set )
+#else
+static void search_cell( record, level, bnd, spx, set )
+int32 record;
+int level;
+unsigned char bnd[4];
+spx_type *spx;
+set_type set;
+#endif
+{
+ int i;
+ unsigned char locbnd[4],cut;
+
+ if (record > spx->maplen) return;
+
+ for(i=0;i<4;i++) locbnd[i] = bnd[i];
+ if(level != 0)
+ { /* level even -> cut on x , level odd -> cut on y */
+ if(level%2 == 1) cut = bnd[0] + ((bnd[2] - bnd[0]) >> 1);
+ else cut = bnd[1] + ((bnd[3] - bnd[1]) >> 1);
+ /* cut on x right cell */
+ if(level%2 == 1 && record%2 == 0) locbnd[0] = cut;
+ /* cut on x left cell */
+ if(level%2 == 1 && record%2 == 1) locbnd[2] = cut;
+ /* cut on y upper cell */
+ if(level%2 == 0 && record%2 == 0) locbnd[1] = cut;
+ /* cut on y lower cell */
+ if(level%2 == 0 && record%2 == 1) locbnd[3] = cut;
+ }
+ if(is_over(locbnd,spx->box) == 1)
+ { get_record(record,spx,set);
+ if(record*2 <= spx->maplen)
+ { search_cell(record*2, level+1,locbnd, spx, set);
+ search_cell(record*2+1,level+1,locbnd, spx, set);
+ }
+ }
+}
+
+
+/*************************************************************************
+ *
+ *N spatial_index_search
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Search the named spatial index file to find all records falling
+ * within the specified extent.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * fname <input>==(char *) path name to a VPF spatial index file.
+ * x1 <input>==(float) left coordinate of the search box.
+ * y1 <input>==(float) bottom coordinate of the search box.
+ * x2 <input>==(float) right coordinate of the search box.
+ * y2 <input>==(float) top coordinate of the search box.
+ * set <output>==(set_type) search set to be filled.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Mody Buchbinder Jul 1991
+ *E
+ *************************************************************************/
+#ifdef PROTO
+set_type spatial_index_search( char *fname,
+ float x1, float y1, float x2, float y2 )
+#else
+set_type spatial_index_search( fname, x1, y1, x2, y2 )
+char *fname;
+float x1;
+float y1;
+float x2;
+float y2;
+#endif
+{
+ int32 head[6];
+ int32 htmp[6];
+ int32 ltmp;
+ float bnd[4],xf,yf;
+ unsigned char tempbox[4];
+ set_type set;
+ spx_type spx;
+ int32 i;
+ int32 machine_byte_order = MACHINE_BYTE_ORDER;
+
+ spx.fp = muse_file_open (fname, "rb");
+ if (!spx.fp)
+ {
+ set.size = 0;
+ set.buf = NULL;
+ return set;
+ }
+
+/* read basic header - int 0 -> number of features in coverage */
+/* int 1 - 4 -> boundaries of coverage */
+/* int 5 -> size of tree in records - each */
+/* record = 2 integers (8 byte) */
+ ogdi_fread (htmp, sizeof (int32), 6, spx.fp);
+
+ if (machine_byte_order != LEAST_SIGNIFICANT)
+ for (i=0; i<6; i++)
+ swap_four ((char*)&htmp[i], (char*)&head[i]);
+ else
+ memcpy (head, htmp, 6*sizeof (int32));
+
+ spx.shift = 6*sizeof (int32);
+ spx.maplen = head[CELLMAP_SIZE];
+
+#if 0 /* DGM */
+ set = set_init(head[TOTAL_NUMBER]+1L);
+#endif
+ set = set_init (head[TOTAL_NUMBER]);
+
+ memcpy (&bnd[0], &head[BOUND_START], 4*sizeof (float));
+
+ /* If the boundaries of the cellmap are completely within the */
+ /* search area, all features are on */
+ if ( (x1 <= bnd[XMIN]) && (x2 >= bnd[XMAX]) &&
+ (y1 <= bnd[YMIN]) && (y2 >= bnd[YMAX]) ) {
+ set_on(set);
+ fclose(spx.fp);
+ return set;
+ }
+
+/* allocate cells */
+ spx.cellmap = (cellmap_rec_type *)xvt_zmalloc(spx.maplen*
+ sizeof(cellmap_rec_type));
+ if (!spx.cellmap) {
+ /* Memory allocation failed - return null set */
+ fclose(spx.fp);
+ set_nuke(&set);
+ set.size=0;
+ return set;
+ }
+
+/* read the cell tree */
+ ogdi_fread(spx.cellmap,sizeof(cellmap_rec_type),spx.maplen,spx.fp);
+
+ if(machine_byte_order != LEAST_SIGNIFICANT) /* DGM */
+ for(i=0;i<spx.maplen;i++){
+ ltmp = spx.cellmap[i].start;
+ swap_four((char*)<mp,(char *)&spx.cellmap[i].start);
+ ltmp = spx.cellmap[i].numfeat;
+ swap_four((char*)<mp,(char *)&spx.cellmap[i].numfeat);
+ }
+
+ spx.shift += 2*spx.maplen*sizeof(int32);
+
+/* translate search box to 1 byte numbers */
+ xf = 255.0 / (bnd[XMAX] - bnd[XMIN]);
+ yf = 255.0 / (bnd[YMAX] - bnd[YMIN]);
+ spx.box[XMIN] = (char)((x1 - bnd[XMIN]) * xf);
+ if (x1 <= bnd[XMIN]) spx.box[XMIN] = 0;
+ if (x1 >= bnd[XMAX]) spx.box[XMIN] = 255;
+ spx.box[YMIN] = (char)((y1 - bnd[YMIN]) * yf);
+ if (y1 <= bnd[YMIN]) spx.box[YMIN] = 0;
+ if (y1 >= bnd[YMAX]) spx.box[YMIN] = 255;
+ spx.box[XMAX] = (char)(((x2 - bnd[XMIN]) * xf) + 1);
+ if (x2 <= bnd[XMIN]) spx.box[XMAX] = 0;
+ if (x2 >= bnd[XMAX]) spx.box[XMAX] = 255;
+ spx.box[YMAX] = (char)(((y2 - bnd[YMIN]) * yf) + 1);
+ if (y2 <= bnd[YMIN]) spx.box[YMAX] = 0;
+ if (y2 >= bnd[YMAX]) spx.box[YMAX] = 255;
+
+/** start search **/
+ tempbox[XMIN] = 0;
+ tempbox[YMIN] = 0;
+ tempbox[XMAX] = 0xff;
+ tempbox[YMAX] = 0xff;
+ search_cell(1,0,tempbox,&spx,set);
+
+ fclose(spx.fp);
+
+ xvt_free((char*)spx.cellmap);
+
+ return set;
+}
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfspx.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfspx.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfspx.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,17 @@
+#ifndef __VPFSPX_H__
+
+#define __VPFSPX_H__
+
+#ifndef __SET_H__
+#include "set.h"
+#endif
+
+/* Function Definitions */
+#ifdef PROTO
+ set_type spatial_index_search( char *spxname, float x1, float y1,
+ float x2, float y2 );
+#else
+ set_type spatial_index_search ();
+#endif
+
+#endif /* ifdef __VPFSPX_H__ */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftable.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftable.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftable.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,1343 @@
+/*****************************************************************************/
+/* */
+/* VPFTABLE.C */
+/* */
+/* This module contains functions to open, close and parse VPF relational */
+/* tables. VPF tables are defined as being a set of rows and columns. */
+/* Each column may contain a single value, a fixed array of values, */
+/* or a variable number of values. */
+/* */
+/* FUNCTIONS: */
+/* quiet_nan */
+/* cpy_del */
+/* parse_get_string */
+/* parse_get_char */
+/* parse_get_number */
+/* swap_two */
+/* swap_four */
+/* swap_eight */
+/* parse_data_def */
+/* vpf_nullify_table */
+/* vpf_open_check */
+/* vpf_open_table */
+/* vpf_close_table */
+/* is_vpf_table */
+/* is_vpf_null_float */
+/* is_vpf_null_double */
+/* format_date */
+/*****************************************************************************/
+
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+
+#ifdef _MAC
+#include <values.h>
+#endif
+
+#ifdef _MSDOS
+#include <io.h>
+#endif
+
+#ifndef H_MUSEDIR
+#include "musedir.h"
+#endif
+#ifndef __STRFUNC_H__
+#include "strfunc.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+
+/*
+ * per heap block byte overhead
+ */
+#define HEAP_OVERHEAD 4
+
+/* Global variable shared by VPFTABLE.C, VPFREAD.C, and VPFWRITE.C */
+/* The above modules are logically one, only separated by file size */
+/* constraints. */
+
+int32 STORAGE_BYTE_ORDER = LEAST_SIGNIFICANT; /* default */
+
+
+
+/* Return floating point Not a Number (for NULL values) */
+
+#ifdef PROTO
+double quiet_nan( int32 unused )
+#else
+ double quiet_nan( unused )
+ int32 unused;
+#endif
+{
+ static char nanstr[8] = {-1,-1,-1,-1,-1,-1,-1,127};
+ double n;
+ memcpy((char *) &n,&nanstr[0],sizeof(n));
+ if (unused) return n;
+ return n;
+}
+
+#ifdef PROTO
+float float_quiet_nan( int32 unused )
+#else
+ float float_quiet_nan( unused )
+ int32 unused;
+#endif
+{
+ static char nanstr[4] = {-1,-1,-1,127};
+ float n;
+ memcpy((char *) &n,&nanstr[0],sizeof(n));
+ if (unused) return n;
+ return n;
+}
+
+
+
+/***************************************************************/
+/* cpy_del */
+/* get string until delimeter */
+/***************************************************************/
+
+#ifdef PROTO
+static char *cpy_del(char *src, char delimiter, int32 *ind )
+#else
+ static char *cpy_del(src, delimiter, ind )
+ char *src;
+ char delimiter;
+ int32 *ind;
+#endif
+{
+ int32 i = 0L, skipchar = 0L;
+ char *temp = (char *)NULL, *tempstr = (char *)NULL;
+ size_t size = 0;
+
+ /* remove all blanks ahead of good data */
+
+ while ( *(src + skipchar) == SPACE || *(src + skipchar) == TAB )
+ skipchar++ ;
+
+ temp = (char *)(src + skipchar);
+
+ /* If the first character is a COMMENT, goto LINE_CONTINUE */
+
+ if ( *temp == (char)COMMENT ) {
+ while ( *temp != (char)LINE_CONTINUE && *temp != (char)END_OF_FIELD && *temp != '\0'){
+ temp++ ;
+ skipchar ++ ;
+ }
+ skipchar++ ;
+ temp++ ; /* skip past LC, EOF, or NULL */
+ }
+
+ /* Start with temporary string value */
+ size = (size_t)strlen (temp);
+ tempstr = (char*)xvt_zmalloc ((size_t)(size + 10)*sizeof(char));
+
+ if ( *temp == '"' ) { /* If field is quoted, do no error checks */
+
+ temp++ ; /* skip past quote character */
+ skipchar++ ; /* update the position pointer */
+
+ for ( i=0 ; *temp != '\0'; temp++,i++) {
+ if ( *temp == (char)LINE_CONTINUE || *temp == (char)TAB ) {
+ temp++ ;
+ skipchar++ ;
+ } else if ( *temp == '"' )
+ break ;
+ /* Now copy the char into the output string */
+ *(tempstr + i) = *temp ;
+ }
+ *(tempstr + i) = '\0' ; /* terminate string */
+ *ind += ( i + skipchar + 2L) ; /* Increment position locate past */
+ return tempstr ; /* quote and semicolon */
+ }
+
+ /* search for delimiter to end, or end of string */
+
+ i=0L ; /* initialize */
+
+ if ( *temp != (char)END_OF_FIELD ) { /* backward compatability check */
+
+ for ( i=0L; *temp != '\0';temp++,i++){ /* Stop on NULL*/
+
+ if ( ( *temp == (char)LINE_CONTINUE && *(temp+1) == '\n') || *temp == (char)TAB ) {
+ temp++ ;
+ skipchar++ ;
+ } else if ( *temp == delimiter )
+ break ; /* break for delimiter */
+ /* Now copy the char into the output string */
+ *(tempstr + i) = *temp ;
+ }
+ /* Eat the delimiter from ind also */
+ *ind += ( i + skipchar + 1L) ; /* Increment position locate */
+ }
+ *(tempstr + i) = '\0' ; /* terminate string */
+ return tempstr;
+}
+
+
+
+
+
+/* parse the next string token from the input string */
+#ifdef PROTO
+char *parse_get_string(int32 *ind, char *src,char delimeter )
+#else
+ char *parse_get_string( ind, src, delimeter )
+ int32 *ind;
+ char *src;
+ char delimeter;
+#endif
+{
+ char *temp = (char *)NULL;
+ temp = cpy_del((src + (*ind)),delimeter, ind);
+ if( ! strcmp ( temp, (char *)TEXT_NULL ))
+ strcpy ( temp, "" ) ;
+ return temp;
+}
+
+
+
+
+/* parse the next character from the input string */
+#ifdef PROTO
+char parse_get_char(int32 *ind, char *src)
+#else
+ char parse_get_char( ind, src)
+ int32 *ind;
+ char *src;
+#endif
+{
+ char temp;
+ while ( *(src + (*ind)) == (char)SPACE || *(src + (*ind)) == (char)TAB )
+ (*ind)++ ;
+ temp = *(src + (*ind));
+ *ind += 2L;
+ return temp;
+}
+
+
+
+
+/* parse the next numeric token from the input string */
+#ifdef PROTO
+int32 parse_get_number(int32 *ind, char *src,char delimeter)
+#else
+ int32 parse_get_number( ind, src, delimeter)
+ int32 *ind;
+ char *src;
+ char delimeter;
+#endif
+{
+ char *temp = (char *)NULL;
+ int32 num = 0L;
+
+ temp = cpy_del((src + (*ind)),delimeter, ind);
+ if (strchr(temp, (int)VARIABLE_COUNT ) == NULL)
+ num = (int32)atoi(temp); /****should this be atol ?****/
+ else
+ num = -1L;
+ if(temp != (char *)NULL) {
+ xvt_free(temp);
+ temp = (char *)NULL;
+ }
+ return num;
+}
+
+
+
+/*****************************************************************************/
+/* swap_two */
+/* */
+/* Purpose: */
+/* This function performs a byte swap for a two-byte numeric field. */
+/* This may be necessary if the data is stored in the opposite */
+/* order of significance than the host platform. Both parameters */
+/* should point to a two-byte data element. */
+/* */
+/* Parameters: */
+/* in <input> == (char *) pointer to the input value. */
+/* out <output> == (char *) pointer to the returned swapped value. */
+/*****************************************************************************/
+#ifdef PROTO
+void swap_two ( char *in, char *out )
+#else
+ void swap_two ( in, out )
+ char *in;
+ char *out ;
+#endif
+{
+ out[0] = in[1] ;
+ out[1] = in[0] ;
+}
+
+
+
+/*****************************************************************************/
+/* swap_four */
+/* */
+/* Purpose: */
+/* This function performs a byte swap for a four-byte numeric field. */
+/* This may be necessary if the data is stored in the opposite */
+/* order of significance than the host platform. Both parameters */
+/* should point to a four-byte data element. */
+/* */
+/* Parameters: */
+/* in <input> == (char *) pointer to the input value. */
+/* out <output> == (char *) pointer to the returned swapped value. */
+/*****************************************************************************/
+#ifdef PROTO
+void swap_four (char *in, char *out)
+#else
+ void swap_four (in, out)
+ char *in;
+ char *out;
+#endif
+{
+ out[0] = in[3];
+ out[1] = in[2];
+ out[2] = in[1];
+ out[3] = in[0];
+ return;
+}
+
+
+
+/*****************************************************************************/
+/* swap_eight */
+/* */
+/* Purpose: */
+/* This function performs a byte swap for an eight-byte numeric field. */
+/* This may be necessary if the data is stored in the opposite */
+/* order of significance than the host platform. Both parameters */
+/* should point to an eight-byte data element. */
+/* */
+/* Parameters: */
+/* in <input> == (char *) pointer to the input value. */
+/* out <output> == (char *) pointer to the returned swapped value. */
+/*****************************************************************************/
+#ifdef PROTO
+void swap_eight (char *in, char *out)
+#else
+ void swap_eight (in, out)
+ char *in;
+ char *out;
+#endif
+{
+ out[0] = in[7];
+ out[1] = in[6];
+ out[2] = in[5];
+ out[3] = in[4];
+ out[4] = in[3];
+ out[5] = in[2];
+ out[6] = in[1];
+ out[7] = in[0];
+ return;
+}
+
+
+
+/****************************************************************************/
+/* PARSE_DATA_DEF */
+/* */
+/* This function parses a table's data definition and creates a header */
+/* in memory that is associated with the table. */
+/* */
+/* Parameters: */
+/* table <inout> == (vpf_table_type *) vpf table structure. */
+/* ddlen <input> == (int32) length of the table's data definition. */
+/* */
+/* return value is the record length if all items are fixed length, or */
+/* -1 if the record contains variable length items */
+/****************************************************************************/
+#ifdef PROTO
+int32 parse_data_def (vpf_table_type *table)
+#else
+ int32 parse_data_def (table)
+ vpf_table_type *table;
+#endif
+{
+ register int32 n,i;
+ int32 p, k;
+ char *buf,*des,*nar,*vdt, *tdx, *doc, byte ; /*temporary storage */
+ char end_of_rec;
+ int32 status;
+ int32 ddlen;
+ int32 reclen = 0;
+
+ if (table->mode == Read)
+ {
+ ogdi_fread ((void*)&ddlen, sizeof(ddlen), 1, table->fp);
+
+ /* Check the next byte to see if the byte order is specified */
+ ogdi_fread (&byte, 1, 1, table->fp);
+ p = 0;
+ table->byte_order = LEAST_SIGNIFICANT; /* default */
+ switch (toupper (byte))
+ {
+ case 'L':
+ p++;
+ break;
+ case 'M':
+ table->byte_order = MOST_SIGNIFICANT;
+ p++;
+ break;
+ }
+ if (MACHINE_BYTE_ORDER != table->byte_order)
+ {
+ k = ddlen;
+ swap_four ((char*)&k, (char*)&ddlen);
+ }
+ STORAGE_BYTE_ORDER = table->byte_order;
+
+ if (ddlen < 0)
+ {
+ xvt_note ("parse_data_def: Bad VPF file.");
+ return ((int32)NULL);
+ }
+
+ /* header without first 4 bytes */
+ table->ddlen = ddlen + sizeof (int32);
+
+ buf = (char*)xvt_zmalloc ((size_t)ddlen + 3);
+ if (buf == NULL)
+ {
+ xvt_note ("Parse_data_definition: malloc failed.");
+ return ((int32)NULL);
+ }
+
+ buf[0] = byte; /* already have the first byte of the buffer */
+ Read_Vpf_Char(&buf[1],table->fp,ddlen-1) ;
+ }
+ else
+ {
+ table->ddlen = strlen (table->defstr);
+ ddlen = table->ddlen;
+
+ buf = (char*)xvt_zmalloc((size_t)ddlen + 3);
+ if (buf == NULL)
+ {
+ xvt_note ("Parse_data_definition: Malloc failed.");
+ return ((int32)NULL);
+ }
+
+ strncpy (buf, table->defstr, (size_t)ddlen);
+ p = 0;
+ table->byte_order = LEAST_SIGNIFICANT; /* default */
+ byte = buf[0];
+ switch (toupper(byte))
+ {
+ case 'L':
+ p++;
+ break;
+ case 'M':
+ table->byte_order = MOST_SIGNIFICANT;
+ p++;
+ break;
+ }
+ STORAGE_BYTE_ORDER = table->byte_order;
+ }
+
+ buf[ddlen-1] = '\0'; /* mark end of string for reading functions */
+ if (buf[p] == ';')
+ p++; /* buf[p] is semi-colon */
+
+ /* Get "description" field */
+ des = parse_get_string (&p, buf, (char)COMPONENT_SEPERATOR);
+ strncpy (table->description, des, 80);
+ if(des != (char *)NULL) {
+ xvt_free (des);
+ des = (char *)NULL;
+ }
+
+ /* Get "narrative" field */
+ nar = parse_get_string (&p, buf, (char)COMPONENT_SEPERATOR);
+ strncpy (table->narrative ,nar, 12);
+ if(nar != (char *)NULL)
+ {xvt_free (nar);nar = (char *)NULL;}
+
+
+ n = 0 ;
+ /* get number of fields */
+ for (i=p; i<ddlen; i++)
+ if (buf[i] == LINE_CONTINUE)
+ i++; /* skip past line continue, and next character */
+ else if (buf[i] == END_OF_FIELD) /* Found end of field */
+ n++; /* increment nfields */
+ else if (buf[i] == COMMENT) /* skip past comments */
+ while (buf[i] != LINE_CONTINUE &&
+ buf[i] != END_OF_FIELD &&
+ buf[i] != '\0')
+ i++; /* increment i */
+
+ table->nfields = n;
+
+ table->header = (header_type)xvt_zmalloc ((size_t)(n + 1) * sizeof(header_cell));
+
+ if (table->header == NULL)
+ {
+ xvt_note ("Parse_data_definition: malloc failed.");
+ return ((int32)NULL);
+ }
+
+ /* Loop the the number of fields in the record */
+ for (i=0; i<n; i++)
+ {
+ end_of_rec = FALSE;
+
+ /* Get the "name" field */
+ table->header[i].name = parse_get_string (&p, buf, FIELD_COUNT);
+
+ if (i == 0)
+ if ((strcmp (table->header[0].name, "ID") != 0) &&
+ (strcmp (table->header[0].name, "id") != 0))
+ {
+ xvt_note ("parse_data_def: No 'ID' in header definition.");
+ return ((int32)NULL);
+ }
+
+ /* Get the "type" field */
+ table->header[i].type = (parse_get_char (&p,buf));
+ table->header[i].type = (char)toupper (table->header[i].type);
+
+ /* Get the "count" field */
+ table->header[i].count = parse_get_number(&p,buf,FIELD_SEPERATOR );
+
+
+ /* Check for variable length flag (-1) */
+ if (table->header[i].count == -1)
+ reclen = -1;
+
+ /* Now set null values and add up record length, if fixed length */
+
+ status = 0;
+
+ switch (table->header[i].type)
+ {
+ case 'I':
+ if (reclen >= 0)
+ reclen += (sizeof (int32) * table->header[i].count);
+ table->header[i].nullval.Int = (int32) NULLINT ;
+ break;
+ case 'S':
+ if (reclen >= 0)
+ reclen += (sizeof (short) * table->header[i].count);
+ table->header[i].nullval.Short = NULLSHORT;
+ break;
+ case 'F':
+ if (reclen >= 0)
+ reclen += (sizeof (float) * table->header[i].count);
+ table->header[i].nullval.Float = NULLFLOAT;
+ break;
+ case 'R':
+ if (reclen >= 0)
+ reclen += (sizeof (double) * table->header[i].count);
+ table->header[i].nullval.Double = NULLDOUBLE;
+ break;
+ case 'T':
+ if (reclen >= 0)
+ { /* if fixed length */
+ reclen += (sizeof (char) * table->header[i].count);
+ table->header[i].nullval.Char =
+ (char*)xvt_zmalloc ((size_t)table->header[i].count + 1);
+ for (k=0; k<table->header[i].count; k++)
+ table->header[i].nullval.Char[k] = NULLCHAR;
+ table->header[i].nullval.Char[k] = '\0';
+ }
+ else
+ { /* variable length */
+ table->header[i].nullval.Char =
+ (char*)xvt_zmalloc (VARIABLE_STRING_NULL_LENGTH + 1);
+ for (k=0; k<VARIABLE_STRING_NULL_LENGTH; k++)
+ table->header[i].nullval.Char[k] = NULLCHAR;
+ table->header[i].nullval.Char[k] = '\0';
+ }
+ break;
+ case 'C':
+ if (reclen >= 0)
+ reclen += (sizeof (coordinate_type) * table->header[i].count);
+ table->header[i].nullval.Other = '\0';
+ break;
+ case 'Z':
+ if (reclen >= 0)
+ reclen += (sizeof (tri_coordinate_type)*table->header[i].count);
+ table->header[i].nullval.Other = '\0';
+ break;
+ case 'B':
+ if (reclen >= 0)
+ reclen += (sizeof(double_coordinate_type)*table->header[i].count);
+ table->header[i].nullval.Other = '\0';
+ break;
+ case 'Y':
+ if (reclen >= 0)
+ reclen +=
+ (sizeof(double_tri_coordinate_type) * table->header[i].count);
+ table->header[i].nullval.Other = '\0';
+ break;
+ case 'D':
+ if (reclen >= 0)
+ reclen += ((sizeof (date_type)-1) * table->header[i].count);
+ strcpy (table->header[i].nullval.Date, NULLDATE);
+ break;
+ case 'K':
+ reclen = -1;
+ table->header[i].nullval.Other = '\0';
+ break;
+ case 'X':
+ /* do nothing */
+ table->header[i].nullval.Other = '\0';
+ break ;
+ default:
+ xvt_note ("parse_data_def: no such type %c", table->header[i].type ) ; /*DGM*/
+ status = 1;
+ break;
+ } /* switch type */
+
+ if (status)
+ return ((int32)NULL);
+
+ /* Get "keytype" field */
+ table->header[i].keytype = parse_get_char (&p, buf);
+
+ /* Get "description" field */
+ des = parse_get_string (&p, buf, FIELD_SEPERATOR);
+ strncpy (table->header[i].description, des, 80);
+ if(des != (char *)NULL)
+ {xvt_free(des);des = (char *)NULL;}
+
+ /* Get "value description table" field */
+ vdt = parse_get_string (&p, buf, FIELD_SEPERATOR);
+ strncpy (table->header[i].vdt, vdt, 12);
+ if(vdt != (char *)NULL)
+ {xvt_free (vdt);vdt = (char *)NULL;}
+
+
+ /* Get "thematic index" field */
+ table->header[i].tdx = (char*)NULL;
+ table->header[i].narrative = (char*)NULL;
+
+ tdx = parse_get_string (&p, buf, FIELD_SEPERATOR);
+ if (! strcmp (tdx, ""))
+ {
+ table->header[i].tdx = (char*)NULL;
+ }
+ else
+ {
+ if (strcmp (tdx,"-") != 0)
+ {
+ table->header[i].tdx = (char*)xvt_zmalloc (strlen (tdx)+ 1);
+ strcpy (table->header[i].tdx, tdx);
+ }
+ else
+ table->header[i].tdx = (char *)NULL;
+ }
+ if(tdx != (char *)NULL)
+ {xvt_free(tdx);tdx = (char *)NULL;}
+
+ /* Test for end of record */
+ if (buf[p] == ':')
+ end_of_rec = TRUE;
+
+
+ /* Retreive "doc" field if present */
+ if (!end_of_rec)
+ {
+ doc = parse_get_string (&p, buf, FIELD_SEPERATOR);
+ if (! strcmp (doc, ""))
+ {
+ table->header[i].narrative = (char*)NULL;
+ end_of_rec = TRUE;
+ }
+ else
+ {
+ if (strcmp (doc, "-") != 0)
+ {
+ table->header[i].narrative = (char*)xvt_zmalloc (strlen (doc) + 1);
+ strcpy (table->header[i].narrative, doc);
+ }
+ else
+ table->header[i].narrative = (char*)NULL;
+ }
+ if(doc != (char *)NULL)
+ {xvt_free(doc);doc = (char *)NULL;}
+ }
+ else
+ table->header[i].narrative = (char*)NULL;
+
+ p += 1; /* Skip over the RECORD_SEPARATOR (:) */
+ }
+ if(buf != (char *)NULL)
+ {xvt_free(buf);buf = (char *)NULL;}
+ return reclen;
+}
+
+
+/**************************************************************************
+ *
+ *N vpf_nullify_table
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Nullify the given VPF table structure.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels DOS Turbo C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void vpf_nullify_table( vpf_table_type *table )
+#else
+ void vpf_nullify_table( table )
+ vpf_table_type *table ;
+#endif
+{
+
+ if (!table) return;
+
+ strcpy(table->name,"");
+ table->path = NULL;
+ table->nfields = 0;
+ strcpy(table->description,"");
+ strcpy(table->narrative,"");
+ table->header = NULL;
+ table->xfp = NULL;
+ table->index = NULL;
+ table->xstorage = 0;
+ table->fp = NULL;
+ table->nrows = 0;
+ table->row = NULL;
+ table->reclen = 0;
+ table->ddlen = 0;
+ table->defstr = NULL;
+ table->storage = 0;
+ table->mode = 0;
+ table->byte_order = LEAST_SIGNIFICANT;
+ table->status = CLOSED;
+ return;
+}
+
+
+/****************************************************************************/
+/* VPFOPENCHECK */
+/* Purpose: */
+/* */
+/* Parameters: */
+/* filename <input> == (char *) full path name of the file to be opened. */
+/* mode <input> == (char *) mode of the file. */
+/* diskname <input> == (char *) descriptive name of the disk the file is */
+/* on. */
+/* return <output> == (FILE *) file pointer newly associated with */
+/* filename. */
+/****************************************************************************/
+#ifdef PROTO
+FILE *vpfopencheck (char *filename, char *mode)
+#else
+ FILE *vpfopencheck(filename, mode)
+ char *filename;
+ char *mode;
+#endif
+{
+ FILE *fp;
+ int32 retry;
+ size_t len;
+ char *copy;
+
+ len = strlen (filename);
+ copy = (char*)xvt_zmalloc (sizeof(char)*(len+1));
+ strcpy(copy,filename);
+ copy[len] = '.';
+ copy[len+1] = '\0';
+ fp = NULL;
+
+ while (fp == NULL)
+ {
+ fp = muse_file_open(filename,mode);
+ if ((fp == NULL) && ((fp = muse_file_open(copy,mode)) == NULL))
+ {
+ retry = FALSE;
+ if (!retry) break;
+ }
+ }
+ if(copy != (char *)NULL)
+ {xvt_free(copy);copy = (char *)NULL;}
+ return (fp);
+}
+
+
+/****************************************************************************/
+/* VPF_OPEN_TABLE */
+/* */
+/* Purpose: */
+/* This function opens a vpf table and either loads it into RAM or sets */
+/* up the structure to read off of disk. */
+/* */
+/* Parameters: */
+/* tablename <input> == (char *) file name of the table. As stated */
+/* in the VPF standard, the table name */
+/* must not end in 'x'. */
+/* storage <input> == (storage_type) table storage mode - */
+/* MUST be ram, disk, or either. */
+/* mode <input> == (char *) file mode for opening the table - */
+/* MUST be the same as fopen() mode in C. */
+/* defstr <input> == (char *) table definition string used for */
+/* creating a writable table. */
+/* If write mode this MUST be a valid */
+/* VPF table definition string. */
+/* vpf_open_table <output> == (vpf_table_type) VPF table structure. */
+/****************************************************************************/
+#ifdef PROTO
+vpf_table_type vpf_open_table (char *tablename, storage_type storage,
+ char *mode, char *defstr)
+#else
+ vpf_table_type vpf_open_table (tablename, storage, mode, defstr)
+ char *tablename;
+ storage_type storage;
+ char *mode;
+ char *defstr;
+#endif
+{
+ vpf_table_type table;
+ char tablepath[255], *idxname,*ptr;
+ int32 i, j, tablesize, idxsize, qty;
+ uint32 ulval;
+ char idxext,idxmaj;
+
+ memset( &table, 0, sizeof(table) );
+ strcpy(tablepath,tablename);
+
+ /* Parse out name and path */
+ j = -1;
+ i=strlen(tablepath);
+ while (i>0)
+ {
+ if (tablepath[i] == '\\' || tablepath[i] == '/' || tablepath[i] == ':' )
+ {
+ j = i;
+ break;
+ }
+ i--;
+ }
+ strncpy(table.name,&(tablepath[j+1]),12);
+ table.path = (char*)xvt_zmalloc (strlen (tablepath) + 5);
+ strcpy(table.path, tablepath);
+
+ /* Establish a read or write table operation */
+
+ if (mode[0] == 'r')
+ table.mode = Read;
+ else
+ table.mode = Write;
+
+ table.fp = muse_file_open (tablepath, mode);
+ table.storage = storage;
+
+ if (table.fp == NULL)
+ {
+ xvt_note ("\nvpf_open_table: error opening <%s>\n",tablepath); /*DGM*/
+ if (table.path != (char*)NULL)
+ {
+ xvt_free (table.path);
+ table.path = (char*)NULL;
+ }
+ return table;
+ }
+
+ /* If file is to be created, copy the def string ptr into header for now */
+
+ if (table.mode == Write)
+ table.defstr = defstr;
+
+ tablesize = muse_filelength (table.path);
+
+ /* Populate table structure with correct data, either for read or write */
+
+ table.reclen = parse_data_def (&table);
+
+ if (table.mode == Write)
+ { /* write out header */
+ rewind (table.fp);
+ Write_Vpf_Int (&table.ddlen, table.fp, 1);
+ Write_Vpf_Char (table.defstr, table.fp, table.ddlen);
+ if (table.defstr != (char*)NULL)
+ {
+ xvt_free (table.defstr);
+ table.defstr = (char*)NULL;
+ }
+ table.defstr = (char*)NULL;
+ table.nrows = 0;
+ }
+
+ if (table.reclen > 0)
+ {
+ /* Index file does not exist */
+ table.xstorage = COMPUTE;
+ if (table.mode != Write)
+ table.nrows = (tablesize - table.ddlen)/table.reclen;
+ table.xfp = (FILE*)NULL;
+ }
+ else
+ {
+
+ qty = strlen(tablename);
+ ptr = &(tablename[qty-3]);
+ if (!strnicmp ("fcs", ptr, 3)) {
+ idxext = 'z'; /* index for fcs is 'fcz' not 'fcx' */
+ idxmaj = 'Z';
+ } else {
+ idxext = 'x';
+ idxmaj = 'X';
+ }
+
+ /* Index file does exist */
+ idxname = (char*)xvt_zmalloc (sizeof (char) * (strlen (tablepath)+2));
+ strcpy(idxname,tablepath);
+
+ /* Test for UNIX CD-ROM filename terminator "." */
+ if (idxname[strlen(tablepath)-1] == '.')
+ idxname[strlen(tablepath)-2] = idxext;
+ else
+ idxname[strlen(tablepath)-1] = idxext;
+
+ table.xfp = muse_file_open(idxname, mode);
+ if (table.xfp == NULL) {
+ /* Test for UNIX CD-ROM filename terminator "." */
+ if (idxname[strlen(tablepath)-1] == '.')
+ idxname[strlen(tablepath)-2] = idxmaj;
+ else
+ idxname[strlen(tablepath)-1] = idxmaj;
+
+ table.xfp = muse_file_open(idxname, mode);
+ }
+
+ /* The FCX CASE */
+
+ if (table.xfp == NULL && idxext == 'z') {
+ idxext = 'x';
+ idxmaj = 'X';
+
+ /* Test for UNIX CD-ROM filename terminator "." */
+ if (idxname[strlen(tablepath)-1] == '.')
+ idxname[strlen(tablepath)-2] = idxext;
+ else
+ idxname[strlen(tablepath)-1] = idxext;
+
+ table.xfp = muse_file_open(idxname, mode);
+ if (table.xfp == NULL) {
+ /* Test for UNIX CD-ROM filename terminator "." */
+ if (idxname[strlen(tablepath)-1] == '.')
+ idxname[strlen(tablepath)-2] = idxmaj;
+ else
+ idxname[strlen(tablepath)-1] = idxmaj;
+
+ table.xfp = muse_file_open(idxname, mode);
+ }
+ }
+
+ /* If mode is READ and no variable length index exists then */
+ /* something has gone wrong so free up memory and return NULL */
+ if ((!table.xfp) && (table.mode == Read))
+ {
+ if (idxname != (char*)NULL)
+ {
+ xvt_free (idxname);
+ idxname = (char*)NULL;
+ }
+ for (i=0; i<table.nfields; i++)
+ if (table.header[i].name != (char*)NULL)
+ {
+ xvt_free (table.header[i].name);
+ table.header[i].name = (char*)NULL;
+ }
+ if (table.header != (header_type)NULL)
+ {
+ xvt_free ((char*)table.header);
+ table.header = (header_type)NULL;
+ }
+ if (table.path != (char*)NULL)
+ {
+ xvt_free (table.path);
+ table.path = (char*)NULL;
+ }
+ fclose (table.fp);
+ table.fp = NULL;
+ return table;
+ }
+
+ if (idxname != (char*)NULL)
+ {
+ xvt_free (idxname);
+ idxname = (char*)NULL;
+ }
+
+ /* Only read in index if file is read only */
+ if (table.xfp && (table.mode == Read))
+ {
+ Read_Vpf_Int (&(table.nrows), table.xfp, 1L);
+ Read_Vpf_Int (&ulval, table.xfp, 1L);
+ idxsize = table.nrows * sizeof (index_cell) + 10L;
+
+ /* Load the index into RAM */
+ table.xstorage = RAM;
+#if 1
+ table.idx_handle = xvt_zmalloc (idxsize);
+ table.index = table.idx_handle;
+#else
+ table.idx_handle = galloc (idxsize);
+ table.index = (index_type)glock (table.idx_handle)
+#endif
+ for (i=0; i<table.nrows; i++)
+ {
+ Read_Vpf_Int (&(table.index[i].pos), table.xfp, 1L);
+ Read_Vpf_Int (&(table.index[i].length),table.xfp,1L);
+ }
+ fclose(table.xfp);
+ }
+ else if (table.mode == Write)
+ {
+ /* Write out dummy header record for index file. */
+ /* vpf_close_table finishes the job. */
+ Write_Vpf_Int ( &(table.ddlen), table.xfp, 1L);
+ Write_Vpf_Int ( &(table.ddlen), table.xfp, 1L);
+ table.xstorage = DISK;
+ table.index = (index_type)NULL;
+ }
+ } /* if table.reclen > 0 */
+
+
+ if ((storage != disk) && ( table.mode == Read))
+ {
+ fseek (table.fp, index_pos (1L, table),SEEK_SET);
+#if 1
+ table.row_handle = xvt_zmalloc ((table.nrows + 1) * sizeof (row_type));
+ table.row = table.row_handle;
+
+#else
+ table.row_handle = galloc ((table.nrows + 1) * sizeof (row_type));
+ table.row = (ROW*)glock (table.row_handle);
+#endif
+ for (i=0; i<table.nrows; i++)
+ {
+ if (i == 13271)
+ i = 13271;
+ table.row[i] = read_next_row (table);
+ }
+ fclose (table.fp);
+ table.storage = RAM;
+ }
+ table.status = OPENED;
+
+ return table;
+}
+
+/*************************************************************************
+ *
+ *N vpf_close_table
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function frees an entire table from memory.
+ * The table must have been previously opened with vpf_open_table().
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * table <inout> == (vpf_table_type) VPF table structure.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels May 1991 DOS Turbo C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void vpf_close_table( vpf_table_type *table )
+#else
+ void vpf_close_table( table )
+ vpf_table_type *table;
+#endif
+{
+ register int32 i;
+
+ if (!table)
+ return;
+
+ if (table->status != OPENED)
+ return;
+
+ /* If the table is writable, write out the final record count */
+
+ if (table->mode == Write && table->xfp)
+ {
+ rewind (table->xfp);
+ Write_Vpf_Int ( &table->nrows, table->xfp, 1 ) ;
+ Write_Vpf_Int ( &table->ddlen, table->xfp, 1 ) ;
+ }
+
+ for (i=0; i<table->nfields; i++)
+ {
+ if (table->header[i].name != (char*)NULL)
+ {
+ xvt_free (table->header[i].name);
+ table->header[i].name = (char*)NULL;
+ }
+ /* free up null text string */
+ if (table->header[i].type == 'T')
+ if (table->header[i].nullval.Char != (char *)NULL)
+ {
+ xvt_free (table->header[i].nullval.Char);
+ table->header[i].nullval.Char = (char*)NULL;
+ }
+ /* free up index file string */
+ if (table->header[i].tdx != (char*)NULL)
+ {
+ xvt_free (table->header[i].tdx);
+ table->header[i].tdx = (char*)NULL;
+ }
+ /* free up narrative table string */
+ if (table->header[i].narrative != (char*)NULL)
+ {
+ xvt_free (table->header[i].narrative);
+ table->header[i].narrative = (char*)NULL;
+ }
+ }
+ if (table->header != (header_type)NULL)
+ {
+ xvt_free ((char*)table->header);
+ table->header = (header_type)NULL;
+ }
+
+ switch (table->storage)
+ {
+ case RAM:
+ for (i=0; i<table->nrows; i++)
+ free_row (table->row[i], *table);
+ if (table->row != (ROW*)NULL)
+ {
+// gunlock (table->row_handle);
+ gfree (table->row_handle);
+ table->row = (ROW*)NULL;
+ }
+ break;
+ case DISK:
+ if( table->fp != NULL )
+ fclose (table->fp);
+ break;
+ default:
+ xvt_note ("%s%s: unknown storage flag: %d\n",table->path,table->name,
+ table->storage);
+ break;
+ }
+
+ switch (table->xstorage)
+ {
+ case RAM:
+ if (table->index != (index_type)NULL)
+ {
+// gunlock (table->idx_handle);
+ gfree (table->idx_handle);
+ table->index = (index_type)NULL;
+ }
+ break;
+ case DISK:
+ fclose (table->xfp);
+ break;
+ case COMPUTE:
+ break;
+ default:
+ xvt_note ("%s%s: unknown index storage flag: %d\n",
+ table->path,table->name,table->storage);
+ break;
+ }
+ table->nfields = 0;
+ if(table->path != (char *)NULL)
+ {xvt_free(table->path);table->path = (char *)NULL;}
+ table->status = CLOSED;
+}
+
+
+/*************************************************************************
+ *
+ *N is_vpf_table
+ *
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * Purpose:
+ *P
+ * This function determines if the file at the specified location
+ * is a valid VPF table. It returns TRUE or FALSE.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * Parameters:
+ *A
+ * fname <input> == (char *) file system path.
+ * return <output> == (int32) TRUE (1) if the file is a VPF table;
+ * FALSE (0) if not.
+ *E
+ *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 is_vpf_table( char *fname )
+#else
+ int32 is_vpf_table( fname )
+ char *fname;
+#endif
+{
+ FILE *fp;
+ int32 n, ok;
+
+ fp = muse_file_open( fname, "rb" );
+ if (!fp) {
+ return FALSE;
+ }
+ Read_Vpf_Int ( &n, fp, 1 ) ;
+ fseek( fp, n-1, SEEK_CUR );
+ if (fgetc(fp) == ';')
+ ok = TRUE;
+ else
+ ok = FALSE;
+ fclose(fp);
+ return ok;
+}
+
+
+/*************************************************************************
+ *
+ *N is_vpf_null_float
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function determines whether a floating point number is the
+ * same as the VPF representation of the floating point NULL value.
+ * It returns TRUE or FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * num <input> == (float) number to evaluate.
+ * return <output> == (int32) TRUE (1) if the number is VPF NULL;
+ * FALSE (0) if not.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 is_vpf_null_float( float num )
+#else
+ int32 is_vpf_null_float( num )
+ float num;
+#endif
+{
+ float nan;
+
+ nan = (float)float_quiet_nan(0);
+ if (memcmp(&nan,&num,sizeof(float))==0) return 1;
+ return 0;
+}
+
+/*************************************************************************
+ *
+ *N is_vpf_null_double
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function determines whether a double precision floating point
+ * number is the same as the VPF representation of the double
+ * precision floating point NULL value. It returns TRUE or FALSE.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * num <input> == (double) number to evaluate.
+ * return <output> == (int32) TRUE (1) if the number is VPF NULL;
+ * FALSE (0) if not.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels April 1991 DOS Turbo C
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 is_vpf_null_double( double num )
+#else
+ int32 is_vpf_null_double( num )
+ double num;
+#endif
+{
+ double nan;
+
+ nan = (double)quiet_nan(0);
+ if (memcmp(&nan,&num,sizeof(double))==0) return 1;
+ return 0;
+}
+
+/**************************************************************************/
+/* FORMAT_DATE */
+/**************************************************************************/
+#if XVT_CC_PROTO
+void format_date (date_type date, char *fmtdate)
+#else
+ void format_date (date, fmtdate)
+ date_type date;
+ char *fmtdate;
+#endif
+{
+ char year[8], month[8], day[8], hour[8], mn[8], sec[8];
+
+ date[20]='\0';
+ strncpy (year, date, 4);
+ year[4]='\0';
+ strncpy (month, &date[4], 2);
+ month[2]='\0';
+ strncpy (day, &date[6], 2);
+ day[2]='\0';
+ strncpy (hour, &date[8], 2);
+ hour[2]='\0';
+ strncpy (mn, &date[10], 2);
+ mn[2]='\0';
+ strncpy (sec, &date[12], 2);
+ sec[2]='\0';
+ sprintf (fmtdate,"%s/%s/%s %s:%s:%s", month, day, year, hour, mn, sec);
+}
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftable.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftable.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftable.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,298 @@
+
+/* VPFTABLE.H */
+
+#ifndef _VPF_TABLE_H_
+
+#define _VPF_TABLE_H_
+
+#include <stdio.h>
+#include <math.h>
+#include <float.h>
+
+
+#ifdef _MSC
+#define MAXLONG LONG_MAX
+#endif
+
+#ifdef _UNIX
+#define MAXLONG LONG_MAX
+#endif
+
+#ifndef _MACHINE_H_
+#include "machine.h"
+#endif
+#ifndef _VPF_IO_
+#include "vpfio.h"
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+
+#define VPF_DIR_SEPARATOR '\\'
+
+
+/* This should be the ISO definition of date */
+typedef char date_type[21] ; /* Include null end of string */
+
+/* NULL value type */
+typedef union
+ {
+ char *Char;
+ short int Short;
+ int32 Int;
+ float Float;
+ double Double;
+ date_type Date;
+ char Other;
+ } null_field;
+
+/* The basic information carried for each field in the table */
+typedef struct {
+ char *name; /* Name of the field */
+ char *tdx; /* Thematic index file name */
+ char *narrative; /* Name of a narrative table describing the field*/
+ int32 count; /* Number of items in this column (-1 =>variable)*/
+ char description[81]; /* Field description */
+ char keytype; /* Type of key - (P)rimary, (F)oreign, (N)onkey */
+ char vdt[13]; /* Value description table name */
+ char type; /* Data type - T,I,F,K,D */
+ null_field nullval ; /* This is used for the converter */
+} header_cell, *header_type;
+
+typedef enum { ram, disk, either, compute } storage_type;
+#define RAM 0
+#define DISK 1
+#define EITHER 2
+#define COMPUTE 3
+
+typedef enum { Read, Write } file_mode ;
+
+#define CLOSED 0
+#define OPENED 1
+
+/* Each column in a table row has a count and a pointer to the data */
+/* and a null value default */
+typedef struct
+ {
+ int32 count;
+ void *ptr;
+ } column_type;
+
+/* A table row is an array of columns */
+typedef column_type *row_type;
+typedef column_type /*huge*/ *ROW;
+
+/* Index for variable width tables. */
+/* One index cell for each row in the table. */
+typedef struct {
+ uint32 pos;
+ uint32 length;
+} index_cell;
+
+typedef index_cell /*huge*/ *index_type;
+
+/* VPF table structure: */
+typedef struct {
+ char *path; /* Directory path to the table */
+ int32 nfields; /* Number of fields */
+ int32 nrows; /* Number of rows in the table */
+ int32 reclen; /* Table record length (-1 => variable */
+ int32 ddlen; /* Data definition string length */
+ FILE *fp; /* Table file pointer */
+ FILE *xfp; /* Index file pointer */
+ index_type index; /* Index structure */
+ GHANDLE idx_handle; /* Huge data handle for index structure */
+ storage_type storage; /* Flag indicating table storage method */
+ storage_type xstorage; /* Flag indicating where index stored */
+ header_type header; /* Table header structure */
+ ROW *row; /* Array of table rows */
+ GHANDLE row_handle; /* Huge data handle for row structure */
+ file_mode mode; /* Table is either reading or writing */
+ char *defstr ; /* rdf, definition string */
+ char name[13]; /* Name of the VPF table */
+ char description[81]; /* Table description */
+ char narrative[13]; /* Table narrative file name */
+ unsigned char status; /* VPF table status - OPENED or CLOSED */
+ unsigned char byte_order; /* Byte order of the table's data */
+} vpf_table_type;
+
+typedef struct {
+ float x,y;
+} coordinate_type;
+
+typedef struct {
+ double x,y;
+} double_coordinate_type;
+
+typedef struct {
+ float x,y,z;
+} tri_coordinate_type;
+
+typedef struct {
+ double x,y, z;
+} double_tri_coordinate_type;
+
+/* VPF id triplet field union structure. Only one of the elements actually
+stores the data correctly at any one time. */
+typedef union {
+ unsigned char f1;
+ unsigned short f2;
+ uint32 f3;
+} key_field;
+
+/* id triplet internal storage type */
+typedef struct {
+ unsigned char type;
+ int32 id, tile, exid;
+} id_triplet_type;
+
+/* These macros help determine the type in the key datatype */
+
+#define TYPE0(cell) ((cell>>6)&(3))
+#define TYPE1(cell) ((cell>>4)&(3))
+#define TYPE2(cell) ((cell>>2)&(3))
+#define TYPE3(cell) ((cell)&(3))
+
+/* These macros set the value in the key datatype */
+
+#define SETTYPE0(cell,value) cell = (((cell)&(~(3<<6)))|(((3)&(value))<<6))
+#define SETTYPE1(cell,value) cell = (((cell)&(~(3<<4)))|(((3)&(value))<<4))
+#define SETTYPE2(cell,value) cell = (((cell)&(~(3<<2)))|(((3)&(value))<<2))
+#define SETTYPE3(cell,value) cell = (((cell)&(~(3)))|(((3)&(value))))
+
+/* This macro helps to write out a key */
+
+#define ASSIGN_KEY (tYPE,kEY,loc,val) { \
+ if (val < 1) { \
+ tYPE(kEY.type,0); \
+ } else if (val < (1<<8)) { \
+ tYPE(kEY.type,1); \
+ kEY.loc = val ; \
+ } else if ( val < (1<<16)) { \
+ tYPE(kEY.type,2); \
+ kEY.loc = val; \
+ } else { \
+ tYPE(kEY.type,3); \
+ kEY.loc = val; }}
+
+/* define NULL values */
+
+#define VARIABLE_STRING_NULL_LENGTH 10
+#define NULLCHAR ' '
+#define NULLTEXT " "
+#define NULLSHORT -MAXSHORT
+#define NULLINT -MAXLONG
+#define NULLDATE " "
+
+#define NULLFLOAT ((float) float_quiet_nan (0))
+#define NULLDOUBLE ((double) quiet_nan (0))
+
+
+
+
+/* Functions: */
+#ifdef PROTO
+ double quiet_nan (int32 unused);
+ double float_quiet_nan (int32 unused);
+ void vpf_nullify_table (vpf_table_type *table);
+ vpf_table_type vpf_open_table (char *tablename, storage_type storage,
+ char *mode, char *defstr);
+ void vpf_close_table (vpf_table_type *table);
+ char *read_text_defstr (FILE *infile, FILE *outerr);
+ int32 index_length (int32 row_number, vpf_table_type table);
+ int32 index_pos (int32 row_number, vpf_table_type table);
+ id_triplet_type read_key (vpf_table_type table);
+ int32 row_offset (int32 field, row_type row, vpf_table_type table);
+ row_type read_next_row (vpf_table_type table);
+ row_type rowcpy (row_type origrow, vpf_table_type table);
+ row_type read_row (int32 row_number, vpf_table_type table);
+ void free_row (row_type row, vpf_table_type table);
+ row_type get_row (int32 row_number, vpf_table_type table);
+ int32 table_pos (char *field_name, vpf_table_type table);
+ void *get_table_element (int32 field_number, row_type row,
+ vpf_table_type table, void *value, int32 *count);
+ void *named_table_element (char *field_name, int32 row_number,
+ vpf_table_type table, void *value, int32 *count);
+ void *table_element (int32 field_number, int32 row_number,
+ vpf_table_type table, void *value, int32 *count);
+ int32 is_vpf_table (char *fname);
+ int32 is_vpf_null_float (float num);
+ int32 is_vpf_null_double (double num);
+ char *parse_get_string (int32*, char*, char);
+ FILE *vpfopencheck (char *filename, char *mode);
+ int32 parse_data_def (vpf_table_type *table);
+
+ /* Write functions */
+ int32 write_key( id_triplet_type key, FILE *fp );
+ int32 write_next_row( row_type row, vpf_table_type *table );
+ int32 write_row( int32 rownum, row_type row, vpf_table_type *table );
+ row_type create_row( vpf_table_type table );
+ void nullify_table_element( int32 field, row_type row,
+ vpf_table_type table );
+ int32 put_table_element( int32 field, row_type row,
+ vpf_table_type table,
+ void *value, int32 count );
+ void swap_two ( char *in, char *out );
+ void swap_four ( char *in, char *out );
+ void swap_eight ( char *in, char *out );
+ void format_date (date_type date, char *fmtdate);
+#else
+ double quiet_nan ();
+ float float_quiet_nan ();
+ void vpf_nullify_table ();
+ vpf_table_type vpf_open_table ();
+ void vpf_close_table ();
+ char *read_text_defstr ();
+ int32 index_length ();
+ int32 index_pos ();
+ id_triplet_type read_key ();
+ int32 row_offset ();
+ row_type read_next_row ();
+ row_type rowcpy ();
+ row_type read_row ();
+ void free_row ();
+ row_type get_row ();
+ int32 table_pos ();
+ void *get_table_element ();
+ void *named_table_element ();
+ void *table_element ();
+ int32 is_vpf_table ();
+ int32 is_vpf_null_float ();
+ int32 is_vpf_null_double ();
+ int32 parse_data_def ();
+
+ /* Write functions */
+ int32 write_key ();
+ int32 write_next_row ();
+ int32 write_row ();
+ row_type create_row ();
+ void nullify_table_element ();
+ int32 put_table_element ();
+ void swap_two ();
+ void swap_four ();
+ void swap_eight ();
+ void format_date ();
+#endif /* If PROTO */
+
+#ifdef MAIN
+ FILE * errorfp = stderr;
+#else
+ extern FILE * errorfp;
+#endif
+
+#ifndef max
+#define max(a,b) ((a > b) ? a : b)
+#endif
+
+#ifndef min
+#define min(a,b) ((a < b) ? a : b)
+#endif
+
+#endif /* #ifndef _VPF_TABLE_H_ */
+
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftidx.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftidx.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftidx.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,2761 @@
+
+/*************************************************************************
+ *
+ * Environmental Systems Research Institute (ESRI) Applications Programming
+ *
+ *N Module VPFTIDX
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ *P
+ * Purpose: Subroutines to create and read both the thematic index
+ * or a gazeteer index on a VPF table column.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * N/A
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn September/October 1991
+ * Barry Michaels January 1992 A few adjustments for DOS.
+ * Added sets to create function to
+ * take advantage of SET's disk-
+ * swapping ability when low on memory.
+ * Dec 1992 Added sorted directory per RFC#67
+ * to VPF. Fixed text, added dates,
+ * rearranged create to use a scratch
+ * file instead of sets.
+ *E
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions:
+ *F
+ *
+ * set_type read_thematic_index ( char *tablename,
+ * char *value ) ;
+ *
+ * ThematicIndex open_thematic_index ( char *tablename );
+ *
+ * set_type search_thematic_index ( ThematicIndex *themindex,
+ * char *value ) ;
+ *
+ * void close_thematic_index ( ThematicIndex *themindex );
+ *
+ * set_type read_gazetteer_index (char * vpfname, char * query_str ) ;
+ *
+ * set_type search_gazetteer_index (ThematicIndex *idx,
+ * char * query_str ) ;
+ *
+ * int32 read_gazetteer_index_directory (
+ * ThematicIndexDirectory ** gid,
+ * ThematicIndexHeader * gi,
+ * FILE * idx_fp);
+ *
+ * int32 write_thematic_index_header ( ThematicIndexHeader h ,
+ * FILE *fp ) ;
+ *
+ * int32 read_thematic_index_header ( ThematicIndexHeader *h ,
+ * FILE *fp ) ;
+ *
+ * int32 write_thematic_index_directory (
+ * ThematicIndexHeader h ,
+ * ThematicIndexDirectory *d,
+ * int32 size,
+ * FILE *fp ) ;
+ *
+ * int32 write_gazetteer_index_directory (
+ * ThematicIndexHeader h ,
+ * ThematicIndexDirectory *d,
+ * int32 size,
+ * FILE *fp ) ;
+ *
+ * int32 create_thematic_index ( char indextype,
+ * char *tablename,
+ * char *idxname ,
+ * char *columnname,
+ * char *idx_set );
+ *
+ * int32 create_gazetteer_index (char *tablename,
+ * char *idx_fname ,
+ * char *columnname,
+ * char *idx_set);
+ *
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible. Created on UNIX first
+ *E
+ *************************************************************************/
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+
+#if 0
+#include <stdio.h>
+#include <malloc.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#endif
+
+#ifndef __VPF_H__
+#include "vpf.h"
+#endif
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+#ifndef H_MUSEDIR
+#include "musedir.h"
+#endif
+#ifndef __STRFUNC_H__
+#include "strfunc.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __VPFTIDX_H__
+#include "vpftidx.h"
+#endif
+
+#ifndef __USE_BSD
+#define bcopy(src,dest,size) memcpy(dest,src,size)
+#endif
+
+#ifdef PROTO
+int32 read_gazetteer_index_directory(
+ ThematicIndexDirectory **gid,
+ ThematicIndexHeader *gi,
+ FILE *idx_fp);
+
+int32 read_thematic_index_header ( ThematicIndexHeader *h,
+ FILE *ifp );
+
+int32 write_thematic_index_header ( ThematicIndexHeader h,
+ FILE *ifp );
+
+int32 write_thematic_index_directory ( ThematicIndexHeader h,
+ ThematicIndexDirectory *d,
+ int32 idsize, /* size of data */
+ FILE *ifp );
+
+int32 write_gazetteer_index_directory ( ThematicIndexHeader h,
+ ThematicIndexDirectory *d,
+ int32 idsize, /* size of data */
+ FILE *ifp );
+#else
+int32 read_gazetteer_index_directory();
+
+int32 read_thematic_index_header ( );
+
+int32 write_thematic_index_header ( );
+
+int32 write_thematic_index_directory ( );
+
+int32 write_gazetteer_index_directory ( );
+#endif
+
+#define Whimper(str) { \
+ xvt_note ("\nvpftidx: < %s >\n", str );}
+
+#define SWhimper(str) { \
+ set_type err; err = set_init (1) ;\
+ xvt_note ("\nvpftidx: < %s >\n", str ) ;\
+ return err ; }
+
+#define OWhimper(str) { \
+ xvt_note ("\nvpftidx: < %s >\n", str ) ;\
+ return idx ; }
+
+/*
+ * an index file directory entry takes up a different amount
+ * of space in memory than it does on disk; the following constant
+ * should be used to calculate the starting offset for
+ * index data
+ *
+ * example: if the number of items to be indexed is t, and each item is
+ * s bytes long, then use
+ *
+ * sizeof(ThematicIndexHeader) + t * (s + DIR_ON_DISK_INCR)
+ *
+ * to find out where the first byte of indexing data will be placed.
+ *
+ * That first byte is what must be stored as the value of Header.nbytes
+ */
+
+#define DIR_ON_DISK_INCR (2 * sizeof(int32))
+
+#ifdef PROTO
+int Icmpval (const void *elem1, const void *elem2 )
+#else
+int Icmpval (elem1, elem2 )
+const void *elem1;
+const void *elem2;
+#endif
+{
+ ThematicIndexDirectory d1,d2;
+
+ memcpy(&d1,elem1,sizeof(ThematicIndexDirectory));
+ memcpy(&d2,elem2,sizeof(ThematicIndexDirectory));
+
+ if (d1.value.ival < d2.value.ival) return -1;
+ if (d1.value.ival > d2.value.ival) return 1;
+ return 0;
+}
+
+
+#ifdef PROTO
+int Scmpval( const void *elem1,
+ const void *elem2 )
+#else
+int Scmpval( elem1, elem2 )
+const void *elem1;
+const void *elem2;
+#endif
+{
+ ThematicIndexDirectory d1,d2;
+
+ memcpy(&d1,elem1,sizeof(ThematicIndexDirectory));
+ memcpy(&d2,elem2,sizeof(ThematicIndexDirectory));
+
+ if (d1.value.sval < d2.value.sval) return -1;
+ if (d1.value.sval > d2.value.sval) return 1;
+ return 0;
+}
+
+
+#ifdef PROTO
+int Fcmpval( const void *elem1,
+ const void *elem2 )
+#else
+int Fcmpval( elem1, elem2 )
+const void *elem1;
+const void *elem2;
+#endif
+{
+ ThematicIndexDirectory d1,d2;
+
+ memcpy(&d1,elem1,sizeof(ThematicIndexDirectory));
+ memcpy(&d2,elem2,sizeof(ThematicIndexDirectory));
+
+ if (d1.value.fval < d2.value.fval) return -1;
+ if (d1.value.fval > d2.value.fval) return 1;
+ return 0;
+}
+
+
+#ifdef PROTO
+int Dcmpval( const void *elem1,
+ const void *elem2 )
+#else
+int Dcmpval( elem1, elem2 )
+const void *elem1;
+const void *elem2;
+#endif
+{
+ ThematicIndexDirectory d1,d2;
+
+ memcpy(&d1,elem1,sizeof(ThematicIndexDirectory));
+ memcpy(&d2,elem2,sizeof(ThematicIndexDirectory));
+
+ if (d1.value.dval < d2.value.dval) return -1;
+ if (d1.value.dval > d2.value.dval) return 1;
+ return 0;
+}
+
+
+#ifdef PROTO
+int Ccmpval( const void *elem1,
+ const void *elem2 )
+#else
+int Ccmpval( elem1, elem2 )
+const void *elem1;
+const void *elem2;
+#endif
+{
+ ThematicIndexDirectory d1,d2;
+
+ memcpy(&d1,elem1,sizeof(ThematicIndexDirectory));
+ memcpy(&d2,elem2,sizeof(ThematicIndexDirectory));
+
+ if (d1.value.cval < d2.value.cval) return -1;
+ if (d1.value.cval > d2.value.cval) return 1;
+ return 0;
+}
+
+
+#ifdef PROTO
+int STRcmpval( const void *elem1,
+ const void *elem2 )
+#else
+int STRcmpval( elem1, elem2 )
+const void *elem1;
+const void *elem2;
+#endif
+{
+ ThematicIndexDirectory d1,d2;
+
+ memcpy(&d1,elem1,sizeof(ThematicIndexDirectory));
+ memcpy(&d2,elem2,sizeof(ThematicIndexDirectory));
+
+ return (strcmp(d1.value.strval,d2.value.strval));
+}
+
+
+#ifdef PROTO
+int bincmp (const void *elem1, const void *elem2)
+#else
+int bincmp (elem1, elem2)
+const void *elem1;
+const void *elem2;
+#endif
+{
+ ThematicIndexDirectory d1,d2;
+
+ memcpy(&d1,elem1,sizeof(ThematicIndexDirectory));
+ memcpy(&d2,elem2,sizeof(ThematicIndexDirectory));
+
+ if (d1.binid < d2.binid) return -1;
+ if (d1.binid > d2.binid) return 1;
+ return 0;
+}
+
+#define KEY_ID 1
+#define KEY_TILE 2
+#define KEY_EXT 3
+
+/*************************************************************************
+ *
+ *N create_thematic_index
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *
+ * Create a thematic index file on a given vpf table.
+ *P
+ *
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * indextype <input> == (char) either 'T' for thematic index or
+ * 'G' for gazetteer.
+ * tablename <input> == (char *) path name of the vpf table.
+ * idxname <input> == (char *) name of the index file to be created.
+ * columnname <input> == (char *) name of column to create index on
+ * if the column is a triplet id, the columnname
+ * should be as such: EDG_ID\ID
+ * EDG_ID\TILE_ID
+ * EDG_ID\EXT_ID
+ * idxset <input> == (char *) array of character values to index on
+ * if the index type is gazetteer. Not used for
+ * index type = 'T'.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * void *vpfmalloc VPFMISC.C
+ * vpf_open_table VPFTABLE.C
+ * table_pos
+ * table_element
+ * vpf_close_table
+ * write_thematic_index_header see below
+ * write_thematic_index_directory see below
+ * Vpf_Write_* macros
+ * set_init SET.C
+ * set_insert
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible. developed on UNIX
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 create_thematic_index ( char indextype,
+ char *tablename,
+ char *idxname ,
+ char *columnname,
+ char *idx_set )
+#else
+int32 create_thematic_index ( indextype, tablename, idxname , columnname, idx_set )
+char indextype;
+char *tablename;
+char *idxname;
+char *columnname;
+char *idx_set;
+#endif
+{
+
+ FILE *ifp, *tmpfp ;
+ int32 i, j, tablepos, k,
+ keycolumn = 0 , /* 1 if key column */
+ itemp , n,
+ idsize , /* either 2 or 4 bytes */
+ totalids = 0,
+ bin,
+ binoff,
+ datasize = 0; /* Directory value data size */
+ char *buf ,
+ ch ,
+ hack[255] ;
+ vpf_table_type table ;
+ ThematicIndexHeader h ;
+ ThematicIndexDirectory *d;
+ short int stemp ;
+ float ftemp ;
+ double dtemp ;
+ date_type datetemp ;
+ id_triplet_type key ;
+
+ if (!tablename) Whimper("Unspecified table name");
+ if (!idxname) Whimper("Unspecified index name");
+ if (!columnname) Whimper("Unspecified column name");
+
+ if ( indextype == 'G' ) {
+ if (!idx_set) Whimper("Unspecified index set");
+ return ( create_gazetteer_index ( tablename, idxname,columnname,idx_set)) ;
+ }
+
+ /* convert columnname to uppercase and check for id triplet */
+
+ for ( i=0 ; i < (int32)strlen(columnname); i++ ) /* copy into header structure */
+ h.vpf_column_name[i] = (char)toupper ( columnname[i] ) ;
+ h.vpf_column_name[i] = '\0';
+
+ h.index_type = 'T' ; /* default */
+ h.type_count = 1 ;
+
+ for ( i=0 ; i < (int32)strlen(columnname); i++ ) {
+
+ columnname[i] = (char)toupper ( columnname[i] ) ;
+
+ /* check if request is on a triplet id field */
+
+ if ( columnname[i] == '\\' ) {
+
+ columnname[i+1] = (char)toupper ( columnname[i+1] ) ;
+
+ switch ( columnname[i+1] ) { /* locate sub-column key */
+ case 'I': /* ID of triplet id */
+ keycolumn = KEY_ID ; break ;
+ case 'T': /* TILE_ID of triplet id */
+ keycolumn = KEY_TILE ; break ;
+ case 'E': /* EXT_ID of triplet id */
+ keycolumn = KEY_EXT ; break ;
+ default:
+ Whimper ("error in key column request") ;
+ /* break ; Whimper contains a return */
+ } /* end of switch */
+ strcpy( h.vpf_column_name, strupr ( columnname )) ;
+ columnname[i] = '\0' ;
+ } /* end of if columnname == \ */
+ } /* end of for loop */
+
+ table = vpf_open_table ( tablename, disk, "rb", '\0') ;
+ if (!table.fp) {
+ sprintf(hack,"Error opening %s\n",tablename);
+ Whimper(hack);
+ }
+
+
+ /* Determine the id_data_size. This will save 50% of file size */
+
+ if ( table.nrows > MAX_ID ) {
+ h.id_data_type = 'I' ; /* int32s */
+ idsize = sizeof ( int32 ) ;
+ } else {
+ h.id_data_type = 'S' ; /* short ints */
+ idsize = sizeof ( short int ) ;
+ }
+
+ /* Find position of column in input table */
+
+ tablepos = table_pos ( columnname, table ) ;
+ if (tablepos < 0) {
+ vpf_close_table(&table);
+ sprintf(hack,"Invalid column name (%s) for %s",columnname,tablename);
+ Whimper(hack);
+ }
+
+ /* Now check data type */
+
+ switch (table.header[tablepos].type) {
+ case 'X':
+ vpf_close_table(&table);
+ Whimper ("Cannot make index on Null Column") ;
+ /* A return is in Whimper - break statement cannot be reached */
+ case 'T':
+ if ( table.header[tablepos].count <= 0 ) {
+ vpf_close_table(&table);
+ Whimper ("Cannot make bin index on variable length text column") ;
+ }
+ datasize = table.header[tablepos].count ;
+ h.type_count = datasize ; /* the special case */
+ break;
+ case 'D':
+ datasize = sizeof ( date_type ) ;
+ break;
+ case 'I':
+ case 'K': /* treat keys like integers */
+ datasize = sizeof ( int32 ) ;
+ break ;
+ case 'S':
+ datasize = sizeof ( short int ) ;
+ break ;
+ case 'F':
+ datasize = sizeof ( float ) ;
+ break ;
+ case 'R':
+ datasize = sizeof ( double ) ;
+ break ;
+ case 'C':
+ case 'Z':
+ case 'B':
+ case 'Y':
+ vpf_close_table(&table);
+ Whimper ("Cannot make index on Coordinate Column") ;
+ default:
+ vpf_close_table(&table);
+ sprintf (hack,"No such type < %c >", table.header[tablepos].type ) ;
+ Whimper ( hack ) ;
+ } /* end of switch */
+
+ /* open output index file */
+
+ if (( ifp = muse_file_open ( idxname, "w+b" )) == NULL ) {
+ vpf_close_table(&table);
+ Whimper ( idxname ) ;
+ }
+
+ /* open scratch file of (bin,binpos) for each table id */
+ if (( tmpfp = tmpfile() ) == NULL ) {
+ vpf_close_table(&table);
+ fclose(ifp);
+ Whimper ( "Error creating scratch file" ) ;
+ }
+
+ /* Create directory size as big as table, for worst case */
+
+ d = (ThematicIndexDirectory *)
+ xvt_malloc (sizeof (ThematicIndexDirectory));
+ h.nbins = 0 ; /* initialize the directory counter */
+
+#define REALLOC_DIRECTORY(loc) { \
+ if ((d = (ThematicIndexDirectory *) \
+ realloc(d,sizeof(ThematicIndexDirectory) * (loc+1))) == NULL ) {\
+ vpf_close_table(&table); \
+ fclose(ifp); \
+ fclose(tmpfp); \
+ Whimper ("error in reallocing directory") ; \
+ } \
+ d[loc].binid = loc; \
+ d[loc].num_items = 0 ; }
+
+#define INCR_ID(loc,id) { \
+ int rtrn; \
+ rtrn = fwrite(&loc,sizeof(int32),1,tmpfp); \
+ j = d[loc].num_items; \
+ rtrn = fwrite(&j,sizeof(int32),1,tmpfp); \
+ d[loc].num_items++ ; \
+ if (d[loc].num_items == 1) \
+ d[loc].start_offset = id; \
+ else if (d[loc].num_items == 2) \
+ totalids += 2; \
+ else \
+ totalids++; }
+
+/* Count up bins */
+
+ switch ( table.header[tablepos].type ) {
+ case 'I':
+
+ for ( i=1; i <= table.nrows; i++ ) {
+ /* read in record from disk */
+ table_element ( tablepos,i,table,&itemp,&n);
+ for ( k=0; k < h.nbins; k++ ) /* Search directory for value*/
+ if ( d[k].value.ival == itemp )
+ break ;/* Found a match */
+ if ( k == h.nbins ) { /* New value in column */
+ REALLOC_DIRECTORY ((size_t)k);
+ d[k].value.ival = itemp ;
+ h.nbins++ ;
+ }
+ INCR_ID(k,i) ;
+ } /* end of for i loop */
+
+ break ;
+ case 'T':
+
+ for ( i = 1; i <= table.nrows; i++ ) {
+
+ if (h.type_count > 1) {
+
+ /* read in record from disk */
+ buf = (char *) table_element (tablepos,i,table,NULL,&n);
+
+ /* strlen ( buf ) should equal datasize */
+
+ for ( k=0; k < h.nbins; k++ ) /* Search directory for value*/
+ if ( ! strcmp ( d[k].value.strval, buf ) )
+ break ;/* Found a match */
+
+ if ( k == h.nbins ) { /* New value in column */
+ REALLOC_DIRECTORY ((size_t)k);
+ d[k].value.strval = (char*)xvt_malloc (strlen (buf));
+ (void) bcopy ( buf, d[k].value.strval, strlen(buf) ) ;
+ d[k].value.strval[n] = '\0';
+ h.nbins++ ;
+ }
+ INCR_ID(k,i) ;
+ xvt_free(buf);
+
+ } else {
+
+ /* read in record from disk */
+ table_element (tablepos,i,table,&ch,&n);
+
+ for ( k=0; k < h.nbins; k++ ) /* Search directory for value*/
+ if ( d[k].value.cval == ch )
+ break ;/* Found a match */
+
+ if ( k == h.nbins ) { /* New value in column */
+ REALLOC_DIRECTORY ((size_t)k);
+ d[k].value.cval = ch;
+ h.nbins++ ;
+ }
+ INCR_ID(k,i) ;
+
+ }
+ } /* end of for i loop */
+
+ break ;
+ case 'S':
+
+ for ( i=1; i <= table.nrows; i++ ) {
+ /* read in record from disk */
+ table_element ( tablepos,i,table,&stemp,&n);
+ for ( k=0; k < h.nbins; k++ ) /* Search directory for value*/
+ if ( d[k].value.sval == stemp )
+ break ;/* Found a match */
+ if ( k == h.nbins ) { /* New value in column */
+ REALLOC_DIRECTORY ((size_t)k);
+ d[k].value.sval = stemp ;
+ h.nbins++ ;
+ }
+ INCR_ID (k,i) ;
+ } /* end of for i loop */
+
+ break ;
+ case 'F':
+
+ for ( i=1; i <= table.nrows; i++ ) {
+ /* read in record from disk */
+ table_element ( tablepos,i,table,&ftemp,&n);
+ for ( k=0; k < h.nbins; k++ ) /* Search directory for value*/
+ if ( d[k].value.fval == ftemp )
+ break ;/* Found a match */
+ if ( k == h.nbins ) { /* New value in column */
+ REALLOC_DIRECTORY ((size_t)k);
+ d[k].value.fval = ftemp ;
+ h.nbins++ ;
+ }
+ INCR_ID (k,i) ;
+ } /* end of for i loop */
+
+ break ;
+ case 'R':
+ for ( i=1; i <= table.nrows; i++ ) {
+ /* read in record from disk */
+ table_element ( tablepos,i,table,&dtemp,&n);
+ for ( k=0; k < h.nbins; k++ ) /* Search directory for value*/
+ if ( d[k].value.dval == dtemp )
+ break ;/* Found a match */
+ if ( k == h.nbins ) { /* New value in column */
+ REALLOC_DIRECTORY ((size_t)k);
+ d[k].value.dval = dtemp ;
+ h.nbins++ ;
+ }
+ INCR_ID (k,i) ;
+ } /* end of for i loop */
+
+ break ;
+ case 'K':
+
+ for ( i=1; i <= table.nrows; i++ ) {
+ /* read in record from disk */
+ table_element ( tablepos,i,table,&key,&n);
+
+ if ( keycolumn == KEY_ID )
+ itemp = key.id ;
+ else if ( keycolumn == KEY_TILE )
+ itemp = key.tile ;
+ else
+ itemp = key.exid ;
+
+ for ( k=0; k < h.nbins; k++ ) /* Search directory for value*/
+ if ( d[k].value.ival == itemp )
+ break ;/* Found a match */
+ if ( k == h.nbins ) { /* New value in column */
+ REALLOC_DIRECTORY ((size_t)k);
+ d[k].value.ival = itemp ;
+ h.nbins++ ;
+ }
+ INCR_ID (k,i) ;
+ } /* end of for i loop */
+
+ break ;
+ case 'D':
+
+ for ( i = 1; i <= table.nrows; i++ ) {
+
+ /* read in record from disk */
+ table_element (tablepos,i,table,datetemp,&n);
+ datetemp[sizeof(date_type)-1]='\0';
+
+ /* strlen ( datetemp ) should equal datasize */
+
+ for ( k=0; k < h.nbins; k++ ) /* Search directory for value*/
+ if ( ! strcmp ( d[k].value.strval, datetemp ) )
+ break ;/* Found a match */
+
+ if ( k == h.nbins ) { /* New value in column */
+ REALLOC_DIRECTORY ((size_t)k);
+ d[k].value.strval = (char*)xvt_malloc ( sizeof (date_type) + 1);
+ (void) bcopy ( datetemp, d[k].value.strval, sizeof(date_type) ) ;
+ d[k].value.strval[sizeof(date_type)-1] = '\0';
+ h.nbins++ ;
+ }
+ INCR_ID(k,i) ;
+
+ } /* end of for i loop */
+
+ break ;
+ default:
+ vpf_close_table(&table);
+ fclose(ifp);
+ fclose(tmpfp);
+ if (h.column_type == 'T' && h.type_count > 1) {
+ for ( i=0; i < h.nbins; i++ ) xvt_free(d[i].value.strval);
+ }
+ xvt_free ((char*)d);
+ Whimper ("error in table reading switch, no such type") ;
+ } /* end of switch */
+
+ /* set up header and write it out */
+ /* h.id_data_size and columnname set up above */
+ /* h.type_count set above */
+
+ h.nbytes = THEMATIC_INDEX_HEADER_SIZE +
+ h.nbins * ( datasize + DIRECTORY_SIZE ) ;
+
+ h.column_type = table.header[tablepos].type ;
+ if ( h.column_type == 'K' ) /* It's really an I */
+ h.column_type = 'I' ;
+ h.sort = 'S';
+ for ( i=0; i < 3; i++ )
+ h.padding[i] = '\0';
+
+ /* only write the table name, no pathname */
+
+ for ( i = strlen ( tablename ); i > 0; i-- )
+ if ( tablename[i] == DIR_SEPARATOR ) break ;
+ if ( tablename[i] == DIR_SEPARATOR )
+#ifdef _MSDOS
+ strncpy ( h.vpf_table_name, strupr ( &tablename[i+1] ), 13 ) ;
+#else
+ strncpy ( h.vpf_table_name, &tablename[i+1], 13 ) ;
+#endif
+ else
+#ifdef _MSDOS
+ strncpy( h.vpf_table_name, strupr ( tablename), 13 );
+#else
+ strncpy( h.vpf_table_name, tablename, 13 );
+#endif
+
+ for ( i=strlen(h.vpf_table_name); i < 12 ; i++ )
+ h.vpf_table_name[i] = ' ' ;
+ h.vpf_table_name[12] = '\0';
+
+ /* columnname setup above */
+
+ h.table_nrows = table.nrows ;
+
+ if (write_thematic_index_header (h, ifp) == 0L) {
+ vpf_close_table(&table);
+ fclose(ifp);
+ fclose(tmpfp);
+ if (h.column_type == 'T' && h.type_count > 1) {
+ for ( i=0; i < h.nbins; i++ ) xvt_free(d[i].value.strval);
+ }
+ xvt_free ((char*)d);
+ Whimper ( "error writing index header" ) ;
+ }
+
+ /* Now write out the rest of the header directory */
+
+ /* ... First, sort the directory ... */
+ switch (h.column_type) {
+ case 'I':
+ qsort ((void*)d, (size_t)h.nbins, sizeof(ThematicIndexDirectory),
+ Icmpval);
+ break;
+ case 'S':
+ qsort((void*)d, (size_t)h.nbins, sizeof(ThematicIndexDirectory),
+ Scmpval);
+ break;
+ case 'F':
+ qsort((void*)d, (size_t)h.nbins, sizeof(ThematicIndexDirectory),
+ Fcmpval);
+ break;
+ case 'R':
+ qsort ((void*)d, (size_t)h.nbins, sizeof(ThematicIndexDirectory),
+ Dcmpval);
+ break;
+ case 'T':
+ if (h.type_count == 1)
+ qsort ((void*)d, (size_t)h.nbins, sizeof(ThematicIndexDirectory),
+ Ccmpval);
+ else
+ qsort ((void*)d, (size_t)h.nbins, sizeof(ThematicIndexDirectory),
+ STRcmpval);
+ break;
+ case 'D':
+ qsort ((void*)d, (size_t)h.nbins, sizeof(ThematicIndexDirectory),
+ STRcmpval);
+ break;
+ case 'K':
+ qsort ((void*)d, (size_t)h.nbins, sizeof(ThematicIndexDirectory),
+ Icmpval);
+ break;
+ }
+
+ if (write_thematic_index_directory (h, d, idsize, ifp) == 0L) {
+ vpf_close_table(&table);
+ fclose(ifp);
+ fclose(tmpfp);
+ if (h.column_type == 'T' && h.type_count > 1) {
+ for ( i=0; i < h.nbins; i++ ) xvt_free(d[i].value.strval);
+ }
+ xvt_free ((char*)d);
+ Whimper ( "error writing index directory" ) ;
+ }
+
+ /* now write the data */
+
+ /* First, fill up all id slots with 0 placeholders */
+ itemp = 0;
+ stemp = 0;
+ if ( h.id_data_type == 'I' )
+ for (i=0;i<totalids;i++) Write_Vpf_Int( &itemp, ifp, 1 );
+ else
+ for (i=0;i<totalids;i++) Write_Vpf_Short( &stemp, ifp, 1 );
+
+ rewind(tmpfp);
+
+ /* Restore original bin order */
+ qsort ((void*)d, (size_t)h.nbins, sizeof(ThematicIndexDirectory), bincmp);
+
+ for ( j=1; j <= table.nrows; j++ ) {
+ int result;
+ result = fread(&bin,sizeof(bin),1,tmpfp);
+ result = fread(&binoff,sizeof(binoff),1,tmpfp);
+ if (d[bin].num_items == 1) continue;
+ if ( h.id_data_type == 'I' ) {
+ fseek(ifp, d[bin].start_offset + (binoff*sizeof(int32)), 0);
+ itemp = (int32)j;
+ Write_Vpf_Int ( &itemp, ifp, 1 ) ;
+ } else {
+ fseek(ifp, d[bin].start_offset + (binoff*sizeof(short int)), 0);
+ stemp = (short int)j;
+ Write_Vpf_Short ( &stemp, ifp, 1 ) ;
+ }
+ }
+
+ /* close up shop and exit */
+
+ vpf_close_table ( &table );
+ fclose ( tmpfp );
+ fclose ( ifp ) ;
+ if (h.column_type == 'T' && h.type_count > 1) {
+ for ( i=0; i < h.nbins; i++ ) xvt_free(d[i].value.strval);
+ }
+ xvt_free ((char*)d);
+ return ( h.nbins ) ;
+
+}
+
+#ifdef PROTO
+ThematicIndexDirectory tidx_linear_search( char *value,
+ ThematicIndexHeader h,
+ FILE *ifp )
+#else
+ThematicIndexDirectory tidx_linear_search( value, h, ifp )
+char *value;
+ThematicIndexHeader h;
+FILE *ifp;
+#endif
+{
+ int32 i , ival = 0;
+ short sval = 0 , Match = (-1) ;
+ float fval = (float)0.0;
+ double dval = 0.0 , atof () ;
+ date_type dateval;
+ char *buf = (char *) NULL, bufalloc=0 ;
+ ThematicIndexDirectory d;
+
+ d.value.ival = 0;
+ d.start_offset = 0;
+ d.num_items = 0;
+
+ if ( value ) /* search for pattern */
+ switch ( h.column_type ) { /* using address */
+ case 'I':
+ memcpy ( &ival, value, sizeof (int32)) ;
+ break ;
+ case 'S':
+ memcpy ( &sval, value, sizeof (short int)) ;
+ break ;
+ case 'F':
+ memcpy ( &fval, value, sizeof (float)) ;
+ break ;
+ case 'R':
+ memcpy ( &dval, value, sizeof (double)) ;
+ break ;
+ case 'T':
+ buf = (char*)xvt_malloc ((size_t)h.type_count);
+ /* leave value as is */
+ bufalloc = 1;
+ break ;
+ case 'D':
+ /* leave value as is */
+ break;
+ }
+ else return d;
+
+ for ( i=0; i < h.nbins; i++ ) {
+
+ switch ( h.column_type ) {
+ case 'I':
+ Read_Vpf_Int ( &d.value.ival, ifp, 1) ;
+ if ( ival == d.value.ival ) {
+ /* found the match */
+ Match = (short)i;
+ i = h.nbins ; /* exit */
+ }
+ break ;
+ case 'S':
+ Read_Vpf_Short ( &d.value.sval, ifp, 1) ;
+ if ( sval == d.value.sval ) {
+ /* found the match */
+ Match = (short)i;
+ i = h.nbins ; /* exit */
+ }
+ break ;
+ case 'F':
+ Read_Vpf_Float ( &d.value.fval, ifp, 1) ;
+ if ( fval == d.value.fval ) {
+ /* found the match */
+ Match = (short)i;
+ i = h.nbins ; /* exit */
+ }
+ break ;
+ case 'R':
+ Read_Vpf_Float ( &d.value.dval, ifp, 1) ;
+ if ( dval == d.value.dval ) {
+ /* found the match */
+ Match = (short)i;
+ i = h.nbins ; /* exit */
+ }
+ break ;
+ case 'T':
+ Read_Vpf_Char ( buf, ifp, h.type_count ) ;
+ bufalloc = 1;
+ if ( ! strcmp ( value, buf ) ) {
+ /* found the match */
+ Match = (short)i;
+ i = h.nbins ; /* exit */
+ }
+ break ;
+ case 'D':
+ Read_Vpf_Char ( dateval, ifp, sizeof(date_type) ) ;
+ dateval[sizeof(date_type)-1] = '\0';
+ if ( ! strncmp ( value, dateval, sizeof(date_type) ) ) {
+ /* found the match */
+ Match = (short)i;
+ i = h.nbins ; /* exit */
+ }
+ break ;
+ } /* end of switch */
+
+ Read_Vpf_Int ( &d.start_offset, ifp, 1) ;
+ Read_Vpf_Int ( &d.num_items, ifp, 1) ;
+
+ } /* end of i loop */
+
+ if ( bufalloc ) xvt_free ( buf ) ;
+
+ if (Match < 0) {
+ d.value.ival = 0;
+ d.start_offset = 0;
+ d.num_items = 0;
+ }
+
+ return d;
+}
+
+#ifdef PROTO
+ThematicIndexDirectory tidx_binary_search( char *value,
+ ThematicIndexHeader h,
+ FILE *ifp )
+#else
+ThematicIndexDirectory tidx_binary_search( value, h, ifp )
+char *value;
+ThematicIndexHeader h;
+FILE *ifp;
+#endif
+{
+ int32 i , ival = 0, left, right;
+ short int sval = 0 , found = 0 , recsize = 0;
+ float fval = (float)0.0 ;
+ double dval = 0.0 , atof () ;
+ date_type dateval;
+ char *buf = (char *) NULL, bufalloc=0 ;
+ ThematicIndexDirectory d ;
+
+ d.value.ival = 0;
+ d.start_offset = 0;
+ d.num_items = 0;
+
+ if ( value ) /* search for pattern */
+ switch ( h.column_type ) { /* using address */
+ case 'I':
+ memcpy ( &ival, value, sizeof (int32)) ;
+ recsize = sizeof(int32) + 8;
+ break ;
+ case 'S':
+ memcpy ( &sval, value, sizeof (short int)) ;
+ recsize = sizeof(short int) + 8;
+ break ;
+ case 'F':
+ memcpy ( &fval, value, sizeof (float)) ;
+ recsize = sizeof(float) + 8;
+ break ;
+ case 'R':
+ memcpy ( &dval, value, sizeof (double)) ;
+ recsize = sizeof(double) + 8;
+ break ;
+ case 'T':
+ buf = (char*)xvt_malloc ((size_t)h.type_count);
+ /* leave value as is */
+ bufalloc = 1;
+ recsize = (short)(h.type_count * sizeof(char) + 8);
+ break ;
+ case 'D':
+ recsize = sizeof(date_type) + 8;
+ break;
+ }
+ else return d;
+
+ left = 0;
+ right = h.nbins-1;
+
+ do {
+
+ i = (left+right)/2;
+ fseek(ifp,THEMATIC_INDEX_HEADER_SIZE+(i*recsize),0);
+
+ switch ( h.column_type ) {
+ case 'I':
+ Read_Vpf_Int ( &d.value.ival, ifp, 1) ;
+ if ( ival == d.value.ival )
+ found = 1;
+ else if ( d.value.ival > ival )
+ right = i-1;
+ else
+ left = i+1;
+ break ;
+ case 'S':
+ Read_Vpf_Short ( &d.value.sval, ifp, 1) ;
+ if ( sval == d.value.sval )
+ found = 1;
+ else if ( d.value.sval > sval )
+ right = i-1;
+ else
+ left = i+1;
+ break ;
+ case 'F':
+ Read_Vpf_Float ( &d.value.fval, ifp, 1) ;
+ if ( fval == d.value.fval )
+ found = 1;
+ else if ( d.value.fval > fval )
+ right = i-1;
+ else
+ left = i+1;
+ break ;
+ case 'R':
+ Read_Vpf_Float ( &d.value.dval, ifp, 1) ;
+ if ( dval == d.value.dval )
+ found = 1;
+ else if ( d.value.dval > dval )
+ right = i-1;
+ else
+ left = i+1;
+ break ;
+ case 'T':
+ Read_Vpf_Char ( buf, ifp, h.type_count ) ;
+ bufalloc = 1;
+ if ( strcmp ( value, buf ) == 0 )
+ found = 1;
+ else if ( strcmp( value, buf ) < 0 )
+ right = i-1;
+ else
+ left = i+1;
+ break;
+ case 'D':
+ Read_Vpf_Char ( dateval, ifp, sizeof(date_type) ) ;
+ dateval[sizeof(date_type)-1]='\0';
+ bufalloc = 1;
+ if ( strncmp ( value, dateval, sizeof(date_type) ) == 0 )
+ found = 1;
+ else if ( strncmp( value, dateval, sizeof(date_type) ) < 0 )
+ right = i-1;
+ else
+ left = i+1;
+ break;
+ } /* end of switch */
+
+ } while ((!found) && (left <= right));
+
+ if (found) {
+ Read_Vpf_Int ( &d.start_offset, ifp, 1) ;
+ Read_Vpf_Int ( &d.num_items, ifp, 1) ;
+ } else {
+ d.value.ival = 0;
+ }
+
+ if ( bufalloc ) xvt_free ( buf ) ;
+
+ return d;
+}
+
+/*************************************************************************
+ *
+ *N read_thematic_index
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To read an index file, regardless of its type ( T or G ) and
+ * return a set type array
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * idxname <input> == (char *) name of index file
+ * value <input> == (char *) address of value to search on.
+ * THE PROGRAMMER MUST INSURE THAT THIS ADDRESS
+ * CORRESPONDS TO THE TABLE COLUMN AND INDEX FILE.
+ *
+ * Returns:
+ *
+ * set_type a set corresponding to the vpf table, where each
+ * bit relates to the ID in the table. This set is
+ * allocated here and should be nuked when no longer
+ * needed.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * read_thematic_index_header see below
+ * set_init SET.C
+ * set_insert
+ * Vpf_Read_* VPFREAD.C
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+set_type read_thematic_index ( char *idxname,
+ char *value )
+#else
+set_type read_thematic_index ( idxname, value )
+char *idxname;
+char *value;
+#endif
+{
+ int32 i , ival = 0;
+ short int sval = 0;
+ FILE *ifp ;
+ char hack[80] ;
+ ThematicIndexHeader h ;
+ ThematicIndexDirectory d ;
+ set_type s ;
+
+ /* open output index file */
+
+ if (( ifp = muse_file_open ( idxname, "rb" )) == NULL ) {
+ sprintf ( hack, "No such index < %s >", idxname ) ;
+ SWhimper ( hack ) ;
+ }
+
+ if (read_thematic_index_header (&h, ifp) == 0L ) {
+ fclose(ifp);
+ SWhimper ( "error reading index header" ) ;
+ }
+
+ if ( h.index_type == 'G' ) {
+ fclose ( ifp ) ;
+ s = read_gazetteer_index ( idxname, value ) ;
+ return s ;
+ }
+
+ s = set_init ( h.table_nrows ) ;
+
+ if (h.sort == 'S')
+ d = tidx_binary_search(value,h,ifp);
+ else
+ d = tidx_linear_search(value,h,ifp);
+
+ if ( d.start_offset == 0 ) {
+ fclose(ifp);
+ return s;
+ }
+
+ if ( d.num_items == 0) {
+ set_insert( d.start_offset, s );
+ fclose(ifp);
+ return s;
+ }
+
+ if ( fseek ( ifp, d.start_offset, 0 ) != 0 ) {
+ fclose(ifp);
+ SWhimper ( "error in fseek") ;
+ }
+
+ /* read data into user-defined pointer. User must free this pointer */
+ if ( h.id_data_type == 'I' )
+ for ( i=0 ; i < d.num_items; i++ ) {
+ Read_Vpf_Int ( &ival, ifp, 1 ) ;
+ set_insert ( ival, s ) ; /* set the id in the set */
+ }
+ else
+ for ( i=0 ; i < d.num_items; i++ ) {
+ Read_Vpf_Short ( &sval, ifp, 1 ) ;
+ set_insert ( (int32) sval, s ) ;
+ }
+
+ fclose ( ifp ) ;
+
+ return s ; /* also return set */
+
+} /*end of read_index */
+
+
+/*************************************************************************
+ *
+ *N open_thematic_index
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Open and initialize a thematic index.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * idxname <input> == (char *) name of index file
+ *
+ * Returns:
+ *
+ * ThematicIndex Thematic index structure.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * read_thematic_index_header see below
+ * set_init SET.C
+ * set_insert
+ * Vpf_Read_* macros
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+ThematicIndex open_thematic_index ( char *idxname, int32 storage )
+#else
+ThematicIndex open_thematic_index ( idxname, storage )
+char *idxname;
+int32 storage;
+#endif
+{
+ char hack[80];
+ ThematicIndex idx ;
+ int32 i;
+
+ idx.d = NULL;
+ idx.gid = NULL;
+
+ /* open output index file */
+
+ if (( idx.fp = muse_file_open ( idxname, "rb" )) == NULL ) {
+ sprintf ( hack, "No such index < %s >", idxname ) ;
+ OWhimper ( hack ) ;
+ }
+
+ if (read_thematic_index_header (&idx.h, idx.fp) == 0L)
+ OWhimper ( "error reading index header" ) ;
+
+ if ( idx.h.index_type == 'G' ) {
+ /* gazetteer_index */
+ if (read_gazetteer_index_directory(&idx.gid,&idx.h,idx.fp) == 0L) {
+ fclose(idx.fp);
+ idx.fp = NULL;
+ }
+ return idx;
+ }
+
+ if (storage == RAM) {
+ idx.d = (ThematicIndexDirectory*)xvt_malloc ((size_t)idx.h.nbins *
+ sizeof(ThematicIndexDirectory));
+ if (idx.d) {
+
+ for ( i=0; i < idx.h.nbins; i++ ) {
+
+ switch ( idx.h.column_type ) {
+ case 'I':
+ Read_Vpf_Int ( &idx.d[i].value.ival, idx.fp, 1) ;
+ break ;
+ case 'S':
+ Read_Vpf_Short ( &idx.d[i].value.sval, idx.fp, 1) ;
+ break ;
+ case 'F':
+ Read_Vpf_Float ( &idx.d[i].value.fval, idx.fp, 1) ;
+ break ;
+ case 'R':
+ Read_Vpf_Float ( &idx.d[i].value.dval, idx.fp, 1) ;
+ break ;
+ case 'T':
+ if (idx.h.type_count == 1) {
+ Read_Vpf_Char ( &idx.d[i].value.cval, idx.fp,
+ idx.h.type_count ) ;
+ } else {
+ idx.d[i].value.strval = (char*)xvt_malloc ((size_t)idx.h.type_count+1);
+ Read_Vpf_Char ( idx.d[i].value.strval, idx.fp,
+ idx.h.type_count ) ;
+ idx.d[i].value.strval[idx.h.type_count] = '\0';
+ }
+ break ;
+ case 'D':
+ idx.d[i].value.strval = (char*)xvt_malloc (sizeof(date_type)+1);
+ Read_Vpf_Char ( idx.d[i].value.strval, idx.fp,
+ sizeof(date_type) );
+ idx.d[i].value.strval[sizeof(date_type)-1] = '\0';
+ break ;
+ } /* end of switch */
+
+ Read_Vpf_Int ( &idx.d[i].start_offset, idx.fp, 1) ;
+ Read_Vpf_Int ( &idx.d[i].num_items, idx.fp, 1) ;
+
+ } /* end of i loop */
+
+ if (idx.h.sort != 'S') {
+ /* Sort the directory in memory */
+ switch ( idx.h.column_type ) {
+ case 'I':
+ qsort ((void*)idx.d, (size_t)idx.h.nbins,
+ sizeof (ThematicIndexDirectory), Icmpval);
+ break ;
+ case 'S':
+ qsort((void*)idx.d, (size_t)idx.h.nbins,
+ sizeof(ThematicIndexDirectory), Scmpval);
+ break ;
+ case 'F':
+ qsort ((void*)idx.d, (size_t)idx.h.nbins,
+ sizeof(ThematicIndexDirectory), Fcmpval);
+ break ;
+ case 'R':
+ qsort ((void*)idx.d, (size_t)idx.h.nbins,
+ sizeof(ThematicIndexDirectory), Dcmpval);
+ break ;
+ case 'T':
+ if (idx.h.type_count == 1) {
+ qsort ((void*)idx.d, (size_t)idx.h.nbins,
+ sizeof (ThematicIndexDirectory), Ccmpval);
+ } else {
+ qsort ((void*)idx.d, (size_t)idx.h.nbins,
+ sizeof (ThematicIndexDirectory), STRcmpval);
+ }
+ break ;
+ case 'D':
+ qsort ((void*)idx.d, (size_t)idx.h.nbins,
+ sizeof (ThematicIndexDirectory), STRcmpval);
+ break ;
+ } /* end of switch */
+
+ }
+ }
+
+ } else {
+ idx.d = NULL;
+ }
+
+ return idx;
+}
+
+/*************************************************************************
+ *
+ *N search_thematic_index
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To search an index file, regardless of its type ( T or G ) and
+ * return a set type array
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * idx <input> == (ThematicIndex) thematic index structure
+ * previously initialized with open_thematic_index().
+ * value <input> == (char *) address of value to search on.
+ * THE PROGRAMMER MUST INSURE THAT THIS ADDRESS
+ * CORRESPONDS TO THE TABLE COLUMN AND INDEX FILE.
+ * It should never be NULL.
+ *
+ * Returns:
+ *
+ * set_type a set corresponding to the vpf table, where each
+ * bit relates to the ID in the table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * read_thematic_index_header see below
+ * set_init SET.C
+ * set_insert
+ * Vpf_Read_* macros
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+set_type search_thematic_index ( ThematicIndex *idx,
+ char *value )
+#else
+set_type search_thematic_index ( idx, value )
+ThematicIndex *idx;
+char *value;
+#endif
+{
+ int32 i , ival = 0;
+ short int sval = 0 ;
+ ThematicIndexDirectory d, dsearch, *dptr = NULL;
+ set_type s ;
+
+ /* open output index file */
+
+ if (!idx->fp) {
+ s = set_init(1);
+ return s;
+ }
+
+ if ( idx->h.index_type == 'G' ) {
+ s = search_gazetteer_index ( idx, value ) ;
+ return s ;
+ }
+
+ /* create set */
+
+ s = set_init ( idx->h.table_nrows ) ;
+
+ /* Look for a matching directory entry */
+
+ d.start_offset = 0;
+
+ if (idx->d) {
+
+ /* Directory in memory */
+ switch ( idx->h.column_type ) {
+ case 'I':
+ memcpy( &dsearch.value.ival, value, sizeof(int32) );
+ dptr = (ThematicIndexDirectory *)bsearch(
+ (void *)&dsearch, (void *)idx->d,
+ (size_t)idx->h.nbins, sizeof(ThematicIndexDirectory),
+ Icmpval);
+ break ;
+ case 'S':
+ memcpy( &dsearch.value.sval, value, sizeof(short int) );
+ dptr = (ThematicIndexDirectory *)bsearch(
+ (void *)&dsearch, (void *)idx->d,
+ (size_t)idx->h.nbins, sizeof(ThematicIndexDirectory),
+ Scmpval);
+ break ;
+ case 'F':
+ memcpy( &dsearch.value.fval, value, sizeof(float) );
+ dptr = (ThematicIndexDirectory *)bsearch(
+ (void *)&dsearch, (void *)idx->d,
+ (size_t)idx->h.nbins, sizeof(ThematicIndexDirectory),
+ Fcmpval);
+ break ;
+ case 'R':
+ memcpy( &dsearch.value.dval, value, sizeof(double) );
+ dptr = (ThematicIndexDirectory *)bsearch(
+ (void *)&dsearch, (void *)idx->d,
+ (size_t)idx->h.nbins, sizeof(ThematicIndexDirectory),
+ Dcmpval);
+ break ;
+ case 'T':
+ if (idx->h.type_count == 1) {
+ memcpy( &dsearch.value.cval, value, sizeof(char) );
+ dptr = (ThematicIndexDirectory *)bsearch(
+ (void *)&dsearch, (void *)idx->d,
+ (size_t)idx->h.nbins, sizeof(ThematicIndexDirectory),
+ Ccmpval);
+ } else {
+ dsearch.value.strval = (char*)xvt_malloc((size_t)idx->h.type_count+1);
+ memcpy (dsearch.value.strval, value, (size_t)idx->h.type_count);
+ dsearch.value.strval[idx->h.type_count] = '\0';
+ dptr = (ThematicIndexDirectory *)bsearch(
+ (void *)&dsearch, (void *)idx->d,
+ (size_t)idx->h.nbins, sizeof(ThematicIndexDirectory),
+ STRcmpval);
+ xvt_free(dsearch.value.strval);
+ }
+ break ;
+ case 'D':
+ dsearch.value.strval = (char*)xvt_malloc(sizeof(date_type)+1);
+ memcpy( dsearch.value.strval, value, sizeof(date_type) );
+ dsearch.value.strval[sizeof(date_type)-1] = '\0';
+ dptr = (ThematicIndexDirectory *)bsearch(
+ (void *)&dsearch, (void *)idx->d,
+ (size_t)idx->h.nbins, sizeof(ThematicIndexDirectory),
+ STRcmpval);
+ xvt_free(dsearch.value.strval);
+ break ;
+ } /* end of switch */
+
+ if (dptr)
+ d = *dptr;
+ else
+ d.start_offset = 0;
+
+ } else {
+
+ /* Search directory on disk */
+ if (idx->h.sort == 'S')
+ d = tidx_binary_search(value,idx->h,idx->fp);
+ else
+ d = tidx_linear_search(value,idx->h,idx->fp);
+ }
+
+ if ( d.start_offset == 0 ) {
+ return s;
+ }
+
+ if ( d.num_items == 0) {
+ set_insert( d.start_offset, s );
+ return s;
+ }
+
+ /* We've got a match, so now read the ids in */
+
+ if ( fseek ( idx->fp, d.start_offset, 0 ) != 0 ) {
+ set_nuke(&s);
+ SWhimper ( "error in fseek") ;
+ }
+
+ /* read data into user-defined pointer. User must free this pointer */
+
+ if ( idx->h.id_data_type == 'I' )
+ for ( i=0 ; i < d.num_items; i++ ) {
+ Read_Vpf_Int ( &ival, idx->fp, 1 ) ;
+ set_insert ( ival, s ) ; /* set the id in the set */
+ }
+ else
+ for ( i=0 ; i < d.num_items; i++ ) {
+ Read_Vpf_Short ( &sval, idx->fp, 1 ) ;
+ set_insert ( (int32) sval, s ) ;
+ }
+
+ return s ; /* also return set */
+
+} /*end of search_index */
+
+
+/*************************************************************************
+ *
+ *N close_thematic_index
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Close a thematic index.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * idx <input> == (ThematicIndex *) thematic index
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * read_thematic_index_header see below
+ * set_init SET.C
+ * set_insert
+ * Vpf_Read_* macros
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void close_thematic_index ( ThematicIndex *idx )
+#else
+void close_thematic_index ( idx )
+ThematicIndex *idx;
+#endif
+{
+ int32 i;
+
+ fclose ( idx->fp ) ;
+ if (idx->d) {
+ if ( (idx->h.column_type == 'T' && idx->h.type_count > 1) ||
+ (idx->h.column_type == 'D') ) {
+ for (i=0;i<idx->h.nbins;i++)
+ if (idx->d[i].value.strval)
+ xvt_free(idx->d[i].value.strval);
+ }
+ xvt_free ((char*)idx->d);
+ }
+ if (idx->gid)
+ xvt_free ((char*)idx->gid);
+}
+
+/*************************************************************************
+ *
+ *N create_gazetteer_index
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To create a gazetteer file
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ *
+ * tablename <input> == (char *) the name of an existing file
+ * <= 11 chars long
+ * idx_fname <input> == (char *) name of index file
+ * columnname <input> == (char *) is a column existing in tablename
+ * <= 24 chars long
+ *
+ * idx_set <input> == (char *) is an array of printable ASCII characters
+ * with no duplicates
+ *
+ * return value < 0
+ *
+ * -1 some OS error, check errno for something more exact
+ * -2 tablename is not a vpf table
+ * -3 columnname is not in the vpf table
+ * -4 column type not text
+ *
+ * return value = 0
+ * an index record for each character in index_set has been created
+ *
+ * the index file name is the same as tablename but with .?ti
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Jim Tenbrink
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * read_thematic_index_header see below
+ * set_init SET.C
+ * set_insert
+ * Vpf_Read_* macros
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+
+#ifdef PROTO
+int32 create_gazetteer_index (char *tablename,
+ char *idx_fname ,
+ char *columnname,
+ char *idx_set)
+#else
+int32 create_gazetteer_index (tablename, idx_fname, columnname, idx_set)
+char *tablename;
+char *idx_fname;
+char *columnname;
+char *idx_set;
+#endif
+{
+ vpf_table_type t;
+ row_type r;
+ int32 c;
+ FILE *idx_fp;
+ ThematicIndexHeader gi;
+ ThematicIndexDirectory *gid;
+ set_type *idx_bit_sets;
+ register int32 i, j, l;
+ int32 set_byte_size;
+
+ if (!tablename) return -2;
+ if (!idx_fname) return -1;
+ if (!columnname) return -3;
+ if (!idx_set) return -1;
+
+ t = vpf_open_table(tablename, disk, "rb", '\0');
+ if (!t.fp) return -2;
+#ifdef _MSDOS
+ c = table_pos(strupr(columnname), t);
+#else
+ c = table_pos(columnname, t);
+#endif
+ if (c<0) return -3;
+
+ if (t.header[c].type != 'T') {
+ vpf_close_table(&t);
+ return -4;
+ }
+
+ idx_fp = muse_file_open(idx_fname, "wb");
+
+ if (idx_fp == NULL) {
+ vpf_close_table(&t);
+ return -1;
+ }
+
+ /* only write out the table name, not the rest */
+
+ for ( i = strlen ( tablename ); i > 0; i-- )
+ if ( tablename[i] == DIR_SEPARATOR ) break ;
+ if ( tablename[i] == DIR_SEPARATOR )
+#ifdef _MSDOS
+ strncpy ( gi.vpf_table_name, strupr ( &tablename[i+1] ), 13 ) ;
+#else
+ strncpy ( gi.vpf_table_name, &tablename[i+1], 13 ) ;
+#endif
+ else
+#ifdef _MSDOS
+ strncpy(gi.vpf_table_name, strupr ( tablename), 13 );
+#else
+ strncpy(gi.vpf_table_name, tablename, 13);
+#endif
+ strncpy(gi.vpf_column_name, columnname,25);
+
+ gi.column_type = 'T';
+ gi.index_type = 'G';
+ gi.type_count = 1 ;
+ gi.id_data_type = 'S' ;
+ gi.nbins = strlen(idx_set);
+ gi.table_nrows = t.nrows;
+ gi.sort = ' ';
+ gi.padding[0] = ' ';
+ gi.padding[1] = ' ';
+ gi.padding[2] = ' ';
+ set_byte_size = (int32)ceil(t.nrows/8.0);
+
+ /* force input string to lower case , rdf */
+
+ for ( i=0; i < gi.nbins; i++ )
+ idx_set[i] = (char)tolower (idx_set[i]);
+
+ /*
+ * ti.nbytes is the offset into the index file at which the
+ * bit arrays start
+ */
+
+ gi.nbytes = THEMATIC_INDEX_HEADER_SIZE +
+ gi.nbins * ( sizeof (char) + DIRECTORY_SIZE ) ;
+
+ gid = (ThematicIndexDirectory*)xvt_malloc (sizeof (ThematicIndexDirectory)
+ * (size_t)gi.nbins);
+ idx_bit_sets = (set_type*)xvt_malloc (sizeof(set_type) * (size_t)gi.nbins);
+
+ for (i = 0; i < gi.nbins; i++) {
+ idx_bit_sets[i] = set_init(t.nrows);
+ gid[i].value.cval = idx_set[i];
+ gid[i].num_items = 1;
+ }
+
+ /*
+ * lets suck up some CPU cycles here
+ */
+ for (l = 0; l < t.nrows; l++) {
+
+ r = get_row(l+1, t);
+
+ for (i = 0; i < gi.nbins; i++)
+ for (j = 0; j < r[c].count; j++)
+ /* No matter the input character, make it lower case , rdf added */
+ if ( tolower (*((char *) r[c].ptr + j)) == idx_set[i]) {
+ set_insert(l, idx_bit_sets[i]);
+ break;
+ }
+
+ free_row(r, t);
+
+ }
+
+ vpf_close_table(&t);
+
+ if (write_thematic_index_header (gi, idx_fp) == '\0') {
+ fclose(idx_fp);
+ for (i = 0; i < gi.nbins; i++)
+ set_nuke(&idx_bit_sets[i]);
+ xvt_free ((char*)idx_bit_sets);
+ xvt_free ((char*)gid);
+ return -1;
+ }
+
+ if (write_gazetteer_index_directory(gi,
+ gid,
+ set_byte_size,
+ idx_fp) == 0 ) {
+ fclose(idx_fp);
+ for (i = 0; i < gi.nbins; i++)
+ set_nuke(&idx_bit_sets[i]);
+ xvt_free ((char*)idx_bit_sets);
+ xvt_free ((char*)gid);
+ return -1;
+ }
+
+ for (i = 0; i < gi.nbins; i++) {
+ if ( ! Write_Vpf_Char(idx_bit_sets[i].buf, idx_fp, set_byte_size) ) {
+ fclose(idx_fp);
+ for (i = 0; i < gi.nbins; i++)
+ set_nuke(&idx_bit_sets[i]);
+ return -1;
+ }
+ }
+
+ fclose(idx_fp);
+ for (i = 0; i < gi.nbins; i++)
+ set_nuke(&idx_bit_sets[i]);
+ xvt_free ((char*)idx_bit_sets);
+ xvt_free ((char*)gid);
+
+ return 0;
+}
+
+
+
+/*************************************************************************
+ *
+ *N read_gazetteer_index
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To read an gazeeteer index file, and return a set type array
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * idx_fname <input> == (char *) the name of a vpf gazetteer index
+ * created with a call to to create_gaz_index.
+ *
+ * query_str <input> == (char *) string that contains only characters
+ * which form a subset of the characters passed
+ * to create_gaz_index when idx_fname was created.
+ *
+ * the vpf table from which the file idx_fname was derived must
+ * exist in the same directory as idx_fname
+ *
+ * out: case the returned set size > 0
+ * a bit array which can be used as a rough filter for the
+ * vpf table from which the index file idx_fname was derived.
+ *
+ * bits which are set in the array are the record numbers in the vpf table
+ * (from which idx_fname was derived) which may contain query_string
+ *
+ * case the returned set size = 0
+ * some system error occurred
+ * most likely the indexed vpf table couldn't be found in the
+ * same directory
+ *
+ * note: query_str is treated as a set, so duplicate occurrences
+ * of the same character are ignored. I need a way of flagging
+ * those duplicate occurrences. Instead of sorting the string
+ * and removing duplicates, I use the num_items field in each
+ * element of the directory array.
+ *
+ * Returns:
+ *
+ * set_type a set corresponding to the vpf table, where each
+ * bit relates to the ID in the table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Jim Tenbrink
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * read_thematic_index_header see below
+ * set_init SET.C
+ * set_insert
+ * Vpf_Read_* macros
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+set_type read_gazetteer_index (char *idx_fname, char *query_str )
+#else
+set_type read_gazetteer_index (idx_fname, query_str )
+char *idx_fname;
+char *query_str;
+#endif
+{
+ ThematicIndexHeader gi;
+ ThematicIndexDirectory
+ * gid;
+ FILE * idx_fp;
+ static set_type query_set = {0, 0},
+ xsect_set,
+ result_set;
+ register int32 query_len = strlen(query_str),
+ i,
+ j;
+ int32 set_byte_size;
+ char query_char;
+
+ if (!idx_fname) return query_set;
+ if (!query_str) return query_set;
+
+ idx_fp = muse_file_open(idx_fname, "rb");
+
+ if (idx_fp == NULL)
+ return query_set;
+
+ if (read_thematic_index_header (&gi, idx_fp) == '\0') {
+ fclose(idx_fp);
+ return query_set;
+ }
+
+ if (read_gazetteer_index_directory (&gid, &gi, idx_fp) == '\0') {
+ fclose(idx_fp);
+ return query_set;
+ }
+
+ for (j = 0; j < gi.nbins; j++)
+ gid[j].num_items = 0;
+
+ query_set = set_init(gi.table_nrows);
+ xsect_set = set_init(gi.table_nrows);
+
+ set_on(query_set);
+ set_byte_size = (int32)ceil (gi.table_nrows/8.0);
+
+ for (i = 0; i < query_len; i++) {
+
+ query_char = (char)tolower (query_str[i]);
+
+ for (j = 0; j < gi.nbins; j++)
+ if (gid[j].value.cval == query_char) {
+ gid[j].num_items++;
+ break;
+ }
+ if (gid[j].num_items > 1)
+ continue;
+
+ fseek(idx_fp, gid[j].start_offset, 0);
+ if ( ! Read_Vpf_Char(xsect_set.buf, idx_fp, set_byte_size) ) {
+ xvt_note ("read_gazetteer_index: error reading index"); /*DGM*/
+ set_off(query_set);
+ set_nuke(&xsect_set);
+ fclose(idx_fp);
+ xvt_free ((char*)gid);
+ return query_set ;
+ }
+
+ result_set = set_intersection(query_set, xsect_set);
+ set_assign(&query_set, result_set);
+ set_nuke(&result_set);
+
+ }
+
+ fclose(idx_fp);
+ xvt_free ((char*)gid);
+ set_nuke(&xsect_set);
+
+ return query_set;
+}
+
+/*************************************************************************
+ *
+ *N search_gazetteer_index
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To search an gazeeteer index file, and return a set type array
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * in : idx is the gazetteer index opened with open_thematic_index
+ *
+ * query_str contains only characters which form a subset of
+ * the characters passed to create_gaz_index when idx_fname
+ * was created
+ *
+ * the vpf table from which the file idx_fname was derived must
+ * exist in the same directory as idx_fname
+ *
+ * out: case the returned set size > 0
+ * a bit array which can be used as a rough filter for the
+ * vpf table from which the index file idx_fname was derived.
+ *
+ * bits which are set in the array are the record numbers in the vpf table
+ * (from which idx_fname was derived) which may contain query_string
+ *
+ * case the returned set size = 0
+ * some system error occurred
+ * most likely the indexed vpf table couldn't be found in the
+ * same directory
+ *
+ * note: query_str is treated as a set, so duplicate occurrences
+ * of the same character are ignored. I need a way of flagging
+ * those duplicate occurrences. Instead of sorting the string
+ * and removing duplicates, I use the num_items field in each
+ * element of the directory array.
+ *
+ * Returns:
+ *
+ * set_type a set corresponding to the vpf table, where each
+ * bit relates to the ID in the table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Jim Tenbrink
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * read_thematic_index_header see below
+ * set_init SET.C
+ * set_insert
+ * Vpf_Read_* macros
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+set_type search_gazetteer_index (ThematicIndex *idx, char *query_str )
+#else
+set_type search_gazetteer_index ( idx, query_str )
+ThematicIndex *idx;
+char *query_str;
+#endif
+{
+ static set_type query_set = {0, 0}, xsect_set, result_set;
+ register int32 query_len = strlen(query_str),
+ i,
+ j;
+ int32 set_byte_size;
+ char query_char;
+
+ if (idx->fp == NULL)
+ return query_set;
+
+ for (j = 0; j < idx->h.nbins; j++)
+ idx->gid[j].num_items = 0;
+
+ query_set = set_init(idx->h.table_nrows);
+ xsect_set = set_init(idx->h.table_nrows);
+
+ set_on(query_set);
+ set_byte_size = (int32)ceil (idx->h.table_nrows / 8.0);
+
+ for (i = 0; i < query_len; i++) {
+
+ query_char = (char)tolower (query_str[i]);
+
+ for (j = 0; j < idx->h.nbins; j++)
+ if (idx->gid[j].value.cval == query_char) {
+ idx->gid[j].num_items++;
+ break;
+ }
+ if (idx->gid[j].num_items > 1)
+ continue;
+
+ fseek(idx->fp, idx->gid[j].start_offset, 0);
+ if ( ! Read_Vpf_Char(xsect_set.buf, idx->fp, set_byte_size) ) {
+ set_type err;
+ err = set_init ( 1 ) ;
+ xvt_note ("read_gazetteer_index: error reading index"); /*DGM*/
+ return err ;
+ }
+
+ result_set = set_intersection(query_set, xsect_set);
+ set_assign(&query_set, result_set);
+ set_nuke(&result_set);
+
+ }
+
+ set_nuke(&xsect_set);
+
+ return query_set;
+}
+
+/*************************************************************************
+ *
+ *N read_gazetteer_index_directory
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To read a gazetteer index directory.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * in : *gid is undefined
+ *
+ * *gi is the gazetteer index header for the open index file
+ * referenced by idx_fp
+ *
+ * out: case return value is one
+ * *gid is an array of directory entries with gi->nbin elements
+ *
+ * the sval member of the value union contains the indexed character
+ *
+ * the start_offset member of the directory structure contains the
+ * disk offset for the start of the indexed characters bit array
+ *
+ * case zero return value
+ * an error was probably encountered during the read
+ * *gid is undefined
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * read_thematic_index_header see below
+ * set_init SET.C
+ * set_insert
+ * Vpf_Read_* macros
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 read_gazetteer_index_directory(
+ ThematicIndexDirectory **gid,
+ ThematicIndexHeader *gi,
+ FILE *idx_fp)
+#else
+int32 read_gazetteer_index_directory(gid, gi, idx_fp)
+ThematicIndexDirectory **gid;
+ThematicIndexHeader *gi;
+FILE *idx_fp;
+#endif
+{
+ int32 i;
+
+ if ( fseek ( idx_fp, THEMATIC_INDEX_HEADER_SIZE, 0 )!= 0 )
+ return 0 ;
+
+ *gid = (ThematicIndexDirectory *) xvt_malloc (sizeof (ThematicIndexDirectory)
+ * (size_t)gi->nbins);
+ if (*gid == NULL)
+ return 0;
+
+ for (i = 0; i < gi->nbins; i++) {
+ if ( ( ! Read_Vpf_Char( &( (*gid)[i].value.cval ), idx_fp, 1) ) ||
+ ( ! Read_Vpf_Int( &( (*gid)[i].start_offset ), idx_fp, 1) ) ||
+ ( ! Read_Vpf_Int( &( (*gid)[i].num_items ), idx_fp, 1) )) {
+ xvt_note ("read_gazetteer_index_directory: error reading dir"); /*DGM*/
+ return ('\0');
+ }
+ }
+ return 1;
+}
+
+/*************************************************************************
+ *
+ *N read_thematic_index_header
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To read the thematic index header in a standard way
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * h < in/out > == (ThematicIndexHeader *) header structure to be filled
+ * ifp <input> == ( FILE *ifp ) index file pointer
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * Read_Vpf_Int
+ * Read_Vpf_Char
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+
+#define RWhimper() { \
+ xvt_note ("\nread_thematic_index_header: error reading header");\
+ } /*DGM*/
+
+#ifdef PROTO
+int32 read_thematic_index_header ( ThematicIndexHeader *h, FILE *ifp )
+#else
+int32 read_thematic_index_header ( h, ifp )
+ThematicIndexHeader *h;
+FILE *ifp;
+#endif
+{
+
+/* char *valid_index_types = "TG"; DGM */
+ char *valid_index_types = "TGIB"; /* DGM */
+ char *valid_column_types = "TDISFR";
+ char *valid_id_data_types = "IS";
+ char *valid_sort = "S ";
+
+ if ( fseek ( ifp, 0, 0 ) != 0 ) /* rewind, just in case */
+ return 0 ; /* error */
+ if ( ! Read_Vpf_Int ( &h->nbytes, ifp, 1 ) )
+ RWhimper();
+ if ( ! Read_Vpf_Int ( &h->nbins, ifp, 1 ) )
+ RWhimper() ;
+ if ( ! Read_Vpf_Int ( &h->table_nrows, ifp, 1 ) )
+ RWhimper() ;
+ if ( ! Read_Vpf_Char ( &h->index_type, ifp, 1 ) )
+ RWhimper() ;
+ if ( ! Read_Vpf_Char ( &h->column_type, ifp, 1 ) )
+ RWhimper() ;
+ if ( ! Read_Vpf_Int ( &h->type_count, ifp, 1 ) )
+ RWhimper() ;
+ if ( ! Read_Vpf_Char ( &h->id_data_type, ifp, 1 ) )
+ RWhimper() ;
+ if ( ! Read_Vpf_Char ( &h->vpf_table_name, ifp, 12 ) )
+ RWhimper() ;
+ h->vpf_table_name[12] = '\0';
+ if ( ! Read_Vpf_Char ( &h->vpf_column_name, ifp, 25 ) )
+ RWhimper() ;
+ h->vpf_column_name[25] = '\0';
+ if ( ! Read_Vpf_Char ( &h->sort, ifp, 1 ) )
+ RWhimper() ;
+ h->sort = (char)toupper(h->sort);
+ if ( ! Read_Vpf_Char ( &h->padding, ifp, 3 ) )
+ RWhimper() ;
+
+ /* Perform a simple (but theoretically not foolproof) validity check */
+ if (!strchr (valid_index_types,(char)toupper(h->index_type)))
+ return ('\0');
+ if (!strchr (valid_column_types,(char)toupper(h->column_type)))
+ return ('\0');
+ if (!strchr (valid_id_data_types,(char)toupper(h->id_data_type)))
+ return ('\0');
+ if (!strchr (valid_sort,(char)toupper(h->sort)))
+ return ('\0');
+
+ return 1 ;
+}
+
+/*************************************************************************
+ *
+ *N write_thematic_index_header
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To write the thematic index header in a standard way
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * h < input > == (ThematicIndexHeader) header structure to write from
+ * ifp <input> == ( FILE *ifp ) index file pointer
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * Write_Vpf_Int
+ * Write_Vpf_Char
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+
+#define WWhimper() {\
+ xvt_note ("write_thematic_index_header: error reading header");}
+
+#ifdef PROTO
+int32 write_thematic_index_header ( ThematicIndexHeader h, FILE *ifp )
+#else
+int32 write_thematic_index_header ( h, ifp )
+ThematicIndexHeader h;
+FILE *ifp;
+#endif
+{
+ if ( fseek ( ifp, 0, 0 ) != 0 ) /* rewind, just in case */
+ WWhimper() ; /* error */
+ if ( ! Write_Vpf_Int ( &h.nbytes, ifp, 1 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Int ( &h.nbins, ifp, 1 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Int ( &h.table_nrows, ifp, 1 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Char ( &h.index_type, ifp, 1 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Char ( &h.column_type, ifp, 1 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Int ( &h.type_count, ifp, 1 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Char ( &h.id_data_type, ifp, 1 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Char ( &h.vpf_table_name, ifp, 12 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Char ( &h.vpf_column_name, ifp, 25 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Char ( &h.sort, ifp, 1 ) )
+ WWhimper() ;
+ if ( ! Write_Vpf_Char ( &h.padding, ifp, 3 ) )
+ WWhimper() ;
+ return 1 ;
+}
+
+
+/*************************************************************************
+ *
+ *N write_thematic_index_directory
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To write the thematic index header in a standard way
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * h < input > == (ThematicIndexHeader) header structure
+ * d < input > == (ThematicIndexDirectory *) directory array structure
+ * idsize < input > == (int32) size of each data element.
+ * for T indexes, this is either 2 bytes or 4 bytes
+ * for G indexes, it will be num_in_set (set)
+ * or the size of the bit array.
+ * ifp <input> == ( FILE *ifp ) index file pointer
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * Vpf_Write_*
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+
+#define WTWhimper() { \
+ xvt_note ("write_thematic_index_directory: error reading header");}
+
+#ifdef PROTO
+int32 write_thematic_index_directory ( ThematicIndexHeader h,
+ ThematicIndexDirectory *d,
+ int32 idsize , /* size of data */
+ FILE *ifp )
+#else
+int32 write_thematic_index_directory ( h, d, idsize , ifp )
+ThematicIndexHeader h;
+ThematicIndexDirectory *d;
+int32 idsize;/* size of data */
+FILE *ifp;
+#endif
+{
+ int32 offset = h.nbytes ,
+ i, zero=0 ;
+
+ /* rewind, just in case */
+ if ( fseek ( ifp, THEMATIC_INDEX_HEADER_SIZE, 0 ) != 0 )
+ WTWhimper() ;
+
+ for ( i=0; i < h.nbins; i++ ) {
+
+ switch ( h.column_type ) {
+ case 'I':
+ if ( ! Write_Vpf_Int ( &d[i].value.ival, ifp, 1 ) )
+ WTWhimper() ;
+ break ;
+ case 'T':
+ if (h.type_count == 1) {
+ if ( ! Write_Vpf_Char ( &d[i].value.cval, ifp, h.type_count ) )
+ WTWhimper() ;
+ } else {
+ if ( ! Write_Vpf_Char ( d[i].value.strval, ifp, h.type_count ) )
+ WTWhimper() ;
+ }
+ break ;
+ case 'D':
+ if ( ! Write_Vpf_Char ( d[i].value.strval, ifp, sizeof(date_type) ) )
+ WTWhimper() ;
+ break ;
+ case 'S':
+ if ( ! Write_Vpf_Short ( &d[i].value.sval, ifp, 1 ) )
+ WTWhimper() ;
+ break ;
+ case 'F':
+ if ( ! Write_Vpf_Float ( &d[i].value.fval, ifp, 1 ) )
+ WTWhimper() ;
+ break ;
+ case 'R':
+ if ( ! Write_Vpf_Double ( &d[i].value.dval, ifp, 1 ) )
+ WTWhimper() ;
+ break ;
+ } /* end of switch */
+
+ if (d[i].num_items > 1) {
+
+ if ( ! Write_Vpf_Int ( &offset, ifp, 1 ) )
+ WTWhimper() ;
+ d[i].start_offset = offset;
+
+ if ( ! Write_Vpf_Int ( &d[i].num_items, ifp, 1 ) )
+ WTWhimper() ;
+
+ /* this offset is constant, no matter the data type */
+
+ offset += ( idsize * d[i].num_items ) ;
+
+ } else {
+
+ /* start_offset has been set to the only id value above */
+ if ( ! Write_Vpf_Int ( &d[i].start_offset, ifp, 1 ) )
+ WTWhimper() ;
+
+ if ( ! Write_Vpf_Int ( &zero, ifp, 1 ) )
+ WTWhimper() ;
+
+ }
+
+ } /* end of i loop */
+
+ return 1 ;
+
+} /* end of write_directory */
+
+
+/*************************************************************************
+ *
+ *N write_gazetteer_index_directory
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * To write the gazetteer thematic index header in a standard way
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * h < input > == (ThematicIndexHeader) header structure
+ * d < input > == (ThematicIndexDirectory *) directory array structure
+ * idsize < input > == (int32) size of each data element.
+ * for T indexes, this is either 2 bytes or 4 bytes
+ * for G indexes, it will be num_in_set (set)
+ * or the size of the bit array.
+ * ifp <input> == ( FILE *ifp ) index file pointer
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn October 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * Vpf_Write_*
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+
+#define WTGWhimper() { \
+ xvt_note ("write_gazetteer_index_directory: error writing header");}
+
+#ifdef PROTO
+int32 write_gazetteer_index_directory ( ThematicIndexHeader h,
+ ThematicIndexDirectory *d,
+ int32 idsize , /* size of data */
+ FILE *ifp )
+#else
+int32 write_gazetteer_index_directory ( h, d, idsize, ifp )
+ThematicIndexHeader h;
+ThematicIndexDirectory *d;
+int32 idsize;
+FILE *ifp;
+#endif
+{
+ int32 offset = h.nbytes ,
+ i ;
+
+ /* rewind, just in case */
+
+ if ( fseek ( ifp, THEMATIC_INDEX_HEADER_SIZE, 0 )!= 0 )
+ WTGWhimper() ;
+
+ for ( i=0; i < h.nbins; i++ ) {
+
+ if ( ! Write_Vpf_Char ( &d[i].value.cval, ifp, 1 ) )
+ WTGWhimper() ;
+
+ if ( ! Write_Vpf_Int ( &offset, ifp, 1 ) )
+ WTGWhimper() ;
+ if ( ! Write_Vpf_Int ( &d[i].num_items, ifp, 1 ) )
+ WTGWhimper() ;
+
+ /* this offset is constant, no matter the data type */
+
+ offset += ( idsize * d[i].num_items ) ;
+
+ } /* end of i loop */
+
+ return 1 ;
+
+} /* end of write_directory */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftidx.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftidx.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpftidx.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,72 @@
+
+#ifndef __VPFTIDX_H__
+#define __VPFTIDX_H__ 1
+
+#include <stdio.h>
+#ifndef __SET_H__
+#include "set.h"
+#endif
+
+typedef struct { /* Total of 40 bytes */
+ int32 nbytes , /* 40 + directory length */
+ nbins , /* Directory size */
+ table_nrows ; /* Num rows in original table */
+ char index_type , /* T = thematic, G = gazetteer */
+ column_type ; /* T, I, R, S, F, K */
+ int32 type_count ; /* usually 1, but more for T */
+ char id_data_type , /* I if > 32767, else S */
+ vpf_table_name[13] ,
+ vpf_column_name[25] , /* 16 bytes + 9 for TILE_ID */
+ sort , /* 'S' if directory sorted */
+ padding[3] ; /* To make it a nice 60 bytes */
+} ThematicIndexHeader ;
+
+#define THEMATIC_INDEX_HEADER_SIZE 60
+
+#define DIRECTORY_SIZE (sizeof(int32)*2)
+
+#define MAX_ID 32767 /* Threshold between S and I ids */
+
+typedef union
+ {
+ char cval , *strval;
+ int32 ival;
+ short sval;
+ float fval;
+ double dval;
+ } ThematicIndexValue;
+
+typedef struct { /* length = sizeof (datatype) + */
+ ThematicIndexValue value; /* 8 * nbins */
+ int32 binid,
+ start_offset ,
+ num_items ; /* For each value, count the ids */
+} ThematicIndexDirectory ;
+
+typedef struct {
+ ThematicIndexHeader h;
+ ThematicIndexDirectory *d, *gid;
+ FILE *fp;
+} ThematicIndex;
+
+/* Prototype Definitions */
+#ifdef PROTO
+ int32 create_thematic_index (char, char*, char*, char*, char*);
+ set_type read_thematic_index (char*, char*);
+ ThematicIndex open_thematic_index (char*, int32);
+ set_type search_thematic_index (ThematicIndex*, char*);
+ void close_thematic_index (ThematicIndex*);
+ int32 create_gazetteer_index (char*, char*, char*, char*);
+ set_type search_gazetteer_index (ThematicIndex*, char*);
+ set_type read_gazetteer_index (char*, char*);
+#else
+ int32 create_thematic_index ();
+ set_type read_thematic_index ();
+ ThematicIndex open_thematic_index ();
+ set_type search_thematic_index ();
+ void close_thematic_index ();
+ int32 create_gazetteer_index ();
+ set_type search_gazetteer_index ();
+ set_type read_gazetteer_index ();
+#endif
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfview.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfview.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfview.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,131 @@
+/* VPFVIEW.H */
+
+#ifndef __VPFVIEW_H__
+
+#define __VPFVIEW_H__ 1
+
+
+#ifndef __SET_H__
+#include "set.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+#ifndef __LINKLIST_H__
+#include "linklist.h"
+#endif
+#ifndef __VPF_H__
+#include "vpf.h"
+#endif
+#ifndef __COORGEOM_H__
+#include "coorgeom.h"
+#endif
+
+
+
+/* VPF library internal structure */
+typedef struct {
+ char name[9]; /* Name of the library */
+ boolean viewable; /* Is this library accessible to the view? */
+ char *path; /* DOS path name to the library */
+ int32 ntiles; /* Number of tiles in the library */
+ set_type tile_set; /* Set of 'active' tiles in the library */
+ vpf_projection_code projection; /* Projection of stored coord data */
+ vpf_units_type units; /* Units of the stored coordinate data */
+} library_type;
+
+/* VPF database internal structure */
+typedef struct {
+ char name[9]; /* Name of the VPF database */
+ char *path; /* UNIX path name to the database */
+ library_type *library; /* Array of library structures for the database */
+ int32 nlibraries; /* Number of libraries in the database */
+} database_type;
+
+/* Each theme has a symbol structure associated with it. Themes on */
+/* simple feature classes just have relevant symbol information for */
+/* one of the four primitive types, but complex feature themes may */
+/* have any or all of the primitive type symbols. */
+typedef struct {
+ int32 point_color;
+ int32 point;
+ int32 line_color;
+ int32 line;
+ int32 area_color;
+ int32 area;
+ int32 text_color;
+ int32 text;
+} theme_symbol_type;
+
+/* A theme is a single entry for a view of the database. It can be */
+/* thought of as a stored query with a description and symbology. */
+/* Each theme is associated with a feature class. */
+typedef struct {
+ char *description; /* Description of the theme */
+ char *database; /* Source Database path */
+ char *library; /* Source Library name */
+ char *coverage; /* Source coverage name */
+ char *fc; /* Feature class name for the theme */
+ char *ftable; /* Feature table path for the fc */
+ primitive_class_type primclass; /* Primitive class(es) of theme */
+ char *expression; /* Logical selection expression */
+#if 0
+ theme_symbol_type symbol; /* Drawing symbol */
+#endif
+} theme_type;
+
+
+/* View structure. Each view is associated with a particular database */
+/* and a particular library within that datbase. */
+typedef struct {
+ char name[9]; /* View name */
+ database_type *database; /* Array of Databases in the view */
+ int32 ndb; /* Number of databases in the view */
+ char *path; /* Directory path to the view */
+ int32 nthemes; /* Number of themes in the view */
+ theme_type *theme; /* Array of themes */
+ set_type selected; /* Set of themes selected for display */
+ set_type displayed; /* Set of displayed themes */
+ linked_list_type sellist; /* List of selected themes (ordered) */
+ extent_type extent; /* MBR of all library extents */
+ double tileheight; /* Min of all library tile heights */
+ char sympath[255]; /* Symbol set path */
+#if 0
+ symbol_set_type sym; /* Symbol set for the view */
+#endif
+} view_type;
+
+
+/* Map environment information */
+typedef struct {
+ extent_type mapextent; /* Current map extent */
+ boolean mapchanged; /* Flag - has anything changed? */
+ boolean mapdisplayed; /* Flag - has the map been displayed? */
+ boolean user_escape; /* Flag - has the user hit escape? */
+ boolean study_area_selected; /* Flag - study area selected? */
+ boolean latlongrid; /* Flag - lat-lon grid to be displayed?*/
+ boolean scale_bar; /* Flag - scale bar to be displayed? */
+ vpf_projection_type projection; /* Current map display projection */
+ coord_units_type distance_unit; /* Units for distance display */
+ coord_units_type scale_bar_unit; /* Units for scale bar display */
+ vpf_units_type locator_unit; /* Units for map locate display */
+} map_environment_type;
+
+typedef struct {
+ extent_type mapextent; /* Current map extent */
+ boolean mapdisplayed; /* Flag - has the map been displayed? */
+ boolean latlongrid; /* Flag - lat-lon grid to be displayed? */
+ boolean tilegrid; /* Flag - tile boundaries to be displayed? */
+ boolean points; /* Flag - libref points to be displayed? */
+ boolean text; /* Flag - libref text to be displayed? */
+ vpf_units_type locator_unit; /* Units for libref map locate display */
+} libref_map_environment_type;
+
+/* Window specifier flags */
+#define COVERAGE_WINDOW 0
+#define LIBREF_WINDOW 1
+
+/* Functions: */
+/* main() */
+
+#endif
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfwrite.c
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfwrite.c 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/vpfwrite.c 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,905 @@
+/*************************************************************************
+ *
+ *N Module VPFWRITE.C
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This contains functions for writing data to VPF tables.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * N/A
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Original Coding: Tom Wood Fall 1990
+ * Modifications: David Flinn January 1991
+ * July 1991
+ * Barry Michaels October 1991
+ * Modified from converter
+ * software (UNIX) for
+ * VPFVIEW software (DOS).
+ * Jim TenBrink October 1991
+ * Made vpfread.c and vpfwrite.c
+ * disjoint
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifndef INCL_XVTH
+#include <xvt.h>
+#endif
+
+#if 0
+#if _MSDOS
+#include <io.h>
+#include <malloc.h>
+#include <dos.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#endif
+#endif
+
+#ifndef _MACHINE_
+#include "machine.h"
+#endif
+
+#ifdef _UNIX
+#include <sys/stat.h>
+#define SEEK_SET 0 /* Turbo C fseek value */
+#define SEEK_CUR 1
+#endif
+
+#ifdef __VPF_H__
+#include "vpf.h"
+#endif
+#ifndef _VPFTABLE_H_
+#include "vpftable.h"
+#endif
+
+extern int32 STORAGE_BYTE_ORDER;
+
+/* Include statically to reduce external module dependencies */
+
+#ifdef PROTO
+void *vpfmalloc( uint32 size )
+#else
+void *vpfmalloc( size )
+uint32 size;
+#endif
+{
+ void *p;
+ p = (void *)xvt_zmalloc ((size_t)size);
+ if (p == (void *)NULL) {
+ xvt_note ("out of memory in vpfwrite\n");
+ }
+ return p;
+}
+
+
+
+/*************************************************************************
+ *
+ *N write_key
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function writes an id triplet key from the specified file.
+ * It is assumed that there is enough free disk space to write to the
+ * file. It is also assumed that the file pointer (fp) is already opened
+ * for writing.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * key <input> == (id_triplet_type) id triplet key.
+ * fp <input> == (FILE *) input file pointer.
+ * return <output> == (int32) size of the key.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn July 1991 Based on read_key in vpftable.c
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 write_key( id_triplet_type key, FILE *fp )
+#else
+int32 write_key( key, fp )
+id_triplet_type key;
+FILE *fp;
+#endif
+{
+ int32 size = 0 ; /* to count size of key write */
+ unsigned char tint ;
+ short int tshort ;
+
+ /* Assume that any count value has been written before this */
+ /* Only write one key in this subroutine, do not write more */
+
+ Write_Vpf_Char (&(key.type),fp,1);
+ size += sizeof ( char ) ;
+
+ switch (TYPE0(key.type)) {
+ case 0:
+ break;
+ case 1:
+ tint = (unsigned char) key.id ;
+ Write_Vpf_Char ( &tint, fp, 1 ) ;
+ size += sizeof ( char ) ;
+ break;
+ case 2:
+ tshort = (short) key.id ;
+ Write_Vpf_Short ( &tshort, fp, 1 ) ;
+ size += sizeof ( short int ) ;
+ break;
+ case 3:
+ Write_Vpf_Int (&(key.id), fp, 1 ) ;
+ size += sizeof ( int32 ) ;
+ break;
+ }
+
+ switch (TYPE1(key.type)) {
+ case 0:
+ break;
+ case 1:
+ tint = (unsigned char) key.tile ;
+ Write_Vpf_Char ( &tint, fp, 1 ) ;
+ size += sizeof ( char ) ;
+ break;
+ case 2:
+ tshort = (short) key.tile ;
+ Write_Vpf_Short ( &tshort, fp, 1 ) ;
+ size += sizeof ( short int ) ;
+ break;
+ case 3:
+ Write_Vpf_Int (&(key.tile), fp, 1 ) ;
+ size += sizeof ( int32 ) ;
+ break;
+ }
+
+ switch (TYPE2(key.type)) {
+ case 0:
+ break;
+ case 1:
+ tint = (unsigned char) key.exid ;
+ Write_Vpf_Char ( &tint, fp, 1 ) ;
+ size += sizeof ( char ) ;
+ break;
+ case 2:
+ tshort = (short) key.exid ;
+ Write_Vpf_Short ( &tshort, fp, 1 ) ;
+ size += sizeof ( short int ) ;
+ break;
+ case 3:
+ Write_Vpf_Int (&(key.exid), fp, 1 ) ;
+ size += sizeof ( int32 ) ;
+ break;
+ }
+ return size ;
+}
+
+/*************************************************************************
+ *
+ *N write_next_row
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function writes the next row of the table.
+ * The parameter row must be initialized prior to this functional, either
+ * by being read in from an existing table or set to valid values.
+ * A row with any empty columns should not be written out.
+ * The parameter table must be a valid table and initialized prior to
+ * this function, by vpf_open_table. It is assumed that there is
+ * enough free disk space to write to the file. It is also assumed that
+ * the file pointer (table->fp) is already opened for writing. The
+ * variable count, set to the values in row, must be greater than 0,
+ * otherwise, if count is -1 the vpf_write functions will lock up
+ * (row[].count should never have a value of 0). Note that if errorfp
+ * is used, it must be opened prior to this function.
+ *
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * row <input> == (row_type) the row to write to the table.
+ * table <input> == (vpf_table_type *) vpf table structure.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Dave Flinn July 1991 Based on read_next_row.
+ * Barry Michaels Oct 1991 Added row as a parameter.
+ * JTB 10/91 guaranteed function always
+ * returns a value:
+ * 0: record written
+ * -1: unknown field type
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 write_next_row(row_type row, vpf_table_type * table )
+#else
+int32 write_next_row( row, table )
+row_type row;
+vpf_table_type * table;
+#endif
+{
+ register int32 i,
+ j;
+ char * tptr,
+ * output ;
+ int32 recordsize = 0;
+ int32 count;
+ id_triplet_type * keys;
+ uint32 pos_for_ndx,
+ length;
+ int32 retn_val = 0;
+ static coordinate_type dummycoord = {(float)0.0, (float)0.0};
+
+ STORAGE_BYTE_ORDER = table->byte_order;
+
+ table->nrows++;
+ fseek(table->fp, 0L, SEEK_END);
+ pos_for_ndx = ftell(table->fp); /* begining of new row */
+
+ for (i = 0; i < table->nfields; i++) { /* for each column */
+
+ count = row[i].count ; /* Retrieve count from row. Should
+ be 0 if variable length null */
+
+ /* In case this column is variable length, write out count */
+
+ if (count == 0) count = 1;
+
+ if ( table->header[i].count < 0 ) {
+ Write_Vpf_Int ( &count, table->fp, 1 ) ;
+ recordsize += sizeof ( int32 ) ;
+ }
+
+ /* Now write out the data type */
+
+ switch (table->header[i].type) {
+
+ case 'T':
+ if ( count == 0 ) /* Assume this is variable length text
+ and don't do anything */
+ break ;
+
+ /* This loop insures that the exact number of characters are written
+ out to disk. */
+
+ output = (char *) vpfmalloc ( count + 1 ) ; /* include null byte */
+ for (j = 0, tptr = row[i].ptr; j < count; j++, tptr++)
+ if ( *tptr )
+ output[j] = *tptr ;
+ else
+ output[j] = SPACE ;
+ output[count] = '\0' ;
+ Write_Vpf_Char( output ,table->fp, count) ;
+ if(output != (char *)NULL)
+ {xvt_free ( output ) ;output = (char *)NULL;}
+ recordsize += sizeof ( char ) * count ;
+ break;
+
+ case 'I':
+ Write_Vpf_Int (row[i].ptr, table->fp, count ) ;
+ recordsize += sizeof ( int32 ) * count ;
+ break;
+
+ case 'S':
+ Write_Vpf_Short (row[i].ptr, table->fp, count ) ;
+ recordsize += sizeof ( short int ) * count ;
+ break;
+
+ case 'F':
+ Write_Vpf_Float (row[i].ptr, table->fp, count ) ;
+ recordsize += sizeof ( float ) * count ;
+ break;
+
+ case 'R':
+ Write_Vpf_Double (row[i].ptr, table->fp, count ) ;
+ recordsize += sizeof ( double ) * count ;
+ break;
+
+ case 'D': /* date has 21 chars in memory, not on disk */
+ Write_Vpf_Date (row[i].ptr, table->fp, count ) ;
+ recordsize += ( sizeof ( date_type ) - 1 ) * count ;
+ break;
+
+ case 'C':
+ if (row[i].ptr) {
+ Write_Vpf_Coordinate(row[i].ptr,table->fp,count);
+ } else {
+ for (j=0;j<count;j++)
+ Write_Vpf_Coordinate(&dummycoord,table->fp,count);
+ }
+ recordsize += sizeof ( coordinate_type ) * count ;
+ break;
+
+ case 'B':
+ Write_Vpf_DoubleCoordinate(row[i].ptr,table->fp,count);
+ recordsize += sizeof ( double_coordinate_type ) * count ;
+ break;
+
+ case 'Z':
+ Write_Vpf_CoordinateZ(row[i].ptr,table->fp,count);
+ recordsize += sizeof ( tri_coordinate_type ) * count ;
+ break;
+
+ case 'Y':
+ Write_Vpf_DoubleCoordinateZ(row[i].ptr,table->fp,count);
+ recordsize += sizeof ( double_tri_coordinate_type ) * count ;
+ break;
+
+ case 'K':
+ keys = (id_triplet_type *) vpfmalloc (count*sizeof(id_triplet_type)) ;
+ memcpy (keys, row[i].ptr, (size_t)count * sizeof(id_triplet_type) ) ;
+ for (j=0;j<count;j++)
+ recordsize += write_key ( keys[j], table->fp);
+ if(keys != (id_triplet_type *)NULL)
+ {xvt_free ((char*)keys);keys = (id_triplet_type *)NULL;}
+ break;
+
+ case 'X':
+ /* do nothing */
+ break;
+
+ default:
+ xvt_note ("write_next_row: no such type < %c >",
+ table->header[i].type ) ; /*DGM*/
+ return(-1);
+ }
+ }
+
+ if ( table->xfp ) { /* only for variable length columns */
+ length = recordsize ;
+ fseek( table->xfp, 0, SEEK_END );
+
+ Write_Vpf_Int ( &pos_for_ndx, table->xfp, 1 ) ;
+ Write_Vpf_Int ( &length, table->xfp, 1 ) ;
+ }
+
+ return retn_val;
+}
+
+
+/*************************************************************************
+ *
+ *N create_row
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * This function creates a null row for the given table.
+ * The parameter table must be a valid table and initialized prior to
+ * this function, by vpf_open_table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * table <input> == (vpf_table_type) vpf table structure.
+ * return <output> == (row_type) row of the table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * Barry Michaels Oct 1991
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * External Variables:
+ *X
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Functions Called:
+ *F
+ * None
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Portability:
+ *O
+ * This module should be ANSI C compatible.
+ *E
+ *************************************************************************/
+#ifdef PROTO
+row_type create_row( vpf_table_type table )
+#else
+row_type create_row( table )
+vpf_table_type table;
+#endif
+{
+ int32 i;
+ row_type row;
+
+ row = (row_type)vpfmalloc(table.nfields*sizeof(column_type));
+ for (i=0;i<table.nfields;i++) {
+ row[i].count = table.header[i].count;
+ row[i].ptr = NULL;
+ }
+ return row;
+}
+
+
+
+/*************************************************************************
+ *
+ *N nullify_table_element
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Frees one field element - no action is taken if the
+ * field index is invalid.
+ * The parameter row must be initialized prior to this functional, either
+ * buy being read in from an existing table or set to valid values. The
+ * parameter table must be a valid table and initialized prior to this
+ * function, by vpf_open_table.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * field <input> == (int32) column offset.
+ * row <inout> == (row_type) row containing element to be removed.
+ * table <inout> == (vpf_table_type) VPF table owning row.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * RDF 7/91 original
+ * JTB 10/91 removed call to exit();
+ *E
+ *************************************************************************/
+#ifdef PROTO
+void nullify_table_element( int32 field,
+ row_type row,
+ vpf_table_type table )
+#else
+void nullify_table_element( field, row, table )
+int32 field;
+row_type row;
+vpf_table_type table;
+#endif
+{
+ if (field < 0 || field >= table.nfields)
+ return;
+
+ if (row[field].ptr)
+ {
+ if(row[field].ptr != (void *)NULL)
+ xvt_free((char *)row[field].ptr);
+ row[field].ptr = NULL;
+ row[field].count = table.header[field].count;
+ }
+}
+
+/*************************************************************************
+ *
+ *N put_table_element
+ *
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Purpose:
+ *P
+ * Copies one element into the designated field.
+ * The parameter row must be initialized prior to this functional, either
+ * buy being read in from an existing table or set to valid values. The
+ * parameter table must be a valid table and initialized prior to this
+ * function, by vpf_open_table. Note that if errorfp is used, it must
+ * be opened prior to this function.
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * Parameters:
+ *A
+ * field <input> == (int32) column offset.
+ * row <in-out> == (row_type) row containing target field.
+ * table <in-out> == (vpf_table_type) VPF table owning row.
+ * value <in> == (void *) source field element.
+ * count <in> == (int32) number of items in value.
+ * put_table_element <output> == (int32)
+ * 0 --> element write succeeded
+ * 1 --> unknown element type or
+ * invalid column offset
+ *E
+ *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ *
+ * History:
+ *H
+ * RDF 7/91 original
+ * JTB 10/91 removed call to exit();
+ * guaranteed function always returns value
+ * 0: element write succeeded
+ * -1: unknown element type or invalid column (field) offset
+ *E
+ *************************************************************************/
+#ifdef PROTO
+int32 put_table_element( int32 field,
+ row_type row,
+ vpf_table_type table,
+ void * value,
+ int32 count )
+#else
+int32 put_table_element( field, row, table, value, count )
+int32 field;
+row_type row;
+vpf_table_type table;
+void *value;
+int32 count;
+#endif
+{
+ int32 i, len, stat;
+ char *str;
+
+ stat=0;
+
+ if ((count != table.header[field].count) &&
+ (table.header[field].count > 0)) {
+ xvt_note ("Invalid element count! (%d, %d)\n",
+ count,table.header[field].count);
+ return -1;
+ }
+
+ if (field < 0 || field >= table.nfields)
+ return -1;
+
+ row[field].count = count;
+
+ if (row[field].ptr != (void *)NULL) {
+ xvt_free(row[field].ptr);
+ row[field].ptr = NULL;
+ }
+
+ switch ( table.header[field].type ) {
+ case 'T':
+ len = (int32)max(count,table.header[field].count);
+ str = (char *) vpfmalloc( len + 1 );
+ row[field].ptr = (char *) vpfmalloc ( len + 1 ) ;
+ strcpy( str, value );
+ for ( i = strlen(value) ; i < table.header[field].count; i++ )
+ str[i] = SPACE ;
+ str[len] = '\0';
+ memcpy (row[field].ptr, str, (size_t)(len+1));
+ if(str != (char *)NULL)
+ {xvt_free(str);str = (char *)NULL;}
+ break ;
+
+ case 'D':
+ row[field].ptr = (date_type *) vpfmalloc (count*sizeof(date_type));
+ memcpy (row[field].ptr, value, sizeof (date_type) * (size_t)count);
+ break;
+
+ case 'I' :
+ row[field].ptr = (int32 *) vpfmalloc (count*sizeof(int32));
+ memcpy (row[field].ptr, value, sizeof (int32) * (size_t)count);
+ break;
+
+ case 'S' :
+ row[field].ptr = (short int *) vpfmalloc (count*sizeof(short int));
+ memcpy (row[field].ptr, value, sizeof (short) * (size_t)count);
+ break;
+
+ case 'F':
+ row[field].ptr = (float *) vpfmalloc (count*sizeof(float));
+ memcpy (row[field].ptr, value, sizeof (float) * (size_t)count);
+ break;
+
+ case 'R':
+ row[field].ptr = (double *) vpfmalloc (count*sizeof(double));
+ memcpy (row[field].ptr, value, sizeof (double) * (size_t)count);
+ break;
+
+ case 'K':
+ row[field].ptr =
+ (id_triplet_type *) vpfmalloc ( count*sizeof(id_triplet_type ));
+ memcpy (row[field].ptr, value, sizeof(id_triplet_type) *
+ (size_t)count);
+ break;
+
+ case 'C':
+ if (value) {
+ row[field].ptr = (coordinate_type*) xvt_zmalloc ((size_t)count *
+ sizeof (coordinate_type));
+ if (row[field].ptr)
+ memcpy (row[field].ptr, value, sizeof (coordinate_type) *
+ (size_t)count);
+ } else {
+ row[field].ptr = NULL;
+ }
+ break;
+
+ case 'Z':
+ if (value) {
+ row[field].ptr = (tri_coordinate_type *)
+ xvt_zmalloc ((size_t)count * sizeof(tri_coordinate_type));
+ if (row[field].ptr)
+ memcpy (row[field].ptr, value,
+ sizeof(tri_coordinate_type) * (size_t)count);
+ } else {
+ row[field].ptr = NULL;
+ }
+ break;
+
+ case 'B':
+ if (value) {
+ row[field].ptr = (double_coordinate_type *)
+ xvt_zmalloc ((size_t)count * sizeof (double_coordinate_type));
+ if (row[field].ptr)
+ memcpy (row[field].ptr, value,
+ sizeof (double_coordinate_type) * (size_t)count);
+ } else {
+ row[field].ptr = NULL;
+ }
+ break;
+
+ case 'Y':
+ if (value) {
+ row[field].ptr = (double_tri_coordinate_type *)
+ xvt_zmalloc ((size_t)count * sizeof (double_tri_coordinate_type));
+ if (row[field].ptr)
+ memcpy( row[field].ptr, value,
+ sizeof (double_tri_coordinate_type) * (size_t)count);
+ } else {
+ row[field].ptr = NULL;
+ }
+ break;
+
+ default:
+ xvt_note ("text2vpf: No such data type < %c > in vpf\n",
+ table.header[field].type ) ; /*DGM*/
+ stat = -1;
+ break ;
+ }
+
+ return stat;
+}
+
+
+
+/* ========================================================================
+
+ Environmental Systems Research Institute (ESRI) Applications Programming
+
+ Project: Conversion from ARC/INFO to VPF
+ Original Coding: Tom Wood Fall 1990
+ Modifications: David Flinn January 1991
+ July 1991
+ JTB 10/91
+
+ The following functions are used when writing from a big-endian machine.
+ VPF requires little-endian words, so byte-swapping must be performed.
+
+ ======================================================================== */
+
+/* #ifdef UNIX */
+
+#ifdef PROTO
+int32 VpfWrite ( void *from, VpfDataType type, int32 count, FILE *to )
+#else
+int32 VpfWrite ( from, type, count, to )
+void *from;
+VpfDataType type;
+int32 count;
+FILE *to;
+#endif
+{
+ int32 retval = 0;
+ int32 i;
+
+ switch ( type ) {
+ case VpfChar:
+ retval = fwrite (from, sizeof (char), (size_t)count, to);
+ break ;
+ case VpfShort:
+ {
+ if (MACHINE_BYTE_ORDER != STORAGE_BYTE_ORDER) {
+ short int stemp ,
+ *sptr = (short *) from ;
+ for ( i=0; i < count; i++, sptr++ ) {
+ swap_two ((char*)sptr,(char*)&stemp);
+ retval = fwrite ( &stemp, sizeof (short), 1, to ) ;
+ }
+ } else {
+ retval = fwrite (from, sizeof (short), (size_t)count, to);
+ }
+ }
+ break ;
+ case VpfInteger:
+ {
+ if (MACHINE_BYTE_ORDER != STORAGE_BYTE_ORDER) {
+ int32 itemp,
+ *iptr = (int32 *) from ;
+ for ( i=0; i < count; i++, iptr++ ) {
+ swap_four ((char*)iptr, (char*)&itemp);
+ retval = fwrite ( &itemp, sizeof (int32), 1, to ) ;
+ }
+ } else {
+ retval = fwrite (from, sizeof (int32), (size_t)count, to);
+ }
+ }
+ break ;
+ case VpfFloat:
+ {
+ if (MACHINE_BYTE_ORDER != STORAGE_BYTE_ORDER) {
+ float ftemp ,
+ *fptr = (float *) from ;
+ for ( i=0; i < count; i++, fptr++ ) {
+ swap_four ((char*)fptr, (char*)&ftemp);
+ retval = fwrite ( &ftemp, sizeof (float), 1, to ) ;
+ }
+ } else {
+ retval = fwrite (from, sizeof (int32), (size_t)count, to);
+ }
+ }
+ break ;
+ case VpfDouble:
+ {
+ if (MACHINE_BYTE_ORDER != STORAGE_BYTE_ORDER) {
+ double dtemp ,
+ *dptr = (double *) from ;
+ for ( i=0; i < count; i++, dptr++ ) {
+ swap_eight ((char*)dptr, (char*)&dtemp);
+ retval = fwrite ( &dtemp, sizeof (double), 1, to ) ;
+ }
+ } else {
+ retval = fwrite (from, sizeof (double), (size_t)count, to);
+ }
+ }
+ break ;
+ case VpfDate: /* only write out 20, not 21 chars */
+ retval = fwrite (from, sizeof (date_type) - 1, (size_t)count, to);
+ break ;
+ case VpfCoordinate:
+ {
+ if (MACHINE_BYTE_ORDER != STORAGE_BYTE_ORDER) {
+ coordinate_type ctemp ,
+ *cptr = (coordinate_type *) from ;
+ for ( i=0; i < count; i++, cptr++ ) {
+ swap_four ((char*)&cptr->x, (char*)&ctemp.x);
+ swap_four ((char*)&cptr->y, (char*)&ctemp.y);
+ retval = fwrite ( &ctemp, sizeof (coordinate_type), 1, to ) ;
+ }
+ } else {
+ retval = fwrite (from, sizeof (coordinate_type), (size_t)count, to);
+ }
+ }
+ break ;
+ case VpfDoubleCoordinate:
+ {
+ if (MACHINE_BYTE_ORDER != STORAGE_BYTE_ORDER) {
+ double_coordinate_type dctemp ,
+ *dcptr = (double_coordinate_type *) from ;
+ for ( i=0; i < count; i++, dcptr++ ) {
+ swap_eight ((char*)&dcptr->x, (char*)&dctemp.x);
+ swap_eight ((char*)&dcptr->y, (char*)&dctemp.y);
+ retval = fwrite ( &dctemp, sizeof (double_coordinate_type),
+ 1, to ) ;
+ }
+ } else {
+ retval = fwrite (from, sizeof (double_coordinate_type),
+ (size_t)count, to);
+ }
+ }
+ break ;
+ case VpfTriCoordinate:
+ {
+ if (MACHINE_BYTE_ORDER != STORAGE_BYTE_ORDER) {
+ tri_coordinate_type ttemp ,
+ *tptr = (tri_coordinate_type *) from ;
+ for ( i=0; i < count; i++, tptr++ ) {
+ swap_four ((char*)&tptr->x, (char*)&ttemp.x);
+ swap_four ((char*)&tptr->y, (char*)&ttemp.y);
+ swap_four ((char*)&tptr->z, (char*)&ttemp.z);
+ retval = fwrite ( &ttemp, sizeof (tri_coordinate_type), 1, to ) ;
+ }
+ } else {
+ retval = fwrite (from, sizeof (tri_coordinate_type),
+ (size_t)count, to);
+ }
+ }
+ break ;
+ case VpfDoubleTriCoordinate:
+ {
+ if (MACHINE_BYTE_ORDER != STORAGE_BYTE_ORDER) {
+ double_tri_coordinate_type dttemp ,
+ *dtptr = (double_tri_coordinate_type *) from ;
+ for ( i=0; i < count; i++, dtptr++ ) {
+ swap_eight ((char*)&dtptr->x, (char*)&dttemp.x);
+ swap_eight ((char*)&dtptr->y, (char*)&dttemp.y);
+ swap_eight ((char*)&dtptr->z, (char*)&dttemp.z);
+ retval = fwrite ( &dttemp,sizeof (double_tri_coordinate_type),
+ 1, to);
+ }
+ } else {
+ retval = fwrite ( from,sizeof (double_tri_coordinate_type),
+ (size_t)count, to);
+ }
+ }
+ break ;
+ case VpfNull:
+ /* Do Nothing */
+ break ;
+ default:
+ xvt_note ("VpfWrite: error on data type < %s >",(char*) type ) ; /*DGM*/
+ break ;
+ }
+
+ return retval;
+}
+
+/* #endif */
Added: packages/ogdi-dfsg/branches/upstream/current/vpflib/xvt.h
===================================================================
--- packages/ogdi-dfsg/branches/upstream/current/vpflib/xvt.h 2007-03-24 09:58:33 UTC (rev 649)
+++ packages/ogdi-dfsg/branches/upstream/current/vpflib/xvt.h 2007-03-26 16:00:49 UTC (rev 650)
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <ctype.h>
+#include <signal.h>
+
+#ifdef __GNU_LIBRARY__
+#include <wait.h>
+#endif
+
+#include <ogdi_macro.h>
+
+extern void G_warning (char *msg);
+
+#define XVT_OS NONE
+#ifdef unix
+#define XVT_OS_WIN NULL
+#endif
+
+#define MAXLONG LONG_MAX
+#define MAXSHORT SHRT_MAX
+#ifdef _WINDOWS
+#define MAXFLOAT DBL_MAX
+#endif
+#define DIR_SEPARATOR '\\'
+#define OS_SEPARATOR '\\'
+#define OS_SEPARATOR_STRING "\\"
+#define SZ_FNAME 256
+
+/* typedef void * GHANDLE; */
+#define GHANDLE void *
+#define xvt_zmalloc(n) calloc(n,1)
+#define xvt_free(a) free(a)
+#define xvt_note printf
+#define xvt_malloc(a) malloc(a)
+#define xvt_realloc(m,s) realloc(m,s)
+#define gmemset memset
+
+
+#define xvt_fatal printf
+#define gunlock
+#define gfree(a) free(a)
+#define xvt_error printf
+#define XVT_CC_ARGS(p) p
+
+#define BOOLEAN unsigned char
+/* typedef unsigned char BOOLEAN; */
+
More information about the Pkg-grass-devel
mailing list