没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
1.
录
入
shp
数
据
1)
创
建
表
格
importjava.io.File;
importjava.io.IOException;
importjava.nio.charset.Charset;
importjava.sql.Connection;
importjava.sql.SQLException;
importjava.util.List;
importorg.geotools.data.shapefile.ShapefileDataStore;
importorg.geotools.data.shapefile.ShapefileDataStoreFactory;
importorg.opengis.feature.type.AttributeDescriptor;
publicclassCreateShpTable{
publicstaticvoidmain(String[]args)throwsIOException,SQLException,
ClassNotFoundException{
Connectionconn=null;
conn=DBUtil.getConn();
StringBuffersql=newStringBuffer();
ShapefileDataStoreFactorydataStoreFactory=newShapefileDataStoreFactory();
Stringpath="C:\Users\wang\Desktop\结果\road1.shp";//shp文件路径
ShapefileDataStoresds=
(ShapefileDataStore)dataStoreFactory.createDataStore(newFile(path).toURI().toURL());
sds.setCharset(Charset.forName("UTF-8"));
StringtypeName=sds.getTypeNames()[0];//输出gis.osm_buildings_a_free_1
//List<Name>name=sds.getNames();//[gis.osm_buildings_a_free_1]
//System.out.println(typeName);
typeName=typeName.replace(".","_e");
sql.append("createtablepublic.road_impact(road_idserialprimarykey,");
List<AttributeDescriptor>schema=sds.getSchema().getAttributeDescriptors();
for(inti=0;i<schema.size();i++){
Stringname=schema.get(i).getLocalName();
Stringlength=schema.get(i).getType().getRestrictions().toString();
Stringtype=schema.get(i).getType().getBinding().getName();
switch(type){
case"org.locationtech.jts.geom.MultiPolygon":
资源评论
xuxu1116
- 粉丝: 2w+
- 资源: 69
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功