Keyhole Mark-up Language (KML) proved to be the solution to all the geographic visualisations I needed to do. The advantages were that it had XML roots – which makes it easy to learn, It had simple vertex based mapping – where all the drawing and projection systems are taken care by the viewer (Google Earth) and I was a simple text based file system – which enables one to create a KML file by just writing in plain text. By combining, KML and C one gets the power to carry out complex calculations and at the same time, store them and display them through a standard format which is widely used. So now my aim was to create a program which creates a KML file from a set of data provided to it in a standard format.
After two days of continuous coding and debugging, the final version of the program is here. What it does is to take input from a text file as pointed by the user and looks for points defined by delimited data (Space, tab or newline) in four columned arrays [name, latitude, longitude and distance] and draws a circle around the points with a radius of distance specified and stores those polygons in a KML file which can be viewed in Google earth. Since I don’t want to get into really minute details of the concepts and directions, as I did last time, I will mention the broad concepts which I learned and extensively used in the program below,
- File management in C – Opening, reading and writing text files through C.
- KML Specification – Constructing different types of geometry in Google Earth through KML files
- Geometry and projection system – Ellipses, Circles, spheres and how they are defined in Cartesian geometry and how do they transform when projected on earth.
The program as of now has two major drawbacks,
- It assumes the earth to be sphere and not a spheroid which can cause small errors in extreme latitudes
- There cannot be any space in the name field of the data, which will cause the program to read it as a delimiter and go berserk with the rest of the data.
The download link is given below. Feel free to point out any blunders, problems and ways for improving the program.
One thought on “Programming Part II”
Good Going! Can’t wait to see a practical utility take shape out of this.