|
|
@@ -28,8 +28,9 @@ public class GeoUtils { |
|
|
|
//测试代码 |
|
|
|
public static void main(String[] args) throws IOException { |
|
|
|
|
|
|
|
JDBCDataStore connnection2mysql = GeoUtils.connnection2mysql("localhost", "gis?serverTimezone=GMT%2B8", 3318, "gly", "glyadmin"); |
|
|
|
SimpleFeatureSource featureSource = readSHP("D:\\NsgkSoft\\files\\uploadPath\\gis\\china_railways.shp"); |
|
|
|
JDBCDataStore connnection2mysql = GeoUtils.connnection2mysql("192.168.31.196", "nsgk_hc?serverTimezone=GMT%2B8", 3318, "gly", "glyadmin"); |
|
|
|
// 会根据shp文件名称创建属性数据table |
|
|
|
SimpleFeatureSource featureSource = readSHP("D:\\NsgkSoft\\files\\uploadPath\\gis\\t_geo_hc_house.shp"); |
|
|
|
JDBCDataStore ds = createTable(connnection2mysql, featureSource); |
|
|
|
writeShp2Mysql(ds, featureSource); |
|
|
|
|
|
|
@@ -42,8 +43,8 @@ public class GeoUtils { |
|
|
|
ShapefileDataStore shpDataStore = null; |
|
|
|
|
|
|
|
shpDataStore = new ShapefileDataStore(file.toURL()); |
|
|
|
//设置编码 |
|
|
|
Charset charset = Charset.forName("utf-8"); |
|
|
|
//设置编码--- 这个不固定,看具体数据 |
|
|
|
Charset charset = Charset.forName("UTF-8"); |
|
|
|
shpDataStore.setCharset(charset); |
|
|
|
String tableName = shpDataStore.getTypeNames()[0]; |
|
|
|
featureSource = shpDataStore.getFeatureSource(tableName); |
|
|
|