--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<chapter id="Address_Standardizer">\r
+ <title>Address Standardizer</title>\r
+ <para>This is a fork of the <ulink url="http://www.pagcgeo.org/docs/html/pagc-11.html">PAGC standardizer</ulink> and a single line address parser.\r
+The code is built into a single postgresql extension library called <code>address_standardizer</code> which can be installed with <code>CREATE EXTENSION address_standardizer</code>.</para>\r
+ <para>The code for this extension can be found in the PostGIS <filename>extras/adress_standardizer</filename> and is currently self-contained.</para>\r
+ <sect1 id="Address_Standardizer_Basics"><title>How the Parser Works</title>\r
+ <para>The parser works from right to left looking first at the macro elements \r
+ for postcode, state/province, city, and then looks micro elements to determine\r
+if we are dealing with a house number street or intersection or landmark.\r
+It currently does not look for a country code or name, but that could be\r
+introduced in the future.</para>\r
+ <variablelist>\r
+ <varlistentry>\r
+ <term>Country code</term>\r
+ <listitem><para>Assumed to be US or CA based on: postcode as US or Canada state/province as US or Canada else US</para></listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <term>Postcode/zipcode</term>\r
+ <listitem><para>These are recognized using Perl compatible regular expressions.\r
+These regexs are currently in the parseaddress-api.c and are relatively\r
+simple to make changes to if needed.</para></listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <term>State/province</term>\r
+ <listitem><para>These are recognized using Perl compatible regular expressions.\r
+These regexs are currently in the parseaddress-api.c but could get moved\r
+into includes in the future for easier maintenance.</para></listitem>\r
+ </varlistentry>\r
+ </variablelist>\r
+ </sect1>\r
+ <sect1 id="Address_Standardizer_Types"><title>Address Standardizer Types</title>\r
+ <sect1info>\r
+ <abstract>\r
+ <para>This section lists the PostgreSQL data types installed by Address Standardizer extension. Note we describe the casting behavior of these which is very \r
+ important especially when designing your own functions. \r
+ </para> \r
+ </abstract>\r
+ </sect1info>\r
+ <refentry id="stdaddr">\r
+ <refnamediv>\r
+ <refname>stdaddr</refname>\r
+ <refpurpose>A composite type that consists of the elements of an address. This is the return type for <varname>standardize_address</varname> function.</refpurpose>\r
+ </refnamediv>\r
+ <refsection>\r
+ <title>Description</title>\r
+ <para>A composite type that consists of elements of an address. This is the return type for <xref linkend="standardize_address" /> function. Some descriptions for elements are borrowed from <ulink url="http://www.pagcgeo.org/docs/html/pagc-12.html#ss12.1">PAGC Postal Attributes</ulink>.</para>\r
+ <para>The token numbers denote the reference number in the <varname>rules</varname> table.</para>\r
+ <variablelist>\r
+ <varlistentry>\r
+ <term>building</term>\r
+ <listitem>\r
+ <para> is text (token number <code>0</code>): Refers to building number or name. Unparsed building identifiers and types. Generally blank for most addresses.</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry><term>house_num</term> \r
+ <listitem>\r
+ <para>is a text (token number <code>1</code>): This is the street number on a street. Example <emphasis>75</emphasis> in <code>75 State Street</code>.</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry><listitem><term>predir</term>\r
+ <para> is text (token number <code>2</code>): STREET NAME PRE-DIRECTIONAL such as North, South, East, West etc.</para>\r
+ </listitem></varlistentry>\r
+ <varlistentry><term>qual</term> \r
+ <listitem>\r
+ <para>is text (token number <code>3</code>): STREET NAME PRE-MODIFIER Example <emphasis>OLD</emphasis> in <code>3715 OLD HIGHWAY 99</code>.</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry><term>pretype</term>\r
+ <listitem>\r
+ <para> is text (token number <code>4</code>): STREET PREFIX TYPE</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry><term>name</term>\r
+ <listitem>\r
+ <para>is text (token number <code>5</code>): STREET NAME</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>suftype</term>\r
+ <para>is text (token number <code>6</code>): STREET POST TYPE e.g. St, Ave, Cir. A street type following the root street name. Example <emphasis>STREET</emphasis> in <code>75 State Street</code>.</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>sufdir</term>\r
+ <para>is text (token number <code>7</code>): STREET POST-DIRECTIONAL A directional modifier that follows the street name.. Example <emphasis>WEST</emphasis> in <code>3715 TENTH AVENUE WEST</code>.</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>ruralroute</term>\r
+ <para>is text (token number <code>8</code>): RURAL ROUTE . Example <emphasis>8</emphasis> in <code>RR 7</code>.</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>extra</term>\r
+ <para>is text: Extra information like Floor number.</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>city</term>\r
+ <para>is text (token number <code>10</code>): Example Boston.</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>state</term>\r
+ <para>is text (token number <code>11</code>): Example <code>MASSACHUSETTS</code></para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>country</term>\r
+ <para>is text (token number <code>12</code>): Example <code>USA</code></para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>postcode</term>\r
+ <para>is text POSTAL CODE (ZIP CODE) (token number <code>13</code>): Example <code>02109</code></para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>box</term>\r
+ <para>is text POSTAL BOX NUMBER (token number <code>14 and 15</code>): Example <code>02109</code></para>\r
+ </listitem>\r
+ </varlistentry>\r
+ <varlistentry>\r
+ <listitem><term>unit</term>\r
+ <para>is text Apartment number or Suite Number (token number <code>17</code>): Example <emphasis>3B</emphasis> in <code>APT 3B</code>.</para>\r
+ </listitem>\r
+ </varlistentry>\r
+ </variablelist>\r
+ </refsection>\r
+ </refentry>\r
+ </sect1>\r
+ <sect1 id="Address_Standardizer_Functions"><title>Address Standardizer Functions</title>\r
+ <refentry id="standardize_address">\r
+ <refnamediv>\r
+ <refname>standardize_address</refname>\r
+ \r
+ <refpurpose>Returns an stdaddr form of an input address utilizing lex, gaz, and rule tables.</refpurpose>\r
+ </refnamediv>\r
+ \r
+ <refsynopsisdiv>\r
+ <funcsynopsis>\r
+ <funcprototype>\r
+ <funcdef>stdaddr <function>standardize_address</function></funcdef>\r
+ <paramdef><type>text </type> <parameter>lextab</parameter></paramdef>\r
+ <paramdef><type>text </type> <parameter>gaztab</parameter></paramdef>\r
+ <paramdef><type>text </type> <parameter>rultab</parameter></paramdef>\r
+ </funcprototype>\r
+ \r
+ <funcprototype>\r
+ <funcdef>stdaddr <function>standardize_address</function></funcdef>\r
+ <paramdef><type>text </type> <parameter>lextab</parameter></paramdef>\r
+ <paramdef><type>text </type> <parameter>gaztab</parameter></paramdef>\r
+ <paramdef><type>text </type> <parameter>rultab</parameter></paramdef>\r
+ <paramdef><type>text </type> <parameter>micro</parameter></paramdef>\r
+ <paramdef><type>text </type> <parameter>macro</parameter></paramdef>\r
+ </funcprototype>\r
+ </funcsynopsis>\r
+ </refsynopsisdiv>\r
+ \r
+ <refsection>\r
+ <title>Description</title>\r
+ \r
+ <para>Returns an <xref linkend="stdaddr" /> form of an input address utilizing lex, gaz, and rule tables.</para>\r
+ \r
+ <!-- optionally mention that this function uses indexes if appropriate -->\r
+ <note>\r
+ <para>This function call will automatically include a bounding box\r
+ comparison that will make use of any indexes that are available on the\r
+ geometries.</para>\r
+ </note>\r
+ <!-- use this format if new function -->\r
+ <para>Availability: 2.2.0</para>\r
+ </refsection>\r
+ \r
+ \r
+ <refsection>\r
+ <title>Examples</title>\r
+ \r
+ <programlisting></programlisting>\r
+ </refsection>\r
+ \r
+ <!-- Optionally add a "See Also" section -->\r
+ <refsection>\r
+ <title>See Also</title>\r
+ \r
+ <para><xref linkend="stdaddr" /></para>\r
+ </refsection>\r
+ </refentry>\r
+ \r
+ </sect1>\r
+</chapter>\r