• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Feature类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CompoundCurve类代码示例发布时间:2022-05-23
下一篇:
Java Extension类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap