本文整理匯總了Java中com.vividsolutions.jts.geom.Geometry.getGeometryType方法的典型用法代碼示例。如果您正苦於以下問題:Java Geometry.getGeometryType方法的具體用法?Java Geometry.getGeometryType怎麽用?Java Geometry.getGeometryType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vividsolutions.jts.geom.Geometry
的用法示例。
在下文中一共展示了Geometry.getGeometryType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: smooth
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static Geometry smooth(final Geometry geom, final double fit,
final GeometryFactory factory, GeometrySmoother smoother) {
switch (geom.getGeometryType().toUpperCase()) {
case "POINT":
case "MULTIPOINT":
// For points, just return the input geometry
return geom;
case "LINESTRING":
// This handles open and closed lines (LinearRings)
return smoothLineString(factory, smoother, geom, fit);
case "MULTILINESTRING":
return smoothMultiLineString(factory, smoother, geom, fit);
case "POLYGON":
return smoother.smooth((Polygon) geom, fit);
case "MULTIPOLYGON":
return smoothMultiPolygon(factory, smoother, geom, fit);
case "GEOMETRYCOLLECTION":
return smoothGeometryCollection(factory, smoother, geom, fit);
default:
throw new UnsupportedOperationException("No smoothing method available for "
+ geom.getGeometryType());
}
}
示例2: toJSON
import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
public static JSONArray toJSON(Geometry geom, StringBuffer buffer) throws Exception
{
if (geom instanceof Polygon)
{
return toJSON((Polygon)geom);
}
else if (geom instanceof LineString)
{
return toJSON((LineString)geom, false);
}
else if (geom instanceof Point)
{
return toJSON((Point)geom);
}
else if (geom instanceof MultiPolygon)
{
return toJSON((MultiPolygon)geom);
}
else
{
throw new Exception("toJSON function is not implemented for " + geom.getGeometryType());
}
}