• 大小: 11.41MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-12
  • 语言: 数据库
  • 标签: Shape  Sqlite  转换  

资源简介

Shape 转换为 Sqlite 数据 Sqlite 抓获为 Shape 把数据都打印出来了

资源截图

代码片段和文件信息

package com.suprui.action;

import java.io.File;
import java.nio.charset.Charset;
import java.util.Iterator;

import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;
import org.opengis.feature.Property;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.type.PropertyType;

import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;

public class shapread {

public static void main(String[] args) {
ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
try {
ShapefileDataStore sds = (ShapefileDataStore) dataStoreFactory
.createDataStore(new File(
“E:\\SH_RD\\android_zj\\zdxm\\zdxm_polygon.shp“)
.toURI().toURL());
sds.setStringCharset(Charset.forName(“GBK“));
SimpleFeatureSource featureSource = sds.getFeatureSource();
SimpleFeatureIterator itertor = featureSource.getFeatures()
.features();

while (itertor.hasNext()) {
SimpleFeature feature = itertor.next();
Iterator it = feature.getProperties().iterator();

while (it.hasNext()) {
Property pro = it.next();
if (pro.getValue() instanceof Point) {
System.out.println(“PointX = “
+ ((Point) (pro.getValue())).getX());
System.out.println(“PointY = “
+ ((Point) (pro.getValue())).getY());
}else if(pro.getValue() instanceof Polygon){
System.out.println(pro.getName() + “ = “
+ pro.getValue());
}
else {
PropertyType typeinfo= pro.getType();

System.out.println(typeinfo.getBinding().getName());
System.out.println(pro.getType().getClass().getName());
System.out.println(pro.getName() + “ = “
+ pro.getValue());
}

}
}
itertor.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3147  2013-10-15 14:06  testshap\.classpath

     文件        384  2013-10-15 13:03  testshap\.project

     文件        629  2012-04-10 09:37  testshap\.settings\org.eclipse.jdt.core.prefs

     文件       3833  2013-10-15 14:06  testshap\bin\com\suprui\action\shapread.class

     文件       5335  2013-10-15 14:06  testshap\bin\com\suprui\action\testshape.class

     文件       4796  2013-10-15 14:06  testshap\bin\com\suprui\action\testwrite.class

     文件     127639  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-api-2.7.2.jar

     文件      12616  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-charts-2.7.2.jar

     文件     426554  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-coverage-2.7.2.jar

     文件     172547  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-cql-2.7.2.jar

     文件      48702  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-data-2.7.2.jar

     文件      30243  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-epsg-extension-2.7.2.jar

     文件    1855641  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-epsg-hsql-2.7.2.jar

     文件       6394  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-epsg-postgresql-2.7.2.jar

     文件     182112  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-epsg-wkt-2.7.2.jar

     文件      42617  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-feature-pregeneralized-2.7.2.jar

     文件      46274  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-geojson-2.7.2.jar

     文件      24680  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-geotiff-2.7.2.jar

     文件      35544  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-gtopo30-2.7.2.jar

     文件      21059  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-image-2.7.2.jar

     文件      86701  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-jdbc-spatialite-2.7.2.jar

     文件      66750  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-jp2k-2.7.2.jar

     文件    1304365  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-main-2.7.2.jar

     文件     486021  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-metadata-2.7.2.jar

     文件     327623  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-opengis-2.7.2.jar

     文件      72369  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-process-2.7.2.jar

     文件      20893  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-property-2.7.2.jar

     文件    1059440  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-referencing-2.7.2.jar

     文件     236015  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-referencing3D-2.7.2.jar

     文件     384060  2013-10-15 11:52  testshap\lib\geotools-2.7.2\gt-render-2.7.2.jar

............此处省略30个文件信息

评论

共有 条评论