Package com.google.common.geometry
Class S2PolygonBuilder.Options.Builder
java.lang.Object
com.google.common.geometry.S2PolygonBuilder.Options.Builder
- Enclosing class:
S2PolygonBuilder.Options
Builder class for
S2PolygonBuilder.Options
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double
private S1Angle
private boolean
private boolean
private boolean
private boolean
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder()
Constructs a new builder with default values, which is equivalent toS2PolygonBuilder.Options.DIRECTED_XOR
. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds and returns a new (immutable) instance ofS2PolygonBuilder.Options
.setEdgeSpliceFraction
(double edgeSpliceFraction) Sets the threshold radius at which vertex are spliced into an edge.setMergeDistance
(S1Angle mergeDistance) Sets the threshold angle at which to merge vertex pairs.setRobustnessRadius
(S1Angle robustnessRadius) SetsmergeDistance
computed from robustness radius and edge splice fraction.setSnapToCellCenters
(boolean snapToCellCenters) Sets whether a polygon will snap its vertices to the centers of s2 cells at the smallest level number such that no vertex will move by more than the robustness radius.setUndirectedEdges
(boolean undirectedEdges) Sets whether edges are undirected.setValidate
(boolean validate) Sets whetherS2Loop.isValid()
is called for all loops.setXorEdges
(boolean xorEdges) Sets whether duplicated edges will be collapsed.
-
Field Details
-
undirectedEdges
private boolean undirectedEdges -
xorEdges
private boolean xorEdges -
validate
private boolean validate -
mergeDistance
-
snapToCellCenters
private boolean snapToCellCenters -
edgeSpliceFraction
private double edgeSpliceFraction
-
-
Constructor Details
-
Builder
public Builder()Constructs a new builder with default values, which is equivalent toS2PolygonBuilder.Options.DIRECTED_XOR
.
-
-
Method Details
-
build
Builds and returns a new (immutable) instance ofS2PolygonBuilder.Options
. -
setUndirectedEdges
Sets whether edges are undirected. SeeS2PolygonBuilder.Options.getUndirectedEdges()
.Default: false
-
setXorEdges
Sets whether duplicated edges will be collapsed. SeeS2PolygonBuilder.Options.getXorEdges()
.Default: true
-
setValidate
Sets whetherS2Loop.isValid()
is called for all loops. SeeS2PolygonBuilder.Options.getValidate()
.Default: false
-
setMergeDistance
Sets the threshold angle at which to merge vertex pairs. SeeS2PolygonBuilder.Options.getMergeDistance()
.Default value: 0.
-
setSnapToCellCenters
Sets whether a polygon will snap its vertices to the centers of s2 cells at the smallest level number such that no vertex will move by more than the robustness radius. If the robustness radius is smaller than half the leaf cell diameter, no snapping will occur. SeeS2PolygonBuilder.Options.getSnapToCellCenters()
.Default value: false
-
setEdgeSpliceFraction
Sets the threshold radius at which vertex are spliced into an edge. SeeS2PolygonBuilder.Options.getEdgeSpliceFraction()
. Must be at leastsqrt(3) / 2
.Default value: 0.866
-
setRobustnessRadius
SetsmergeDistance
computed from robustness radius and edge splice fraction. TheedgeSpliceFraction
cannot be zero to have a robustness guarantee.See
S2PolygonBuilder.Options.getRobustnessRadius()
. To guarantee that a polygon remains valid when its vertices are moved by an angle of up to epsilon, you needmergeDistance * edgeSpliceFraction >= 2 * epsilon
, as the edge and the vertex can each move by epsilon upon snapping.If your grid has maximum diameter
d
, callsetRobustnessRadius(d/2)
.
-