本文整理汇总了C#中IGeometryFactory.CreateMultiPoint方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometryFactory.CreateMultiPoint方法的具体用法?C# IGeometryFactory.CreateMultiPoint怎么用?C# IGeometryFactory.CreateMultiPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometryFactory
的用法示例。
在下文中一共展示了IGeometryFactory.CreateMultiPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
/// <summary>
/// Reads a stream and converts the shapefile record to an equilivant geometry object.
/// </summary>
/// <param name="file">The stream to read.</param>
/// <param name="geometryFactory">The geometry factory to use when making the object.</param>
/// <returns>The Geometry object that represents the shape file record.</returns>
public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
{
int shapeTypeNum = file.ReadInt32();
type = (ShapeGeometryType) Enum.Parse(typeof(ShapeGeometryType), shapeTypeNum.ToString());
if (type == ShapeGeometryType.NullShape)
return geometryFactory.CreateMultiPoint(new IPoint[] { });
if (!(type == ShapeGeometryType.MultiPoint || type == ShapeGeometryType.MultiPointM ||
type == ShapeGeometryType.MultiPointZ || type == ShapeGeometryType.MultiPointZM))
throw new ShapefileException("Attempting to load a non-multipoint as multipoint.");
// Read and for now ignore bounds.
int bblength = GetBoundingBoxLength();
bbox = new double[bblength];
for (; bbindex < 4; bbindex++)
{
double d = file.ReadDouble();
bbox[bbindex] = d;
}
// Read points
int numPoints = file.ReadInt32();
IPoint[] points = new IPoint[numPoints];
for (int i = 0; i < numPoints; i++)
{
double x = file.ReadDouble();
double y = file.ReadDouble();
IPoint point = geometryFactory.CreatePoint(new Coordinate(x, y));
points[i] = point;
}
geom = geometryFactory.CreateMultiPoint(points);
GrabZMValues(file);
return geom;
}
示例2: Read
/// <summary>
/// Reads a stream and converts the shapefile record to an equilivant geometry object.
/// </summary>
/// <param name="file">The stream to read.</param>
/// <param name="totalRecordLength">Total length of the record we are about to read</param>
/// <param name="geometryFactory">The geometry factory to use when making the object.</param>
/// <returns>The Geometry object that represents the shape file record.</returns>
public override IGeometry Read(BigEndianBinaryReader file, int totalRecordLength, IGeometryFactory geometryFactory)
{
int totalRead = 0;
int shapeTypeNum = ReadInt32(file, totalRecordLength, ref totalRead);
var type = (ShapeGeometryType) EnumUtility.Parse(typeof(ShapeGeometryType), shapeTypeNum.ToString());
if (type == ShapeGeometryType.NullShape)
return geometryFactory.CreateMultiPoint(new IPoint[] { });
if (type != ShapeType)
throw new ShapefileException(string.Format("Encountered a '{0}' instead of a '{1}'", type, ShapeType));
// Read and for now ignore bounds.
int bblength = GetBoundingBoxLength();
boundingBox = new double[bblength];
for (; boundingBoxIndex < 4; boundingBoxIndex++)
{
double d = ReadDouble(file, totalRecordLength, ref totalRead);
boundingBox[boundingBoxIndex] = d;
}
// Read points
var numPoints = ReadInt32(file, totalRecordLength, ref totalRead);
var buffer = new CoordinateBuffer(numPoints, NoDataBorderValue, true);
var points = new IPoint[numPoints];
var pm = geometryFactory.PrecisionModel;
for (var i = 0; i < numPoints; i++)
{
var x = pm.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));
var y = pm.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));
buffer.AddCoordinate(x, y);
buffer.AddMarker();
}
// Trond Benum: We have now read all the points, let's read optional Z and M values
GetZMValues(file, totalRecordLength, ref totalRead, buffer);
var sequences = buffer.ToSequences(geometryFactory.CoordinateSequenceFactory);
for (var i = 0; i < numPoints; i++)
points[i] = geometryFactory.CreatePoint(sequences[i]);
geom = geometryFactory.CreateMultiPoint(points);
return geom;
}
示例3: Read
/// <summary>
/// Reads a stream and converts the shapefile record to an equilivant geometry object.
/// </summary>
/// <param name="file">The stream to read.</param>
/// <param name="geometryFactory">The geometry factory to use when making the object.</param>
/// <returns>The Geometry object that represents the shape file record.</returns>
public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
{
int shapeTypeNum = file.ReadInt32();
ShapeGeometryTypes shapeType = (ShapeGeometryTypes) Enum.Parse(typeof(ShapeGeometryTypes), shapeTypeNum.ToString());
if ( ! ( shapeType == ShapeGeometryTypes.MultiPoint || shapeType == ShapeGeometryTypes.MultiPointM ||
shapeType == ShapeGeometryTypes.MultiPointZ || shapeType == ShapeGeometryTypes.MultiPointZM))
throw new ShapefileException("Attempting to load a non-multipoint as multipoint.");
// Read and for now ignore bounds.
double[] box = new double[4];
for (int i = 0; i < 4; i++)
box[i] = file.ReadDouble();
// Read points
int numPoints = file.ReadInt32();
IPoint[] points = new IPoint[numPoints];
for (int i = 0; i < numPoints; i++)
points[i] = geometryFactory.CreatePoint(new Coordinate(file.ReadDouble(), file.ReadDouble()));
return geometryFactory.CreateMultiPoint(points);
}
示例4: ParseWkbMultiPoint
private static IMultiPoint ParseWkbMultiPoint(byte[] blob, ref int offset, IGeometryFactory factory, ReadCoordinatesFunction readCoordinates, GaiaImport gaiaImport)
{
var getInt32 = gaiaImport.GetInt32;
var getDouble = gaiaImport.GetDouble;
var number = getInt32(blob, ref offset);
var coords = new Coordinate[number];
for (var i = 0; i < number; i++)
{
if (blob[offset++] != (byte)GaiaGeoBlobMark.GAIA_MARK_ENTITY)
throw new Exception();
var gt = getInt32(blob, ref offset);
if (ToBaseGeometryType((GaiaGeoGeometry)gt) != GaiaGeoGeometry.GAIA_POINT)
throw new Exception();
coords[i] = new Coordinate(getDouble(blob, ref offset),
getDouble(blob, ref offset));
if (gaiaImport.HasZ)
coords[i].Z = getDouble(blob, ref offset);
if (gaiaImport.HasM)
/*coords[i].M =*/
getDouble(blob, ref offset);
}
return factory.CreateMultiPoint(coords);
}
示例5: RandomMultiPoint
private static IMultiPoint RandomMultiPoint(IGeometryFactory geometryFactory)
{
return geometryFactory.CreateMultiPoint(RandomCoordinates(geometryFactory));
}
示例6: TransformMultiPoint
/// <summary>
/// Transforms a <see cref="GeoAPI.Geometries.IMultiPoint"/>.
/// </summary>
/// <param name="points">MultiPoint 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 MultiPoint</returns>
public static IMultiPoint TransformMultiPoint(IMultiPoint points, ProjectionInfo from, ProjectionInfo to, IGeometryFactory toFactory)
{
try
{
var seq = toFactory.CoordinateSequenceFactory.Create(points.Coordinates);
var toSeq = TransformSequence(seq, from, to, toFactory.CoordinateSequenceFactory);
return toFactory.CreateMultiPoint(toSeq);
}
catch
{
return null;
}
}
示例7: ReadMultiPointText
/// <summary>
/// Creates a Point 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 <Point Text>.</param>
/// <param name="factory">The factory to create the result geometry</param>
/// <returns>Returns a Point specified by the next token in
/// the stream.</returns>
/// <remarks>
/// ParseException is thrown if an unexpected token is encountered.
/// </remarks>
private static IMultiPoint ReadMultiPointText(WktStreamTokenizer tokenizer, IGeometryFactory factory)
{
string nextToken = GetNextEmptyOrOpener(tokenizer);
if (nextToken == "EMPTY")
return factory.CreateMultiPoint((Coordinate[])null);
var points = new List<Coordinate>();
points.Add(new Coordinate(GetNextNumber(tokenizer), GetNextNumber(tokenizer)));
nextToken = GetNextCloserOrComma(tokenizer);
while (nextToken == ",")
{
points.Add(new Coordinate(GetNextNumber(tokenizer), GetNextNumber(tokenizer)));
nextToken = GetNextCloserOrComma(tokenizer);
}
return factory.CreateMultiPoint(points.ToArray());
}
示例8: ReadMultiPointText
/// <summary>
/// Creates a <c>MultiPoint</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 <MultiPoint Text.
/// </param>
/// <param name="factory"> </param>
/// <returns>
/// A <c>MultiPoint</c> specified by the next
/// token in the stream.</returns>
private IMultiPoint ReadMultiPointText(IEnumerator<Token> tokens, IGeometryFactory factory)
{
return factory.CreateMultiPoint(ToPoints(GetCoordinates(tokens, true), factory));
}
示例9: Parse
/// <summary>
/// See http://www.gaia-gis.it/gaia-sins/BLOB-Geometry.html
/// for the specification of the spatialite BLOB geometry format
/// Derived from WKB, but unfortunately it is not practical to reuse existing
/// WKB encoding/decoding code
/// </summary>
/// <param name="spatialliteGeom">The geometry blob</param>
/// <param name="factory">The factory to create the result geometry</param>
/// <returns>A geometry</returns>
public static IGeometry Parse(byte[] spatialliteGeom, IGeometryFactory factory)
{
var nBytes = spatialliteGeom.Length;
if (spatialliteGeom.Length < 44
|| spatialliteGeom[0] != 0
|| spatialliteGeom[38] != 0x7C
|| spatialliteGeom[nBytes - 1] != 0xFE)
throw new ApplicationException("Corrupt SpatialLite geom");
bool isLittleEndian = spatialliteGeom[1] == 0x01;
if (spatialliteGeom[1] != 0x00 && spatialliteGeom[1] != 0x01)
throw new ApplicationException("Corrupt SpatialLite geom");
int idx = 39;
int nGType = ReadUInt32(spatialliteGeom, ref idx, isLittleEndian);
if (nGType < 1 || nGType > 7)
throw new ApplicationException("Unsupported geom type!");
/* -------------------------------------------------------------------- */
/* Point */
/* -------------------------------------------------------------------- */
if (nGType == 1)
{
return factory.CreatePoint(ReadPoint(spatialliteGeom, ref idx, isLittleEndian));
}
/* -------------------------------------------------------------------- */
/* LineString */
/* -------------------------------------------------------------------- */
else if (nGType == 2)
{
return ReadLineString(spatialliteGeom, ref idx, isLittleEndian, factory);
}
/* -------------------------------------------------------------------- */
/* Polygon */
/* -------------------------------------------------------------------- */
else if (nGType == 3)
{
return ReadPolygon(spatialliteGeom, ref idx, isLittleEndian, factory);
}
/* -------------------------------------------------------------------- */
/* MultiPoint */
/* -------------------------------------------------------------------- */
else if (nGType == 4)
{
List<GeoAPI.Geometries.IPoint> pts = new List<GeoAPI.Geometries.IPoint>();
int numGeoms = ReadUInt32(spatialliteGeom, ref idx, isLittleEndian);
for (int i = 0; i < numGeoms; i++)
{
if (spatialliteGeom[idx] != 0x69)
throw new ApplicationException("FormatError in SpatiaLIteGeom");
idx++;
int gt = ReadUInt32(spatialliteGeom, ref idx, isLittleEndian);
if (gt != 1)
throw new ApplicationException("MultiPoint must Contain Point entities");
pts.Add(factory.CreatePoint(ReadPoint(spatialliteGeom, ref idx, isLittleEndian)));
}
return factory.CreateMultiPoint(pts.ToArray());
}
/* -------------------------------------------------------------------- */
/* MultiLineString */
/* -------------------------------------------------------------------- */
else if (nGType == 5)
{
List<GeoAPI.Geometries.ILineString> lss = new List<GeoAPI.Geometries.ILineString>();
int numGeoms = ReadUInt32(spatialliteGeom, ref idx, isLittleEndian);
for (int i = 0; i < numGeoms; i++)
{
if (spatialliteGeom[idx] != 0x69)
throw new ApplicationException("FormatError in SpatiaLIteGeom");
idx++;
int gt = ReadUInt32(spatialliteGeom, ref idx, isLittleEndian);
if (gt != 2)
throw new ApplicationException("MultiLineString must contain LineString Entities");
lss.Add(ReadLineString(spatialliteGeom, ref idx, isLittleEndian, factory));
}
return factory.CreateMultiLineString(lss.ToArray());
}
/* -------------------------------------------------------------------- */
/* MultiPolygon */
/* -------------------------------------------------------------------- */
else if (nGType == 6)
{
List<GeoAPI.Geometries.IPolygon> polys = new List<GeoAPI.Geometries.IPolygon>();
int numPolys = ReadUInt32(spatialliteGeom, ref idx, isLittleEndian);
for (int i = 0; i < numPolys; i++)
{
if (spatialliteGeom[idx] != 0x69)
throw new ApplicationException("FormatError in SpatiaLIteGeom");
idx++;
//.........这里部分代码省略.........
示例10: FromMultiPoint
/// <summary>
/// Creates a new MultiPoint geometry from a MultiPoint shape
/// </summary>
/// <param name="factory">The IGeometryFactory to use to create the new shape.</param>
/// <returns></returns>
protected IGeometry FromMultiPoint(IGeometryFactory factory)
{
if (factory == null) factory = Geometry.DefaultFactory;
List<Coordinate> coords = new List<Coordinate>();
foreach (PartRange part in _shapeRange.Parts)
{
int i = part.StartIndex;
foreach (Vertex vertex in part)
{
Coordinate c = new Coordinate(vertex.X, vertex.Y);
coords.Add(c);
if (M != null && M.Length != 0) c.M = M[i];
if (Z != null && Z.Length != 0) c.Z = Z[i];
i++;
}
}
return factory.CreateMultiPoint(coords);
}
示例11: TransformMultiPoint
/// <summary>
/// Transforms a <see cref="MultiPoint" /> object.
/// </summary>
/// <param name="factory"></param>
/// <param name="points"></param>
/// <param name="transform"></param>
/// <returns></returns>
public static IMultiPoint TransformMultiPoint(IGeometryFactory factory,
IMultiPoint points, IMathTransform transform)
{
//We assume the first point holds all the ordinates
var firstPoint = (IPoint) points.GetGeometryN(0);
var ordinateFlags = firstPoint.CoordinateSequence.Ordinates;
var ordinates = OrdinatesUtility.ToOrdinateArray(ordinateFlags);
var coordSequence = factory.CoordinateSequenceFactory.Create(points.NumPoints, ordinateFlags);
for (var i = 0; i < points.NumGeometries; i++)
{
var currPoint = (IPoint) points.GetGeometryN(i);
var seq = currPoint.CoordinateSequence;
foreach (var ordinate in ordinates)
{
double d = seq.GetOrdinate(0, ordinate);
coordSequence.SetOrdinate(i, ordinate, d);
}
}
var transPoints = transform.Transform(coordSequence);
return factory.CreateMultiPoint(transPoints);
}
示例12: FromMultiPoint
/// <summary>
/// Creates a new MultiPoint geometry from a MultiPoint shape
/// </summary>
/// <param name="factory">The IGeometryFactory to use to create the new shape.</param>
/// <returns></returns>
protected IGeometry FromMultiPoint(IGeometryFactory factory)
{
if (factory == null) factory = Geometry.DefaultFactory;
var coords = new List<Coordinate>();
foreach (var part in _shapeRange.Parts)
{
GetCoordinates(part, coords);
}
return factory.CreateMultiPoint(coords);
}
示例13: ReadMultiPointText
/// <summary>
/// Creates a <c>MultiPoint</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 <MultiPoint Text.
/// </param>
/// <param name="factory"> </param>
/// <returns>
/// A <c>MultiPoint</c> specified by the next
/// token in the stream.</returns>
private IMultiPoint ReadMultiPointText(IEnumerator<Token> tokens, IGeometryFactory factory)
{
var hasZ = false;
var coords = GetCoordinates(tokens, true, ref hasZ);
return factory.CreateMultiPoint(ToPoints(ToSequence(hasZ, coords), factory));
}
示例14: TransformMultiPoint
/// <summary>
/// Transforms a <see cref="GeoAPI.Geometries.IMultiPoint"/>.
/// </summary>
/// <param name="points">MultiPoint to transform</param>
/// <param name="transform">MathTransform</param>
/// <param name="targetFactory">The factory to create the target geometry</param>
/// <returns>Transformed MultiPoint</returns>
public static IMultiPoint TransformMultiPoint(IMultiPoint points, IMathTransform transform, IGeometryFactory targetFactory)
{
return targetFactory.CreateMultiPoint(TransformCoordinates(points.Coordinates, transform));
}
示例15: TransformMultiPoint
/// <summary>
/// Transforms a <see cref="MultiPoint" /> object.
/// </summary>
/// <param name="factory"></param>
/// <param name="points"></param>
/// <param name="transform"></param>
/// <returns></returns>
public static IMultiPoint TransformMultiPoint(IGeometryFactory factory,
IMultiPoint points, IMathTransform transform)
{
List<double[]> pointList = new List<double[]>(points.Geometries.Length);
foreach (IPoint p in points.Geometries)
pointList.Add(ToArray(p.X, p.Y));
pointList = transform.TransformList(pointList);
IPoint[] array = new IPoint[pointList.Count];
for (int i = 0; i < pointList.Count; i++)
array[i] = ToNTS(factory, pointList[i][0], pointList[i][1]);
return factory.CreateMultiPoint(array);
}