本文整理汇总了C#中Geotools.Geometries.GeometryFactory.CreateLineString方法的典型用法代码示例。如果您正苦于以下问题:C# GeometryFactory.CreateLineString方法的具体用法?C# GeometryFactory.CreateLineString怎么用?C# GeometryFactory.CreateLineString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geotools.Geometries.GeometryFactory
的用法示例。
在下文中一共展示了GeometryFactory.CreateLineString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMLS1
private MultiLineString CreateMLS1()
{
Coordinates coords = new Coordinates();
Coordinate coord = new Coordinate();
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString lineString = gf.CreateLineString(coords);
LineString[] ls = new LineString[10];
int c = 0;
for(int i = 10; i > 0; i--)
{
for(int j = i; j < i+10; j++)
{
coord = new Coordinate();
coord.X = (double)j;
coord.Y = (double)j+5;
coords.Add(coord);
}
lineString = gf.CreateLineString(coords);
ls[c] = lineString;
c++;
}
MultiLineString multiLS = gf.CreateMultiLineString(ls);
return multiLS;
}
示例2: nonSimpleMLS
private MultiLineString nonSimpleMLS()
{
Coordinates coords = new Coordinates();
Coordinate coord = new Coordinate();
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString lineString = gf.CreateLineString(coords);
LineString[] ls = new LineString[1];
coord = new Coordinate(2, 2);
coords.Add(coord);
coord = new Coordinate(3, 3);
coords.Add(coord);
coord = new Coordinate(4, 4);
coords.Add(coord);
coord = new Coordinate(5, 5);
coords.Add(coord);
coord = new Coordinate(6, 6);
coords.Add(coord);
coord = new Coordinate(7, 7);
coords.Add(coord);
coord = new Coordinate(8, 8);
coords.Add(coord);
coord = new Coordinate(9, 7);
coords.Add(coord);
coord = new Coordinate(10, 6);
coords.Add(coord);
coord = new Coordinate(10, 5);
coords.Add(coord);
coord = new Coordinate(9, 4);
coords.Add(coord);
coord = new Coordinate(8, 3);
coords.Add(coord);
coord = new Coordinate(7, 4);
coords.Add(coord);
coord = new Coordinate(7, 5);
coords.Add(coord);
coord = new Coordinate(6, 6);
coords.Add(coord);
coord = new Coordinate(5, 7);
coords.Add(coord);
coord = new Coordinate(4, 8);
coords.Add(coord);
coord = new Coordinate(3, 9);
coords.Add(coord);
ls[0] = gf.CreateLineString(coords);
MultiLineString multiLS = gf.CreateMultiLineString(ls);
return multiLS;
}
示例3: test_Geometry
public void test_Geometry()
{
LineString[] linestrings = new LineString[2];
Coordinates coords1 = new Coordinates();
Coordinate coord = new Coordinate(5,3);
coords1.Add(coord);
coord = new Coordinate(4,5);
coords1.Add(coord);
coord = new Coordinate(3,4);
coords1.Add(coord);
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls = gf.CreateLineString(coords1);
linestrings[0] = ls;
Coordinates coords2 = new Coordinates();
coord = new Coordinate(2,7);
coords2.Add(coord);
coord = new Coordinate(9,2);
coords2.Add(coord);
coord = new Coordinate(7,9);
coords2.Add(coord);
ls = gf.CreateLineString(coords2);
linestrings[1] = ls;
MultiLineString mls = gf.CreateMultiLineString(linestrings);
Assertion.AssertEquals("Geometry-1: ", "LineString:(5, 3, NaN),(4, 5, NaN),(3, 4, NaN)", mls.GetGeometryN(0).ToString());
Assertion.AssertEquals("Geometry-2: ", "LineString:(2, 7, NaN),(9, 2, NaN),(7, 9, NaN)", mls.GetGeometryN(1).ToString());
}
示例4: closedMLS
private MultiLineString closedMLS()
{
Coordinates coords = new Coordinates();
Coordinate coord = new Coordinate();
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString lineString = gf.CreateLineString(coords);
LineString[] ls = new LineString[2];
coord = new Coordinate(10, 13);
coords.Add(coord);
coord = new Coordinate(11, 13);
coords.Add(coord);
coord = new Coordinate(12, 13);
coords.Add(coord);
coord = new Coordinate(13, 14);
coords.Add(coord);
coord = new Coordinate(14, 15);
coords.Add(coord);
coord = new Coordinate(15, 16);
coords.Add(coord);
coord = new Coordinate(15, 17);
coords.Add(coord);
coord = new Coordinate(15, 18);
coords.Add(coord);
coord = new Coordinate(14, 19);
coords.Add(coord);
coord = new Coordinate(13, 20);
coords.Add(coord);
coord = new Coordinate(12, 21);
coords.Add(coord);
coord = new Coordinate(11, 21);
coords.Add(coord);
coord = new Coordinate(10, 21);
coords.Add(coord);
coord = new Coordinate(9, 20);
coords.Add(coord);
coord = new Coordinate(8, 19);
coords.Add(coord);
coord = new Coordinate(7, 18);
coords.Add(coord);
coord = new Coordinate(7, 17);
coords.Add(coord);
coord = new Coordinate(7, 16);
coords.Add(coord);
coord = new Coordinate(8, 15);
coords.Add(coord);
coord = new Coordinate(9, 14);
coords.Add(coord);
coord = new Coordinate(10, 13);
coords.Add(coord);
ls[0] = gf.CreateLineString(coords);
coords = new Coordinates();
coord = new Coordinate(5, 1);
coords.Add(coord);
coord = new Coordinate(6, 2);
coords.Add(coord);
coord = new Coordinate(7, 3);
coords.Add(coord);
coord = new Coordinate(6, 4);
coords.Add(coord);
coord = new Coordinate(5, 5);
coords.Add(coord);
coord = new Coordinate(4, 4);
coords.Add(coord);
coord = new Coordinate(3, 3);
coords.Add(coord);
coord = new Coordinate(4, 2);
coords.Add(coord);
coord = new Coordinate(5, 1);
coords.Add(coord);
ls[1] = gf.CreateLineString(coords);
MultiLineString multiLS = gf.CreateMultiLineString(ls);
return multiLS;
}
示例5: 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 Geometry Read(BigEndianBinaryReader file, GeometryFactory geometryFactory)
{
int shapeTypeNum = file.ReadInt32();
ShapeType shapeType = (ShapeType)Enum.Parse(typeof(ShapeType),shapeTypeNum.ToString());
if (shapeType != ShapeType.Arc)
{
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();
}
LineString[] lines = new LineString[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;
Coordinates points = new Coordinates();
points.Capacity=length;
Coordinate external;
for (int i = 0; i < length; i++)
{
external = new Coordinate(file.ReadDouble(),file.ReadDouble());
points.Add( geometryFactory.PrecisionModel.ToInternal(external));
}
lines[part] = geometryFactory.CreateLineString(points);
}
return geometryFactory.CreateMultiLineString(lines);
}
示例6: CreateCollection3
private GeometryCollection CreateCollection3()
{
//create a new geometries array
Geometry[] geom = new Geometry[10];
Coordinate coordinate = new Coordinate();
Coordinates coords = new Coordinates();
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
Point point = gf.CreatePoint(coordinate);
LineString lineString = gf.CreateLineString(coords);
for(int c = 0; c < 5; c++)
{
for(int i = c; i < c+5; i++)
{
//if this isn't here the coordinates for all the points are reset every time the coordinate is reset
coordinate = new Coordinate();
//make the x coordinate equal to the iterator
coordinate.X = (double)i;
//make the y coordinate equal to the iterator plus 10
coordinate.Y = (double)i + 10;
coords.Add(coordinate);
}
lineString = gf.CreateLineString(coords);
geom[c] = lineString;
}
for(int i = 5; i < 10; i++)
{
//if this isn't here the coordinates for all the points are reset every time the coordinate is reset
coordinate = new Coordinate();
//make the x coordinate equal to the iterator
coordinate.X = (double)i;
//make the y coordinate equal to the iterator plus 10
coordinate.Y = (double)i + 10;
//create a new point to put in the geometry
point = gf.CreatePoint(coordinate);
//put the point in the geometies
geom[i] = point;
}
//put the geometries into a geometry collection
GeometryCollection geoColl = gf.CreateGeometryCollection(geom);
return geoColl;
}
示例7: test_ToString
public void test_ToString()
{
Coordinates coords = new Coordinates();
Coordinate coord = new Coordinate(1.0, 2.0);
coords.Add(coord);
coord = new Coordinate(3.0, 4.0);
coords.Add(coord);
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls1 = gf.CreateLineString(coords);
Assertion.AssertEquals("ToString-1: ", "LineString:(1, 2, NaN),(3, 4, NaN)", ls1.ToString());
coord = new Coordinate(2.4, 4.9);
coords.Add(coord);
LineString ls2 = gf.CreateLineString(coords);
Assertion.AssertEquals("ToString-2: ", "LineString:(1, 2, NaN),(3, 4, NaN),(2.4, 4.9, NaN)", ls2.ToString());
coord = new Coordinate(1.0, 1.0);
coords.Add(coord);
LineString ls3 = gf.CreateLineString(coords);
Assertion.AssertEquals("ToString-3: ", "LineString:(1, 2, NaN),(3, 4, NaN),(2.4, 4.9, NaN),(1, 1, NaN)", ls3.ToString());
}
示例8: SimpleOpen
/// <summary>
/// Method to create a Simple NonClosed Linestring for testing purposes
/// </summary>
/// <returns>A lineString</returns>
private LineString SimpleOpen()
{
_coords = new Coordinates();
Coordinate coord = new Coordinate(0.0,0.0);
for(int i = 1; i < 12; i++)
{
coord = new Coordinate((double)i, (double)i);
_coords.Add(coord);
}
coord = new Coordinate(11, 12);
_coords.Add(coord);
coord = new Coordinate(10, 13);
_coords.Add(coord);
coord = new Coordinate(9, 14);
_coords.Add(coord);
coord = new Coordinate(8, 15);
_coords.Add(coord);
coord = new Coordinate(9, 16);
_coords.Add(coord);
coord = new Coordinate(10, 17);
_coords.Add(coord);
coord = new Coordinate(11, 18);
_coords.Add(coord);
coord = new Coordinate(12, 19);
_coords.Add(coord);
coord = new Coordinate(11, 20);
_coords.Add(coord);
coord = new Coordinate(10, 21);
_coords.Add(coord);
coord = new Coordinate(9, 22);
_coords.Add(coord);
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls = gf.CreateLineString(_coords);
return ls;
}
示例9: test_IsEmpty
public void test_IsEmpty()
{
Coordinates coords = new Coordinates();
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls = gf.CreateLineString(coords);
Assertion.AssertEquals("IsEmpty-1: ", true, ls.IsEmpty());
ls = SimpleOpen();
Assertion.AssertEquals("IsEmpty-2: ", false, ls.IsEmpty());
}
示例10: test_NumPoints
public void test_NumPoints()
{
LineString ls1 = SimpleOpen();
LineString ls2 = NonSimpleOpen();
LineString ls3 = SimpleClosed();
LineString ls4 = NonSimpleClosed();
Coordinates testCoords = new Coordinates();
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls5 = gf.CreateLineString(testCoords);
Assertion.AssertEquals("NumPoints-1: ", 22, ls1.GetNumPoints());
Assertion.AssertEquals("NumPoints-2: ", 18, ls2.GetNumPoints());
Assertion.AssertEquals("NumPoints-3: ", 21, ls3.GetNumPoints());
Assertion.AssertEquals("NumPoints-4: ", 32, ls4.GetNumPoints());
Assertion.AssertEquals("NumPoints-5: ", 0, ls5.GetNumPoints());
}
示例11: test_Envelope
public void test_Envelope()
{
LineString ls = SimpleOpen();
//put the envelope into a geometry
Geometry geom = ls.GetEnvelope() as Geometry;
//make sure there is something in the geometry
Assertion.AssertEquals("Envelope-1: ", false, geom.IsEmpty());
//get the coordinates out of the geometry
Coordinates coords = geom.GetCoordinates();
//check the first set of coordinates (minX, minY)
Assertion.AssertEquals("Envelope-2: ", 1.0, coords[0].X);
Assertion.AssertEquals("Envelope-3: ", 1.0, coords[0].Y);
//check the second set of coordinates (maxX, minY)
Assertion.AssertEquals("Envelope-4: ", 12.0, coords[1].X);
Assertion.AssertEquals("Envelope-5: ", 1.0, coords[1].Y);
//check the third set of coordinates (maxX, maxY)
Assertion.AssertEquals("Envelope-6: ", 12.0, coords[2].X);
Assertion.AssertEquals("Envelope-7: ", 22.0, coords[2].Y);
//check the forth set of coordinates (minX, maxY)
Assertion.AssertEquals("Envelope-8: ", 1.0, coords[3].X);
Assertion.AssertEquals("Envelope-9: ", 22.0, coords[3].Y);
//check the fifth set of coordinates (minX, minY)
Assertion.AssertEquals("Envelope-10: ", 1.0, coords[4].X);
Assertion.AssertEquals("Envelope-11: ", 1.0, coords[4].Y);
Coordinates coords2 = new Coordinates();
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls2 = gf.CreateLineString(coords2);
geom = ls2.GetEnvelope() as Geometry;
//make sure there is nothing in the geometry
Assertion.AssertEquals("Envelope-12: ", true, geom.IsEmpty());
}
示例12: ThrowsException
private LineString ThrowsException()
{
Coordinates coords = new Coordinates();
Coordinate coord = new Coordinate(1,1);
coords.Add(coord);
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls = gf.CreateLineString(coords);
return ls;
}
示例13: NonSimpleClosed
/// <summary>
/// Method to create a NonSimple Closed Linestring for testing purposes
/// </summary>
/// <returns>A lineString</returns>
private LineString NonSimpleClosed()
{
Coordinates coords = new Coordinates();
Coordinate coord = new Coordinate(0, 0);
coord = new Coordinate(2, 2);
coords.Add(coord);
coord = new Coordinate(3, 1);
coords.Add(coord);
coord = new Coordinate(4, 2);
coords.Add(coord);
coord = new Coordinate(5, 3);
coords.Add(coord);
coord = new Coordinate(6, 4);
coords.Add(coord);
coord = new Coordinate(7, 5);
coords.Add(coord);
coord = new Coordinate(7, 6);
coords.Add(coord);
coord = new Coordinate(7, 7);
coords.Add(coord);
coord = new Coordinate(7, 8);
coords.Add(coord);
coord = new Coordinate(7, 9);
coords.Add(coord);
coord = new Coordinate(6, 10);
coords.Add(coord);
coord = new Coordinate(5, 11);
coords.Add(coord);
coord = new Coordinate(6, 12);
coords.Add(coord);
coord = new Coordinate(7, 13);
coords.Add(coord);
coord = new Coordinate(8, 14);
coords.Add(coord);
coord = new Coordinate(9, 13);
coords.Add(coord);
coord = new Coordinate(10, 12);
coords.Add(coord);
coord = new Coordinate(10, 11);
coords.Add(coord);
coord = new Coordinate(10, 10);
coords.Add(coord);
coord = new Coordinate(10, 9);
coords.Add(coord);
coord = new Coordinate(9, 8);
coords.Add(coord);
coord = new Coordinate(8, 7);
coords.Add(coord);
coord = new Coordinate(7, 7);
coords.Add(coord);
coord = new Coordinate(6, 7);
coords.Add(coord);
coord = new Coordinate(5, 8);
coords.Add(coord);
coord = new Coordinate(4, 8);
coords.Add(coord);
coord = new Coordinate(3, 7);
coords.Add(coord);
coord = new Coordinate(2, 6);
coords.Add(coord);
coord = new Coordinate(1, 5);
coords.Add(coord);
coord = new Coordinate(2, 4);
coords.Add(coord);
coord = new Coordinate(1, 3);
coords.Add(coord);
coord = new Coordinate(2, 2);
coords.Add(coord);
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls = gf.CreateLineString(coords);
return ls;
}
示例14: SimpleClosed
/// <summary>
/// Method to create a Simple Closed Linestring for testing purposes
/// </summary>
/// <returns>A lineString</returns>
private LineString SimpleClosed()
{
Coordinates coords = new Coordinates();
Coordinate coord ;//Coordinate(0, 0);
coord = new Coordinate(10, 13);
coords.Add(coord);
coord = new Coordinate(11, 13);
coords.Add(coord);
coord = new Coordinate(12, 13);
coords.Add(coord);
coord = new Coordinate(13, 14);
coords.Add(coord);
coord = new Coordinate(14, 15);
coords.Add(coord);
coord = new Coordinate(15, 16);
coords.Add(coord);
coord = new Coordinate(15, 17);
coords.Add(coord);
coord = new Coordinate(15, 18);
coords.Add(coord);
coord = new Coordinate(14, 19);
coords.Add(coord);
coord = new Coordinate(13, 20);
coords.Add(coord);
coord = new Coordinate(12, 21);
coords.Add(coord);
coord = new Coordinate(11, 21);
coords.Add(coord);
coord = new Coordinate(10, 21);
coords.Add(coord);
coord = new Coordinate(9, 20);
coords.Add(coord);
coord = new Coordinate(8, 19);
coords.Add(coord);
coord = new Coordinate(7, 18);
coords.Add(coord);
coord = new Coordinate(7, 17);
coords.Add(coord);
coord = new Coordinate(7, 16);
coords.Add(coord);
coord = new Coordinate(8, 15);
coords.Add(coord);
coord = new Coordinate(9, 14);
coords.Add(coord);
coord = new Coordinate(10, 13);
coords.Add(coord);
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls = gf.CreateLineString(coords);
return ls;
}
示例15: NonSimpleOpen
/// <summary>
/// Method to create a NonSimple NonClosed Linestring for testing purposes
/// </summary>
/// <returns>A lineString</returns>
private LineString NonSimpleOpen()
{
Coordinates coords = new Coordinates();
Coordinate coord = new Coordinate(0, 0);
coord = new Coordinate(2, 2);
coords.Add(coord);
coord = new Coordinate(3, 3);
coords.Add(coord);
coord = new Coordinate(4, 4);
coords.Add(coord);
coord = new Coordinate(5, 5);
coords.Add(coord);
coord = new Coordinate(6, 6);
coords.Add(coord);
coord = new Coordinate(7, 7);
coords.Add(coord);
coord = new Coordinate(8, 8);
coords.Add(coord);
coord = new Coordinate(9, 7);
coords.Add(coord);
coord = new Coordinate(10, 6);
coords.Add(coord);
coord = new Coordinate(10, 5);
coords.Add(coord);
coord = new Coordinate(9, 4);
coords.Add(coord);
coord = new Coordinate(8, 3);
coords.Add(coord);
coord = new Coordinate(7, 4);
coords.Add(coord);
coord = new Coordinate(7, 5);
coords.Add(coord);
coord = new Coordinate(6, 6);
coords.Add(coord);
coord = new Coordinate(5, 7);
coords.Add(coord);
coord = new Coordinate(4, 8);
coords.Add(coord);
coord = new Coordinate(3, 9);
coords.Add(coord);
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LineString ls = gf.CreateLineString(coords);
return ls;
}