This page is intended to document the software approach, useful links, and lessons learned in creating the software used to process the GEOSAP trail maps into the desired statistics and/or plots.
Software Development Priorities
The initial approach will be to find an automatic way to generate CSV files from the GE trail maps. This will allow us to post-process the files into whatever statistics or plots are desired with Excel, Matlab, or similar software.
In the medium term, it may be useful to be able to down-select the data prior to export to CSV to reduce the amount that needs to be post-processed (e.g. "only give me intermediate trails from ski areas in NH and VT").
In the longer term, having the statistical/plotting software tightly coupled with GE would allow easier data exploration. For example, one could call up the plots/stats within GE, then as ski areas and trails are selected or de-selected, the plots/stats would update on the fly.
In the very long term, it would be ideal to have statistics and plots updated and displayed "live" on the website as people revise and upload new maps.
It would also be useful to provide utilities that help in selecting/de-selecting placemarks based on GEOSAP parameters (e.g. "only select ski areas with vertical drop > 500').
Making the statistics/plots aware of distance from the user's location (or better yet, drive time), would enable users to rank areas by nearness, as well, which is a key parameter when deciding where to go skiing. One could even incorporate flying time and drive time from the nearest airport so you could optimize vacation planning.
Statistical software
An initial cut at the statistic-generation portion of the software is now available. It operates on these "hand-made" sample csv's, generated from Sunday River, ME:
- area.csv contains a single lift, trail centerline, trail boundary, and area boundary.
- area2.csv contains two lifts, two trail centerlines, 1 trail boundary, and area boundary.
The file geosap.m can be run in Matlab, and it depends on lla2enu.m and transform.m to do coordinate transformations. To run this software, put all 3 files in the current directory in Matlab. If you've put area.csv in 'mydirectory', you can run the software by typing:
>> geosap c:\mydirectory\area.csv
… in the command window and it will produce a file c:\mydirectory\area.txt that looks like these, generated from the sample files above:
This is basically at the proof-of-concept stage. Once the routine is more functional, I'll include a compiled, executable version that does not require Matlab to run.
Links
- Google Earth COM API Documentation
- A massive thread about the API at the Google Earth Community forum that started when the beta was released.
- The KML Developer Support Google Group is the successor to the massive GEC thread.
- KML documentation
- A new Google Earth Community Thread about generating statistics from GE polygons and paths.
- A .NET (C#) wrapper for the API.
- The project file provided with the C# wrapper is for Visual C# 2005, which is a free download. There is now a 2008 version available as well, but it generates error messages with the C# wrapper "out of the box."
- C# tutorial given by Microsoft.
- Java version of the GE API with how-to guide that is said to not work well at all.
Lessons Learned
- The "Google Maps API" is for people who want to embed Google Maps into their websites—it does not appear useful for this effort.
- It appears that using Visual C# Express and the C# wrapper above is a widely used approach, so we'll try that first.
- GetMainHwnd must be called to select the GE application.
- SetForegroundWindow makes sure GE is the current application.
- SendKeys is used to copy ("^C") the placemarks to the clipboard so their properties can be accessed.
- GetPointOnTerrainFromScreenCoords must be called to get altitude data for each point.
- StreamWriter is a simple way to write text files.