🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.soft-sys.khoros
Article #984

Re: DLG2VIFF

#984
From: Donna Okazaki
Date: Fri, 20 Nov 1992 21:41
120 lines
5543 bytes
In article <41543@pprg.eece.unm.edu.pprg.unm.edu> rasure@borris.eece.unm.edu (John Rasure) writes:
>
>In "DLG2VIFF", Chris Blasband writes:
>+ I have received over 900 DLG files from USGS and I am
>+ trying to use the dlg2viff command to transform them
>+ into viff files. When I type in the command, Khoros
>+ just sits there and does nothing (it does not even
>+ open up the output file).
>+ 
>+ Has anyone successfully read in the optional formatted
>+ DLG files, and if so, what's the trick.
>
>It has been awhile since this has come up.  About 9 months ago, we
>considered rewriting the dlg2viff code for a Khoros 1.0 patch - but
>we did not.  It was implemented poorly.
>
>What prompted us to look at it in detail was that there was a bug on SUNS
>that did not show up on DEC machines .... in trying to track it down we
>decided the best thing to do was leave it alone and rewrite it when we
>get resources to do so - it may or may not be in Khoros 2.0.
>

I have been using DLG2VIFF on a Sparc 2 running SunOS 4.1.2
on USGS Optional format, level-3 DLG files with no problem.
(Using Khoros 1.0.5).  When I read the data from the tape, I
converted them from fixed length to variable length records,
terminated by newlines.

However, I agree that its design leaves much to be desired
and may get around to rewriting it myself if my stack ever gets
that low. <wishful thinking> :-)

BTW, there is a small bug/oversight in the readline() function in
dlg.c which doesn't seem to affect DLG2VIFF, but is annoying 
for those of us trying to use the readdlg() function to extract 
line records from level-3 files.  The following patch fixes this:

*****patch dlg.c in $KHOROS_HOME/src/file_formats/Lib*****
591a592
>     /* 11-13-92 - patched to read line number */
593c594
<     readfixed (file,  5, "%d", dummys);
---
>     readfixed (file,  5, "%d", &(lineptr->linenum));
*****end of patch*****


Also, there is a major bug in DEM2VIFF which causes it to crash
on some DEM files.  I also thought it should be able to read DEM's
with elevation in FEET and convert it to meters instead of
rejecting the DEM and it should also apply the z-resolution factor
to the elevations.  These fixes are contained in the following patch:

*****patch ldem2viff.c in $KHOROS_HOME/src/file_formats/Lib*****
61a62
> #include <math.h>
62a64
> #define FEET2METERS .3048
180a183
>      * 10-15-92 Added feet capability.
183,185c186,188
<         if (dem_img->elevationunit != METERS) {
<             fprintf (stderr, "error in ldem2viff: 1-degree DEM data must ");
<             fprintf (stderr, "have elevations given in meters\n");
---
>         if (dem_img->elevationunit != METERS && dem_img->elevationunit != FEET) {
>             fprintf (stderr, "error in ldem2viff: 1-degree DEM data must ");
>             fprintf (stderr, "have elevations given in meters or feet\n");
190,192c193,195
<         if (dem_img->elevationunit != METERS) {
<             fprintf (stderr, "error in ldem2viff: 7.5-minute DEM data must ");
<             fprintf (stderr, "have elevations given in meters\n");
---
>         if (dem_img->elevationunit != METERS && dem_img->elevationunit != FEET) {
>             fprintf (stderr, "error in ldem2viff: 7.5-minute DEM data must ");
>             fprintf (stderr, "have elevations given in meters or feet\n");
291c294,295
<                 elevation = elevation + (float)dem_img->data[x]->elevation;
---
>                 elevation = elevation + 
>                             (float)(dem_img->data[x]->elevation * dem_img->zres);
292a297,303
>                 /*
>                  * 10-15-92 Adjust feet to meters if necessary.
>                  */
>                 if (dem_img->elevationunit == FEET) {
>                     elevation *= FEET2METERS;
>                 }
> 
406c417,418
<                 elevation = elevation + dem_img->data[x]->elevation;
---
>                 elevation = elevation +
>                             (float)(dem_img->data[x]->elevation * dem_img->zres);
409,410c421
<                  *
<                  *
---
>                  * 10-15-92 Adjust feet to meters if necessary.
411a423,430
>                 if (dem_img->elevationunit == FEET) {
>                     elevation *= FEET2METERS;
>                 }
> 
>                 /*
>                  * 10-21-92 Fix calculation of i.  Range must go from
>                  * 0 to (xv_rows-1) so data won't overflow outside of array.
>                  */
413,414c432,433
<                 i = (int) (((northing-min_northing)/northing_range) * xv_rows);
<                 i = xv_rows -i;
---
>                 i = irint(((xv_rows-1)*(northing-min_northing))/northing_range);
>                 i = (xv_rows-1) - i;
*****end of patch*****

-----
She surveys seafloors       | Donna Okazaki
to the seashore             | Univ. of Hawaii, Geography Dept.
        ~ ~ ~ ~             | donna@uhunix.uhcc.hawaii.edu
Technical Details
Message-ID: <1992Nov20.214121.19791@news.Hawaii.Edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!news.hawaii.edu!uhunix.uhcc.Hawaii.Edu!donna
References: <41543@pprg.eece.unm.edu.pprg.unm.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.soft-sys.khoros
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!news.hawaii.edu!uhunix.uhcc.Hawaii.Edu!donna
From: donna@uhunix.uhcc.Hawaii.Edu (Donna Okazaki)
Subject: Re: DLG2VIFF
Message-ID: <1992Nov20.214121.19791@news.Hawaii.Edu>
Sender: root@news.Hawaii.Edu (News Service)
Nntp-Posting-Host: uhunix.uhcc.hawaii.edu
Organization: University of Hawaii
References: <41543@pprg.eece.unm.edu.pprg.unm.edu>
Date: Fri, 20 Nov 1992 21:41:21 GMT
Lines: 120