Java 解析 clob 包含座标

纯SQL更新 st_geometry 语句。
点座标更新SQL:
update a99
   set SHAPE = st_point(120.913881027, 37.40471325200002,4326)
 where objectid = 9527
 
 
 
 线类座标更新SQL:
 update a98
    set SHAPE = st_LINESTRING('LINESTRING(117.14161515333333 36.68986946888889,
                               117.14165322333332 36.68978380888889,
                               117.14175791333332 36.68966006888889,
                               117.14180550333333 36.68958392888889,
                               117.14184357333333 36.68950778888889,
                               117.14190068333333 36.68943164888889,
                               117.14194827333333 36.68935549888889,
                               117.14202379222223 36.68927824777778,
                               117.14208089222222 36.68920210777778,
                               117.14211896222223 36.689125957777776,
                               117.14214752222223 36.68904981777778,
                               117.14221414222223 36.68897367777778,
                               117.14225221222223 36.68889753777778)',
                              4326)
  where objectid = 9527


面类资源更新座标:
  update a97
   set SHAPE = st_polygon('polygon((115.54533362444444 34.823791657777775,
                          115.54533362444444 34.823058787777775,
                          115.54535266444445 34.823058787777775,
                          115.54542880444444 34.823058787777775,
                          115.54550494444445 34.82303974777778,
                          115.54558109444444 34.82302071777778,
                          115.54565723444445 34.822992157777776,
                          115.54573337444444 34.82296360777778,
                          115.54580951444444 34.822935047777776,
                          115.54588566444444 34.82294456777778,
                          115.54596180444445 34.822992157777776,
                          115.54596180444445 34.82306830777778,
                          115.54596180444445 34.82314444777778,
                          115.54596180444445 34.823220587777776,
                          115.54597132444445 34.82329672777778,
                          115.54597132444445 34.82337287777778,
                          115.54596180444445 34.823449017777776,
                          115.54596180444445 34.82352515777778,
                          115.54596180444445 34.82360129777778,
                          115.54597132444445 34.823677447777776,
                          115.54599035444444 34.82375358777778,
                          115.54595228444444 34.82382972777778,
                          115.54587614444445 34.82382972777778,
                          115.54580000444444 34.82382972777778,
                          115.54572385444445 34.82381069777778,
                          115.54564771444444 34.82381069777778,
                          115.54557157444445 34.823791657777775,
                          115.54549542444444 34.823791657777775,
                          115.54540976444444 34.823791657777775,
                          115.54533362444444 34.823791657777775))',
                          4326)
 where objectid = 9527

JAVA 中获取 CLOB 解析并更新
//锁定数据行进行更新,注意“for update”语句,这里不用for update锁定不可以插入clob
 pstmt =  gisConnection.getConnection().prepareStatement("select st_astext(shape) SHAPE from a100 where objectid = 9527 for update");
 rs = pstmt.executeQuery();
 if(rs.next()){
 CLOB clob =((OracleResultSet)rs).getCLOB(1);
 String tempStr = "偏移之后的座标数据";
 // 这个地方最为关键, 最外面没有'' , linestring同样
 String xystring="POLYGON(("+tempStr+"))"; 
 clob.putString(1,xystring); 
 String upsql = "update a100 set SHAPE =ST_POLYGON(?,4326)  WHERE OBJECTID=9527";
 pstmt =  gisConnection.prepareStatement(upsql);
 pstmt.setClob(1, clob);
 int p =pstmt.executeUpdate();
 System.out.println("POLYGON 更新成功 : "+p);
 }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章