整体更新

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> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build> </build>
<packaging>jar</packaging> <packaging>jar</packaging>

View File

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

View File

@ -4,5 +4,5 @@ import java.util.Map;
public interface PostGISDao { public interface PostGISDao {
public void CommonCreateTable(Map<String,Object> tableStructure); 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.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport; import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Repository @Repository
@ -20,10 +20,15 @@ public class PostGISDaoImpl extends SqlSessionDaoSupport implements PostGISDao {
@Override @Override
public void CommonCreateTable(Map<String,Object> tableStructure){ public void CommonCreateTable(Map<String,Object> tableStructure){
System.out.println(tableStructure);
getSqlSession().update("PostGISSql.commonCreateTable",tableStructure); getSqlSession().update("PostGISSql.commonCreateTable",tableStructure);
} }
@Override @Override
public void CreateSpatialIndex(String tableName){ public void CreateSpatialIndex(String tableName,String geometryColumn){
getSqlSession().update("PostGISSql.createSpatialIndex",tableName); 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); SpatialIndexParam.put("geometryColumn",geometryColumn);
postGISDao.CommonCreateTable(tableStructure); postGISDao.CommonCreateTable(tableStructure);
postGISDao.CreateSpatialIndex(tableName); postGISDao.CreateSpatialIndex(tableName,geometryColumn);
} }
} }

View File

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