本文整理汇总了C#中IGeometryFactory.CreateGeometryCollection方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometryFactory.CreateGeometryCollection方法的具体用法?C# IGeometryFactory.CreateGeometryCollection怎么用?C# IGeometryFactory.CreateGeometryCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometryFactory
的用法示例。
在下文中一共展示了IGeometryFactory.CreateGeometryCollection方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadGeometriesFromWktString
/**
* Reads one or more WKT geometries from a string.
*
* @param wkt
* @param geomFact
* @return
* @throws ParseException
* @throws IOException
*/
public static IGeometry ReadGeometriesFromWktString(String wkt, IGeometryFactory geomFact)
{
var reader = new WKTReader(geomFact);
WKTFileReader fileReader = new WKTFileReader(new StringReader(wkt), reader);
var geomList = fileReader.Read();
if (geomList.Count == 1)
return geomList[0];
return geomFact.CreateGeometryCollection(GeometryFactory.ToGeometryArray(geomList));
}
示例2: Buffer
/// <summary>
///
/// </summary>
/// <param name="g"></param>
/// <param name="distance"></param>
/// <returns></returns>
public IGeometry Buffer(IGeometry g, double distance)
{
IPrecisionModel precisionModel = workingPrecisionModel;
if (precisionModel == null)
precisionModel = g.PrecisionModel;
// factory must be the same as the one used by the input
geomFact = g.Factory;
OffsetCurveBuilder curveBuilder = new OffsetCurveBuilder(precisionModel, quadrantSegments);
curveBuilder.EndCapStyle = endCapStyle;
OffsetCurveSetBuilder curveSetBuilder = new OffsetCurveSetBuilder(g, distance, curveBuilder);
IList bufferSegStrList = curveSetBuilder.GetCurves();
// short-circuit test
if (bufferSegStrList.Count <= 0)
{
IGeometry emptyGeom = geomFact.CreateGeometryCollection(new IGeometry[0]);
return emptyGeom;
}
ComputeNodedEdges(bufferSegStrList, precisionModel);
graph = new PlanarGraph(new OverlayNodeFactory());
graph.AddEdges(edgeList.Edges);
IList subgraphList = CreateSubgraphs(graph);
PolygonBuilder polyBuilder = new PolygonBuilder(geomFact);
BuildSubgraphs(subgraphList, polyBuilder);
IList resultPolyList = polyBuilder.Polygons;
IGeometry resultGeom = geomFact.BuildGeometry(resultPolyList);
return resultGeom;
}
示例3: TransformGeometryCollection
/// <summary>
/// Transforms a <see cref="GeoAPI.Geometries.IGeometryCollection"/>.
/// </summary>
/// <param name="geoms">GeometryCollection 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 GeometryCollection</returns>
public static IGeometryCollection TransformGeometryCollection(IGeometryCollection geoms, ProjectionInfo from, ProjectionInfo to, IGeometryFactory toFactory)
{
var gOut = new IGeometry[geoms.Count];
for (var i = 0; i < geoms.Count; i++)
gOut[i] = TransformGeometry(geoms.GetGeometryN(i), from, to, toFactory);
return toFactory.CreateGeometryCollection(gOut);
}
示例4: ReadGeometryCollectionText
/// <summary>
/// Creates a <see cref="GeometryCollection"/> using the next token in the stream.
/// </summary>
/// <param name="tokenizer"> Tokenizer over a stream of text in Well-known Text
/// format. The next tokens must form a GeometryCollection Text.</param>
/// <param name="factory">The factory to create the result geometry</param>
/// <returns>
/// A <see cref="GeometryCollection"/> specified by the next token in the stream.</returns>
private static IGeometryCollection ReadGeometryCollectionText(WktStreamTokenizer tokenizer, IGeometryFactory factory)
{
var nextToken = GetNextEmptyOrOpener(tokenizer);
if (nextToken.Equals("EMPTY"))
return factory.CreateGeometryCollection(null);
var geometries = new List<IGeometry>();
geometries.Add(ReadGeometryTaggedText(tokenizer));
nextToken = GetNextCloserOrComma(tokenizer);
while (nextToken.Equals(","))
{
geometries.Add(ReadGeometryTaggedText(tokenizer));
nextToken = GetNextCloserOrComma(tokenizer);
}
return factory.CreateGeometryCollection(geometries.ToArray());
}
示例5: CreateEmptyResult
/// <summary>
/// Creates an empty result geometry of the appropriate dimension,
/// based on the given overlay operation and the dimensions of the inputs.
/// The created geometry is always an atomic geometry,
/// not a collection.
/// <para/>
/// The empty result is constructed using the following rules:
/// <list type="Bullet">
/// <item><see cref="SpatialFunction.Intersection"/> - result has the dimension of the lowest input dimension</item>
/// <item><see cref="SpatialFunction.Union"/> - result has the dimension of the highest input dimension</item>
/// <item><see cref="SpatialFunction.Difference"/> - result has the dimension of the left-hand input</item>
/// <item><see cref="SpatialFunction.SymDifference"/> - result has the dimension of the highest input dimension
/// (since symDifference is the union of the differences).</item>
/// </list>
/// </summary>
/// <param name="overlayOpCode">The overlay operation being performed</param>
/// <param name="a">An input geometry</param>
/// <param name="b">An input geometry</param>
/// <param name="geomFact">The geometry factory being used for the operation</param>
/// <returns>An empty atomic geometry of the appropriate dimension</returns>
public static IGeometry CreateEmptyResult(SpatialFunction overlayOpCode, IGeometry a, IGeometry b, IGeometryFactory geomFact)
{
IGeometry result = null;
switch (ResultDimension(overlayOpCode, a, b))
{
case Dimension.False:
result = geomFact.CreateGeometryCollection(new IGeometry[0]);
break;
case Dimension.Point:
result = geomFact.CreatePoint((Coordinate)null);
break;
case Dimension.Curve:
result = geomFact.CreateLineString((Coordinate[])null);
break;
case Dimension.Surface:
result = geomFact.CreatePolygon(null, null);
break;
}
return result;
}
示例6: ReadGeometryCollectionText
/// <summary>
/// Creates a <c>GeometryCollection</c> using the next token in the
/// stream.
/// </summary>
/// <param name="tokens">
/// Tokenizer over a stream of text in Well-known Text
/// format. The next tokens must form a <GeometryCollection Text.
/// </param>
/// <param name="factory"> </param>
/// <returns>
/// A <c>GeometryCollection</c> specified by the
/// next token in the stream.</returns>
private IGeometryCollection ReadGeometryCollectionText(IEnumerator<Token> tokens, IGeometryFactory factory)
{
string nextToken = GetNextEmptyOrOpener(tokens);
if (nextToken.Equals("EMPTY"))
return factory.CreateGeometryCollection(new IGeometry[] { } );
var geometries = new List<IGeometry>();
var geometry = ReadGeometryTaggedText(tokens);
geometries.Add(geometry);
nextToken = GetNextCloserOrComma(tokens);
while (nextToken.Equals(","))
{
geometry = ReadGeometryTaggedText(tokens);
geometries.Add(geometry);
nextToken = GetNextCloserOrComma(tokens);
}
return factory.CreateGeometryCollection(geometries.ToArray());
}
示例7: TransformGeometryCollection
/// <summary>
/// Transforms a <see cref="GeoAPI.Geometries.IGeometryCollection"/>.
/// </summary>
/// <param name="geoms">GeometryCollection to transform</param>
/// <param name="transform">MathTransform</param>
/// <param name="targetFactory">The factory to create the target geometry</param>
/// <returns>Transformed GeometryCollection</returns>
public static IGeometryCollection TransformGeometryCollection(IGeometryCollection geoms, IMathTransform transform, IGeometryFactory targetFactory)
{
var geomList = new IGeometry[geoms.NumGeometries];
for(var i = 0; i < geoms.NumGeometries; i++)
{
geomList[i] = TransformGeometry(geoms[i], transform, targetFactory);
}
return targetFactory.CreateGeometryCollection(geomList);
}
示例8: TransformGeometryCollection
/// <summary>
/// Transforms a <see cref="GeometryCollection" /> object.
/// </summary>
/// <param name="factory"></param>
/// <param name="geoms"></param>
/// <param name="transform"></param>
/// <returns></returns>
public static IGeometryCollection TransformGeometryCollection(IGeometryFactory factory,
GeometryCollection geoms, IMathTransform transform)
{
List<IGeometry> coll = new List<IGeometry>(geoms.Geometries.Length);
foreach (IGeometry g in geoms.Geometries)
{
IGeometry item = TransformGeometry(factory, g, transform);
coll.Add(item);
}
return factory.CreateGeometryCollection(coll.ToArray());
}
示例9: CreateWKBGeometryCollection
private static IGeometry CreateWKBGeometryCollection(BinaryReader reader, WkbByteOrder byteOrder, IGeometryFactory factory)
{
// The next byte in the array tells the number of geometries in this collection.
var numGeometries = (int) ReadUInt32(reader, byteOrder);
// Create a new array for the geometries.
var geometries = new IGeometry[numGeometries];
// Loop on the number of geometries.
for (var i = 0; i < numGeometries; i++)
{
// Call the main create function with the next geometry.
geometries[i] = Parse(reader, factory);
}
// Create and return the next geometry.
return factory.CreateGeometryCollection(geometries);
}
示例10: ToNTSGeometryCollection
internal static NTSGeometryCollection ToNTSGeometryCollection(Geometries.GeometryCollection geom,
IGeometryFactory factory)
{
NTSGeometry[] geometries = new NTSGeometry[geom.Collection.Count];
int index = 0;
foreach (Geometries.Geometry geometry in geom.Collection)
geometries[index++] = ToNTSGeometry(geometry, factory);
return factory.CreateGeometryCollection(geometries) as NTSGeometryCollection;
}
示例11: GetVoronoiDiagram
/// <summary>
/// Gets the cells in the Voronoi diagram for this triangulation.
/// The cells are returned as a <see cref="IGeometryCollection" /> of <see cref="IPolygon"/>s
/// </summary>
/// <remarks>
/// The userData of each polygon is set to be the <see cref="Coordinate" />
/// of the cell site. This allows easily associating external
/// data associated with the sites to the cells.
/// </remarks>
/// <param name="geomFact">a geometry factory</param>
/// <returns>a GeometryCollection of Polygons</returns>
public IGeometryCollection GetVoronoiDiagram(IGeometryFactory geomFact)
{
var vorCells = GetVoronoiCellPolygons(geomFact);
return geomFact.CreateGeometryCollection(GeometryFactory.ToGeometryArray(vorCells));
}
示例12: GetTriangles
/// <summary>
/// Gets the geometry for the triangles in a triangulated subdivision as a <see cref="IGeometryCollection"/>
/// of triangular <see cref="IPolygon"/>s.
/// </summary>
/// <param name="geomFact">the GeometryFactory to use</param>
/// <returns>a GeometryCollection of triangular Polygons</returns>
public IGeometryCollection GetTriangles(IGeometryFactory geomFact)
{
var triPtsList = GetTriangleCoordinates(false);
IPolygon[] tris = new Polygon[triPtsList.Count];
int i = 0;
foreach (var triPt in triPtsList)
{
tris[i++] = geomFact
.CreatePolygon(geomFact.CreateLinearRing(triPt), null);
}
return geomFact.CreateGeometryCollection(tris);
}
示例13: ParseWkbGeometryCollection
private static IGeometryCollection ParseWkbGeometryCollection(byte[] blob, ref int offset, IGeometryFactory factory, GaiaImport gaiaImport)
{
var number = gaiaImport.GetInt32(blob, ref offset);
var geometries = new IGeometry[number];
for (var i = 0; i < number; i++)
{
if (blob[offset++] != (byte)GaiaGeoBlobMark.GAIA_MARK_ENTITY)
throw new Exception();
geometries[i] = ParseWkbGeometry((GaiaGeoGeometry)gaiaImport.GetInt32(blob, ref offset), blob, ref offset, factory, gaiaImport);
}
return factory.CreateGeometryCollection(geometries);
}
示例14: ReadGeometriesFromWkbHexString
public static IGeometry ReadGeometriesFromWkbHexString(String wkb, IGeometryFactory geomFact)
{
var reader = new WKBReader(geomFact);
var fileReader = new WKBHexFileReader(reader);
var geomList = new List<IGeometry>();
using (var ms = new MemoryStream())
{
new StreamWriter(ms).Write(wkb);
geomList.AddRange(fileReader.Read(ms));
}
if (geomList.Count == 1)
return geomList[1];
return geomFact.CreateGeometryCollection(GeometryFactory.ToGeometryArray(geomList));
}