整体更新

This commit is contained in:
hukekuan@163.com 2017-05-12 14:13:26 +08:00
parent ac08e29ff8
commit e866eca211
6 changed files with 19 additions and 14 deletions

View File

@ -17,6 +17,14 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
<packaging>jar</packaging>

View File

@ -2,7 +2,6 @@ package com.gis3c;
import com.gis3c.service.HelloService;
import com.gis3c.service.PostGISService;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.IOException;

View File

@ -4,5 +4,5 @@ import java.util.Map;
public interface PostGISDao {
public void CommonCreateTable(Map<String,Object> tableStructure);
public void CreateSpatialIndex(String tableName);
public void CreateSpatialIndex(String tableName,String geometryColumn);
}

View File

@ -4,9 +4,9 @@ import com.gis3c.dao.PostGISDao;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@Repository
@ -20,10 +20,15 @@ public class PostGISDaoImpl extends SqlSessionDaoSupport implements PostGISDao {
@Override
public void CommonCreateTable(Map<String,Object> tableStructure){
System.out.println(tableStructure);
getSqlSession().update("PostGISSql.commonCreateTable",tableStructure);
}
@Override
public void CreateSpatialIndex(String tableName){
getSqlSession().update("PostGISSql.createSpatialIndex",tableName);
public void CreateSpatialIndex(String tableName,String geometryColumn){
Map<String,Object> param = new HashMap<>();
param.put("tableName",tableName);
param.put("geometryColumn",geometryColumn);
param.put("spatialIndexName","sidx_" + tableName +"_" + geometryColumn);
getSqlSession().update("PostGISSql.createSpatialIndex",param);
}
}

View File

@ -30,6 +30,6 @@ public class PostGISServiceImpl implements PostGISService {
SpatialIndexParam.put("geometryColumn",geometryColumn);
postGISDao.CommonCreateTable(tableStructure);
postGISDao.CreateSpatialIndex(tableName);
postGISDao.CreateSpatialIndex(tableName,geometryColumn);
}
}

View File

@ -46,7 +46,7 @@
CREATE INDEX ${spatialIndexName}
ON ${tableName}
USING gist
($(geometryColumn));
(${geometryColumn});
</update>
<!--查询表是否存在,返回表个数-->
@ -114,18 +114,11 @@
</delete>
<select id="allCity" resultMap="GeoCityResultMap">
<!--
select t.name,t.code,t.geom as geom from geocity t
select t.name,t.code,ST_AsText(t.geom) as geom from geocountry t
where ST_Within(ST_GeometryFromText(#{geom,javaType=Geometry}),t.geom);
-->
select t.stationid,t.subtype,t.geom as geom from station t where ST_Intersects(
ST_Buffer(
Geography(#{geom,javaType=Geometry}),1000
),
t.geom
)
</select>
</mapper>