本文整理汇总了C#中IMultiPolygon.GetGeometryN方法的典型用法代码示例。如果您正苦于以下问题:C# IMultiPolygon.GetGeometryN方法的具体用法?C# IMultiPolygon.GetGeometryN怎么用?C# IMultiPolygon.GetGeometryN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMultiPolygon
的用法示例。
在下文中一共展示了IMultiPolygon.GetGeometryN方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformMultiPolygon
/// <summary>
/// Transforms a <see cref="GeoAPI.Geometries.IMultiPolygon"/>.
/// </summary>
/// <param name="polys">MultiPolygon to transform</param>
/// <param name="from">Source Projection</param>
/// <param name="to">Target Projection</param>
/// <param name="toFactory">The factory to create geometries for <paramref name="to"/></param>
/// <returns>Transformed MultiPolygon</returns>
public static IMultiPolygon TransformMultiPolygon(IMultiPolygon polys, ProjectionInfo from, ProjectionInfo to, IGeometryFactory toFactory)
{
var pOut = new IPolygon[polys.Count];
for (var i = 0; i < polys.Count; i++)
pOut[i] = TransformPolygon((IPolygon)polys.GetGeometryN(i), from, to, toFactory);
return toFactory.CreateMultiPolygon(pOut);
}
示例2: Write
/// <summary>
///
/// </summary>
/// <param name="multiPolygon"></param>
/// <param name="writer"></param>
public void Write(IMultiPolygon multiPolygon, BinaryWriter writer)
{
writer.Write((int) ShapeGeometryTypes.Polygon);
// Write BoundingBox
WriteBoundingBox(multiPolygon, writer);
// Write NumParts and NumPoints
int numParts = multiPolygon.NumGeometries; // Exterior rings count
for (int i = 0; i < multiPolygon.NumGeometries; i++) // Adding interior rings count
numParts += ((IPolygon) multiPolygon.GetGeometryN(i)).NumInteriorRings;
writer.Write((int) numParts);
writer.Write((int) multiPolygon.NumPoints);
// Write IndexParts
int count = 0;
writer.Write((int) count);
for (int i = 0; i < multiPolygon.NumGeometries; i++)
{
IPolygon polygon = (IPolygon) multiPolygon.GetGeometryN(i);
ILineString shell = polygon.ExteriorRing;
count += shell.NumPoints;
if (count == multiPolygon.NumPoints)
break;
writer.Write((int) count);
for (int j = 0; j < polygon.NumInteriorRings; j++)
{
ILineString hole = (ILineString) polygon.GetInteriorRingN(j);
count += hole.NumPoints;
if (count == multiPolygon.NumPoints)
break;
writer.Write((int) count);
}
}
// Write Coordinates
for (int i = 0; i < multiPolygon.NumPoints; i++)
Write(multiPolygon.Coordinates[i], writer);
}
示例3: AppendMultiPolygonText
/// <summary>
/// Converts a <c>MultiPolygon</c> to <MultiPolygon Text format,
/// then appends it to the writer.
/// </summary>
/// <param name="multiPolygon">The <c>MultiPolygon</c> to process.</param>
/// <param name="level"></param>
/// <param name="writer">The output writer to append to.</param>
private void AppendMultiPolygonText(IMultiPolygon multiPolygon, int level, TextWriter writer)
{
if (multiPolygon.IsEmpty)
writer.Write(" EMPTY");
else
{
int level2 = level;
bool doIndent = false;
writer.Write("(");
for (int i = 0; i < multiPolygon.NumGeometries; i++)
{
if (i > 0)
{
writer.Write(",");
level2 = level + 1;
doIndent = true;
}
AppendPolygonText((IPolygon) multiPolygon.GetGeometryN(i), level2, doIndent, writer);
}
writer.Write(")");
}
}
示例4: WriteMultiPolygon
/// <summary>
/// Writes a multipolygon.
/// </summary>
/// <param name="mp">The mulitpolygon to be written.</param>
/// <param name="bWriter">Stream to write to.</param>
/// <param name="byteorder">Byte order</param>
private static void WriteMultiPolygon(IMultiPolygon mp, BinaryWriter bWriter, WkbByteOrder byteorder)
{
//Write the number of polygons.
int num = mp.NumGeometries;
WriteUInt32((uint) num, bWriter, byteorder);
//Loop on the number of polygons.
//NOTE: by contract, the first item returned
// from GetEnumerator (i.e. using foreach) is the IMultiPolygon itself!
for (int i = 0; i < num; i++)
{
IPolygon poly = (IPolygon) mp.GetGeometryN(i);
//Write polygon header
bWriter.Write((byte) byteorder);
WriteUInt32((uint) WKBGeometryType.wkbPolygon, bWriter, byteorder);
//Write each polygon.
WritePolygon(poly, bWriter, byteorder);
}
}
示例5: TransformMultiPolygon
/// <summary>
///
/// </summary>
/// <param name="geom"></param>
/// <param name="parent"></param>
/// <returns></returns>
protected virtual IGeometry TransformMultiPolygon(IMultiPolygon geom, IGeometry parent)
{
ArrayList transGeomList = new ArrayList();
for (int i = 0; i < geom.NumGeometries; i++)
{
IGeometry transformGeom = TransformPolygon((IPolygon) geom.GetGeometryN(i), geom);
if (transformGeom == null) continue;
if (transformGeom.IsEmpty) continue;
transGeomList.Add(transformGeom);
}
return factory.BuildGeometry(transGeomList);
}
示例6: FromMultiPolygon
private static DSMultiPolygon FromMultiPolygon(IMultiPolygon geometry, DSGeometryFactory factory, bool setUserData)
{
var dsPolygons = new DotSpatial.Topology.IPolygon[geometry.NumGeometries];
for (var i = 0; i < dsPolygons.Length; i++)
dsPolygons[i] = FromPolygon((IPolygon)geometry.GetGeometryN(i), factory, setUserData);
var result = factory.CreateMultiPolygon(dsPolygons);
if (setUserData)
result.UserData = geometry.UserData;
return result;
}
示例7: FromMultiPolygon
private static GeoAPIMultiPolygon FromMultiPolygon(IMultiPolygon geometry, GeoAPIGeometryFactory factory, bool copyUserData)
{
var dsPolygons = new GeoAPI.Geometries.IPolygon[geometry.NumGeometries];
for (var i = 0; i < dsPolygons.Length; i++)
dsPolygons[i] = FromPolygon((IPolygon)geometry.GetGeometryN(i), factory, copyUserData);
var result = factory.CreateMultiPolygon(dsPolygons);
if (copyUserData)
result.UserData = geometry.UserData;
return result;
}
示例8: CheckShellsNotNested
/// <summary>
/// Tests that no element polygon is wholly in the interior of another element polygon.
/// Preconditions:
/// Shells do not partially overlap.
/// Shells do not touch along an edge.
/// No duplicate rings exists.
/// This routine relies on the fact that while polygon shells may touch at one or
/// more vertices, they cannot touch at ALL vertices.
/// </summary>
private void CheckShellsNotNested(IMultiPolygon mp, GeometryGraph graph)
{
for (int i = 0; i < mp.NumGeometries; i++)
{
IPolygon p = (IPolygon) mp.GetGeometryN(i);
ILinearRing shell = p.Shell;
for (int j = 0; j < mp.NumGeometries; j++)
{
if (i == j)
continue;
IPolygon p2 = (IPolygon) mp.GetGeometryN(j);
CheckShellNotNested(shell, p2, graph);
if (validErr != null) return;
}
}
}
示例9: AppendMultiPolygonText
/// <summary>
/// Converts a MultiPolygon to <MultiPolygon Text> format, then Appends to it to the writer.
/// </summary>
/// <param name="multiPolygon">The MultiPolygon to process.</param>
/// <param name="writer">The output stream to Append to.</param>
private static void AppendMultiPolygonText(IMultiPolygon multiPolygon, StringWriter writer)
{
if (multiPolygon == null || multiPolygon.IsEmpty)
writer.Write("EMPTY");
else
{
writer.Write("(");
for (int i = 0; i < multiPolygon.NumGeometries; i++)
{
if (i > 0)
writer.Write(", ");
AppendPolygonText((IPolygon)multiPolygon.GetGeometryN(i), writer);
}
writer.Write(")");
}
}