使用 GeoServer 设置 Postgres PostGIS 数据库时遇到问题
我在 Postgres 数据库中创建了一个表,其中包含名称 image_id 和几何列。架构如下所示:
CREATE TABLE images
(
"name" character varying(256) NOT NULL,
image_id integer NOT NULL,
srid integer NOT NULL DEFAULT 4326,
images_geom geometry,
CONSTRAINT images_pkey PRIMARY KEY (name),
CONSTRAINT enforce_dims_images_geom CHECK (st_ndims(images_geom) = 2),
CONSTRAINT enforce_srid_images_geom CHECK (st_srid(images_geom) = 4326)
)
WITH (
OIDS=FALSE
);
ALTER TABLE images OWNER TO postgres;
ALTER TABLE images ALTER COLUMN images_geom SET STATISTICS 4326;
我使用此 SQL 语句将测试记录插入表中:
insert into images (name, image_id, srid, images_geom) values ('image1.png', 1, 4326, ST_GeomFromText('point(21.12312 -125.01010)', 4326));
然后在 GeoServer 中创建一个新的 PostGIS 存储并将其连接到我在 Postgres 中创建的数据库。当我尝试创建一个新图层并将其与我创建的新商店连接时,它会出错并显示此错误消息:
java.lang.RuntimeException: Error occurred while building the resources for the configuration page
at org.geoserver.web.data.layer.NewLayerPage.buildLayerInfo(NewLayerPage.java:202)
at org.geoserver.web.data.layer.NewLayerPage$3.onClick(NewLayerPage.java:173)
at org.geoserver.web.wicket.SimpleAjaxLink$1.onClick(SimpleAjaxLink.java:44)
at org.apache.wicket.ajax.markup.html.AjaxLink$1.onEvent(AjaxLink.java:65)
at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:163)
at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:297)
at org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:104)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1239)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1316)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1418)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:532)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:356)
at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:124)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:158)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:23)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:183)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:41)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: java.io.IOException
at org.geotools.jdbc.JDBCFeatureSource.buildFeatureType(JDBCFeatureSource.java:340)
at org.geotools.jdbc.JDBCDataStore.createFeatureSource(JDBCDataStore.java:712)
at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:383)
at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:348)
at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:647)
at org.geoserver.catalog.CatalogBuilder.buildFeatureType(CatalogBuilder.java:324)
at org.geoserver.web.data.layer.NewLayerPage.buildLayerInfo(NewLayerPage.java:198)
... 73 more
Caused by: org.postgresql.util.PSQLException: ERROR: relation "geometry_columns" does not exist
Position: 18
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:252)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.geotools.data.postgis.PostGISDialect.getMapping(PostGISDialect.java:225)
at org.geotools.jdbc.JDBCFeatureSource.buildFeatureType(JDBCFeatureSource.java:258)
... 79 more
我在设置步骤中做错了什么吗?
I made a table in a Postgres database with a name image_id and geometry column in it. Here is what the schema looks like:
CREATE TABLE images
(
"name" character varying(256) NOT NULL,
image_id integer NOT NULL,
srid integer NOT NULL DEFAULT 4326,
images_geom geometry,
CONSTRAINT images_pkey PRIMARY KEY (name),
CONSTRAINT enforce_dims_images_geom CHECK (st_ndims(images_geom) = 2),
CONSTRAINT enforce_srid_images_geom CHECK (st_srid(images_geom) = 4326)
)
WITH (
OIDS=FALSE
);
ALTER TABLE images OWNER TO postgres;
ALTER TABLE images ALTER COLUMN images_geom SET STATISTICS 4326;
I used this SQL statement to insert a test record into the table:
insert into images (name, image_id, srid, images_geom) values ('image1.png', 1, 4326, ST_GeomFromText('point(21.12312 -125.01010)', 4326));
Then in GeoServer I created a new PostGIS store and connected it to the database I made in Postgres. When I try to create a new layer and connect it with the new store I created it errors out and displays this error message:
java.lang.RuntimeException: Error occurred while building the resources for the configuration page
at org.geoserver.web.data.layer.NewLayerPage.buildLayerInfo(NewLayerPage.java:202)
at org.geoserver.web.data.layer.NewLayerPage$3.onClick(NewLayerPage.java:173)
at org.geoserver.web.wicket.SimpleAjaxLink$1.onClick(SimpleAjaxLink.java:44)
at org.apache.wicket.ajax.markup.html.AjaxLink$1.onEvent(AjaxLink.java:65)
at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:163)
at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:297)
at org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:104)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1239)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1316)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1418)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:532)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:356)
at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:124)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:158)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:23)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:183)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:41)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: java.io.IOException
at org.geotools.jdbc.JDBCFeatureSource.buildFeatureType(JDBCFeatureSource.java:340)
at org.geotools.jdbc.JDBCDataStore.createFeatureSource(JDBCDataStore.java:712)
at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:383)
at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:348)
at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:647)
at org.geoserver.catalog.CatalogBuilder.buildFeatureType(CatalogBuilder.java:324)
at org.geoserver.web.data.layer.NewLayerPage.buildLayerInfo(NewLayerPage.java:198)
... 73 more
Caused by: org.postgresql.util.PSQLException: ERROR: relation "geometry_columns" does not exist
Position: 18
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:252)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.geotools.data.postgis.PostGISDialect.getMapping(PostGISDialect.java:225)
at org.geotools.jdbc.JDBCFeatureSource.buildFeatureType(JDBCFeatureSource.java:258)
... 79 more
Am I doing something wrong in my setup steps?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
检查您是否有一个名为
geometry_columns
的表。如果没有,则 PostGIS 的安装可能未成功执行。
哦,如果您的主机上有多个数据库,请确保在可以访问 PostGIS 内容的数据库中创建表。
Check if you have a table called
geometry_columns
.If not, then the installation of PostGIS might not have been performed successfully.
Oh, and if you've got multiple databases on your host, make sure that you create your table in a database where you have access to your PostGIS stuff.
在将 PostGIS 添加到现有 PostgreSQL 表时,我遇到了类似的问题。事实证明,“geometry_columns”和“spatial_ref_sys”表所有者是“postgres”,而不是现有 postgresql 表的我的用户名(即“user1”)。
我以“postgres”身份登录并执行“ALTER TABLE tablename OWNER TO user1;”瞧 - 问题解决了。
I had similar problems when adding PostGIS to an existing PostgreSQL table. Turns out that the 'geometry_columns' and 'spatial_ref_sys' table owner was 'postgres' instead of my user name for the existing postgresql tables (i.e. 'user1').
I logged in as 'postgres' and performed 'ALTER TABLE tablename OWNER TO user1; et voila - problem solved.
我没有使用安装程序,但您必须为要与 PostGIS 一起使用的每个数据库启用几何类型。说明此处。执行摘要:在数据库上启用 plpgsql,然后使用这两个文件路径的某些变体通过管道传输这两个文件:
/opt/local/share/postgresql84/contrib/postgis-2.0/postgis.sql
然后:
/opt/local/share/postgresql84/contrib/postgis-1.5/spatial_ref_sys.sql
这些sql文件将根据PostGIS的版本创建2-3个表,包括
geometry_columns
。即:psql -d my_geo_db -f /opt/whatever/postgis.sql
,然后与spatial_ref_sys.sql
相同。由于某种原因,找到postgis.sql
或spatial_ref_sys.sql
绝非易事。使用聚光灯并不羞耻。设置模板以避免对以后的数据库重复这些步骤是明智的,请参阅 这里。也可能是安装程序已经创建了这样的数据库,请在
psql
提示符下尝试\l
,看看是否有名为template_postgis
的东西。如果是这样,您可以使用(作为用户 postgres)createdb -T template_postgis -O your_username new_postgis_db_name
创建新数据库I haven't used the installer but you have to enable the geometry types for each database you want to use with PostGIS. Instructions here. Executive summary: enable plpgsql on the database, then pipe it these two files with some variant of these two filepaths:
/opt/local/share/postgresql84/contrib/postgis-2.0/postgis.sql
then:
/opt/local/share/postgresql84/contrib/postgis-1.5/spatial_ref_sys.sql
Those sql files will create 2-3 tables depending on the version of PostGIS, including
geometry_columns
. That is:psql -d my_geo_db -f /opt/whatever/postgis.sql
, then the same withspatial_ref_sys.sql
. It is never easy to findpostgis.sql
orspatial_ref_sys.sql
for some reason. No shame in using spotlight.It is smart to set up a template to avoid having to repeat these steps with later databases, see here. It may also be that the installer has created such a database, try
\l
from thepsql
prompt and see if there is something calledtemplate_postgis
. If so you can create new databases with (as user postgres)createdb -T template_postgis -O your_username new_postgis_db_name
确保运行以下 SQL 语句:
这将在 yout 数据库中创建以下视图:
Make sure you run the following SQL statement:
This will create the following views in yout database: