ov2optimizer - Implementation

Development Environment

This incarnation of ov2optimizer (v2.x) is a re-write of a utility I built years ago using VB6 and the Jet database engine. While that old v1.x version still works okay, even with Windows 8.1, I wanted to bring it more up to date by using C# and System.Data.Sqlite. It still runs as a 32-bit application (because it was written on a 32-bit machine), but v2.x runs noticeably faster than v1.x, mainly because the SQLite database is maintained completely in memory.

Algorithm

The key piece of the application is a method named ProcessBlock(). As the POI records are loaded into the SQLite database the application keeps track of the maximum and minimum values for Longitude and Latitude. Once all of the POIs are loaded the application calls ProcessBlock() with those max/min values, which represents a rectangle that covers the entire set of POIs.

ProcessBlock() queries the database to see if more than 20 POIs are in the specified rectangle. If so, it divides the rectangle in half and calls itself recursively to work on each half. This recursion continues (alternating North/South and East/West splits) until a specified rectangle contains no more than 20 POIs, at which point ProcessBlock() writes the skipper record and POI data (eventual OV2 output) to a binary buffer. After all rectangles have been completely processed the binary OV2 data is written to a .ov2 file on disk.

Source Code

The source code is available at https://github.com/gordthompson/ov2optimizer