整体更新

This commit is contained in:
hukekuan@163.com 2017-05-12 09:29:37 +08:00
parent 2d068611ad
commit ac08e29ff8
5 changed files with 40 additions and 21 deletions

View File

@ -1,21 +1,15 @@
package com.gis3c;
import com.gis3c.service.HelloService;
import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.map.FeatureLayer;
import org.geotools.map.Layer;
import org.geotools.map.MapContent;
import org.geotools.styling.SLD;
import org.geotools.styling.Style;
import org.geotools.swing.JMapFrame;
import org.geotools.swing.data.JFileDataStoreChooser;
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.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class App {
public static ApplicationContext ContextInit(){
@ -25,6 +19,26 @@ public class App {
public static void main(String[] args) throws IOException {
ApplicationContext context =ContextInit();
HelloService obj = (HelloService) context.getBean("helloService");
PostGISService postGISService = (PostGISService) context.getBean("postGISService");
List<Map<String,Object>> columns = new ArrayList<>();
Map<String,Object> column = new HashMap<>();
column.put("columnName","fid");
column.put("typeCode",1);
columns.add(column);
column = new HashMap<>();
column.put("columnName","name");
column.put("typeCode",3);
columns.add(column);
column = new HashMap<>();
column.put("columnName","geom");
column.put("typeCode",91);
columns.add(column);
postGISService.CommonCreateTable("test","geom",columns);
System.out.println(obj.SayHello());
}
}

View File

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

View File

@ -1,7 +1,6 @@
package com.gis3c.service.impl;
import com.gis3c.dao.HelloDao;
import com.gis3c.demo.Hello;
import com.gis3c.service.HelloService;
import org.springframework.stereotype.Service;

View File

@ -14,6 +14,12 @@ public class PostGISServiceImpl implements PostGISService {
public void CommonCreateTable(
String tableName,String geometryColumn,List<Map<String,Object>> columns){
if(tableName == null || "".equals(tableName)
|| geometryColumn == null || "".equals(geometryColumn)
|| columns == null || columns.size() == 0){
throw new IllegalArgumentException("参数错误");
}
Map<String,Object> tableStructure = new HashMap<>();
tableStructure.put("tableName",tableName);
tableStructure.put("columnList",columns);
@ -24,6 +30,6 @@ public class PostGISServiceImpl implements PostGISService {
SpatialIndexParam.put("geometryColumn",geometryColumn);
postGISDao.CommonCreateTable(tableStructure);
postGISDao.CreateSpatialIndex(SpatialIndexParam);
postGISDao.CreateSpatialIndex(tableName);
}
}

View File

@ -19,22 +19,22 @@
${item.columnName} character varying(254)
</when>
<when test='item.typeCode == 91'>
geo geometry(POINT,4326)
${item.columnName} geometry(POINT,4326)
</when>
<when test='item.typeCode == 911'>
geo geometry(MULTIPOINT,4326)
${item.columnName} geometry(MULTIPOINT,4326)
</when>
<when test='item.typeCode == 92'>
geo geometry(LINESTRING,4326)
${item.columnName} geometry(LINESTRING,4326)
</when>
<when test='item.typeCode == 922'>
geo geometry(MULTILINESTRING,4326)
${item.columnName} geometry(MULTILINESTRING,4326)
</when>
<when test='item.typeCode == 93'>
geo geometry(POLYGON,4326)
${item.columnName} geometry(POLYGON,4326)
</when>
<when test='item.typeCode == 933'>
geo geometry(MULTIPOLYGON,4326)
${item.columnName} geometry(MULTIPOLYGON,4326)
</when>
</choose>
</foreach>