Batch method

Locations may be entered into the system by the batch method. The batch method is more efficient in both data volume and processing time. The batch method may also be implemented from a spreadsheet export.

 
Setting batch of locations
Figure 3.4.2a below displays the use of the <locations_batch> method for entering data. The format attribute described the fields used in the data set. The colon delimited data is is contained between the opening <locations_batch> and closing </locations_batch> tags, encapsulated by CDATA.

<locations_batch format="id:lat:lon:address1:city:state_code:zip:country_code" ><![CDATA[


|9:42.5222:-72.6242:655 Long Street:Shattuckville:MA:01369:US|
|10:42.5534:-72.3927:327 Kindred Highway:Wendell Depot:MA:01380:US|
|11:42.4464:-71.4594:885 Carpenter Lane:Pepperell:MA:01463:US|
|12:42.2754:-72.0893:563 49th Avenue:North Brookfield:MA:01535:US|


]]></locations_batch>

Fig 3.4.2a Example location batch

Each line of data represents one location record with field data separated by a : (colon) character. The record starts and ends with a | (pipe) character. Table 3.4.1b in the previous section details the permissible contents of each field. The location record id must be the first field, other fields may be in any order as specified by the format attribute. Note that fields containing website links must be URL encoded.

Each XML file may contain one or more <locations_batch> tags. Restrict file size to 125 kilobytes, use multiple files to distribute data.

 
Converting spreadsheet data

Spreadsheet data may be used to generate the location batch. Make a copy of the spreadsheet file before starting, work with the copy.

Start by inserting a column for the location id field. The id column must be the first column. Fill the column with a numerical sequence, one unique number per row. Most spreadsheet programs will perform incremental numerical fills.

The first row should contain the field names as specified in table 3.4.1b in the previous section. Note that field names should be lower case and contain underscores instead of spaces. Remove any blank rows or rows that do not contain data.

Columns containing website addresses must be URL encoded. This means that certain characters must be replaced with with a code starting with the % symbol. Use the spreadsheet program to perform a search-replace on the columns containing website address. Table 3.4.2d details encoding characters.

Insert two more columns, one at the start and one at the end. Fill these columns with the | (pipe) character, shift-backslash key. Remove the pipe characters in the first row.

Save the spreadsheet. Next export the spreadsheet to a text file by specifying field and record delimiters. The field delimiter should be the : (colon) character and new line for the record. Save the exported file as locations_batch.txt.

Open the text file with a text editor. Note that each records starts with a |: (pipe colon) and ends with a :| (colon pipe), this needs to be corrected. Perform a search-replace to change the |: (pipe colon) and :| (colon pipe) with just a | (pipe) throughout the entire file. Replace the starting and ending : (colon) characters in the first row with a " (double quote) character. Save the text file.

Start a new XML file with the structure as shown in the Figure 3.4.2b below.

<?xml version="1.0" encoding="UTF-8" ?>
<MapTron_1207>

<locations_batch format="PASTE FORMAT HERE " ><![CDATA

PASTE DATA HERE

]]></locations_batch>

<MapTron_1207>

Fig 3.4.2b File structure

Copy the first line of the text file and paste into the format attribute value, replacing the PASTE FORMAT HERE. Copy the remaining lines of text and paste replacing the PASTE DATA HERE. Save the XML file as locations_batch.xml

Check the XML file size. It may be necessary to split the file into multiple batch files to keep file size under 125 kilobytes. Do so by duplicating the locations_batch.xml into locations_batch_1.xml, locations_batch_2.xml and so forth then removing portions of data from each file. Usually no more that 3 files required.

Specify the locations XML filenames in the startup XML file named MapTron1207.xml as described in figure 3.4.2c below.

<loadlocations source="locations_batch.xml" />

<loadlocations source="locations_batch_1.xml" />
<loadlocations source="locations_batch_2.xml" />
<loadlocations source="locations_batch_3.xml" />

Fig 3.4.2c Loading of locations
 
Character Encoding
: %3A
= %3D
? %3F
& %26
[space] %20
Table 3.4.2d URL Encoding