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


Java Geometry.getClass方法代碼示例

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


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

示例1: removeCollinearVertices

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
 * Removes collinear vertices from the provided {@link Geometry}.
 * 
 * <p>
 * For the moment this implementation only accepts, {@link Polygon}, {@link LineString} and {@link MultiPolygon} It will throw an exception if the
 * geometry is not one of those types
 * 
 * @param g the instance of a {@link Geometry} to remove collinear vertices from.
 * @return a new instance of the provided {@link Geometry} without collinear vertices.
 */
public static Geometry removeCollinearVertices(final Geometry g) {
    if (g == null) {
        throw new NullPointerException("The provided Geometry is null");
    }
    if (g instanceof LineString) {
        return removeCollinearVertices((LineString) g);
    } else if (g instanceof Polygon) {
        return removeCollinearVertices((Polygon) g);
    } else if (g instanceof MultiPolygon) {
        MultiPolygon mp = (MultiPolygon) g;
        Polygon[] parts = new Polygon[mp.getNumGeometries()];
        for (int i = 0; i < mp.getNumGeometries(); i++) {
            Polygon part = (Polygon) mp.getGeometryN(i);
            part = removeCollinearVertices(part);
            parts[i] = part;
        }

        return g.getFactory().createMultiPolygon(parts);
    }

    throw new IllegalArgumentException(
            "This method can work on LineString, Polygon and Multipolygon: " + g.getClass());
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:34,代碼來源:JTS.java


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