Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Give Your Applications Mapping Capabilities, Part 1  : Page 2

Discover how easy it is to acquire and store geographic data that you can use to add maps and 3D rendering to your applications.


advertisement
Applying the Data
There are many ways you can apply stored geographic data, depending on your goals. For example, a point-of-sale system can bind marketing information to geographical positions to create maps that show different icons for different POS results, such as plotting appropriately sized markers to show the sales volume in various locations. Or you might create a detailed plan of a city mass-transit system, binding bus-stop data, route lines, schedules, tourist attractions, and other points of interest, as this PalmBUS system does.

The process of relating geographic points to "attributes" that facilitate creating the map view you want is always the same: You associate point data to other information, and then display the information on a map. You can do all this using any standard database and any standard GIS rendering engine.

Author's Note: Take care that your applications always treat the three point values as a single entity. Isolated latitude, longitude, and altitude measurements aren't usually very useful. You always need at least the latitude and longitude values to plot an accurate point—and most systems require all three values.

 
Figure 1. Map Coordinates: You can jump to a specific Google Map view by entering latitude/longitude coordinates such as "45.703909N 9.66276E" in the Google Map address field.
After collecting your points as described earlier, you can test them using Google Maps or Google Earth. For example, open Google Maps. This web-based mapping application accepts addresses in text form, but it can also accept latitude/longitude coordinates. For example, if you enter 45.703909N 9.66276E (which means latitude 45.703909 North, longitude 9.66276 East) in the application's "Search the Map" field, and then click "Search Maps" (or just click Enter), you will go to the map shown in Figure 1, which has the coordinates you entered.

Working with Google Earth is quite different from Google Maps, but more exciting. Google Earth renders data defined in XML files. For example, to show a map at a point you've collected, you create an XML file containing the data. To try it, open Notepad, and paste in the following XML:

<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.2"> <Document> <name>Arena di Verona.kml</name> <Placemark> <name>Arena di Verona</name> <LookAt> <longitude>10.99394514599905</longitude> <latitude>45.44023503220072</latitude> <altitude>200</altitude> <range>759.5637314343327</range> <tilt>58.7902038199754</tilt> <heading>0.8203667851755632</heading> <altitudeMode>relativeToGround</altitudeMode> </LookAt> <Point> <coordinates>10.99451099760466,45.43891075160266,0</coordinates> </Point> </Placemark> </Document> </kml>

The preceding Google Earth XML structure is written in an XML language called Keyhole Markup Language (KML). The most important portion of the code is the <Point> element, which defines a point using the <coordinates> node. The <coordinates> node takes three comma-separated values that specify longitude, latitude, and altitude.

 
Figure 2. Arena di Verona: You'll see an image similar to this one in Google Earth when you open the "myPoint.kml" file that specifies the coordinates and the viewing position.
Another important feature of the KML you defined above is the <LookAt> node, which contains the coordinates for the point over which the map is centered—in other words, the current point of view. You can change the LookAt element's sub-nodes to define a different point of view. Also, note the <altitudeMode>relativeToGround</altitudeMode> element. Google Earth manages altitude values as relative to the ground, not relative to sea level, so although the <Point> element in the KML describes a point with an altitude of 0, Google Earth will render the view relative to the point on the Earth's surface (which at this location is actually about 62 meters above sea level). That's convenient for most purposes, because you don't have to have an accurate altitude value to render a usable view. You can study the KML documentation for more information.

To view the point in Google Earth, save the Notepad file in some convenient folder as myPoint.kml and then open the file with Google Earth, by clicking the File → Open menu and selecting the saved file. You'll see a satellite map view similar to Figure 2 (depending on your Google Earth settings, you may see a different image.

Author's Note: Google Earth shows position in degrees, minutes, and seconds (DD, MM SS format) by default, but you can switch to decimal notation through the configuration menu.

As you can see, getting started with GID applications is quite simple. You collect points via GPS or existing maps, and render them using a mapping application. You don't need expensive hardware, and you can write simple software without too much work. With a little effort, you can write exciting business applications that feature 2D maps or 3D earth-rendering systems.



Bruno A. Zambetti is founder of Huge! srl, an Italy-based company specializing in Internet and distributed solutions. He is a .NET Architect, a Fortinet-certified network specialist, and has authored several articles on .NET and web infrastructures.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap