With WPF now being supported under Net5 and Visual Studio 2019 I thought it was time to re-acquaint myself with it. Since I learn mostly by doing I figured I’d write an app I could use. The result was GeoProcessor. You can find the source code for it, as well as the core library it uses, on github. This is the story of how it was built and what I learned along the way1.
Background
This app derives from my love of motorcycle riding through California’s hinterlands. I like to write up those journeys and include the routes I’ve traveled for display in things like Google Earth. But the raw GPS tracking data is stored in GPX files which aren’t as useful as KML or KMZ files. More importantly, they’re just raw GPS points; they’re not snapped to the roads on a map, resulting in “jaggy” displays. The app I wrote takes a GPX, KML or KMZ file as input, cleans it up, snaps it to roads, and outputs either a KML or KMZ file.
It depends on a number of open-source libraries (GPL v3 or later) I’ve written which I won’t describe here (except for WPF View Model). They’re all available on nuget. You can read more about them on their github pages:
Library | Functionality | |
---|---|---|
J4J Logger | wrapper around Serilog providing capture of source code and type information | |
Dependency Injection | defines a composition root framework | |
Visual Utilities | utilities for dealing with colors | |
WPF View Model | extends the dependency injection library to provide view model locator services for WPF apps | |
GeoProcessor core | core routines for handling GPX, KML and KMZ files, and for interfacing with the Google and Microsoft snap-to-route engines |
Development Environment
This app was developed in Visual Studio 2019, version 16.8.4. It targets Net5 (as do my libraries) and enforces nullability requirements. It was built to run under the latest version of Windows 10 available at the time it was written.
It utilizes the MahApps.Metro extension framework to provide a more modern (“Metro”) look-and-feel.
For similar reasons it also uses the Material Design In XAML toolkit. There’s a separate package you’ll need to include to integrate the Material Design stuff into MahApps.Metro. There are instructions for how to do this integration available at the Material Design site.
Whenever possible I’ve eliminated MahApps.Metro and Material Design details from the code snippets. But if you see a method call or declaration you don’t recognize, or is not available in plain vanilla WPF, the odds are it’s from one of those frameworks.
Please remember I’m sharing my current understanding…and the main reason I write software is to learn new concepts, so that understanding changes over time. At any given point my understanding may be wrong or incomplete. If you come across a glitch like that please write and let me know about it. ↩