本章记录了 PostGIS 源 tarball 和源存储库的 extras 文件夹中的功能。 这些并不总是与 PostGIS 二进制版本一起打包,但通常是基于 PL/pgSQL 或可以按原样运行的标准 shell 脚本。
这是 PAGC 标准化器的一个分支(这部分的原始代码是 PAGC PostgreSQL 地址标准化器)。
地址标准化器是一个单行地址解析器,它获取输入地址并根据存储在表以及辅助 lex 和 gaz 表中的一组规则对其进行规范化。
该代码内置于一个名为 address_standardizer 的 PostgreSQL 扩展库中,可以使用 CREATE EXTENSION address_standardizer; 安装。 除了address_standardizer 扩展之外,还构建了一个名为address_standardizer_data_us 扩展的示例数据扩展,其中包含US 数据的gaz、lex 和规则表。 该扩展可以通过以下方式安装:CREATE EXTENSION address_standardizer_data_us;
此扩展的代码可以在 PostGIS extensions/address_standardizer 中找到,并且当前是独立的。
有关安装说明,请参阅:Section 2.3, “安装和使用地址标准化工具”。
解析器从右到左工作,首先查看邮政编码、州/省、城市的宏观元素,然后查看微观元素以确定我们是否正在处理门牌号、街道、十字路口或地标。 目前,它不查找国家/地区代码或名称,但将来可能会引入。
根据邮政编码为美国或加拿大,或者州/省为美国或加拿大,否则为美国
这些是使用 Perl 兼容的正则表达式来识别的。 这些正则表达式当前位于 parseaddress-api.c 中,并且在需要时进行更改相对简单。
这些是使用 Perl 兼容的正则表达式来识别的。 这些正则表达式当前位于 parseaddress-api.c 中,但将来可能会被移至包含中以便于维护。
本节列出了由 Address Standardizer 扩展安装的 PostgreSQL 数据类型。 请注意,我们描述了这些的强制转换行为,这非常重要,尤其是在设计您自己的函数时。
standardize_address 函数的返回类型。
本节列出了 address_standardizer 用于规范化地址的 PostgreSQL 表格式。 请注意,这些表的名称不需要与此处引用的名称相同。 例如,您可以为每个国家/地区或您的自定义地理编码器设置不同的 lex、gaz、规则表。 这些表的名称被传递到地址标准化器函数中。
打包的扩展address_standardizer_data_us包含用于标准化美国地址的数据。
一个基于 PL/pgSQL 编写的地理编码器,美国人口普查局发布的 TIGER(拓扑集成地理编码与参照系统)/ Line and Master Address database export 配合使用。
地理编码器有四个组件:数据加载器函数、地址标准化器、地址地理编码器和反向地理编码器。
尽管它是专门为美国设计的,但许多概念和功能都是适用的,并且可以适应其他国家的地址和道路网络。
The script builds a schema called tiger to house all the TIGER-related functions, reusable lookup data such as road type prefixes, suffixes, states, various control tables for managing data load, and skeleton base tables from which all the TIGER-loaded tables inherit.
Another schema called tiger_data is also created which houses all the census data for each state that the loader downloads from the Census site and loads into the database. In the current model, each set of state tables is prefixed with the state code e.g ma_addr, ma_edges etc with constraints to enforce only that state data. Each of these tables inherits from the tables addr, faces, edges, etc located in the tiger schema.
All the geocode functions only reference the base tables, so there is no requirement that the data schema be called tiger_data or that data can't be further partitioned into other schemas -- e.g. a different schema for each state, as long as all the tables inherit from the tables in the tiger schema.
有关如何在数据库中启用扩展程序以及如何使用它加载数据的说明,请参阅Section 2.4.1, “在 PostGIS 数据库中启用Tiger地理编码器”。
|
|
|
If you are using the TIGER Geocoder (tiger_2010), you can upgrade the scripts using the accompanying upgrade_geocoder.bat / .sh scripts in extras/tiger. One major change between |
|
|
|
You can install the TIGER Geocoder with the PostgreSQL extension model. Refer to Section 2.4.1, “在 PostGIS 数据库中启用Tiger地理编码器” for details. |
Pagc_Normalize_Address函数可替代内置 Normalize_Address。 有关编译和安装说明,请参阅Section 2.3, “安装和使用地址标准化工具”。
设计:
该项目的目标是构建一个功能齐全的地理编码器,可以处理任意美国地址字符串并使用标准化的 TIGER 人口普查数据,生成反映给定地址位置和位置可能性的点几何和评级。 评级数字越高,结果越差。
The reverse_geocode function is useful for deriving the street address and cross streets of a GPS location.
对于熟悉 PostGIS 的任何人来说,地理编码器都应该易于安装和使用,并且应该可以在 PostGIS 支持的所有平台上轻松安装和使用。
尽管存在格式和拼写错误,但它应该足够强大,能够正常运行。
它应该具有足够的可扩展性,以便与未来的数据更新一起使用,或者以最少的编码更改来替代数据源。
|
|
|
必须将 |
Tiger_data。
County_all、state_all 或state代码开头,后跟county或state的所有表。
Tiger_data。
标准化地址 (addy )每个位置以及评级。 评级越低,匹配的可能性越大。 结果首先按最低评分排序。 可以选择传入最大结果,默认为 10。使用 Tiger 数据(edges、faces、addr)、PostgreSQL 模糊字符串匹配(soundex、levenshtein)。
Tiger_data 架构中。 每个状态脚本都作为单独的记录返回。
Tiger_data 模式中。 每个状态脚本都作为单独的记录返回。 最新版本支持 Tiger 2010 结构变化,还加载人口普查区、区块组和区块表。
norm_addy类型,该类型具有道路后缀、前缀和标准化类型、街道、街道名称等,分为单独的字段。 该函数仅适用于与 Tiger_geocoder 打包的查找数据(不需要tiger普查数据)。
norm_addy类型,该类型具有道路后缀、前缀和标准化类型、街道、街道名称等,分为单独的字段。 该函数仅适用于与 Tiger_geocoder 打包的查找数据(不需要tiger普查数据)。 需要 address_standardizer 扩展。
norm_addy复合类型对象,返回它的漂亮的打印表示。 通常与normalize_address结合使用。
There are a couple other open source geocoders for PostGIS, that unlike the TIGER Geocoder have the advantage of multi-country geocoding support
Nominatim uses OpenStreetMap gazeteer formatted data. It requires osm2pgsql for loading the data together with PostgreSQL and PostGIS. It is packaged as a webservice interface and seems designed to be called as a webservice. Just like the TIGER Geocoder, it has both a geocoder and a reverse geocoder component. From the documentation, it is unclear if it has a pure SQL interface like the TIGER Geocoder, or if a good deal of the logic is implemented in the web interface.
GIS Graphy can utilize PostGIS and like Nominatim uses OpenStreetMap (OSM) data along with some other sources. It comes with a loader to load OSM data and similar to Nominatim is capable of geocoding not just US. Much like Nominatim, it runs as a webservice and relies on Java 1.5, Servlet apps, Solr. GisGraphy is cross-platform and also has a reverse geocoder among some other neat features.