當前位置: 首頁>>代碼示例>>Java>>正文


Java Geometry.getFactory方法代碼示例

本文整理匯總了Java中com.vividsolutions.jts.geom.Geometry.getFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java Geometry.getFactory方法的具體用法?Java Geometry.getFactory怎麽用?Java Geometry.getFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.vividsolutions.jts.geom.Geometry的用法示例。


在下文中一共展示了Geometry.getFactory方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: repair

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
 *
 * @param geom
 * @return
 */
public static Geometry repair (Geometry geom) {
    GeometryFactory factory = geom.getFactory();
    if (geom instanceof MultiPolygon) {
        MultiPolygon mp = (MultiPolygon)geom;
        Polygon[] polys = new Polygon[mp.getNumGeometries()];
        for (int i = 0; i < mp.getNumGeometries(); i += 1) {
            polys[i] = repair((Polygon)mp.getGeometryN(i));
        }
        return factory.createMultiPolygon(polys);
    } else if (geom instanceof Polygon) {
        return repair((Polygon)geom);
    } else if (geom.getGeometryType().equals("GeometryCollection")) {
        GeometryCollection gc = (GeometryCollection)geom;
        Geometry[] geoms = new Geometry[gc.getNumGeometries()];
        for (int i = 0; i < gc.getNumGeometries(); i += 1) {
            geoms[i] = repair(gc.getGeometryN(i));
        }
        Thread.dumpStack();
        return factory.createGeometryCollection(geoms);
    } else {
        return(geom);
    }
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:29,代碼來源:JTSUtil.java

示例2: transformIntoPointGeometryCollection

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
 * Transform into GeometryCollection.
 *
 * @param geom input geometry
 * @return a geometry collection
 */
private static GeometryCollection transformIntoPointGeometryCollection(Geometry geom) {
    UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
    geom.apply(filter);
    Coordinate[] coord = filter.getCoordinates();

    Geometry[] geometries = new Geometry[coord.length];
    for (int i = 0; i < coord.length; i++) {
        Coordinate[] c = new Coordinate[]{coord[i]};
        CoordinateArraySequence cs = new CoordinateArraySequence(c);
        geometries[i] = new Point(cs, geom.getFactory());
    }

    return new GeometryCollection(geometries, geom.getFactory());
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:21,代碼來源:ConcaveHull.java

示例3: ConcaveHull

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
 * Create a new concave hull construction for the input {@link Geometry}.
 *
 * @param geometry
 * @param threshold
 */
public ConcaveHull(Geometry geometry, double threshold) {
    this.geometries = transformIntoPointGeometryCollection(geometry);
    this.threshold = threshold;
    this.geomFactory = geometry.getFactory();
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:12,代碼來源:ConcaveHull.java


注:本文中的com.vividsolutions.jts.geom.Geometry.getFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。