page setup cn - longaspire/vita GitHub Wiki

1. 生成器的环境要求

本系统是在Windows环境下开发的,以下方法均以此为前提,Linux和Mac OSX的环境配置类似。

生成器使用了 PostgreSQL、PostGIS数据库存储DBI数据,大楼的空间信息在经过一次import之后会自动保存到数据库中,所以以上两者都是必要的,另外如果想要使用图形界面来编写生成器的GUI,推荐安装上SWT和Window Builder,会方便的多。

相关链接下载

2. 环境配置

2.1 PostgreSQL、PostGIS的安装与配置

2.1.1 安装注意点

PostgreSQL的安装并没有什么特别的地方,只是记得在安装的时候记住PostgreSQL的端口号,以及数据库的登录帐号与密码(生成器使用的分别是 postgres和123456).

还有在完成的时候,进入Stack Builder,选择 spatial extention 安装PostGIS,当然也可以单独在 PostgreSQL 的网站单独下载 postgis.exe 文件,然后双击安装。在这里推荐使用 postgis2.1,原因是在生成器代码中选择了这个版本

在安装 postgis 完毕之时,会提示是否选择创建空间数据库,选择是则会尝试创建控件数据库模板,但是很有可能会创建失败,因此需要我们手动创建空间数据库模板。

2.1.2 spatial_ref控件数据库模板的创建

参考链接,此教程为 linux 环境,需要注意的是在教程中:

$psql template1
template1=#create database template_postgis with template=template1;
template1=#update pg_database set datistemplate=TRUE where datname='template_postgis';
template1=#\c template_postgis
template_postgis=#create language plpgsql;
template_postgis=#\i /opt/locale/share/postgis/lwpostgis.sql;
template_postgis=#\i /opt/locale/share/postgis/spatial_ref_sys.sql;
template_postgis=#GRANT ALL ON geometry_columns TO PUBLIC;
template_postgis=#GRANT ALL ON spatial_ref_sys TO PUBLIC;
template_postgis=#VACUUM FREEZE;
template_postgis=#\q

随后需要创建模板数据库postgis_21_sample用于程序初始化

createdb postgis_21_sample -T template_postgis

psql其实在postgres的安装目录中,通过命令行进入目录,运行psql,则为

psql -U postgres template1

U为大写,加上用户名,选择的数据库。另外,在选择\i 运行 sql 脚本时,lwpostgis.sql\spatial_ref_sys.sql 文件在 postgis 的安装目录中,即 share/contribute 目录中,在 windows 环境中,postgis.sql 文件对应 linux 的 lwpostgis.sql 文件。(windows版本的postgis.sql\spatial_ref_sys.sql可以在源代码的/sql文件夹中找到)

如果在运行脚本时发生 .dll 文件丢失的错误,建议重新安装 postgis。