我在Postgres数据库中创建了一个表,其中包含名称image_id和geometry列。这是架构的样子:
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
我在设置步骤中做错了什么?
答案 0 :(得分:4)
检查您是否有一个名为geometry_columns
的表。
如果没有,则可能未成功安装PostGIS。
哦,如果您的主机上有多个数据库,请确保在可以访问PostGIS内容的数据库中创建表。
答案 1 :(得分:2)
将PostGIS添加到现有的PostgreSQL表时,我遇到了类似的问题。事实证明'geometry_columns'和'spatial_ref_sys'表所有者是'postgres'而不是现有postgresql表的用户名(即'user1')。
我以“postgres”身份登录并执行了'ALTER TABLE tablename OWNER to user1; et voila - 问题解决了。
答案 2 :(得分:1)
我没有使用安装程序,但您必须为要与PostGIS一起使用的每个数据库启用几何类型。说明here。执行摘要:在数据库上启用plpgsql,然后使用这两个文件路径的一些变体将这两个文件通过管道传输:
/opt/local/share/postgresql84/contrib/postgis-2.0/postgis.sql
然后:
/opt/local/share/postgresql84/contrib/postgis-1.5/spatial_ref_sys.sql
这些sql文件将创建2-3个表,具体取决于PostGIS的版本,包括geometry_columns
。即:psql -d my_geo_db -f /opt/whatever/postgis.sql
,然后与spatial_ref_sys.sql
相同。由于某种原因,查找postgis.sql
或spatial_ref_sys.sql
绝非易事。使用聚光灯并不羞耻。
设置模板以避免在以后的数据库中重复这些步骤是明智之举,请参阅here。也可能是安装程序已创建此类数据库,请从\l
提示符处尝试psql
,并查看是否存在名为template_postgis
的内容。如果是这样,您可以使用(作为用户postgres)createdb -T template_postgis -O your_username new_postgis_db_name
答案 3 :(得分:0)
确保运行以下SQL语句:
CREATE EXTENSION postgis;
这将在yout数据库中创建以下视图:
geography_columns
geometry_columns
raster_columns
raster_overviews