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

Java DelaunayTriangulationBuilder类代码示例

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

本文整理汇总了Java中com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder的典型用法代码示例。如果您正苦于以下问题:Java DelaunayTriangulationBuilder类的具体用法?Java DelaunayTriangulationBuilder怎么用?Java DelaunayTriangulationBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DelaunayTriangulationBuilder类属于com.vividsolutions.jts.triangulate包,在下文中一共展示了DelaunayTriangulationBuilder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: iterateOverTriangles

import com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder; //导入依赖的package包/类
public static void iterateOverTriangles(final Polygon polygon, final Consumer<Geometry> action) {
	final double elevation = getContourCoordinates(polygon).averageZ();
	final double sizeTol = FastMath.sqrt(polygon.getArea()) / 100.0;
	final DelaunayTriangulationBuilder dtb = new DelaunayTriangulationBuilder();
	final PreparedGeometry buffered = PREPARED_GEOMETRY_FACTORY.create(polygon.buffer(sizeTol, 5, 0));
	final Envelope3D env = Envelope3D.of(buffered.getGeometry());
	try {
		dtb.setSites(polygon);
		dtb.setTolerance(sizeTol);
		applyToInnerGeometries(dtb.getTriangles(GEOMETRY_FACTORY), (gg) -> {
			final ICoordinates cc = getContourCoordinates(gg);
			if (cc.isCoveredBy(env) && buffered.covers(gg)) {
				cc.setAllZ(elevation);
				gg.geometryChanged();
				action.accept(gg);
			}
		});
	} catch (final LocateFailureException | ConstraintEnforcementException e) {
		final IScope scope = GAMA.getRuntimeScope();
		GamaRuntimeException.warning("Impossible to triangulate: " + new WKTWriter().write(polygon), scope);
		iterateOverTriangles((Polygon) DouglasPeuckerSimplifier.simplify(polygon, 0.1), action);
		return;
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:25,代码来源:GeometryUtils.java


示例2: triangularize

import com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder; //导入依赖的package包/类
private static List<Geometry> triangularize(GeometryFactory geometryFactory, Geometry geometry) {
  DelaunayTriangulationBuilder dtb = new DelaunayTriangulationBuilder();
  dtb.setSites(geometry);
  Geometry triangularizedGeom = dtb.getTriangles(geometryFactory);
  List<Geometry> triangles = new ArrayList<Geometry>(triangularizedGeom.getNumGeometries());
  for(int i = 0; i < triangularizedGeom.getNumGeometries(); ++i) {
    triangles.add(triangularizedGeom.getGeometryN(i));
  }
  return triangles;
}
 
开发者ID:foursquare,项目名称:shapefile-geo,代码行数:11,代码来源:WaterDelaunayTriangulationSimplifier.java


示例3: generateTin

import com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder; //导入依赖的package包/类
/**
 * Generate a tin from a given coords list. The internal tin geoms array is set from the result.
 * 
 * @param coordinateList the coords to use for the tin generation.
 */
private void generateTin( List<Coordinate> coordinateList ) {
    pm.beginTask("Generate tin...", -1);
    DelaunayTriangulationBuilder b = new DelaunayTriangulationBuilder();
    b.setSites(coordinateList);
    Geometry tinTriangles = b.getTriangles(gf);
    tinGeometries = new Geometry[tinTriangles.getNumGeometries()];
    for( int i = 0; i < tinTriangles.getNumGeometries(); i++ ) {
        tinGeometries[i] = tinTriangles.getGeometryN(i);
    }
    pm.done();
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:17,代码来源:TinHandler.java


示例4: actionPerformed

import com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
  this.projectFrame = application.getMainFrame().getSelectedProjectFrame();
  IPopulation<? extends IFeature> pop = getPopulation();

  Vector<Population<DefaultFeature>> vectPop = new Vector<Population<DefaultFeature>>();

  Population<DefaultFeature> popForShape = new Population<DefaultFeature>();

  ArrayList<Coordinate> listCoord = new ArrayList<Coordinate>();

  for (IFeature iFeature : pop.getElements()) {
    Coordinate c = new Coordinate(iFeature.getGeom().centroid().getX(), iFeature.getGeom().centroid().getY());
    listCoord.add(c);
  }
  GeometryFactory g = new GeometryFactory();
  DelaunayTriangulationBuilder dtb = new DelaunayTriangulationBuilder();
  dtb.setSites(listCoord);
  GeometryCollection gc = (GeometryCollection) dtb.getTriangles(g);

  VectTriangle vt = new VectTriangle();

  for (int i = 0; i < gc.getNumGeometries(); i++) {

    Polygon p = (Polygon) gc.getGeometryN(i);
    Coordinate[] tab = p.getCoordinates();

    DirectPositionList idpl = new DirectPositionList();
    for (Coordinate coordinate : tab) {
      idpl.add(new DirectPosition(coordinate.x, coordinate.y));
    }

    GM_Triangle tri = new GM_Triangle(idpl);

    vt.add(tri); 
    popForShape.add(new DefaultFeature(tri));
  }

  int n = 7;

  for(int i=0; i<n; i++)
    vectPop.add(new Population<DefaultFeature>("Triangulation - "+(i*100/n)));


  for (int i = 0; i < vt.size(); i++) {
    vectPop.get((int)(((double)i)/vt.size()*n)).add(new DefaultFeature(vt.get(i)));
  }

  for(int i=0; i<n; i++){
    projectFrame.getDataSet().addPopulation(vectPop.get(i));
    Layer layerC = projectFrame.getSld().createLayer("Triangulation - "+(i*100/n),GM_Polygon.class, Color.BLACK, new Color(232, i*255/(n-1), 12), 1f, 1);
    layerC.getSymbolizer().setUnitOfMeasurePixel();

    projectFrame.getSld().add(layerC);
  }


  ShapefileWriter.chooseAndWriteShapefile(popForShape);

}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:61,代码来源:TriangulationPlugin.java


示例5: process

import com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder; //导入依赖的package包/类
@Execute
public void process() throws Exception {
    checkNull(inMap);

    if (!EGeometryType.isPoint(inMap.getSchema().getGeometryDescriptor())) {
        throw new ModelsIllegalargumentException("The input geometry needs to be points.", this, pm);
    }

    if (fElev != null) {
        fElev = FeatureUtilities.findAttributeName(inMap.getSchema(), fElev);
        if (fElev == null) {
            throw new ModelsIllegalargumentException("Couldn't find field: " + fElev, this);
        }
    }

    CoordinateReferenceSystem crs = inMap.getBounds().getCoordinateReferenceSystem();
    List<SimpleFeature> fList = FeatureUtilities.featureCollectionToList(inMap);

    pm.beginTask("Processing...", fList.size());
    DelaunayTriangulationBuilder b = new DelaunayTriangulationBuilder();
    List<Coordinate> cList = new ArrayList<Coordinate>();
    for( SimpleFeature f : fList ) {
        Geometry geometry = (Geometry) f.getDefaultGeometry();
        double elev = 0.0;
        if (fElev != null)
            elev = (Double) f.getAttribute(fElev);

        Coordinate c = geometry.getCoordinate();
        c.z = elev;
        cList.add(c);
        pm.worked(1);
    }
    pm.done();

    b.setSites(cList);

    List<Geometry> geosList = new ArrayList<Geometry>();
    Geometry triangles = b.getTriangles(gf);
    for( int i = 0; i < triangles.getNumGeometries(); i++ ) {
        Geometry geometryN = triangles.getGeometryN(i);
        Coordinate[] coordinates = geometryN.getCoordinates();
        double min = Double.POSITIVE_INFINITY;
        double max = Double.NEGATIVE_INFINITY;
        for( Coordinate coordinate : coordinates ) {
            min = Math.min(min, coordinate.z);
            max = Math.max(max, coordinate.z);
        }
        geometryN.setUserData(new String[]{"" + min, "" + max});
        geosList.add(geometryN);
    }
    outMap = FeatureUtilities.featureCollectionFromGeometry(crs, geosList.toArray(new Geometry[0]));
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:53,代码来源:OmsDelaunayTriangulation.java


示例6: triangulate

import com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder; //导入依赖的package包/类
/**
 * Triangulates (delaunay standard) a geometry.
 * 
 * @param g
 *            a JTS geometry, on which contains() operations are valid (ie:
 *            one composed of non-intersecting polygons)
 * @return a triangulation, consisting of triples of indices (in the order
 *         defined by g.getCoordinates())
 */
public static short[] triangulate(Geometry g) {
	DelaunayTriangulationBuilder triangulator = new DelaunayTriangulationBuilder();
	Coordinate cs[] = g.getCoordinates();
	if (cs.length > Short.MAX_VALUE) {
		throw new IllegalArgumentException(
				" cannot triangulate polygons exceeding " + Short.MAX_VALUE
						+ " vertices; this one has " + cs.length
						+ " vertices");
	}

	HashMap<Coordinate, Short> cMap = new HashMap<Coordinate, Short>();
	// do not close (because the last == the first)
	for (short i = 0; i < cs.length - 1; i++) {
		cMap.put(cs[i], i);
	}

	Gdx.app.debug("GeometryUtils", "triangulating " + (cs.length - 1));

	triangulator.setSites(g);
	Geometry all = triangulator.getTriangles(gf);
	int allTriangles = all.getNumGeometries();
	Array<Coordinate[]> ts = new Array<Coordinate[]>(allTriangles);
	for (int i = 0; i < allTriangles; i++) {
		Geometry tg = all.getGeometryN(i);
		if (g.contains(tg.getInteriorPoint())) {
			ts.add(tg.getGeometryN(i).getCoordinates());
		}
	}

	Gdx.app.debug("GeometryUtils", "... got " + ts.size + " triangles");

	short indices[] = new short[ts.size * 3];
	int j = 0;
	for (Coordinate[] triangle : ts) {
		indices[j++] = cMap.get(triangle[0]);
		indices[j++] = cMap.get(triangle[1]);
		indices[j++] = cMap.get(triangle[2]);
		Gdx.app.debug("GeometryUtils", "Added triangle: " + indices[j - 1]
				+ " " + indices[j - 2] + " " + indices[j - 3]);
	}
	return indices;
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:52,代码来源:GeometryUtils.java


示例7: getFaces

import com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder; //导入依赖的package包/类
/**
 * Performs a JTS Delaunay triangulation on the current state of the point
 * cloud and returns a list of faces comprising the resulting mesh.
 * 
 * @return a list of Vertex arrays corresponding to the faces of the mesh
 */
public List<Vertex[]> getFaces() {
    DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder();
    builder.setSites(pointCloud);
    return builder.getSubdivision().getTriangleVertices(false);
}
 
开发者ID:Geocent,项目名称:geoserver-exportscene-plugin,代码行数:12,代码来源:SceneType.java



注:本文中的com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ProjectFacetManager类代码示例发布时间:2022-05-23
下一篇:
Java RegistrySimple类代码示例发布时间: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