本文整理汇总了C#中Geotools.Geometries.GeometryFactory.CreateMultiLineString方法的典型用法代码示例。如果您正苦于以下问题:C# GeometryFactory.CreateMultiLineString方法的具体用法?C# GeometryFactory.CreateMultiLineString怎么用?C# GeometryFactory.CreateMultiLineString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geotools.Geometries.GeometryFactory
的用法示例。
在下文中一共展示了GeometryFactory.CreateMultiLineString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_NumPoints
public void test_NumPoints()
{
//create a geomerty collection
MultiLineString multiLS = CreateMLS();
Assertion.AssertEquals("NumPoints-1: ", 100, multiLS.GetNumPoints());
//now try it with a null geometry collection
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
multiLS = gf.CreateMultiLineString(null);
Assertion.AssertEquals("NumPoints-2: ", 0, multiLS.GetNumPoints());
//now try it with a different geometry collection
multiLS = closedMLS();
Assertion.AssertEquals("NumPoints-3: ", 30, multiLS.GetNumPoints());
//now try it with a mixed geometry collection
multiLS = nonSimpleMLS();
Assertion.AssertEquals("NumPoints-4: ", 18, multiLS.GetNumPoints());
}
示例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: test_IsEmpty
public void test_IsEmpty()
{
//create a geomerty collection
MultiLineString multiLS = CreateMLS();
Assertion.AssertEquals("IsEmpty-1: ", false, multiLS.IsEmpty());
//now try it with a null geometry collection
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
multiLS = gf.CreateMultiLineString(null);
Assertion.AssertEquals("IsEmpty-2: ", true, multiLS.IsEmpty());
//now try it with a different geometry collection
multiLS = CreateMLS1();
Assertion.AssertEquals("IsEmpty-3: ", false, multiLS.IsEmpty());
//now try it again
multiLS = closedMLS();
Assertion.AssertEquals("IsEmpty-4: ", false, multiLS.IsEmpty());
}
示例6: test_IsSimple
public void test_IsSimple()
{
//create a geomerty collection
MultiLineString multiLS = CreateMLS();
Assertion.AssertEquals("IsSimple-1: ", false, multiLS.IsSimple());
//now try it with a null geometry collection
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
multiLS = gf.CreateMultiLineString(null);
Assertion.AssertEquals("IsSimple-2: ", true, multiLS.IsSimple());
//now try it with a different geometry collection
multiLS = CreateMLS1();
//TODO: This is really slow!!!!!!!!! Why?
//Assertion.AssertEquals("IsSimple-3: ", false, multiLS.IsSimple());
//now try it with a mixed geometry collection
multiLS = nonSimpleMLS();
Assertion.AssertEquals("IsSimple-4: ", false, multiLS.IsSimple());
//now try it with a closed geometry collection
multiLS = closedMLS();
//TODO: Uncomment when IsSimple is working.
Assertion.AssertEquals("IsSimple-5: ", true, multiLS.IsSimple());
}
示例7: 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());
}
示例8: test_GetBoundaryDimension
public void test_GetBoundaryDimension()
{
//create a multilinestring
MultiLineString multiLS = CreateMLS();
//this returns a zero because it is not closed
Assertion.AssertEquals("GetBoundaryDimension-1: ", 0, multiLS.GetBoundaryDimension());
//now try it with a null multilinestring
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
multiLS = gf.CreateMultiLineString(null);
//this returns a zero because it is not closed
Assertion.AssertEquals("GetBoundaryDimension-2: ", 0, multiLS.GetBoundaryDimension());
//now try it with a closed multilinestring
multiLS = closedMLS();
//this returns a -1 because it is closed
Assertion.AssertEquals("GetBoundaryDimension-3: ", -1, multiLS.GetBoundaryDimension());
}
示例9: test_EqualExact
public void test_EqualExact()
{
//create a geomerty collection
MultiLineString multiLS1 = CreateMLS();
//create another geometry collection that is null
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
MultiLineString multiLS2 = gf.CreateMultiLineString(null);
//create another geometry collection that is different
MultiLineString multiLS3 = CreateMLS1();
//create another geometry collection that is different
MultiLineString multiLS4 = closedMLS();
//create another geometry collection that is the same as the first
MultiLineString multiLS5 = CreateMLS();
Assertion.AssertEquals("Equals-1: ", true , multiLS1.Equals(multiLS5));
Assertion.AssertEquals("Equals-2: ", false, multiLS1.Equals(multiLS2));
Assertion.AssertEquals("Equals-3: ", false, multiLS1.Equals(multiLS3));
Assertion.AssertEquals("Equals-4: ", false, multiLS1.Equals(multiLS4));
}
示例10: test_Envelope
public void test_Envelope()
{
//create a new collection
MultiLineString multiLS = CreateMLS();
//put the envelope into a geometry
Geometry env = multiLS.GetEnvelope() as Geometry;
//make sure there is something in the envelope
Assertion.AssertEquals("Envelope-1: ", false, env.IsEmpty());
Coordinates coords = env.GetCoordinates();
//check the first set of coordinates (minX, minY)
Assertion.AssertEquals("Envelope-2: ", 0.0, coords[0].X);
Assertion.AssertEquals("Envelope-3: ", 5.0, coords[0].Y);
//check the second set of coordinates (maxX, minY)
Assertion.AssertEquals("Envelope-4: ", 18.0, coords[1].X);
Assertion.AssertEquals("Envelope-5: ", 5.0, coords[1].Y);
//check the third set of coordinates (maxX, maxY)
Assertion.AssertEquals("Envelope-6: ", 18.0, coords[2].X);
Assertion.AssertEquals("Envelope-7: ", 23.0, coords[2].Y);
//check the forth set of coordinates (minX, maxY)
Assertion.AssertEquals("Envelope-8: ", 0.0, coords[3].X);
Assertion.AssertEquals("Envelope-9: ", 23.0, coords[3].Y);
//check the fifth set of coordinates (minX, minY)
Assertion.AssertEquals("Envelope-10: ", 0.0, coords[4].X);
Assertion.AssertEquals("Envelope-11: ", 5.0, coords[4].Y);
//create a null collection
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
multiLS = gf.CreateMultiLineString(null);
//put the envelope into a geometry
env = multiLS.GetEnvelope() as Geometry;
//make sure there is something in the envelope
Assertion.AssertEquals("Envelope-12: ", true, env.IsEmpty());
}
示例11: test_Coordinates
public void test_Coordinates()
{
//create a geomerty collection
MultiLineString multiLS = CreateMLS();
//this geometry conatins 10 sets of coordinates
Assertion.AssertEquals("Coordinates-1: ", 100, multiLS.GetCoordinates().Count);
//now try it with a null geometry collection
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
multiLS = gf.CreateMultiLineString(null);
Assertion.AssertEquals("Coordinates-2: ", 0, multiLS.GetCoordinates().Count);
//now try it with a different geometry collection
multiLS = CreateMLS1();
//1000 sets of coordinates
Assertion.AssertEquals("Cordinates-3: ", 1000, multiLS.GetCoordinates().Count);
}
示例12: 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);
}
示例13: CreateMP1
private MultiPolygon CreateMP1()
{
Polygon[] polygons = new Polygon[2];
LineString[] rings = new LineString[2];
Coordinates coords = new Coordinates();
Coordinate 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);
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
LinearRing exterior1 = gf.CreateLinearRing(coords);
polygons[0] = gf.CreatePolygon(exterior1);
rings[0] = exterior1 as LineString;
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);
LinearRing exterior2 = gf.CreateLinearRing(coords);
polygons[1] = gf.CreatePolygon(exterior2);
rings[1] = exterior2;
_mls1 = gf.CreateMultiLineString(rings);
return gf.CreateMultiPolygon(polygons);
}