本文整理汇总了C#中IGeometryFactory.CreateLineString方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometryFactory.CreateLineString方法的具体用法?C# IGeometryFactory.CreateLineString怎么用?C# IGeometryFactory.CreateLineString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometryFactory
的用法示例。
在下文中一共展示了IGeometryFactory.CreateLineString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
factory = GeometryFactory.Fixed;
a = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(0, 0),
new Coordinate(100, 0),
new Coordinate(200, 100),
new Coordinate(200, 200),
});
b = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(0, 0),
new Coordinate(100, 100),
new Coordinate(200, 200),
});
c = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(0, 0),
new Coordinate(0, 100),
new Coordinate(100, 200),
new Coordinate(200, 200),
});
d = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(0, 0),
new Coordinate(300, 0),
new Coordinate(300, 200),
new Coordinate(150, 200),
new Coordinate(150, 300),
});
e = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(100, 300),
new Coordinate(150, 300),
new Coordinate(200, 300),
});
result = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(0, 0),
new Coordinate(300, 0),
new Coordinate(300, 200),
new Coordinate(150, 200),
new Coordinate(150, 300),
});
revresult = result.Reverse();
start = a.StartPoint;
end = d.EndPoint;
}
示例2: CreateLine
private static IGeometry CreateLine(IGeometryFactory factory, Size size)
{
return factory.CreateLineString( new []
{
new Coordinate(2, 2),
new Coordinate(0.3f * size.Width, 0.5*size.Height),
new Coordinate(0.65f * size.Width, 0.5*size.Height+1),
new Coordinate(size.Width -4, size.Height -4),
});
}
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:10,代码来源:DefaultSymbolizerLegendItemFactory.cs
示例3: Setup
public void Setup()
{
factory = GeometryFactory.Fixed;
// Build sample geometries
a = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(0, 0),
new Coordinate(100, 0),
new Coordinate(200, 100),
new Coordinate(200, 200),
});
b = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(0, 0),
new Coordinate(100, 100),
new Coordinate(200, 200),
});
c = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(0, 0),
new Coordinate(0, 100),
new Coordinate(100, 200),
new Coordinate(200, 200),
});
d = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(0, 0),
new Coordinate(300, 0),
new Coordinate(300, 200),
new Coordinate(150, 200),
new Coordinate(150, 300),
});
e = factory.CreateLineString(new ICoordinate[]
{
new Coordinate(100, 300),
new Coordinate(150, 300),
new Coordinate(200, 300),
});
start = a.StartPoint;
end = d.EndPoint;
}
示例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();
type = (ShapeGeometryType) Enum.Parse(typeof(ShapeGeometryType), shapeTypeNum.ToString());
if (type == ShapeGeometryType.NullShape)
return geometryFactory.CreateMultiLineString(null);
if (!(type == ShapeGeometryType.LineString || type == ShapeGeometryType.LineStringM ||
type == ShapeGeometryType.LineStringZ || type == ShapeGeometryType.LineStringZM))
throw new ShapefileException("Attempting to load a non-arc as arc.");
// Read and for now ignore bounds.
int bblength = GetBoundingBoxLength();
bbox = new double[bblength];
for (; bbindex < 4; bbindex++)
{
double d = file.ReadDouble();
bbox[bbindex] = d;
}
int numParts = file.ReadInt32();
int numPoints = file.ReadInt32();
int[] partOffsets = new int[numParts];
for (int i = 0; i < numParts; i++)
partOffsets[i] = file.ReadInt32();
ILineString[] lines = new ILineString[numParts];
for (int part = 0; part < numParts; part++)
{
int start, finish, length;
start = partOffsets[part];
if (part == numParts - 1)
finish = numPoints;
else finish = partOffsets[part + 1];
length = finish - start;
CoordinateList points = new CoordinateList();
points.Capacity = length;
for (int i = 0; i < length; i++)
{
double x = file.ReadDouble();
double y = file.ReadDouble();
ICoordinate external = new Coordinate(x, y);
geometryFactory.PrecisionModel.MakePrecise(external);
points.Add(external);
}
ILineString line = geometryFactory.CreateLineString(points.ToArray());
lines[part] = line;
}
geom = geometryFactory.CreateMultiLineString(lines);
GrabZMValues(file);
return geom;
}
示例5: ToGeometry
/// <summary>
/// Converts a collection of <see cref="ISegmentString"/>s into a <see cref="IGeometry"/>.
/// The geometry will be either a <see cref="ILineString"/>
/// or a <see cref="IMultiLineString"/> (possibly empty).
/// </summary>
/// <param name="segStrings">A collection of <see cref="ISegmentString"/>.</param>
/// <param name="geomFact">A geometry factory</param>
/// <returns>A <see cref="ILineString"/> or a <see cref="IMultiLineString"/>.</returns>
public static IGeometry ToGeometry(IList<ISegmentString> segStrings, IGeometryFactory geomFact)
{
ILineString[] lines = new ILineString[segStrings.Count];
int index = 0;
foreach (ISegmentString ss in segStrings)
{
ILineString line = geomFact.CreateLineString(ss.Coordinates);
lines[index++] = line;
}
if (lines.Length == 1)
return lines[0];
return geomFact.CreateMultiLineString(lines);
}
示例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 ))
throw new ShapefileException("Attempting to load a non-arc as arc.");
//read and for now ignore bounds.
double[] box = new double[4];
for (int i = 0; i < 4; i++)
{
double d= file.ReadDouble();
box[i] =d;
}
int numParts = file.ReadInt32();
int numPoints = file.ReadInt32();
int[] partOffsets = new int[numParts];
for (int i = 0; i < numParts; i++)
partOffsets[i] = file.ReadInt32();
ILineString[] lines = new ILineString[numParts];
int start, finish, length;
for (int part = 0; part < numParts; part++)
{
start = partOffsets[part];
if (part == numParts - 1)
finish = numPoints;
else finish = partOffsets[part + 1];
length = finish - start;
CoordinateList points = new CoordinateList();
points.Capacity=length;
ICoordinate external;
for (int i = 0; i < length; i++)
{
external = new Coordinate(file.ReadDouble(),file.ReadDouble());
geometryFactory.PrecisionModel.MakePrecise( external);
points.Add(external);
}
lines[part] = geometryFactory.CreateLineString(points.ToArray());
}
return geometryFactory.CreateMultiLineString(lines);
}
示例7: 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.NullShape)
return null;
if( ! ( shapeType == ShapeGeometryTypes.LineString || shapeType == ShapeGeometryTypes.LineStringM ||
shapeType == ShapeGeometryTypes.LineStringZ || shapeType == ShapeGeometryTypes.LineStringZM ))
throw new ShapefileException("Attempting to load a non-arc as arc.");
//read and for now ignore bounds.
double[] box = new double[4];
for (int i = 0; i < 4; i++)
{
double d= file.ReadDouble();
box[i] =d;
}
int numParts = file.ReadInt32();
int numPoints = file.ReadInt32();
int[] partOffsets = new int[numParts];
for (int i = 0; i < numParts; i++)
partOffsets[i] = file.ReadInt32();
ILineString[] lines = new ILineString[numParts];
int start, finish, length;
for (int part = 0; part < numParts; part++)
{
start = partOffsets[part];
if (part == numParts - 1)
finish = numPoints;
else finish = partOffsets[part + 1];
length = finish - start;
CoordinateList points = new CoordinateList();
points.Capacity=length;
ICoordinate external;
for (int i = 0; i < length; i++)
{
external = new Coordinate(file.ReadDouble(),file.ReadDouble());
geometryFactory.PrecisionModel.MakePrecise( external);
points.Add(external);
}
if (numPoints < 2)
lines[part] = geometryFactory.CreateLineString(null as Topology.Geometries.ICoordinate[]);
else
lines[part] = geometryFactory.CreateLineString(points.ToArray());
}
//If we have Z-coordinates, read them..
if (shapeType == ShapeGeometryTypes.LineStringZ || shapeType == ShapeGeometryTypes.LineStringZM)
{
//z-Bounds
double zMin = file.ReadDouble();
double zMax = file.ReadDouble();
for (int part = 0; part < numParts; part++)
{
start = partOffsets[part];
if (part == numParts - 1)
finish = numPoints;
else finish = partOffsets[part + 1];
length = finish - start;
for (int i = 0; i < length; i++)
{
double val = file.ReadDouble();
if (numPoints > 1)
{
lines[part].Coordinates[i].Z = val;
}
}
}
}
//If we have M-coordinates, read them..
if (shapeType == ShapeGeometryTypes.LineStringM || shapeType == ShapeGeometryTypes.LineStringZM)
{
//m-Bounds
double mMin = file.ReadDouble();
double mMax = file.ReadDouble();
for (int part = 0; part < numParts; part++)
{
start = partOffsets[part];
if (part == numParts - 1)
finish = numPoints;
else finish = partOffsets[part + 1];
length = finish - start;
for (int i = 0; i < length; i++)
{
double val = file.ReadDouble();
//dont store..
}
//.........这里部分代码省略.........
示例8: ReadLineStringText
/// <summary>
/// Creates a <c>LineString</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 <LineString Text.
/// </param>
/// <param name="factory"> </param>
/// <returns>
/// A <c>LineString</c> specified by the next
/// token in the stream.</returns>
private ILineString ReadLineStringText(IEnumerator<Token> tokens, IGeometryFactory factory)
{
return factory.CreateLineString(GetCoordinates(tokens, false));
}
示例9: FromLine
/// <summary>
/// Gets the line for the specified index
/// </summary>
/// <returns>A LineString or MultiLineString geometry created from this shape.</returns>
protected IGeometry FromLine(IGeometryFactory factory)
{
if (factory == null) factory = Geometry.DefaultFactory;
var lines = new List<IBasicLineString>();
foreach (var part in _shapeRange.Parts)
{
var coords = GetCoordinates(part);
lines.Add(factory.CreateLineString(coords));
}
if (lines.Count == 1) return (IGeometry)lines[0];
return factory.CreateMultiLineString(lines.ToArray());
}
示例10: TransformLineString
/// <summary>
/// Transforms a <see cref="GeoAPI.Geometries.ILineString"/>.
/// </summary>
/// <param name="l">LineString 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 LineString</returns>
public static ILineString TransformLineString(ILineString l, ProjectionInfo from, ProjectionInfo to, IGeometryFactory toFactory)
{
try
{
var toSeq = TransformSequence(l.CoordinateSequence, from, to, toFactory.CoordinateSequenceFactory);
return toFactory.CreateLineString(toSeq);
}
catch
{
return null;
}
}
示例11: 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;
}
示例12: ReadLineStringText
/// <summary>
/// Creates a LineString 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 LineString Text.</param>
/// <param name="factory">The factory to create the result geometry</param>
/// <returns>Returns a LineString specified by the next token in the stream.</returns>
/// <remarks>
/// ParseException is thrown if an unexpected token is encountered.
/// </remarks>
private static ILineString ReadLineStringText(WktStreamTokenizer tokenizer, IGeometryFactory factory)
{
return factory.CreateLineString(GetCoordinates(tokenizer));
}
示例13: ToNodedLines
private IGeometry ToNodedLines(ICollection<ISegmentString> segStrings, IGeometryFactory geomFact)
{
var lines = new List<IGeometry>();
foreach (NodedSegmentString nss in segStrings)
{
// skip collapsed lines
if (nss.Count < 2)
continue;
//Coordinate[] pts = getCoords(nss);
var pts = nss.NodeList.GetSplitCoordinates();
lines.Add(geomFact.CreateLineString(pts));
}
return geomFact.BuildGeometry(lines);
}
示例14: generateLines
private static void generateLines(IGeometryFactory geometryFactory,
ICollection<IGeometry> geometry,
Random rndGen)
{
ICoordinateSequenceFactory coordinateSequenceFactory =
geometryFactory.CoordinateSequenceFactory;
ICoordinateFactory coordinateFactory = geometryFactory.CoordinateFactory;
ICoordinateSequence coords = coordinateSequenceFactory.Create(CoordinateDimensions.Two);
Int32 lineCount = rndGen.Next(10, 100);
for (Int32 lineIndex = 0; lineIndex < lineCount; lineIndex++)
{
Int32 vertexCount = rndGen.Next(4, 15);
ICoordinate coordinate = coordinateFactory.Create(rndGen.NextDouble() * 1000,
rndGen.NextDouble() * 1000);
coords.Add(coordinate);
for (Int32 vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++)
{
ICoordinate next = coordinateFactory.Create(coordinate[Ordinates.X] + rndGen.Next(-50, 50),
coordinate[Ordinates.Y] + rndGen.Next(-50, 50));
coords.Add(next);
coordinate = next;
}
ILineString line = geometryFactory.CreateLineString(coords);
geometry.Add(line);
}
}
示例15: ReadLineString
private static GeoAPI.Geometries.ILineString ReadLineString(byte[] geom, ref int idx, bool isLittleEndian, IGeometryFactory factory)
{
double[] adfTuple = new double[2];
int nPointCount;
int iPoint;
nPointCount = ReadUInt32(geom, ref idx, isLittleEndian);
if (nPointCount < 0 || nPointCount > Int32.MaxValue / (2 * 8))
throw new ApplicationException("Currupt SpatialLite geom");
List<GeoAPI.Geometries.Coordinate> pts = new List<GeoAPI.Geometries.Coordinate>();
for (iPoint = 0; iPoint < nPointCount; iPoint++)
{
pts.Add(ReadPoint(geom, ref idx, isLittleEndian));
}
return factory.CreateLineString(pts.ToArray());
}