本文整理汇总了C#中IGeometry.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.Clone方法的具体用法?C# IGeometry.Clone怎么用?C# IGeometry.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometry
的用法示例。
在下文中一共展示了IGeometry.Clone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Match
public bool Match(IGeometry a, IGeometry b)
{
var aClone = (IGeometry)a.Clone();
var bClone = (IGeometry)b.Clone();
aClone.Normalize();
bClone.Normalize();
return aClone.EqualsExact(bClone, _tolerance);
}
示例2: Move
public virtual void Move(IFeature targetFeature, IGeometry sourceGeometry, IList<IGeometry> trackers,
IList<int> handleIndices, int mouseIndex,
double deltaX, double deltaY)
{
IGeometry geometry = (IGeometry)sourceGeometry.Clone();
Move(geometry, sourceGeometry, trackers, handleIndices, mouseIndex, deltaX, deltaY);
targetFeature.Geometry = geometry;
}
示例3: Setup
public void Setup()
{
ringFallOffPolicy = new RingFallOffPolicy();
lineStringSource =
new LineString(new[]
{
new Coordinate(0, 0), new Coordinate(10, 0), new Coordinate(20, 0),
new Coordinate(30, 0), new Coordinate(40, 0), new Coordinate(0, 0)
});
lineStringTarget = (ILineString)lineStringSource.Clone();
}
示例4: RemoveCommonBits
/// <summary>
/// Computes a copy of each input <c>Geometry</c>s with the calculated common bits
/// removed from each coordinate.
/// </summary>
/// <param name="geom0">A Geometry to remove common bits from.</param>
/// <param name="geom1">A Geometry to remove common bits from.</param>
/// <returns>
/// An array containing copies
/// of the input Geometry's with common bits removed.
/// </returns>
private IGeometry[] RemoveCommonBits(IGeometry geom0, IGeometry geom1)
{
cbr = new CommonBitsRemover();
cbr.Add(geom0);
cbr.Add(geom1);
IGeometry[] geom = new IGeometry[2];
geom[0] = cbr.RemoveCommonBits((IGeometry) geom0.Clone());
geom[1] = cbr.RemoveCommonBits((IGeometry) geom1.Clone());
return geom;
}
示例5: UnionSafe
/// <summary>
/// Computes the union of two geometries,
/// either or both of which may be null.
/// </summary>
/// <param name="g0">A Geometry</param>
/// <param name="g1">A Geometry</param>
/// <returns>The union of the input(s) or
/// <value>null</value> if both inputs are null</returns>
private IGeometry UnionSafe(IGeometry g0, IGeometry g1)
{
if (g0 == null && g1 == null)
return null;
if (g0 == null)
return (IGeometry)g1.Clone();
if (g1 == null)
return (IGeometry)g0.Clone();
return UnionOptimized(g0, g1);
}
示例6: normalize
public static IGeometry normalize(IGeometry g)
{
IGeometry gNorm = (IGeometry)g.Clone();
gNorm.Normalize();
return gNorm;
}
示例7: Union
/// <summary>
/// Returns a <c>Geometry</c> representing all the points in this <c>Geometry</c>
/// and <c>other</c>.
/// </summary>
/// <param name="other">The <c>Geometry</c> with which to compute the union.</param>
/// <returns>A set combining the points of this <c>Geometry</c> and the points of <c>other</c>.</returns>
public IGeometry Union(IGeometry other)
{
// Special case: if either input is empty ==> other input
if (IsEmpty)
return (IGeometry) other.Clone();
if (other.IsEmpty)
return (IGeometry) Clone();
CheckNotGeometryCollection(this);
CheckNotGeometryCollection(other);
return SnapIfNeededOverlayOp.Overlay(this, other, SpatialFunction.Union);
}
示例8: Union
/// <summary>
/// Computes a <c>Geometry</c> representing the point-set
/// which is contained in both this
/// <c>Geometry</c> and the <c>other</c> Geometry.
/// </summary>
/// <remarks>
/// The method may be used on arguments of different dimension, but it does not
/// support <see cref="IGeometryCollection"/> arguments.
/// <para/>
/// The union of two geometries of different dimension produces a result
/// geometry of dimension equal to the maximum dimension of the input
/// geometries.
/// The result geometry may be a heterogenous
/// <see cref="IGeometryCollection"/>.
/// If the result is empty, it is an atomic geometry
/// with the dimension of the highest input dimension.
/// <para/>
/// Unioning <see cref="ILineString"/>s has the effect of
/// <b>noding</b> and <b>dissolving</b> the input linework. In this context
/// "noding" means that there will be a node or endpoint in the result for
/// every endpoint or line segment crossing in the input. "Dissolving" means
/// that any duplicate (i.e. coincident) line segments or portions of line
/// segments will be reduced to a single line segment in the result.
/// If <b>merged</b> linework is required, the <see cref="LineMerger"/>
/// class can be used.
/// <para/>
/// Non-empty <see cref="IGeometryCollection"/> arguments are not supported.</remarks>
/// <param name="other">the <c>Geometry</c> with which to compute the union</param>
/// <returns>A point-set combining the points of this <c>Geometry</c> and the
/// points of <c>other</c></returns>
/// <exception cref="TopologyException">Thrown if a robustness error occurs</exception>
/// <exception cref="ArgumentException">Thrown if either input is a non-empty GeometryCollection</exception>
/// <seealso cref="LineMerger"/>
public IGeometry Union(IGeometry other)
{
// handle empty geometry cases
if (IsEmpty || (other == null || other.IsEmpty))
{
if (IsEmpty && (other == null || other.IsEmpty))
return OverlayOp.CreateEmptyResult(SpatialFunction.Union, this, other, _factory);
// Special case: if either input is empty ==> other input
if (other == null || other.IsEmpty) return (IGeometry)Clone();
if (IsEmpty) return (IGeometry)other.Clone();
}
CheckNotGeometryCollection(this);
CheckNotGeometryCollection(other);
return SnapIfNeededOverlayOp.Overlay(this, other, SpatialFunction.Union);
}
示例9: internalBuild
private void internalBuild(IGeometry geometry1, IGeometry geometry2)
{
if (geometry1 != null)
this._sourceGeometry1 = (IGeometry)geometry1.Clone();
else
this._sourceGeometry1 = null;
if (geometry2 != null)
this._sourceGeometry2 = (IGeometry)geometry2.Clone();
else
this._sourceGeometry2 = null;
this.build();
}
示例10: NormalizeGeometry
public static IGeometry NormalizeGeometry(IGeometry geometryToNormalize)
{
if (geometryToNormalize is IPoint)
{
return geometryToNormalize;
}
if (geometryToNormalize is IGeometryCollection)
{
var geometries = (IGeometryCollection)geometryToNormalize.Clone();
for (int i=0;i<geometries.Geometries.Length;i++)
{
geometries.Geometries[i] = NormalizeGeometry(geometries.Geometries[i]);
}
return geometries;
}
var resultCoordinates = geometryToNormalize.Coordinates.ToList();
var removed = true;
while (removed)
{
removed = RemoveRedundantPoint(resultCoordinates);
}
if (geometryToNormalize is IPolygon)
{
//re-add the closing point as it was removed by removedundantpoint
resultCoordinates.Add(resultCoordinates[0]);
return new Polygon(new LinearRing(resultCoordinates.ToArray()));
}
return new LineString(resultCoordinates.ToArray());
}
示例11: SetCoordinate
public static IGeometry SetCoordinate(IGeometry geometry, int coordinateIndex, ICoordinate coordinate)
{
var newGeometry = (IGeometry)geometry.Clone();
newGeometry.Coordinates[coordinateIndex].X = coordinate.X;
newGeometry.Coordinates[coordinateIndex].Y = coordinate.Y;
newGeometry.GeometryChangedAction();
return newGeometry;
}
示例12: Normalize
public static IGeometry Normalize(IGeometry g)
{
Geometry g2 = (Geometry) g.Clone();
g2.Normalize();
return g2;
}
示例13: SymmetricDifference
/// <summary>
/// Computes a <c>Geometry </c> representing the closure of the point-set
/// which is the union of the points in this <c>Geometry</c> which are not
/// contained in the <c>other</c> Geometry,
/// with the points in the <c>other</c> Geometry not contained in this
/// <c>Geometry</c>.
/// If the result is empty, it is an atomic geometry
/// with the dimension of the highest input dimension.
/// <para/>
/// Non-empty <see cref="IGeometryCollection"/> arguments are not supported.
/// </summary>
/// <param name="other">The <c>Geometry</c> with which to compute the symmetric difference.</param>
/// <returns>a Geometry representing the point-set symmetric difference of this <c>Geometry</c> with <c>other</c>.</returns>
public IGeometry SymmetricDifference(IGeometry other)
{
// handle empty geometry cases
if (IsEmpty || (other == null || other.IsEmpty))
{
// both empty - check dimensions
if (IsEmpty && (other == null || other.IsEmpty))
return OverlayOp.CreateEmptyResult(SpatialFunction.SymDifference, this, other, _factory);
// special case: if either input is empty ==> result = other arg
if (other == null || other.IsEmpty) return (IGeometry)Clone();
if (IsEmpty) return (IGeometry)other.Clone();
}
CheckNotGeometryCollection(this);
CheckNotGeometryCollection(other);
return SnapIfNeededOverlayOp.Overlay(this, other, SpatialFunction.SymDifference);
}
示例14: calculateNonIntersectedObjectsOverlay
private GeometryCollection calculateNonIntersectedObjectsOverlay(IGeometry geometry1, IGeometry geometry2, OverlayType operation, bool performSnapping)
{
GeometryCollection result = new GeometryCollection();
// zero crossing
if (operation == OverlayType.Intersection)
return result;
// difference is equal to the first object
if (operation == OverlayType.Difference)
{
result.Add((IGeometry)geometry1.Clone());
return result;
}
// symmetric difference and the union concatenating
try
{
if (geometry1 is Polygon && geometry2 is Polygon)
{
_polygon1Contours = SimplifyContours(((Polygon)geometry1).Contours);
_polygon2Contours = SimplifyContours(((Polygon)geometry2).Contours);
Polygon p = new Polygon();
foreach (Contour c in _polygon1Contours)
p.Contours.Add(c);
foreach (Contour c in _polygon2Contours)
p.Contours.Add(c);
result.Add(p);
}
else if (geometry1 is Polyline && geometry2 is Polyline)
{
Polyline p = new Polyline();
foreach (LinePath path in ((Polyline)geometry1).Paths)
p.Paths.Add(path);
foreach (LinePath path in ((Polyline)geometry2).Paths)
p.Paths.Add(path);
result.Add(p);
}
else
{
// If a figure is still a proving ground to normalize topology
if (geometry1 is Polygon)
{
geometry1 = (IGeometry)((Polygon)geometry1).Clone();
((Polygon)geometry1).Simplify();
}
if (geometry2 is Polygon)
{
geometry2 = (IGeometry)((Polygon)geometry2).Clone();
((Polygon)geometry2).Simplify();
}
result.Add(geometry1);
result.Add(geometry2);
}
return result;
}
finally
{
_polygon1Contours = null;
_polygon2Contours = null;
}
}
示例15: GetBuffer
/// <summary>
/// Builds a buffer for the specified geometry.
/// </summary>
/// <param name="geometry">The geometry to build a buffer</param>
/// <param name="distance">Buffer distance</param>
/// <param name="pointsPerCircle">The number of points in a polygon approximating a circle of a point object buffer</param>
/// <param name="allowParallels">The value indicating whether the parallel computing will be used when possible</param>
/// <returns>>A geometry that represents the resulting buffer</returns>
public static IGeometry GetBuffer(IGeometry geometry, double distance, int pointsPerCircle, bool allowParallels)
{
#if DEMO
throw new NotSupportedException("Buffer builder is not supported in demo version");
#else
if (!(geometry is PointD) && !(geometry is Polyline) && !(geometry is Polygon) && !(geometry is MultiPoint))
throw new NotSupportedException("Buffer calculation for \"" + geometry.GetType().FullName + "\" is not supported.");
if (distance == 0)
return (IGeometry)geometry.Clone();
if (pointsPerCircle <= 2)
throw new ArgumentOutOfRangeException("pointsPerCircle");
if (geometry is Polygon)
return getPolygonBuffer((Polygon)geometry, distance, pointsPerCircle, allowParallels);
if (distance < 0)
throw new ArgumentException("Buffer value should not be negative for this geometry", "distance");
if (geometry is PointD)
return getPointBuffer((PointD)geometry, distance, pointsPerCircle);
if (geometry is Polyline)
return getPolylineBuffer((Polyline)geometry, distance, pointsPerCircle, allowParallels);
if (geometry is MultiPoint)
return getMultiPointBuffer((MultiPoint)geometry, distance, pointsPerCircle, allowParallels);
throw new InvalidOperationException("Internal error");
#endif
}