初始化
This commit is contained in:
parent
3d5342f5cb
commit
141cdf98d6
@ -2,6 +2,8 @@ package com.gis3c.spatial.dao;
|
|||||||
|
|
||||||
import com.gis3c.common.persistence.annotation.C3SpatialDao;
|
import com.gis3c.common.persistence.annotation.C3SpatialDao;
|
||||||
import com.gis3c.spatial.entity.Region;
|
import com.gis3c.spatial.entity.Region;
|
||||||
|
import com.gis3c.spatial.entity.RegionCenter;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -11,9 +13,28 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@C3SpatialDao
|
@C3SpatialDao
|
||||||
public interface RegionDao {
|
public interface RegionDao {
|
||||||
public Region findRegionByCode(String reginTable, String reginCode);
|
public Region findRegionByCode(
|
||||||
public String findRgionCenterByCode(String reginTable, String reginCode);
|
@Param("reginTable") String reginTable,
|
||||||
public List<Region> findAroundRegions(String reginTable, String reginCode);
|
@Param("reginCode") String reginCode
|
||||||
public List<Region> findRegionsByParentCode(String reginTable, String parentCode);
|
);
|
||||||
public List<Map<String,String>> findRegionCentersByParentCode(String reginTable, String parentCode);
|
|
||||||
|
public String findRgionCenterByCode(
|
||||||
|
@Param("reginTable") String reginTable,
|
||||||
|
@Param("reginCode") String reginCode
|
||||||
|
);
|
||||||
|
|
||||||
|
public List<Region> findAroundRegions(
|
||||||
|
@Param("reginTable") String reginTable,
|
||||||
|
@Param("reginCode") String reginCode
|
||||||
|
);
|
||||||
|
|
||||||
|
public List<Region> findRegionsByParentCode(
|
||||||
|
@Param("reginTable") String reginTable,
|
||||||
|
@Param("parentCode") String parentCode
|
||||||
|
);
|
||||||
|
|
||||||
|
public List<RegionCenter> findRegionCentersByParentCode(
|
||||||
|
@Param("reginTable") String reginTable,
|
||||||
|
@Param("parentCode") String parentCode
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
25
src/main/java/com/gis3c/spatial/entity/RegionCenter.java
Normal file
25
src/main/java/com/gis3c/spatial/entity/RegionCenter.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.gis3c.spatial.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by hukekuan on 2018/3/10.
|
||||||
|
*/
|
||||||
|
public class RegionCenter {
|
||||||
|
private String regionCode;
|
||||||
|
private String center;
|
||||||
|
|
||||||
|
public String getRegionCode() {
|
||||||
|
return regionCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegionCode(String regionCode) {
|
||||||
|
this.regionCode = regionCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCenter() {
|
||||||
|
return center;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCenter(String center) {
|
||||||
|
this.center = center;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package com.gis3c.spatial.service;
|
package com.gis3c.spatial.service;
|
||||||
|
|
||||||
import com.gis3c.spatial.entity.Region;
|
import com.gis3c.spatial.entity.Region;
|
||||||
|
import com.gis3c.spatial.entity.RegionCenter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -41,5 +42,5 @@ public interface RegionService {
|
|||||||
* @param parentCode
|
* @param parentCode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Map<String,String>> findRegionCentersByParentCode(String parentCode);
|
public List<RegionCenter> findRegionCentersByParentCode(String parentCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.gis3c.spatial.service.impl;
|
|||||||
|
|
||||||
import com.gis3c.spatial.dao.RegionDao;
|
import com.gis3c.spatial.dao.RegionDao;
|
||||||
import com.gis3c.spatial.entity.Region;
|
import com.gis3c.spatial.entity.Region;
|
||||||
|
import com.gis3c.spatial.entity.RegionCenter;
|
||||||
import com.gis3c.spatial.entity.RegionType;
|
import com.gis3c.spatial.entity.RegionType;
|
||||||
import com.gis3c.spatial.service.RegionService;
|
import com.gis3c.spatial.service.RegionService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -57,7 +58,7 @@ public class RegionServiceImpl implements RegionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, String>> findRegionCentersByParentCode(String parentCode) {
|
public List<RegionCenter> findRegionCentersByParentCode(String parentCode) {
|
||||||
RegionType parentType = regionTableByCode(parentCode);
|
RegionType parentType = regionTableByCode(parentCode);
|
||||||
RegionType regionType = parentType.ChildType();
|
RegionType regionType = parentType.ChildType();
|
||||||
if (regionType == null) {
|
if (regionType == null) {
|
||||||
|
|||||||
@ -6,8 +6,12 @@ import com.gis3c.ol.entity.Map;
|
|||||||
import com.gis3c.ol.service.LayerService;
|
import com.gis3c.ol.service.LayerService;
|
||||||
import com.gis3c.ol.service.MapService;
|
import com.gis3c.ol.service.MapService;
|
||||||
import com.gis3c.ol.service.SourceService;
|
import com.gis3c.ol.service.SourceService;
|
||||||
|
import com.gis3c.spatial.common.FeatureUtilities;
|
||||||
|
import com.gis3c.spatial.entity.Region;
|
||||||
import com.gis3c.spatial.entity.RegionType;
|
import com.gis3c.spatial.entity.RegionType;
|
||||||
|
import com.gis3c.spatial.service.RegionService;
|
||||||
import com.gis3c.spatial.service.TestService;
|
import com.gis3c.spatial.service.TestService;
|
||||||
|
import org.opengis.feature.simple.SimpleFeature;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
|
||||||
@ -30,11 +34,15 @@ public class App {
|
|||||||
// LayerService layerService = context.getBean(LayerService.class);
|
// LayerService layerService = context.getBean(LayerService.class);
|
||||||
// MapService mapService = context.getBean(MapService.class);
|
// MapService mapService = context.getBean(MapService.class);
|
||||||
// TestService testService = context.getBean(TestService.class);
|
// TestService testService = context.getBean(TestService.class);
|
||||||
|
RegionService regionService = context.getBean(RegionService.class);
|
||||||
|
|
||||||
|
// List<Region> regionList = regionService.findRegionsByParentCode("370000");
|
||||||
String code = "370300";
|
// String region = regionService.findRegionCentersByParentCode("370100");
|
||||||
System.out.println(code.substring(0,4));
|
System.out.println(regionService.findRegionCentersByParentCode("370100").get(0).getCenter());
|
||||||
|
//
|
||||||
|
// List<SimpleFeature> featureList = FeatureUtilities.JavaBeans2Features(regionList);
|
||||||
|
//
|
||||||
|
// System.out.println(FeatureUtilities.Features2GeoJSON(featureList));
|
||||||
// RegionType r1 = RegionType.CITY;
|
// RegionType r1 = RegionType.CITY;
|
||||||
// RegionType r2 = RegionType.CITY;
|
// RegionType r2 = RegionType.CITY;
|
||||||
//
|
//
|
||||||
|
|||||||
27
src/test/resources/log4j.properties
Normal file
27
src/test/resources/log4j.properties
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
### 设置###
|
||||||
|
log4j.rootLogger = debug,stdout,E
|
||||||
|
|
||||||
|
### 输出信息到控制抬 ###
|
||||||
|
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.stdout.Target = System.out
|
||||||
|
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
|
||||||
|
|
||||||
|
|
||||||
|
### 输出ERROR 级别以上的日志到=E://logs/error.log ###
|
||||||
|
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
|
||||||
|
#log4j.appender.E.File = ${webapp.root}/WEB-INF/logs/error.html
|
||||||
|
log4j.appender.E.File = E://logs/error.html
|
||||||
|
log4j.appender.E.Append = true
|
||||||
|
log4j.appender.E.Threshold = ERROR
|
||||||
|
log4j.appender.E.layout = org.apache.log4j.HTMLLayout
|
||||||
|
log4j.appender.E.layout.ConversionPattern = [%d{yyy MMM dd HH:mm:ss,SSS}] [Log-1] [%-5p] [%c{1}] %m%n
|
||||||
|
|
||||||
|
|
||||||
|
log4j.logger.com.ibatis=DEBUG
|
||||||
|
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
|
||||||
|
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
|
||||||
|
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
|
||||||
|
log4j.logger.java.sql.Connection=DEBUG
|
||||||
|
log4j.logger.java.sql.Statement=DEBUG
|
||||||
|
log4j.logger.java.sql.PreparedStatement=DEBUG
|
||||||
@ -6,6 +6,10 @@
|
|||||||
<result property="regionName" column="name" />
|
<result property="regionName" column="name" />
|
||||||
<result property="geometry" column="geom" javaType="Geometry"/>
|
<result property="geometry" column="geom" javaType="Geometry"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<resultMap id="regionCenterResult" type="com.gis3c.spatial.entity.RegionCenter">
|
||||||
|
<result property="regionCode" column="code" jdbcType="VARCHAR"/>
|
||||||
|
<result property="center" column="center" jdbcType="VARCHAR"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<select id="findRegionByCode" resultMap="regionResult">
|
<select id="findRegionByCode" resultMap="regionResult">
|
||||||
SELECT t.code, t.name, t.geom
|
SELECT t.code, t.name, t.geom
|
||||||
@ -13,8 +17,8 @@
|
|||||||
where t.code = #{reginCode, javaType=java.lang.String};
|
where t.code = #{reginCode, javaType=java.lang.String};
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findRgionCenterByCode" resultType="java.util.HashMap">
|
<select id="findRgionCenterByCode" resultType="java.lang.String">
|
||||||
SELECT t.code, st_astext(st_centroid(t.geom)) as center
|
SELECT st_astext(st_centroid(t.geom))
|
||||||
FROM ${reginTable} t
|
FROM ${reginTable} t
|
||||||
where t.code = #{reginCode, javaType=java.lang.String};
|
where t.code = #{reginCode, javaType=java.lang.String};
|
||||||
</select>
|
</select>
|
||||||
@ -26,4 +30,16 @@
|
|||||||
) t2
|
) t2
|
||||||
where ST_Disjoint(t2.geom,t1.geom) = false;
|
where ST_Disjoint(t2.geom,t1.geom) = false;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="findRegionsByParentCode" resultMap="regionResult">
|
||||||
|
SELECT t.code, t.name, t.geom
|
||||||
|
FROM ${reginTable} t
|
||||||
|
where t.code like #{parentCode, javaType=java.lang.String} || '%';
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="findRegionCentersByParentCode" resultMap="regionCenterResult">
|
||||||
|
SELECT t.code, st_astext(st_centroid(t.geom)) AS center
|
||||||
|
FROM ${reginTable} t
|
||||||
|
where t.code like #{parentCode, javaType=java.lang.String} || '%';
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
<!-- 设置但JDBC类型为空时,某些驱动程序 要指定值,default:OTHER,插入空值时不需要指定类型 -->
|
<!-- 设置但JDBC类型为空时,某些驱动程序 要指定值,default:OTHER,插入空值时不需要指定类型 -->
|
||||||
<setting name="jdbcTypeForNull" value="NULL"/>
|
<setting name="jdbcTypeForNull" value="NULL"/>
|
||||||
|
|
||||||
|
<setting name="logImpl" value="LOG4J" />
|
||||||
</settings>
|
</settings>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user