From 79a773d25c82614c461e86aeb63a6b690c1a40b2 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 8 Apr 1998 23:28:57 +0000 Subject: [PATCH] Adopted Gnu automake/autoconf system. --- Bucket/Makefile.am | 7 + Bucket/Makefile.in | 319 +++++++++++++++++++++++++++++++++++++++++++ Bucket/bucketutils.c | 317 ++++++++++++++++++++++++++++++++++++++++++ Bucket/bucketutils.h | 123 +++++++++++++++++ 4 files changed, 766 insertions(+) create mode 100644 Bucket/Makefile.am create mode 100644 Bucket/Makefile.in create mode 100644 Bucket/bucketutils.c create mode 100644 Bucket/bucketutils.h diff --git a/Bucket/Makefile.am b/Bucket/Makefile.am new file mode 100644 index 00000000..a374b39e --- /dev/null +++ b/Bucket/Makefile.am @@ -0,0 +1,7 @@ +libdir = ${exec_prefix}/lib + +lib_LTLIBRARIES = libBucket.la + +libBucket_la_SOURCES = bucketutils.c bucketutils.h + +INCLUDES += -I../.. diff --git a/Bucket/Makefile.in b/Bucket/Makefile.in new file mode 100644 index 00000000..c7df0488 --- /dev/null +++ b/Bucket/Makefile.in @@ -0,0 +1,319 @@ +# Makefile.in generated automatically by automake 1.2h from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DISTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +CC = @CC@ +CXX = @CXX@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +NM = @NM@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ + +libdir = ${exec_prefix}/lib + +lib_LTLIBRARIES = libBucket.la + +libBucket_la_SOURCES = bucketutils.c bucketutils.h +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../../Simulator/Include/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../../Simulator/Include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +libBucket_la_LDFLAGS = +libBucket_la_LIBADD = +libBucket_la_OBJECTS = bucketutils.lo +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +DEP_FILES = .deps/bucketutils.P +SOURCES = $(libBucket_la_SOURCES) +OBJECTS = $(libBucket_la_OBJECTS) + +all: Makefile $(LTLIBRARIES) + +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .s +$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Simulator/Scenery/Bucket/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libBucket.la: $(libBucket_la_OBJECTS) $(libBucket_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libBucket_la_LDFLAGS) $(libBucket_la_OBJECTS) $(libBucket_la_LIBADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = Simulator/Scenery/Bucket + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Simulator/Scenery/Bucket/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + +maintainer-clean-depend: + -rm -rf .deps + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).P -c $< + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $< + @-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \ + < .deps/$(*F).p > .deps/$(*F).P + @-rm -f .deps/$(*F).p +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-libLTLIBRARIES + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: uninstall-libLTLIBRARIES + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(DATADIR)$(libdir) + + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-libLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +clean: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean + +distclean: distclean-libLTLIBRARIES distclean-compile distclean-libtool \ + distclean-tags distclean-depend distclean-generic clean + -rm -f config.status + -rm -f libtool + +maintainer-clean: maintainer-clean-libLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info dvi \ +installcheck install-exec install-data install uninstall all \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +INCLUDES += -I../.. + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Bucket/bucketutils.c b/Bucket/bucketutils.c new file mode 100644 index 00000000..193b70bd --- /dev/null +++ b/Bucket/bucketutils.c @@ -0,0 +1,317 @@ +/************************************************************************** + * bucketutils.c -- support routines to handle fgBUCKET operations + * + * Written by Curtis Olson, started January 1998. + * + * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#include +#include + +#include + +#include "bucketutils.h" + + +/* Generate the unique scenery tile index containing the specified + lon/lat parameters. + + The index is constructed as follows: + + 9 bits - to represent 360 degrees of longitude (-180 to 179) + 8 bits - to represent 180 degrees of latitude (-90 to 89) + + Each 1 degree by 1 degree tile is further broken down into an 8x8 + grid. So we also need: + + 3 bits - to represent x (0 to 7) + 3 bits - to represent y (0 to 7) */ +long int fgBucketGenIndex(struct fgBUCKET *p) { + long index = 0; + + index = ((p->lon + 180) << 14) + ((p->lat + 90) << 6) + (p->y << 3) + p->x; + /* printf(" generated index = %ld\n", index); */ + + return(index); +} + + +/* Parse a unique scenery tile index and find the lon, lat, x, and y */ +void fgBucketParseIndex(long int index, struct fgBUCKET *p) { + p->lon = index >> 14; + index -= p->lon << 14; + p->lon -= 180; + + p->lat = index >> 6; + index -= p->lat << 6; + p->lat -= 90; + + p->y = index >> 3; + index -= p->y << 3; + + p->x = index; +} + + +/* Build a path name from an tile index */ +void fgBucketGenBasePath(struct fgBUCKET *p, char *path) { + long int index; + int top_lon, top_lat, main_lon, main_lat; + char hem, pole; + + index = fgBucketGenIndex(p); + + path[0] = '\0'; + + top_lon = p->lon / 10; + main_lon = p->lon; + if ( (p->lon < 0) && (top_lon * 10 != p->lon) ) { + top_lon -= 1; + } + top_lon *= 10; + if ( top_lon >= 0 ) { + hem = 'e'; + } else { + hem = 'w'; + top_lon *= -1; + } + if ( main_lon < 0 ) { + main_lon *= -1; + } + + top_lat = p->lat / 10; + main_lat = p->lat; + if ( (p->lat < 0) && (top_lat * 10 != p->lat) ) { + top_lat -= 1; + } + top_lat *= 10; + if ( top_lat >= 0 ) { + pole = 'n'; + } else { + pole = 's'; + top_lat *= -1; + } + if ( main_lat < 0 ) { + main_lat *= -1; + } + + sprintf(path, "%c%03d%c%03d/%c%03d%c%03d", + hem, top_lon, pole, top_lat, + hem, main_lon, pole, main_lat); +} + + +/* offset an bucket struct by the specified amounts in the X & Y direction */ +void fgBucketOffset(struct fgBUCKET *in, struct fgBUCKET *out, int x, int y) { + int diff, temp; + int dist_lat; + + out->lon = in->lon; + out->lat = in->lat; + out->x = in->x; + out->y = in->y; + + /* do X direction */ + diff = out->x + x; + /* printf(" reducing x (%d)\n", diff); */ + if ( diff >= 0 ) { + temp = diff / 8; + } else if ( diff < -7 ) { + temp = (diff + 1) / 8 - 1; + } else { + temp = diff / 8 - 1; + } + out->x = ((diff % 8) + 8) % 8; + out->lon = ( (out->lon + 180 + 360 + temp) % 360 ) - 180; + + /* do Y direction */ + diff = out->y + y; + /* printf(" reducing x (%d)\n", diff); */ + if ( diff >= 0 ) { + temp = diff / 8; + } else if ( diff < -7 ) { + temp = (diff + 1) / 8 - 1; + } else { + temp = diff / 8 - 1; + } + out->y = ((diff % 8) + 8) % 8; + out->lat = out->lat + temp; + + if ( out->lat >= 90 ) { + dist_lat = out->lat - 90; + /* printf(" +lat = %d +y = %d\n", dist_lat, out->y); */ + + out->lat = 90 - (dist_lat + 1); + out->lon = ( (out->lon + 180 + 180) % 360 ) - 180; + out->y = 7 - out->y; + } + + if ( out->lat < -90 ) { + dist_lat = -90 - out->lat; + /* printf(" +lat = %d +y = %d\n", dist_lat, out->y); */ + + out->lat = -90 + (dist_lat - 1); + out->lon = ( (out->lon + 180 + 180) % 360 ) - 180; + out->y = 7 - out->y; + } +} + + +/* Given a lat/lon, find the "bucket" or tile that it falls within */ +void fgBucketFind(double lon, double lat, struct fgBUCKET *p) { + double diff; + + diff = lon - (double)(int)lon; + /* printf("diff = %.2f\n", diff); */ + if ( (lon >= 0) || (fabs(diff) < FG_EPSILON) ) { + p->lon = (int)lon; + } else { + p->lon = (int)lon - 1; + } + /* printf(" p->lon = %d\n", p->lon); */ + + diff = lat - (double)(int)lat; + /* printf("diff = %.2f\n", diff); */ + if ( (lat >= 0) || (fabs(diff) < FG_EPSILON) ) { + p->lat = (int)lat; + } else { + p->lat = (int)lat - 1; + } + /* printf(" p->lat = %d\n", p->lat); */ + + p->x = (int)((lon - p->lon) * 8); + p->y = (int)((lat - p->lat) * 8); + /* printf( "Bucket = lon,lat = %d,%d x,y index = %d,%d\n", + p->lon, p->lat, p->x, p->y); */ +} + + +/* Given a lat/lon, fill in the local tile index array */ +void fgBucketGenIdxArray(struct fgBUCKET *p1, struct fgBUCKET *tiles, + int width, int height) { + struct fgBUCKET *p2; + int dw, dh, i, j; + + dh = height / 2; + dw = width / 2; + for ( j = 0; j < height; j++ ) { + for ( i = 0; i < width; i++ ) { + fgBucketOffset(p1, &tiles[(j*width)+i], i - dw, j - dh); + p2 = &tiles[(j*width)+i]; + /* printf( " bucket = %d %d %d %d index = %ld\n", + p2->lon, p2->lat, p2->x, p2->y, + fgBucketGenIndex(&tiles[(j*width)+i])); */ + } + } +} + + +/* sample main for testing +int main() { + struct fgBUCKET p1; + long int tile[49]; + char path[256]; + double lon, lat; + int i, j; + + p1.lon = 180; + p1.lat = 90; + p1.x = 7; + p1.y = 7; + + printf("Max index = %ld\n", gen_index(&p1)); + + lon = -50.0; + lat = -50.0; + find_bucket(lon, lat, &p1); + gen_idx_array(&p1, tile, 7, 7); + for ( j = 0; j < 7; j++ ) { + for ( i = 0; i < 7; i++ ) { + gen_path(tile[(j*7)+i], path); + printf(" path = %s\n", path); + } + } + + lon = 50.0; + lat = 50.0; + find_bucket(lon, lat, &p1); + gen_idx_array(&p1, tile, 7, 7); + for ( j = 0; j < 7; j++ ) { + for ( i = 0; i < 7; i++ ) { + gen_path(tile[(j*7)+i], path); + printf(" path = %s\n", path); + } + } + + return(1); +} */ + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:28:58 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.6 1998/02/09 15:07:51 curt + * Minor tweaks. + * + * Revision 1.5 1998/01/29 00:51:38 curt + * First pass at tile cache, dynamic tile loading and tile unloading now works. + * + * Revision 1.4 1998/01/27 03:26:41 curt + * Playing with new fgPrintf command. + * + * Revision 1.3 1998/01/27 00:48:01 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * + * Revision 1.2 1998/01/24 00:03:28 curt + * Initial revision. + * + * Revision 1.1 1998/01/23 20:06:51 curt + * tileutils.* renamed to bucketutils.* + * + * Revision 1.6 1998/01/19 19:27:18 curt + * Merged in make system changes from Bob Kuehne + * This should simplify things tremendously. + * + * Revision 1.5 1998/01/14 02:19:04 curt + * Makde offset_bucket visible to outside. + * + * Revision 1.4 1998/01/13 00:23:12 curt + * Initial changes to support loading and management of scenery tiles. Note, + * there's still a fair amount of work left to be done. + * + * Revision 1.3 1998/01/10 00:01:47 curt + * Misc api changes and tweaks. + * + * Revision 1.2 1998/01/08 02:22:28 curt + * Continue working on basic features. + * + * Revision 1.1 1998/01/07 23:50:52 curt + * "area" renamed to "tile" + * + * Revision 1.1 1998/01/07 23:23:40 curt + * Initial revision. + * + * */ + + diff --git a/Bucket/bucketutils.h b/Bucket/bucketutils.h new file mode 100644 index 00000000..012fc510 --- /dev/null +++ b/Bucket/bucketutils.h @@ -0,0 +1,123 @@ +/************************************************************************** + * bucketutils.h -- support routines to handle fgBUCKET operations + * + * Written by Curtis Olson, started January 1998. + * + * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + * (Log is kept at end of this file) + **************************************************************************/ + + +#ifndef _BUCKETUTILS_H +#define _BUCKETUTILS_H + + +#ifdef __cplusplus +extern "C" { +#endif + + +struct fgBUCKET { + int lon; /* longitude (-180 to 179) */ + int lat; /* latitude (-90 to 89) */ + int x; /* x (0 to 7) */ + int y; /* y (0 to 7) */ +}; + + +/* Generate the unique scenery tile index containing the specified + lon/lat parameters. + + The index is constructed as follows: + + 9 bits - to represent 360 degrees of longitude (-180 to 179) + 8 bits - to represent 180 degrees of latitude (-90 to 89) + + Each 1 degree by 1 degree tile is further broken down into an 8x8 + grid. So we also need: + + 3 bits - to represent x (0 to 7) + 3 bits - to represent y (0 to 7) */ +long int fgBucketGenIndex(struct fgBUCKET *p); + + +/* Parse a unique scenery tile index and find the lon, lat, x, and y */ +void fgBucketParseIndex(long int index, struct fgBUCKET *p); + + +/* Build a path name from an tile index */ +void fgBucketGenBasePath(struct fgBUCKET *p, char *path); + + +/* offset an bucket struct by the specified amounts in the X & Y direction */ +void fgBucketOffset(struct fgBUCKET *in, struct fgBUCKET *out, int x, int y); + + +/* Given a lat/lon, find the "bucket" or tile that it falls within */ +void fgBucketFind(double lon, double lat, struct fgBUCKET *p); + + +/* Given a lat/lon, fill in the local tile index array */ +void fgBucketGenIdxArray(struct fgBUCKET *p1, struct fgBUCKET *tiles, + int width, int height); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _BUCKETUTILS_H */ + + +/* $Log$ +/* Revision 1.1 1998/04/08 23:28:59 curt +/* Adopted Gnu automake/autoconf system. +/* + * Revision 1.2 1998/01/24 00:03:28 curt + * Initial revision. + * + * Revision 1.1 1998/01/23 20:06:52 curt + * tileutils.* renamed to bucketutils.* + * + * Revision 1.6 1998/01/22 02:59:42 curt + * Changed #ifdef FILE_H to #ifdef _FILE_H + * + * Revision 1.5 1998/01/14 02:19:05 curt + * Makde offset_bucket visible to outside. + * + * Revision 1.4 1998/01/13 00:23:12 curt + * Initial changes to support loading and management of scenery tiles. Note, + * there's still a fair amount of work left to be done. + * + * Revision 1.3 1998/01/10 00:01:48 curt + * Misc api changes and tweaks. + * + * Revision 1.2 1998/01/08 02:22:28 curt + * Continue working on basic features. + * + * Revision 1.1 1998/01/07 23:50:52 curt + * "area" renamed to "tile" + * + * Revision 1.1 1998/01/07 23:23:40 curt + * Initial revision. + * + * */ + + -- 2.39.5