本文整理汇总了C#中IGeometryFactory.CreatePoint方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometryFactory.CreatePoint方法的具体用法?C# IGeometryFactory.CreatePoint怎么用?C# IGeometryFactory.CreatePoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometryFactory
的用法示例。
在下文中一共展示了IGeometryFactory.CreatePoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
/// <summary>
/// Reads a stream and converts the shapefile record to an equilivent 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="factory">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 factory)
{
int totalRead = 0;
ShapeGeometryType type = (ShapeGeometryType)ReadInt32(file, totalRecordLength, ref totalRead);
//type = (ShapeGeometryType) EnumUtility.Parse(typeof (ShapeGeometryType), shapeTypeNum.ToString());
if (type == ShapeGeometryType.NullShape)
return factory.CreatePoint((Coordinate)null);
if (type != ShapeType)
throw new ShapefileException(string.Format("Encountered a '{0}' instead of a '{1}'", type, ShapeType));
CoordinateBuffer buffer = new CoordinateBuffer(1, NoDataBorderValue, true);
IPrecisionModel precisionModel = factory.PrecisionModel;
double x = precisionModel.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));
double y = precisionModel.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));
double? z = null, m = null;
// Trond Benum: Let's read optional Z and M values
if (HasZValue() && totalRead < totalRecordLength)
z = ReadDouble(file, totalRecordLength, ref totalRead);
if ((HasMValue() || HasZValue()) &&
(totalRead < totalRecordLength))
m = ReadDouble(file, totalRecordLength, ref totalRead);
buffer.AddCoordinate(x, y, z, m);
return factory.CreatePoint(buffer.ToSequence(factory.CoordinateSequenceFactory));
}
示例2: Read
/// <summary>
/// Reads a stream and converts the shapefile record to an equilivent 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)
{
ICoordinate emptyCoordinate = null;
return geometryFactory.CreatePoint(emptyCoordinate);
}
if (!(type == ShapeGeometryType.Point || type == ShapeGeometryType.PointM ||
type == ShapeGeometryType.PointZ || type == ShapeGeometryType.PointZM))
throw new ShapefileException("Attempting to load a point as point.");
double x = file.ReadDouble();
double y = file.ReadDouble();
ICoordinate external = new Coordinate(x,y);
geometryFactory.PrecisionModel.MakePrecise(external);
IPoint point = geometryFactory.CreatePoint(external);
if (HasZValue() || HasMValue())
{
IDictionary<ShapeGeometryType, double> data = new Dictionary<ShapeGeometryType, double>(2);
if (HasZValue())
GetZValue(file, data);
if (HasMValue())
GetMValue(file, data);
// point.UserData = data;
}
return point;
}
示例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();
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;
}
示例4: Read
/// <summary>
/// Reads a stream and converts the shapefile record to an equilivent 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.Point || shapeType == ShapeGeometryTypes.PointM ||
shapeType == ShapeGeometryTypes.PointZ || shapeType == ShapeGeometryTypes.PointZM ))
throw new ShapefileException("Attempting to load a point as point.");
double x= file.ReadDouble();
double y= file.ReadDouble();
ICoordinate external = new Coordinate(x,y);
geometryFactory.PrecisionModel.MakePrecise( external);
return geometryFactory.CreatePoint(external);
}
示例5: 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;
}
示例6: Read
/// <summary>
/// Reads a stream and converts the shapefile record to an equilivent 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.LineString || shapeType == ShapeGeometryTypes.LineStringM ||
shapeType == ShapeGeometryTypes.LineStringZ || shapeType == ShapeGeometryTypes.LineStringZM ||
shapeType == ShapeGeometryTypes.MultiPatch || shapeType == ShapeGeometryTypes.NullShape ||
shapeType == ShapeGeometryTypes.Polygon || shapeType == ShapeGeometryTypes.PolygonM ||
shapeType == ShapeGeometryTypes.PolygonZ || shapeType == ShapeGeometryTypes.PolygonZM
))
throw new ShapefileException("Attempting to load a non-point shapefile as point.");
double x= file.ReadDouble();
double y= file.ReadDouble();
Coordinate external = new Coordinate(x,y);
// return geometryFactory.CreatePoint(geometryFactory.PrecisionModel.ToInternal(external));
new PrecisionModel(geometryFactory.PrecisionModel).MakePrecise(external);
return geometryFactory.CreatePoint(external);
}
示例7: 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);
}
示例8: FromPoint
/// <summary>
/// Get the point for this shape if this is a point shape.
/// </summary>
/// <param name="factory"></param>
/// <returns></returns>
protected IGeometry FromPoint(IGeometryFactory factory)
{
if (factory == null) factory = Geometry.DefaultFactory;
foreach (PartRange part in _shapeRange.Parts)
{
foreach (Vertex vertex in part)
{
Coordinate c = new Coordinate(vertex.X, vertex.Y);
return factory.CreatePoint(c);
}
}
return null;
}
示例9: 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;
}
示例10: CreateWKBPoint
private static IPoint CreateWKBPoint(BinaryReader reader, WkbByteOrder byteOrder, IGeometryFactory factory)
{
// Create and return the point.
return factory.CreatePoint(new Coordinate(ReadDouble(reader, byteOrder), ReadDouble(reader, byteOrder)));
}
示例11: 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++;
//.........这里部分代码省略.........
示例12: TransformPoint
/// <summary>
/// Transforms a <see cref="GeoAPI.Geometries.IPoint"/>.
/// </summary>
/// <param name="p">Point to transform</param>
/// <param name="from">The source Projection</param>
/// <param name="to">The target Projection</param>
/// <param name="toFactory">The factory to create geometries for <paramref name="to"/></param>
/// <returns>Transformed Point</returns>
public static IPoint TransformPoint(IPoint p, ProjectionInfo from, ProjectionInfo to, IGeometryFactory toFactory)
{
try
{
var toSeq = TransformSequence(p.CoordinateSequence, from, to, toFactory.CoordinateSequenceFactory);
return toFactory.CreatePoint(toSeq);
}
catch
{
return null;
}
}
示例13: Edit
/// <summary>
///
/// </summary>
/// <param name="geometry"></param>
/// <param name="factory"></param>
/// <returns></returns>
public virtual IGeometry Edit(IGeometry geometry, IGeometryFactory factory)
{
if (geometry is LinearRing)
return factory.CreateLinearRing(Edit(geometry.Coordinates, geometry));
if (geometry is LineString)
return factory.CreateLineString(Edit(geometry.Coordinates, geometry));
if (geometry is Point)
{
IList<Coordinate> newCoordinates = Edit(geometry.Coordinates, geometry);
return factory.CreatePoint((newCoordinates.Count > 0) ? newCoordinates[0] : null);
}
return geometry;
}
示例14: ReadPointText
/// <summary>
/// Creates a <c>Point</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 <Point Text.
/// </param>
/// <param name="factory"> </param>
/// <returns>A <c>Point</c> specified by the next token in
/// the stream.</returns>
private IPoint ReadPointText(IEnumerator<Token> tokens, IGeometryFactory factory)
{
var nextToken = GetNextEmptyOrOpener(tokens);
if (nextToken.Equals("EMPTY"))
return factory.CreatePoint((Coordinate) null);
var hasZ = false;
var coord = GetPreciseCoordinate(tokens, false, ref hasZ);
var point = factory.CreatePoint(ToSequence(hasZ, coord));
/*var closer = */GetNextCloser(tokens);
return point;
}
示例15: TransformPoint
/// <summary>
/// Transforms a <see cref="Point" /> object.
/// </summary>
/// <param name="factory"></param>
/// <param name="p"></param>
/// <param name="transform"></param>
/// <returns></returns>
public static IPoint TransformPoint(IGeometryFactory factory,
IPoint p, IMathTransform transform)
{
try
{
var transformed = transform.Transform(p.CoordinateSequence);
return factory.CreatePoint(transformed);
}
catch { return null; }
}