postgis 中的问题

 在将shapefile数据导入postgis1.5中,导入polygon时,当getNumPoints大于2000(大概,没仔细统计过),postgis中geometry显示为空值,在admin中,郁闷很久。附部分代码,

source = shpDataStore.getFeatureSource("world");
			FilterFactory2 filterFactory2 = CommonFactoryFinder.getFilterFactory2(null);
			FeatureCollection collection = source.getFeatures(filterFactory2.not(CQL.toFilter("NAME like ''")));
			// FeatureCollection collection = source.getFeatures();
			System.out.println(collection.size());
			// Transaction transaction = new DefaultTransaction();
			FeatureWriter<SimpleFeatureType, SimpleFeature> featureWriter = dataStore.getFeatureWriter("province",
					Transaction.AUTO_COMMIT);

			try {
				for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
					SimpleFeature feature = (SimpleFeature) iterator.next();
					System.out.println(feature.getAttribute("NAME"));
					SimpleFeature newFeature = featureWriter.next();
					newFeature.setAttribute(0, feature.getAttribute("NAME"));
					newFeature.setAttribute(1, "中国");
					Object geometry = feature.getDefaultGeometry();
					if (geometry instanceof MultiPolygon) {
						MultiPolygon multiPolygon = (MultiPolygon) geometry;
						Polygon polygon = null;
						int i = 0;
						while (polygon == null && i <= multiPolygon.getNumGeometries()) {
							polygon = (Polygon) multiPolygon.getGeometryN(i);
							i++;
						}
						if (polygon != null) {
							int pointCount = polygon.getNumPoints();
							System.out.println(i + " polygon:" + polygon.getNumPoints());
							System.out.println(pointCount / 1000);
							newFeature.setAttribute(2, polygon);
							System.out.println("第一个");
						}
					}
					featureWriter.write();
				}
				// transaction.commit();
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				// transaction.close();
				featureWriter.close();
			}
 

 

 

结果还是reference找到答案

PostGIS 1.5.1 Manual 写道
3.11.

I did an ST_AsEWKT and ST_AsText on my rather large geometry and it returned blank field. What gives?


You are probably using PgAdmin or some other tool that doesn't output large text. If your geometry is big enough, it will appear blank in these tools. Use PSQL if you really need to see it or output it in WKT.


--To check number of geometries are really blank
SELECT count(gid) FROM geotable WHERE the_geom IS NULL;
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值