Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 5: Storing and Sharing Information


Using an RDBMS


The problem with both XML and text files is that you are limited to editing the files one at a
time. Using these files in a Google Maps application is a not a problem if you are the only per-
son editing and dealing with the data. If you want to offer interactivity or provide the facility
for multiple people to store and edit the information you are using, however, you need to either
consider using some sort of locking mechanism (to prevent multiple applications trying to
update the same file) or take a look at a proper database solution that handles the locking and
storage of the data.

An RDBMS provides the ability for multiple clients to update and access the information in
the database at the same time. For this reason using an RDBMS makes it much easier to sup-
port a large Google Maps application with multiple users.

Most RDBMS solutions use SQL as the method for querying and updating information.
Examples of SQL databases include commercial solutions such as Microsoft’s SQL Server,
Oracle, and free software solutions like MySQL, PostgreSQL, and Derby. All are capable
examples of database software that you can use for storing vast quantities of information in a
format that also makes it easy to retrieve the data when you want it.

If you support a SQL interface within your application, you can connect and interact with
existing databases that you may have access to. For example, you might want to expose sales
or customer information through your Google Maps application, and that will require combin-
ing location data with the information from the RDBMS that you already use to store this
information.

Parsing and Generating Text Files


When you are developing Google Maps applications, you may be forced to work with existing
text files that have been exported by other applications and environments, or you may want to
use a flat-text file as an interface for exchanging information between applications.

Storing structured data in a standard text file means applying some simple rules about the for-
mat of the information. These are rules that you will need to know in order to be able to read
the information back. Once you know the format, generating the file or parsing the content is
comparatively easy. The two basic formats are as follows:

Fixed-width files, in which the record and its content is of a fixed size.

Delimited files, in which a special character is used to separate individual fields and
records.

I don’t recommend text files of either type for storing information, but you may often need to
exchange data between other applications (like Excel) that use fixed-width files. For that rea-
son, here’s a quick look at how to read and write both delimited and fixed-width files.
Free download pdf