本文整理汇总了Java中org.gdal.ogr.Feature类的典型用法代码示例。如果您正苦于以下问题:Java Feature类的具体用法?Java Feature怎么用?Java Feature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Feature类属于org.gdal.ogr包,在下文中一共展示了Feature类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: FeatureNative
import org.gdal.ogr.Feature; //导入依赖的package包/类
public FeatureNative(Feature javaObject, long cPtr) {
super(javaObject, refQueue);
if (cleanupThread == null)
{
/* We didn't manage to have a daemon cleanup thread */
/* so let's clean manually */
while(true)
{
FeatureNative nativeObject =
(FeatureNative) refQueue.poll();
if (nativeObject != null)
nativeObject.delete();
else
break;
}
}
refList.add(this);
swigCPtr = cPtr;
}
开发者ID:FAIMS,项目名称:faims-android,代码行数:23,代码来源:FeatureNative.java
示例2: reprojectShapeFile
import org.gdal.ogr.Feature; //导入依赖的package包/类
public static void reprojectShapeFile(String pathFile, String outPathFile) {
ogr.RegisterAll();
DataSource vector = ogr.Open(pathFile);
SpatialReference src = new SpatialReference(WKTString.WKT3995);
SpatialReference dst = new SpatialReference(WKTString.WKTWGS84);
CoordinateTransformation tr = new CoordinateTransformation(src, dst);
Driver drv = ogr.GetDriverByName("ESRI Shapefile");
File file = new File(outPathFile);
if (file.exists())
drv.DeleteDataSource(outPathFile);
DataSource outputDs = drv.CreateDataSource(outPathFile);
Layer outLayer = outputDs.CreateLayer(outPathFile, dst);
FieldDefn field_def = new FieldDefn("DN",ogr.OFTInteger);
outLayer.CreateField(field_def);
Layer ll = vector.GetLayer(0);
// Get the Layer's Feature Definition
FeatureDefn featureDefn = ll.GetLayerDefn();
int n = ll.GetFeatureCount();
// outLayer.StartTransaction();
for (int i = 0; i < n; i++) {
Feature feat = ll.GetNextFeature();
Geometry gg = feat.GetGeometryRef();
Geometry newgg = new Geometry(ogr.wkbPolygon);
int srcType = gg.GetGeometryType() ;//& (ogrConstants.wkb25DBit);
if (srcType == ogr.wkbPolygon) {
//int resg = gg.Transform(tr);
newgg.AddGeometry(gg);
} else if (srcType == ogr.wkbMultiPolygon) {
int geomCount = gg.GetGeometryCount();
for (int geomIndex = 0; geomIndex < geomCount; geomIndex++) {
Geometry g=gg.GetGeometryRef(geomIndex);
int resg = g.Transform(tr);
newgg.AddGeometry(g);
}
}
// create a new feature
Feature f = new Feature(featureDefn);
f.SetGeometry(newgg);
// f.SetFID(i);
for (int j = 0; j < feat.GetFieldCount(); j++) {
String type = feat.GetFieldDefnRef(j).GetFieldTypeName(feat.GetFieldType(j));
if (type.equals("String")) {
f.SetField(feat.GetFieldDefnRef(j).GetName(), feat.GetFieldAsString(j));
} else if (type.equals("StringList")) {
} else if (type.equals("Integer")) {
f.SetField(feat.GetFieldDefnRef(j).GetName(), feat.GetFieldAsInteger(j));
} else if (type.equals("IntegerList")) {
} else if (type.equals("Real")) {
f.SetField(feat.GetFieldDefnRef(j).GetName(), feat.GetFieldAsDouble(j));
} else if (type.equals("RealList")) {
}
}
// Add new feature to output Layer
int res = outLayer.CreateFeature(f);
System.out.println("create feature:" + res);
gg.delete();
feat.delete();
}
// outLayer.CommitTransaction();
}
开发者ID:ec-europa,项目名称:sumo,代码行数:76,代码来源:GDALWarpReprojection.java
示例3: createEdgeLayer
import org.gdal.ogr.Feature; //导入依赖的package包/类
private static Layer createEdgeLayer(final DataSource dataSource,
final Collection<Node> nodes,
final Iterable<Edge> edges,
final SpatialReference spatialReference)
{
final Map<Integer, Node> nodeMap = new HashMap<>(nodes.size());
for(final Node node : nodes)
{
nodeMap.put(node.getIdentifier(), node);
}
final Layer edgeLayer = dataSource.CreateLayer("edges",
spatialReference,
ogrConstants.wkbLineString);
try
{
for(final Edge edge : edges)
{
final Feature edgeFeature = new Feature(edgeLayer.GetLayerDefn());
final Geometry line = new Geometry(ogrConstants.wkbLineString);
final Node node0 = nodeMap.get(edge.getFrom());
final Node node1 = nodeMap.get(edge.getTo());
line.AddPoint(node0.getX(), node0.getY());
line.AddPoint(node1.getX(), node1.getY());
if(edgeFeature.SetGeometry(line) != gdalconstConstants.CE_None)
{
throw new RuntimeException(new GdalError().getMessage());
}
if(edgeLayer.CreateFeature(edgeFeature) != gdalconstConstants.CE_None)
{
throw new RuntimeException(new GdalError().getMessage());
}
}
}
catch(final Throwable th)
{
edgeLayer.delete();
throw th;
}
return edgeLayer;
}
开发者ID:GitHubRGI,项目名称:swagd,代码行数:50,代码来源:Utility.java
注:本文中的org.gdal.ogr.Feature类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论