显示postgis几何变换点?

时间:2014-01-31 13:00:26

标签: java sql postgresql postgis

我想用我的表格及其geom点来显示我的表格。

我只能展示几何

"010300000001000000040000009EDBE50D6862404000000000A06E5E407CCF473E0D9B3B4000000000002E5D407C535EB51A3A3C4000000000D02E60409EDBE50D6862404000000000A06E5E40"

我希望它在执行sql时显示

SELECT ST_AsText(geom) from gtest where polyname='ttttttt';

结果,例如

"POLYGON((32.7688004848817 121.728515625,27.6056708264655 116.71875,28.2269700389183 129.462890625,32.7688004848817 121.728515625))"

这是我的jsp代码

<%@ page language="java" contentType="text/html;charset=utf-8" import="java.io.*" import="java.util.*" import="java.sql.*"%> 
<% 
    Class.forName("org.postgresql.Driver").newInstance(); 
    String url="jdbc:postgresql://localhost/template_postgis_20"; 
    String user="postgres"; 
    String password="123456"; 
    Connection con=DriverManager.getConnection(url,user,password); 
    Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 
    String sql="select * from gtest"; 
    ResultSet rs=stmt.executeQuery(sql); 
    while(rs.next()){
%>
    <%=rs.getString("polyname")%>,
    <%=rs.getString("geom")%>,//I want it transform to SQL:SELECT ST_AsText(geom) from gtest
<%
    }
rs.last();
rs.close();
stmt.close();
con.close();
%>

我的postgresql sql:

CREATE TABLE gtest
(
  polyname character varying(20) NOT NULL,
  geom geometry(Polygon),
  CONSTRAINT gtest_pkey PRIMARY KEY (polyname)
)

0 个答案:

没有答案