munso / iris-geocoder-bundle
法国IRIS INSSE代码地址编码器
dev-master
2017-05-19 10:51 UTC
Requires
- php: ^5.3 || ^7.0
- jsor/doctrine-postgis: ~1
- kriswallsmith/buzz: ^0.15
This package is not auto-updated.
Last update: 2024-09-29 01:51:27 UTC
README
Symfony扩展包,用于从地址反向地理编码到法国IRIS区域。
基于: https://github.com/garaud/pyris,用Python编写。
安装
要求
您必须安装postgreSQL和PostGIS。对于Debian
sudo apt-get install postgresql postgis
您必须是PostgreSQL超级用户才能为您数据库创建postgis扩展。如果不是这种情况,您可以
su su - postgres psql DATABASENAME -c "CREATE EXTENSION postgis;"
在URL: https://www.data.gouv.fr/fr/datasets/contour-des-iris-insee-tout-en-un/ 下载最新的IRIS形状文件
配置
创建一个数据库,并在 app/config.yml 中添加一个新的doctrine连接Symfony 文档
doctrine: dbal: connections: #[...] psql: driver: pdo_pgsql host: "%psql_database_host%" port: "%psql_database_port%" dbname: "%psql_database_name%" user: "%psql_database_user%" password: "%psql_database_password%" charset: UTF8
添加 'geometry' 映射列类型
doctrine: dbal: types: geometry: Jsor\Doctrine\PostGIS\Types\GeometryType
为最近添加的连接添加一个新的doctrine entity_manager
orm: entity_managers: #[...] geocodage: connection: psql mappings: MunsoIRISGeocoderBundle: ~ dql: numeric_functions: ST_MakePoint: Jsor\Doctrine\PostGIS\Functions\ST_MakePoint ST_Contains: Jsor\Doctrine\PostGIS\Functions\ST_Contains ST_SetSRID: Jsor\Doctrine\PostGIS\Functions\ST_SetSRID
自定义
如果您已经在项目中配置了postgresql连接,则可以编辑使用的entity_manager名称。
如果您的*.shp文件中映射的列与IrisItem实体不匹配,您可以通过编辑munso.iris_geocoder.entity_name
参数来创建自己的实体。
munso.iris_geocoder.entity_manager.name: 'geocodage' munso.iris_geocoder.entity_name: 'MunsoIRISGeocoderBundle:IrisItem'
导入
通过运行以下命令将您的形状导入到postgresql数据库中
php bin/console munso:iris:import-shape path/to/file.shp
.shx 和 .dbf 文件必须与 *.shp 文件在同一个目录下。除非您使用 --append
选项,否则SQL表将被截断。
#用法
地址查询IRIS代码
使用服务 munso.iris_geocoder
$IrisItem = $this->get('munso.iris_geocoder')->getIRISByAddress('2b Allée Forain Francois verdier');