Ocean Information Center Intern Postings https://sites.udel.edu/OceanicInterns Change is good...we'll go first! Mon, 19 Mar 2012 18:13:11 +0000 en-US hourly 1 https://sites.udel.edu/?v=6.0.3 Creating a KMZ with 7Zip https://sites.udel.edu/OceanicInterns/2011/05/20/creating-a-kmz-with-7zip/ Fri, 20 May 2011 16:49:16 +0000 http://sites.udel.edu/OceanicInterns/?p=114 Continue Reading ]]> Since the original KML file of the ship track was 3.4MB and had dependent files, a KMZ was necessary for stability and bandwidth reasons, and the KMZ had to be compressed using the Deflate algorithm. The C# compression (GZip) didn’t have much documentation to help, or details on the specifics of the compression algorithm. Another method was the #ziplib library. I was trying to avoid adding extra complexity to the program from using a 3rd-party library, so I  decided to call 7-zip from a batch script. The program is now run using the batch script as follows:

SMS.exe -k
7z.exe a RVSharp.zip values.kml placemarkBY.png placemarkY.png
del RVSharp.kmz
ren RVSharp.zip RVSharp.kmz

The first line calls my program and updates values.kml
After updating the script generates the zip file, the KMZ extension cannot be used yet because of default settings issues
The KMZ is made (after deleting the previous file) by renaming the file from *.zip to *.kmz

]]>
Merging programs https://sites.udel.edu/OceanicInterns/2011/04/15/merging-programs/ Fri, 15 Apr 2011 18:41:31 +0000 http://sites.udel.edu/OceanicInterns/?p=110 Continue Reading ]]> I am still working on merging my smaller programs into one, and plan on using flags to call each sub-program. At the moment, the csv generator and database writer have been merged, but still has bugs where the csv generator as a standalone program isn’t  breaking down into modules nicely. The difficult part is getting each part of the program interfaced without breaking it. Afterwards, I will be writing the KML generator and interfacing it, hopefully a little easier than this the csv is going. It’s strangely like the rubiks cube sitting on the desk, where fixing one part breaks another. However, taking a couple minutes to work with the cube actually makes the structure of the program easier to follow when I go back to it. Probably a good idea for any programmer to have one on the desk.

]]>
Surface Mapping to KML Overview https://sites.udel.edu/OceanicInterns/2011/04/01/surface-mapping-to-kml-overview/ Fri, 01 Apr 2011 17:10:15 +0000 http://sites.udel.edu/OceanicInterns/?p=103 Continue Reading ]]> I’m programming the next step of the SMS application now. The goal is to go from the database that I made earlier to a KML track. With the exception of generating the KML data, all modules are working at the moment. I will be upgrading the database side from SQLCE 3.5 to 4.0, then combining the the several scattered modules into a smaller program. Currently, the different applications I have made will be repeating tasks if I continue with my current code. The programs and functions are listed below:

SMSDatabse – Original Program, reads in SMS text files, removes entries with invalid data, then stores to a database

SMStoCSV – New Program, reads files from database made by SMSDatabase, scans for valid data at 10 min. intervals, then outputs a CSV or stores in a database

SMStoKML – New Program, uses output of SMStoCSV to generate a KML ship track

Seeing each programs function broken down, it’s obvious that the 1st and 2nd programs are doing duplicate steps and storing unnecessary data. The better solution would be to merge the CSV function from the 2nd program into the 3rd as an option of either KML or CSV. Then merge what remains of the 1st and 2nd together, making a program that reads SMS files directly for 10 min. intervals to store in a database. Additionally, a record of which files have been scanned in needs to be kept. I plan on using a database of only file names or another unique identifier to keep track of what has been done. I will be posting updates as I work through each of these steps.

]]>
Surface Mapping Application is Finished https://sites.udel.edu/OceanicInterns/2010/08/20/surface-mapping-application-is-finished/ Fri, 20 Aug 2010 17:07:06 +0000 http://sites.udel.edu/OceanicInterns/?p=96 Continue Reading ]]> The surface mapping application is finished. It checks the data for consistency (not as a numerical anlysis), and writes it to a database, possibly for later use as the source of a KML file for Google Earth or use in analysis software. I’ve written the documentation posted below.

The SMSDatabase program was designed to import measurement data from the Surface Mapping System onboard a research vessel into a database. The files necessary for the program are SharpHeader.csv and SMSDatabase.sdf, both must be in the program directory. Included in SharpHeader is the column headers, explanations of columns, and data types necessary for the program. The data types are contained in the 3rd row and determine how the program scans in each field. Also included is SMSDatabase – Blank, an empty database made in the required format.

Running the program

The program is called using the following console application –

     SMSDatabase.exe “DriveLetter:\\Folder\\Folder\\File”

The doubled backslashes are required as the file path is read in as a C string; an escape character to use a backslash is necessary. When run the program will scan in the specified file, format the data into a normalized set, then write the data to the database. No output is shown while running or at completion, the program is assumed to have run successfully if no error codes are displayed.

Functions of the program

The basic structure of the program is the following:

  • Import header 3rd row of header, for data types
  • Split header into array to match types
  • Read file in as array (each row is an element)
  • Open SQL connection (using SQL Compact Edition)

For each row in the file do the following:

  • Split row into array then run checkForValid (does row have valid lat/lon data)
  • If row is valid then run castRowData (checks decimal elements/formats position)
  • Build SQL command then write to database

checkForValid requires an array (the row array), and returns a Boolean value. The function scans the latitude and longitude and final element of the row for valid data. The data is determined invalid if it meets 1 of the following; equal to -99 (null value), format exception error (the element is not a number), index out of range at row 7, 10, or 29 (the element does not exist). The Boolean value returned if the data is valid is true, if invalid it is false.

castRowData requires 2 arrays (the row array and data type array), and returns the row array as cleaned data. A comparison test is run for each element of the data type array. The array looks for a String, Dec, LatSuffix, or LonSuffix. If the type is string then nothing is done to the array. Dec requires a data test. Each element is cast as a decimal value then saved as a string, using the value if the test succeeded or NA if it failed. LatSuffix and LonSuffix are similar operations. Both scan the value for which hemisphere to use and convert the lat/lon data to an absolute reference. The value is multiplied by -1 where applicable to correct the data.

Expanding the program

In the future, the program may need to be modified to work with a file with more columns. To update the code the following changes would need to be made:

  • Modify SharpHeader.csv to show the correct format and number of columns
  • Modify SMSDatabase.sdf to contain the necessary number of columns
  • For loop after creating SQL command, change <= 30 to correct number
  • testRead = rowArray[29] in checkForValid, change 29 to correct number

So this program concludes my internship with UD. I had some prior experience with C, but never any with C++ or C#, so I learned a lot from that. Databases and file access actually turned out to be very easy with the .NET framework. Even though I never got to use the skills I’ve learned with Google Earth and KML files, I learned a lot from the graduate students while working in the ORB lab. They have been a great crew to work with.

]]>
Surface Mapping Database https://sites.udel.edu/OceanicInterns/2010/08/19/surface-mapping-database/ Thu, 19 Aug 2010 17:12:08 +0000 http://sites.udel.edu/OceanicInterns/?p=90 Continue Reading ]]> The database application is mostly finished. Using SQL Compact, it can read in a file name as a parameter passed into the program, correct missing or corrupt values, then save to a database. To be officially finished with the application I have some commenting to do and a couple subroutines to clean up in the database section. The location of the SQL commands actually was very important to the performance of the program. Leaving them inside of the loops where I had intended to use them increased the run time by almost 10x, so they were ungracefully removed from within the subroutines.

]]>
Surface Mapping Application Pt. 2 https://sites.udel.edu/OceanicInterns/2010/08/12/surface-mapping-application-pt-2/ Thu, 12 Aug 2010 19:09:43 +0000 http://sites.udel.edu/OceanicInterns/?p=85 Continue Reading ]]> Still copying the source code from my previous projects into a complete application. Most functions integrated seemlessly. At the moment my program is has 3 subroutines, about 80 lines in the main function and is only missing the database access and KML subroutines. The database access is proving to be the hardest part, the function likely is going to be very large as the array has a possible size of 30×360, and I haven’t found a way to add each row without adding each element individually.

So far the application can validate each row of data for lat/lon and useable values. Next will be writing the database application,expanding on the previous SQL CE database. Even though it’s still copy and paste from my old code, the subroutines for writing have been difficult to visualize.

]]>
Surface Mapping Application https://sites.udel.edu/OceanicInterns/2010/08/10/surface-mapping-application/ Tue, 10 Aug 2010 18:03:57 +0000 http://sites.udel.edu/OceanicInterns/?p=82 Continue Reading ]]> I’ve started working on the full application for the SMS data. So far I have the application broken up into the different functions and will be pasting the working applications into each function. The database access still seems to be the most difficult part, although I’ve only roughly outlined the section to produce KML files from the database. I will post more information Thursday as the program starts to come together more.

]]>
Data protection https://sites.udel.edu/OceanicInterns/2010/08/03/data-protection/ Tue, 03 Aug 2010 17:57:13 +0000 http://sites.udel.edu/OceanicInterns/?p=74 Continue Reading ]]> At the moment, I have lost my operating system on my laptop about 6 times this year, primarily due to data corruption. After several lessons in doing proper backups I’ve finally found a method that works instantly and can be left alone after it’s set up. I’m using Dropbox, a free tool for keeping a directory synced with a server. It couldn’t be used as the only part of the setup as it can’t sync any chosen directory, only its own. However, I’m using PureSync (also free) to keep multiple directories synced to the Dropbox directory. When a file is updated PureSync sees the modification and copies it to the Dropbox directory, where it gets stored online.  In theory, you could have multiple computers using the same Dropbox, which would maintain current copies of your Documents/Photos/etc. folders across all computers.

]]>
SQL Compact Pt. 2 https://sites.udel.edu/OceanicInterns/2010/08/03/sql-compact-pt-2/ Tue, 03 Aug 2010 17:39:33 +0000 http://sites.udel.edu/OceanicInterns/?p=71 Continue Reading ]]> After getting some help from the members at stackoverflow.com, learning SQL CE is going better. Last time I spent a lot of time trying to solve a problem with my code, then after posting my code online had a solution in less than a hour. I haven’t had to post anything today, but have been learning from some searches on the site and have finally have a small program with Read/Write access to a database.

]]>
SQL Compact https://sites.udel.edu/OceanicInterns/2010/07/29/sql-compact/ Thu, 29 Jul 2010 19:41:00 +0000 http://sites.udel.edu/OceanicInterns/?p=67 Continue Reading ]]> I’ve been working with SQL database access, and have run into a problem. I’ve been following a sample online to do a basic write, made some progress with it but I haven’t been able to solve what I’ve gotten to. I’ve posted the question at stackoverflow, any help would be very appreciated.

]]>