初始化

This commit is contained in:
hukekuan@163.com 2018-01-23 17:25:00 +08:00
parent bc7e49f4c9
commit 08475d2f40
13 changed files with 98 additions and 11 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.c3gis</groupId>
<artifactId>c3gis</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<build>
<plugins>
<plugin>

View File

@ -2,6 +2,8 @@ package com.gis3c.ol.dao;
import com.gis3c.common.persistence.annotation.C3olDao;
import com.gis3c.ol.entity.Map;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
@ -10,6 +12,9 @@ import java.util.List;
@C3olDao
public interface MapDao {
public List<Map> findAllList();
public List<Map> findMapsByByPage(
@Param("pageSize") Integer pageSize,
@Param("currentPage") Integer currentPage);
public Map findMapById(String mapId);
public Map findMapByName(String mapName);

View File

@ -2,12 +2,19 @@ package com.gis3c.ol.dao;
import com.gis3c.common.persistence.annotation.C3olDao;
import com.gis3c.ol.entity.View;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Created by hukekuan on 2017/12/15.
*/
@C3olDao
public interface ViewDao {
public List<View> findViewsByByPage(
@Param("pageSize") Integer pageSize,
@Param("currentPage") Integer currentPage);
public View findeViewById(String viewId);
public View findeViewByName(String viewName);

View File

@ -9,6 +9,7 @@ import java.util.List;
*/
public interface MapService {
public List<Map> findAllList();
public List<Map> findMapsByByPage(Integer pageSize,Integer currentPage);
public Map findMapById(String mapId);
public Map findMapByName(String mapName);

View File

@ -2,10 +2,14 @@ package com.gis3c.ol.service;
import com.gis3c.ol.entity.View;
import java.util.List;
/**
* Created by hukekuan on 2017/12/14.
*/
public interface ViewService {
public List<View> findViewsByByPage(Integer pageSize,Integer currentPage);
public View findeViewById(String viewId);
public View findeViewByName(String viewName);

View File

@ -21,6 +21,11 @@ public class MapServiceImpl implements MapService {
return mapDao.findAllList();
}
@Override
public List<Map> findMapsByByPage(Integer pageSize,Integer currentPage) {
return mapDao.findMapsByByPage(pageSize,currentPage);
}
@Override
public Map findMapById(String mapId) {
return mapDao.findMapById(mapId);

View File

@ -6,6 +6,8 @@ import com.gis3c.ol.service.ViewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by hukekuan on 2017/12/14.
*/
@ -14,6 +16,11 @@ public class ViewServiceImpl implements ViewService {
@Autowired
private ViewDao viewDao;
@Override
public List<View> findViewsByByPage(Integer pageSize, Integer currentPage) {
return viewDao.findViewsByByPage(pageSize,currentPage);
}
@Override
public View findeViewById(String viewId) {
return viewDao.findeViewById(viewId);

View File

@ -1,19 +1,66 @@
package com.gis3c.spatial.common;
import com.gis3c.spatial.entity.feature.BaseFeature;
import org.geotools.data.DataUtilities;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.geojson.feature.FeatureJSON;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
/**
* Created by hukekuan on 2018/1/16.
*/
public class FeatureUtilities {
/**
* @Description: 将java bean转换为Simple Feature
* @param beansList
* @return
* @throws IllegalAccessException
*/
public static List<SimpleFeature> JavaBeans2Features(List<? extends BaseFeature> beansList)
throws IllegalAccessException {
if(beansList == null || beansList.size() == 0){
throw new NullPointerException("参数无效");
}
List<SimpleFeature> simpleFeatureList = new ArrayList<>();
SimpleFeatureType featureType = beansList.get(0).createFeatureType();
for(int i = 0,len = beansList.size();i < len;i++){
simpleFeatureList.add(beansList.get(i).javaBean2SimpleFeature(featureType,Integer.toString(i)));
}
return simpleFeatureList;
}
/**
* @Description: 将java bean转换SimpleFeatureCollection
* @param beansList
* @return
* @throws IllegalAccessException
*/
public static SimpleFeatureCollection JavaBeans2Collections(List<? extends BaseFeature> beansList)
throws IllegalAccessException {
List<SimpleFeature> simpleFeatureList = JavaBeans2Features(beansList);
return Features2Collection(simpleFeatureList);
}
/**
* @Description: 将java bean转换GeoJSON
* @param beansList
* @return
* @throws IllegalAccessException
* @throws IOException
*/
public static String JavaBeans2Json(List<? extends BaseFeature> beansList)
throws IllegalAccessException, IOException {
List<SimpleFeature> simpleFeatureList = JavaBeans2Features(beansList);
return Features2GeoJSON(simpleFeatureList);
}
/**
* @author hukekuan

View File

@ -91,7 +91,7 @@ public class BaseFeature implements IFeature {
* @throws IllegalAccessException
* @date 2017-07-10 下午7:10
*/
public SimpleFeature attribute2Feature(SimpleFeatureType featureType, String featureIndex)
public SimpleFeature javaBean2SimpleFeature(SimpleFeatureType featureType, String featureIndex)
throws IllegalArgumentException, IllegalAccessException {
SimpleFeature simpleFeature = null;
if(featureType == null){

View File

@ -5,8 +5,6 @@ import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.gis3c.spatial.entity.geometry.C3Point;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedTypes;
import org.apache.ibatis.type.TypeHandler;

View File

@ -5,12 +5,13 @@ import com.gis3c.ol.service.LayerService;
import com.gis3c.ol.service.MapService;
import com.gis3c.ol.service.SourceService;
import com.gis3c.ol.service.ViewService;
import com.gis3c.spatial.common.FeatureUtilities;
import com.gis3c.spatial.entity.Test;
import com.gis3c.spatial.entity.feature.IFeature;
import com.gis3c.spatial.service.TestService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.IOException;
import java.util.List;
/**
@ -20,7 +21,7 @@ public class App {
public static ApplicationContext ApplicationInit(){
return new ClassPathXmlApplicationContext("classpath:spring-config.xml");
}
public static void main(String[] args) {
public static void main(String[] args) throws IllegalAccessException, IOException {
ApplicationContext context = ApplicationInit();
ViewService viewService = context.getBean(ViewService.class);
SourceService sourceService = context.getBean(SourceService.class);
@ -29,11 +30,17 @@ public class App {
TestService testService = context.getBean(TestService.class);
// List<Map> mapList = mapService.findMapsByByPage(10,0);
Map map = mapService.findMapById("fc813a1f-6a31-4202-9419-8d125ba203c9");
System.out.println(map);
List<Test> result = testService.allList();
Test test = result.get(0);
System.out.println(test.AllFieldes());
// List<Test> result = testService.allList();
// Test test = result.get(0);
// SimpleFeatureType type = test.createFeatureType();
//
// System.out.println(type);
// System.out.println(FeatureUtilities.JavaBeans2Json(result));
// //地图接口
// Map map = mapService.findMapById("fc813a1f-6a31-4202-9419-8d125ba203c9");

View File

@ -1,8 +1,6 @@
package com.gis3c.spatial.entity;
import com.gis3c.spatial.entity.feature.BaseFeature;
import com.gis3c.spatial.entity.geometry.C3Point;
import com.vividsolutions.jts.geom.Point;
/**
* Created by hukekuan on 2018/1/16.

View File

@ -33,6 +33,14 @@
FROM c3gis_ol_map;
</select>
<select id="findMapsByByPage" resultMap="mapResult">
SELECT
<include refid="mapColumns"/>
FROM c3gis_ol_map
limit #{pageSize, javaType=java.lang.Integer}
offset #{currentPage, javaType=java.lang.Integer};
</select>
<select id="findMapById" resultMap="mapResult">
SELECT
<include refid="mapColumns" />