本文整理了Java中com.vividsolutions.jts.geom.Geometry.buffer()
方法的一些代码示例,展示了Geometry.buffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.buffer()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Geometry
类名称:Geometry
方法名:buffer
[英]Computes a buffer area around this geometry having the given width. The buffer of a Geometry is the Minkowski sum or difference of the geometry with a disc of radius abs(distance)
.
Mathematically-exact buffer area boundaries can contain circular arcs. To represent these arcs using linear geometry they must be approximated with line segments. The buffer geometry is constructed using 8 segments per quadrant to approximate the circular arcs. The end cap style is CAP_ROUND
.
The buffer operation always returns a polygonal result. The negative or zero-distance buffer of lines and points is always an empty Polygon. This is also the result for the buffers of degenerate (zero-area) polygons.
[中]计算此几何体周围具有给定宽度的缓冲区。几何体的缓冲区是半径为[$0$]的圆盘的几何体的Minkowski和或差。
数学上精确的缓冲区边界可以包含圆弧。要使用线性几何体表示这些圆弧,必须使用线段近似这些圆弧。缓冲区几何体使用每个象限8个分段来近似圆弧。端盖样式为CAP_ROUND
。
缓冲区操作始终返回多边形结果。直线和点的负距离或零距离缓冲区始终为空多边形。这也是退化(零面积)多边形缓冲区的结果。
代码示例来源:origin: opentripplanner/OpenTripPlanner
private static void WriteNodesInSubGraph(Subgraph subgraph, PrintWriter islandLog, boolean hadRemoved){
Geometry convexHullGeom = subgraph.getConvexHull();
if (convexHullGeom != null && !(convexHullGeom instanceof Polygon)) {
convexHullGeom = convexHullGeom.buffer(0.0001,5);
}
islandLog.printf("%d\t%d\t%d\t%s\t%b\n", islandCounter, subgraph.stopSize(),
subgraph.streetSize(), convexHullGeom, hadRemoved);
islandCounter++;
}
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
Geometry point = geomf.createPoint(vertexSeconds.getKey().getCoordinate());
point = JTS.transform(point, toMeters);
Geometry buffer = point.buffer(remainingMeters);
bufferLists.put(thresholdSeconds, buffer);
代码示例来源:origin: opentripplanner/OpenTripPlanner
geom = geom.buffer(0.01); // ~10 meters
} else if (geom instanceof Point) {
geom = geom.buffer(0.05); // ~50 meters, so that it shows up
代码示例来源:origin: opentripplanner/OpenTripPlanner
/**
* The function is run periodically by the update manager.
* The extending class should provide the getNote method. It is not implemented here
* as the requirements for different updaters can be vastly different dependent on the data source.
*/
@Override
protected void runPolling() throws IOException{
LOG.info("Run WFS polling updater with hashcode: {}", this.hashCode());
notesForEdge = HashMultimap.create();
uniqueMatchers = new HashMap<>();
FeatureIterator<SimpleFeature> features = featureSource.getFeatures(query).features();
while ( features.hasNext()){
SimpleFeature feature = features.next();
if (feature.getDefaultGeometry() == null) continue;
Alert alert = getNote(feature);
if (alert == null) continue;
Geometry geom = (Geometry) feature.getDefaultGeometry();
Geometry searchArea = geom.buffer(SEARCH_RADIUS_DEG);
Collection<Edge> edges = graph.streetIndex.getEdgesForEnvelope(searchArea.getEnvelopeInternal());
for(Edge edge: edges){
if (edge instanceof StreetEdge && !searchArea.disjoint(edge.getGeometry())) {
addNote(edge, alert, NOTE_MATCHER);
}
}
}
updaterManager.execute(new WFSGraphWriter());
}
代码示例来源:origin: com.vividsolutions/jts
/**
* Creates a valid area geometry from one that possibly has bad topology
* (i.e. self-intersections). Since buffer can handle invalid topology, but
* always returns valid geometry, constructing a 0-width buffer "corrects"
* the topology. Note this only works for area geometries, since buffer
* always returns areas. This also may return empty geometries, if the input
* has no actual area.
*
* @param roughAreaGeom
* an area geometry possibly containing self-intersections
* @return a valid area geometry
*/
private Geometry createValidArea(Geometry roughAreaGeom) {
return roughAreaGeom.buffer(0.0);
}
}
代码示例来源:origin: com.vividsolutions/jts
/**
* Creates a valid area geometry from one that possibly has
* bad topology (i.e. self-intersections).
* Since buffer can handle invalid topology, but always returns
* valid geometry, constructing a 0-width buffer "corrects" the
* topology.
* Note this only works for area geometries, since buffer always returns
* areas. This also may return empty geometries, if the input
* has no actual area.
*
* @param rawAreaGeom an area geometry possibly containing self-intersections
* @return a valid area geometry
*/
private Geometry createValidArea(Geometry rawAreaGeom)
{
if ( isEnsureValidTopology)
return rawAreaGeom.buffer(0.0);
return rawAreaGeom;
}
}
代码示例来源:origin: com.vividsolutions/jts
static Geometry createCircle(Coordinate centre, double radius)
{
Geometry centrePt = geomFact.createPoint(centre);
return centrePt.buffer(radius, POLYGON_SIZE);
}
代码示例来源:origin: com.vividsolutions/jts
static Geometry createCircle()
{
Geometry centrePt = geomFact.createPoint(new Coordinate(0.5, 0.5));
return centrePt.buffer(0.5, 20);
}
代码示例来源:origin: com.vividsolutions/jts
private Geometry bufferUnion(List geoms)
{
GeometryFactory factory = ((Geometry) geoms.get(0)).getFactory();
Geometry gColl = factory.buildGeometry(geoms);
Geometry unionAll = gColl.buffer(0.0);
return unionAll;
}
代码示例来源:origin: com.vividsolutions/jts
public static void unionUsingBuffer(Geometry[] geom)
{
GeometryFactory fact = geom[0].getFactory();
Geometry geomColl = fact.createGeometryCollection(geom);
Geometry union = geomColl.buffer(0.0);
System.out.println(union);
}
代码示例来源:origin: com.vividsolutions/jts
private Geometry bufferUnion(Geometry g0, Geometry g1)
{
GeometryFactory factory = g0.getFactory();
Geometry gColl = factory.createGeometryCollection(new Geometry[] { g0, g1 } );
Geometry unionAll = gColl.buffer(0.0);
return unionAll;
}
代码示例来源:origin: com.vividsolutions/jts
/**
* Computes the buffer a geometry,
* using enhanced precision.
* @param geom0 the Geometry to buffer
* @param distance the buffer distance
* @return the Geometry representing the buffer of the input Geometry.
*/
public Geometry buffer(Geometry geom0, double distance)
{
Geometry geom = removeCommonBits(geom0);
return computeResultPrecision(geom.buffer(distance));
}
代码示例来源:origin: com.vividsolutions/jts
private Geometry bufferUnion(Geometry g0, Geometry g1)
{
GeometryFactory factory = g0.getFactory();
Geometry gColl = factory.createGeometryCollection(new Geometry[] { g0, g1 } );
Geometry unionAll = gColl.buffer(0.0);
return unionAll;
}
代码示例来源:origin: com.vividsolutions/jts
private Geometry fixPolygonalTopology(Geometry geom)
{
/**
* If precision model was *not* changed, need to flip
* geometry to targetPM, buffer in that model, then flip back
*/
Geometry geomToBuffer = geom;
if (! changePrecisionModel) {
geomToBuffer = changePM(geom, targetPM);
}
Geometry bufGeom = geomToBuffer.buffer(0);
Geometry finalGeom = bufGeom;
if (! changePrecisionModel) {
// a slick way to copy the geometry with the original precision factory
finalGeom = geom.getFactory().createGeometry(bufGeom);
}
return finalGeom;
}
代码示例来源:origin: com.vividsolutions/jts
/**
* Snaps the vertices in the component {@link LineString}s
* of the source geometry
* to the vertices of the given snap geometry.
*
*@param snapTolerance the snapping tolerance
*@param cleanResult whether the result should be made valid
* @return a new snapped Geometry
*/
public Geometry snapToSelf(double snapTolerance, boolean cleanResult)
{
Coordinate[] snapPts = extractTargetCoordinates(srcGeom);
SnapTransformer snapTrans = new SnapTransformer(snapTolerance, snapPts, true);
Geometry snappedGeom = snapTrans.transform(srcGeom);
Geometry result = snappedGeom;
if (cleanResult && result instanceof Polygonal) {
// TODO: use better cleaning approach
result = snappedGeom.buffer(0);
}
return result;
}
代码示例来源:origin: com.vividsolutions/jts
Geometry result = geom.buffer(distance);
return result;
代码示例来源:origin: org.geotools/gt2-main
static public Geometry buffer(Geometry arg0,double arg1)
{
Geometry _this = arg0;
return _this.buffer(arg1);
}
代码示例来源:origin: org.geotools/gt-main
static public Geometry bufferWithSegments(Geometry arg0, Double arg1, Integer arg2)
{
if (arg0 == null || arg1 == null || arg2 == null) return null;
Geometry _this = arg0;
return _this.buffer(arg1,arg2);
}
代码示例来源:origin: com.vividsolutions/jts-example
static Geometry createCircle(Coordinate centre, double radius)
{
Geometry centrePt = geomFact.createPoint(centre);
return centrePt.buffer(radius, POLYGON_SIZE);
}
代码示例来源:origin: com.vividsolutions/jts-example
static Geometry createCircle()
{
Geometry centrePt = geomFact.createPoint(new Coordinate(0.5, 0.5));
return centrePt.buffer(0.5, 20);
}
内容来源于网络,如有侵权,请联系作者删除!