在PostGIS中有一个通用的GEOGRAPHY专栏 [英] Having a generic GEOGRAPHY column with PostGIS
问题描述
在PostgreSQL 9 + PostGIS 1.5中,是否可以创建通用" GEOGRAPHY列?我的意思是说,该列可以接受POINT以及POLYGON,LINESTRING等.到目前为止,我在互联网上只看到过GEOGRAPHY(POINT,4326)之类的列.
In PostgreSQL 9 + PostGIS 1.5, is there a way to create a "generic" GEOGRAPHY column? By that I mean a column that would accept POINTs as well as POLYGONs, LINESTRINGs, etc. Until now, I've only seen columns like GEOGRAPHY(POINT,4326) on the Internet.
如果这不可能,那么您将如何设计(从数据库角度出发)链接到随机地理对象(点,多边形等)的实体?我应该为每种类型的地理对象创建3、4、5个不同的表吗? (1个表用于POINT对象,1个表用于POLYGON对象,依此类推)?
If that is not possible, then how would you design (from a DB point of view) an entity that is linked to a random geographical object (point, polygon, whatever)? Should I create 3, 4, 5 different tables for each type of geographical object I'd like to support? (1 table for POINT objets, 1 table for POLYGON objects and so on)?
谢谢.
罗曼
推荐答案
是的,只是不要在CREATE TABLE语句中指定类型约束.
Yes, just don't specify a type constraint in the CREATE TABLE statement.
CREATE TABLE mytable ( geog GEOGRAPHY, id SERIAL PRIMARY KEY );
这篇关于在PostGIS中有一个通用的GEOGRAPHY专栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!