DCD documentation (09/15/2009)

 

The Vision, part 1: I want to make applications using IBM’s ILOG Elixir:

http://www.ilog.com/products/ilogelixir/

http://visudemos.ilog.com/blogsamples/factbook2/FactBookSE.html

and Stateline.org’s online maps, both static as well as movies/time-series:

http://www.stateline.org/live/sections/Recession+%26+Recovery

 

 

I am looking for a platform/software/etc that is 1)  “in the cloud” [not on a client’s machine/client’s server] and 2) lighter than Google Maps/Google Earth/MapCruncher for Bing Maps/Silverlight [Microsoft Silverlight 3 Tools for Visual Studio 2008 SP1]/MapServer.

 

It looks like Adobe Flash and Flex are the tools I want; Flash seems to be for Animations (and for “Designers”), while Flex (also produces files in swf/Flash file format) seems to be for static visualizations and “will become the standard method for making flash applications that are not based on animating” (and seems to be for people coming from a “development background”).

 

Working with Flex

 

Flex (currently Adobe Flex 3) is a language for deploying programs that reside on a Web Server. A user types in a URL in their Internet browser (or clicks on a link) and Adobe Flash Player (currently version 10.0.32.18) [installed on the client] “plays” the appropriate swf file from the Web Server. It is “very light”; to have the client work off-line, create an Adobe AIR application which can be loaded onto a client’s machine and run anytime – obviously this is “heavier”.

http://www.adobe.com/products/flex/

 

Flex is available as a free SDK, or as part of the “Flex Builder 3 trial”. “free” is good, but Flex Builder provides a development environment to create Flex programs, and most of the documentation I have seen discuss working within Flex Builder to create Flex (and AIR) programs. I have been using the free-trial version of Flex Builder 3 since August 1, 2009 (and I have been using IBM’s ILOG Elixir free-trial since August 6, 2009).

 

Reading lots of documentation, I have created ~20 swf files/applications, six of which are up on www.dennisdixon.net

 

Runner.swf     labels, a text-input box, calculated text, calculated entries in a list box

 

 

Pictures2.swf    5 Ansel Adams mini-images – click on one to have it appear big

 

 

DCincomeMap.swf    DC Income Map – no legend, but click on a tract and all the other tracts-in-that-range get shaded also

 

 

Appendix A describes the steps to create this swf file.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


StateList generate Abbreviations & FIPS Code    “List Control” example displaying hard-coded list of states; click on one and get response (name, abbreviation, FIPS Code)

 


 

multi-line chart and columns chart with an XML data file    Line Chart with multiple lines, and Column Chart with multiple columns, plus tool tips, plus ability to right-click and View Source Code [MUCH MORE about this later!!!] (XML file s.b. in the src folder, and copy the whole srcview folder you get the source code)

 

 

 

So then I tried to populate the List Control Example (StateList generate Abbreviations & FIPS Code) from an XML file instead of the hard-coded list. It did not work:

 

 

But then I discovered Cascading Menus!! (both Alphabetical and Regional Groupings)

When you click on the button, you open a Menu of State Groups; mousing over each category displays the next-level-down.

Select an MSA by clicking on it, and you get a nice Alert Box:

 

The next project is to tie that to a database, and have a Form/Report and a Map appear.

 

Flex Builder 3 documentation

 

There is a lot of documentation “out there” regarding Flex Builder 3. I started with “getting_started_with_Flex3.pdf” (148 pages available from the Adobe Developer Center http://www.adobe.com/devnet/flex/ ).

 

Beginning with Installing Flex Builder 3, it walks you through examples, shows various Flex applications, and discusses resources (IBM’s ILOG Elixir, for example). Halfway through the pdf is “Chapter 5: Working with the Server” – now we go down another branch of the mapping-on-the-Internet tree!

 

The Vision, part 2

 

The Vision, part 1, says (essentially) that I want to make thematic-maps-on-the-Internet (it is not important for them to be tied to the Google Maps/Google Earth/etc platforms). The first implication is “client interaction”, at least at the initial selection-of-geography and selection-of-variable level. That also means that there will have to be interaction with a database to retrieve specific data associated with specific Census Tracts.

 

“interaction with a database” means learning about the Web Server paradigm – a Web Server has various programs running on it, including a database program, plus a program that communicates with the database program. The Web Server receives commands from the client browser (over the Internet), processes the job, and sends the results back out to the client browser:

 

When I asked Aunko what “localhost/formtest.php” means, he told me I needed to make my machine into a Web Server, and after that, http (Internet Explorer, or any browser) can display various “web files” [formtest.php is a web file]:

 

Aunko mentioned Microsoft’s IIS (Internet Information Services), but I discovered Apache Friends and their installation of XAMPP (which packages Apache with MySQL, PHP, phpMyAdmin and Perl)

http://www.apachefriends.org/en/xampp.html

http://www.mkportal.it/support/showthread.php?t=28627

 

MySQL is an open-source (free) database program that runs on a Web Server (GoDaddy.com hosts MySQL versions up through 5.0). You work in MySQL/on MySQL databases through a DOS window.

 

Wikipedia: PHP, or PHP: Hypertext Preprocessor, is a widely used, general-purpose scripting language that was originally designed for web development, to produce dynamic web pages. It can be embedded into HTML and generally runs on a web server, which needs to be configured to process PHP code and create web page content from it. It can be deployed on most web servers and on almost every operating system and platform free of charge.[2] PHP is installed on over 20 million websites and 1 million web servers.[3]

 

Wikipedia: phpMyAdmin is an open source tool written in PHP intended to handle the administration of MySQL over the World Wide Web. It can perform various tasks such as creating, modifying or deleting databases, tables, fields or rows; executing SQL statements; or managing users and permissions.

Wikipedia: Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall, a linguist working as a systems administrator for NASA, in 1987, as a general-purpose Unix scripting language to make report processing easier.[1][2] Since then, it has undergone many changes and revisions and become widely popular amongst programmers. Larry Wall continues to oversee development of the core language, and its upcoming version, Perl 6. Perl borrows features from other programming languages including C, shell scripting (sh), AWK, and sed.[3] The language provides powerful text processing facilities without the arbitrary data length limits of many contemporary Unix tools,[4] facilitating easy manipulation of text files. It is also used for graphics programming, system administration, network programming, applications that require database access and CGI programming on the Web. Perl is nicknamed "the Swiss Army chainsaw of programming languages" due to its flexibility and adaptability.[5]

On August 27, 2009, I downloaded and installed XAMPP/Apache/MySQL/etc on my laptop, turning it into a WEB SERVER! and, from the Waltham Public Library, I took out

 

Working in MySQL

 

Appendix B shows the screenshots for working in MySQL. To begin, open the XAMPP Control Panel Application (double-click the icon  on your desktop, or Start>Programs>XAMPP for Windows>XAMPP Control Panel). For Apache, click the Start button; once it is , click the Start button for MySQL. You can now weither minimize this window, or close it (it stays in your lower-right icons panel). When you are done with your session, Stop both applications.

 

For MySQL, open the DOS window (Start>Programs>Accessories>Command Prompt). Change the active directory to C:\xampp\mysql\bin. The original command line looks like:

 

C:\Documents and Settings\Dennis>

 

After typing, the line looks like:

 

C:\Documents and Settings\Dennis>cd c:\xampp\mysql\bin

 

and hit the enter/return button.

 

The new command line looks like:

 

C:\xampp\mysql\bin>

 

To open MySQL, type mysql –u root –p       and hit enter/return

For Enter Password: just hit enter/return  [I know, I know, I have no password for MySQL!!!]

 

You now have the MySQL prompt

 

mysql>

 

Type SHOW DATABASES; and hit enter/return, and your databases in MySQL are listed.

 

I used the CREATE DATABASE command to make a new database test02

mysql> CREATE DATABASE test02;

 

Type SHOW DATABASES; and hit enter/return, and your new test02 database is listed.

To get into test02, type \u test02 and hit enter/return, and you get the response:

Database changed

 

In the 21st century, it is not a database that holds data – it is a table within the database.

 

I used the CREATE TABLE command to make a new database states

mysql> CREATE TABLE states (

    -> fips_55 VARCHAR(2)    PRIMARY KEY,

    -> state_name  VARCHAR(30)   NOT NULL,

    -> state_abrv  VARCHAR(2)    NOT NULL);

 

I get the response

Query OK, 0 rows affected (0.13 sec)

meaning that the table is created but without any rows (data).

 

You can insert data into the table, row-by-row:

mysql> INSERT into states

    -> (fips_55, state_name, state_abrv)

    -> values

    -> (“01”, “Alabama”, “AL”);

 

I get the response

Query OK, 1 row affected (0.05 sec)

meaning that the row has been added into the table.

 

I repeated for the 49 other states, plus DC, plus American Soma, Guam, Northern Mariana Islands, Puerto Rico, and the US Virgin Islands. It was boring, but gives me a good feel for “getting data into a table/database”. Use the SELECT command to select all the records:

mysql> SELECT * FROM states;

 

I get a table listing all the data. At the bottom is the status message:

56 rows in set (0.14 sec)

 

I used the CREATE TABLE command to make a new database counties

mysql> CREATE TABLE counties (

    -> fips_55 VARCHAR(5)    PRIMARY KEY,

    -> county_name VARCHAR(44)   NOT NULL,

    -> state_fips  VARCHAR(2)    NOT NULL),

    -> county_fips VARCHAR(3)    NOT NULL);

 

I get the response

Query OK, 0 rows affected (0.14 sec)

meaning that the table is created but without any rows (data).

 

There are 3,232 counties in those 56 “states” – I am definitely not going to type in that data!

I am going to use the LOAD DATA INFILE command, which will allow me to import a txt file!

 

Get a good clean file of all the counties – I use MapInfo and our county04.tab file. In MapInfo, select fips_55, name, state, county from county04 order by fips_55. Export the result as cou04.txt (make the Delimiter a comma, and uncheck “Use First Line for Column Titles”). Open the file in WordPad and see all the quote marks; go to Edit>Replace, type “ in the top box and then click Replace All. When done, it looks good, but go to the bottom of the file – delete the bottom white space below the last line of text. Save it and quit.

 

Copy the cou04.txt file to your C:\xampp\mysql\data\test02 folder.

 

Use the LOAD DATA INFILE command to import the file

mysql> LOAD DATA INFILE ‘cou04.txt’

    -> INTO TABLE counties

    -> FIELDS TERMINATED BY ‘,’

    -> (fips_55, county_name, state_fips, county_fips);

 

I get the response

Query OK, 3232 rows affected, 3231 warnings (0.03 sec)

Records: 3232  Deleted: 0  Skipped: 0  Warnings: 3231

meaning that the table had 3,232 rows  inserted (I don’t know why there is a warning).

 

To test the data, us the SELECT command

mysql> SELECT * FROM counties WHERE state_fips=”09”;

 

The response is the 8 counties in Connecticut:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Appendix B:  showing the screenshots for working in MySQL.