数据转换中遇到的问题

以下是数据转换中存在的一些问题和解决(部分)

1.把shp文件导入postgis数据库中(非使用shp2pgsql.exe),shp中为polygon类型,转换到数据库则为multipolygin

                        CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
			
                        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
			SimpleFeatureType schema = shpDataStore.getSchema(fileName);
			builder.setName(fileName);
			builder.setCRS(crs);
			for (AttributeDescriptor descriptor : schema.getAttributeDescriptors()) {
				if (descriptor instanceof GeometryDescriptor) {
					builder.add(descriptor);
				}
			}
			SimpleFeatureType simpleFeatureType = builder.buildFeatureType();
			try {
				dataStore.createSchema(simpleFeatureType);
			} catch (Exception e) {
				System.out.println(e.getLocalizedMessage());
			}

  上网Google了下:http://n2.nabble.com/Polygon-or-MultiPolygon-this-is-the-question-td2951547.html

写道
> If I create a feature which is Polygon and save it to the shape file
> (using ShapefileDataStore), then when I read it back it comes as a
> MultiPolygon. If I create a feature as a LineString and save it to the
> shape file , then when I read it back it comes as a MultiLineString.
>
> Could anyone explain that to me please, I am not getting it?
« [hide part of quote]

Shapefiles do not have the concept of plain linestrings or plain
polygons, the have just one type that can contain both multiple
and simple geometries, but there is no way to tell what is actually
stored (unless, of course, one does not try to read the entire
shapefile just to determine that information, which would be
prohibitively expensive).

So the only safe approach is to always use multi geometries no
matter what.
 

 

 

 

 

你可能感兴趣的:(html,Google)