本文整理汇总了C#中Geotools.Geometries.GeometryFactory类的典型用法代码示例。如果您正苦于以下问题:C# GeometryFactory类的具体用法?C# GeometryFactory怎么用?C# GeometryFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeometryFactory类属于Geotools.Geometries命名空间,在下文中一共展示了GeometryFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EdgeRing
private EdgeRing _shell; // if non-null, the ring is a hole and this EdgeRing is its containing shell
#endregion Fields
#region Constructors
/// <summary>
/// Initializes a new instance of the EdgeRing class.
/// </summary>
public EdgeRing( DirectedEdge start, GeometryFactory geometryFactory, CGAlgorithms cga )
{
_geometryFactory = geometryFactory;
_cga = cga;
ComputePoints(start);
ComputeRing();
}
示例2: TestRoundTrip
public void TestRoundTrip(string filename)
{
//
// can't round trip since I added the ToExternal/ ToInternal to the shapefile readers and writers.
//
PrecisionModel pm = new PrecisionModel();
GeometryFactory geometryFactory = new GeometryFactory(pm,-1);
int differenceCount=0;
string testName="";
string srcShpFilename= Global.GetUnitTestRootDirectory()[email protected]"\IO\Shapefile\Testfiles\"+filename;
string destShpFilename = Global.GetUnitTestRootDirectory()[email protected]"\IO\Shapefile\Testfiles\testroundtrip"+filename;
// do the round trip
ShapefileReader shpReader = new ShapefileReader(srcShpFilename+".shp", geometryFactory);
GeometryCollection shapes = shpReader.ReadAll();
ShapefileWriter.Write(destShpFilename,shapes, geometryFactory);
// perfom binary compare on the .shp
testName = String.Format("Test round trip .shp - {0}",filename);
differenceCount = Compare.BinaryCompare(srcShpFilename+".shp", destShpFilename+".shp");
Assertion.AssertEquals(testName,0,differenceCount);
// perfom binary compare on the .shx file
testName = String.Format("Test round trip .shx - {0}",filename);
differenceCount = Compare.BinaryCompare(srcShpFilename+".shx", destShpFilename+".shx");
Assertion.AssertEquals(testName,0,differenceCount);
}
示例3: BufferOp
/// <summary>
/// Initializes a new instance of the BufferOp class.
/// </summary>
/// <param name="g0"></param>
public BufferOp(Geometry g0) : base(g0)
{
_graph = new PlanarGraph(new OverlayNodeFactory());
_geomFact = new GeometryFactory( g0.PrecisionModel, g0.GetSRID() );
}
示例4: CreateTester1
/// <summary>
/// Method to create a MultiPoint for testing purposes
/// </summary>
/// <returns>A MultiPoint</returns>
private MultiPoint CreateTester1()
{
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
Point[] points = new Point[23];
for(int i = 0; i < 12; i++)
{
points[i] = gf.CreatePoint(new Coordinate(i, i));
}
points[12] = gf.CreatePoint(new Coordinate(11, 12));
points[13] = gf.CreatePoint(new Coordinate(10, 13));
points[14] = gf.CreatePoint(new Coordinate(9, 14));
points[15] = gf.CreatePoint(new Coordinate(8, 15));
points[16] = gf.CreatePoint(new Coordinate(9, 16));
points[17] = gf.CreatePoint(new Coordinate(10, 17));
points[18] = gf.CreatePoint(new Coordinate(11, 18));
points[19] = gf.CreatePoint(new Coordinate(12, 19));
points[20] = gf.CreatePoint(new Coordinate(11, 20));
points[21] = gf.CreatePoint(new Coordinate(10, 21));
points[22] = gf.CreatePoint(new Coordinate(9, 22));
MultiPoint mp = gf.CreateMultiPoint(points);
return mp;
}
示例5: TestHelper
public static bool TestHelper(string wkt)
{
PrecisionModel pm = new PrecisionModel(1, 0, 0);
GeometryFactory fact = new GeometryFactory(pm, 0);
//read wkt
Geometry a = (Geometry)fact.CreateFromWKT(wkt);
//write wkb
FileStream fs = new FileStream("TestFile.wkb", FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
GeometryWKBWriter bWriter = new GeometryWKBWriter(fact);
bWriter.Write(a, bw, (byte)1);
bw.Close();
fs.Close();
//read wkb
fs = new FileStream("TestFile.wkb", FileMode.Open);
byte[] bytes = new byte[fs.Length];
for(int i = 0; i < fs.Length; i++)
{
bytes[i] = (byte)fs.ReadByte();
}
GeometryWKBReader bReader = new GeometryWKBReader(fact);
Geometry geom = bReader.Create(bytes);
fs.Close();
//write to wkt & compare with original text.
bool results = ( Compare.WktStrings(wkt,a.ToText()));
return results;
}
示例6: Poly1
private Polygon Poly1()
{
_coords1 = new Coordinates();
Coordinate coord = new Coordinate(5, 1);
_coords1.Add(coord);
coord = new Coordinate(6, 2);
_coords1.Add(coord);
coord = new Coordinate(7, 3);
_coords1.Add(coord);
coord = new Coordinate(6, 4);
_coords1.Add(coord);
coord = new Coordinate(5, 5);
_coords1.Add(coord);
coord = new Coordinate(4, 4);
_coords1.Add(coord);
coord = new Coordinate(3, 3);
_coords1.Add(coord);
coord = new Coordinate(4, 2);
_coords1.Add(coord);
coord = new Coordinate(5, 1);
_coords1.Add(coord);
_gf = new GeometryFactory(_precMod, _sRID);
_exterior1 = _gf.CreateLinearRing(_coords1);
Polygon polygon = _gf.CreatePolygon(_exterior1);
return polygon;
}
示例7: test_ApplyCoordinateFilter
public void test_ApplyCoordinateFilter()
{
//create a new point
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
Point point = gf.CreatePoint(_coor);
//CoordinateFilter filter = new CoordinateFilter();
//todo(Ronda): Apply
//point.Apply(filter);
}
示例8: test_constructor
public void test_constructor()
{
GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
//create a new point
Point point = gf.CreatePoint(_coor);
//Make sure the values
Assertion.AssertEquals("Const-x: ", 1.0, point.X);
Assertion.AssertEquals("Const-y: ", 2.0, point.Y);
}
示例9: 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);
}
示例10: TestGetNextWord
public void TestGetNextWord()
{
string wkt = "POINT *( 3 4 )";
GeometryFactory factory = new GeometryFactory();
try
{
IGeometry geometry = factory.CreateFromWKT(wkt);
Assertion.Fail("parse exception");
}
catch(ParseException)
{
}
}
示例11: Test1
public void Test1()
{
string wkt = null;
GeometryFactory factory = new GeometryFactory();
try
{
IGeometry geometry = factory.CreateFromWKT(wkt);
Assertion.Fail("parse exception");
}
catch(ArgumentNullException)
{
}
}
示例12: DisplayTest
/// <summary>
/// Writes three geometries to an svg file
/// </summary>
/// <param name="filename">The path of the svg file.</param>
/// <param name="a">The A geometry</param>
/// <param name="b">The B geometry</param>
/// <param name="c">The C geometry</param>
public void DisplayTest(string filename, Geometry a, Geometry b, Geometry c)
{
Geotools.Geometries.PrecisionModel pm = new Geotools.Geometries.PrecisionModel(1, 0, 0);
GeometryFactory fact = new GeometryFactory(pm, 0);
GeometrySVGWriter svgWriter = new GeometrySVGWriter(fact.PrecisionModel);
StreamWriter sw = new StreamWriter(filename);
GeometryCollection geomCollection= fact.CreateGeometryCollection(new Geometry[]{a,b,c});
double minx, miny, maxx, maxy;
geomCollection.Extent2D(out minx, out miny, out maxx, out maxy);
sw.WriteLine(String.Format("<svg viewBox=\"{0} {1} {2} {3}\">",minx,miny,maxx,maxy*1.2));
svgWriter.Write(a,sw,"fill-rule:evenodd;","fill:none;stroke:blue;stroke-width:1;fill-opacity:0.2");
svgWriter.Write(b,sw,"fill-rule:evenodd;","fill:none;stroke:red;stroke-width:1;fill-opacity:0.2");
svgWriter.Write(c,sw,"fill-rule:evenodd;","fill:yellow;stroke:green;stroke-width:2;fill-opacity:0.5;stroke-dasharray:2,2");
sw.WriteLine("</svg>");
sw.Close();
}
示例13: Test_MultipleRead
/// <summary>
/// Test getting and setting the properties
/// </summary>
public void Test_MultipleRead()
{
PrecisionModel pm = new PrecisionModel(1,0,0);
GeometryFactory geometryFactory = new GeometryFactory(pm,-1);
string filename= Global.GetUnitTestRootDirectory()[email protected]"\IO\Shapefile\Testfiles\statepop.shp";
// tests two readers reading the file as the same time.
Geotools.IO.ShapefileReader shpFile = new Geotools.IO.ShapefileReader(filename, geometryFactory);
Geotools.IO.ShapefileReader shpFile2 = new Geotools.IO.ShapefileReader(filename, geometryFactory);
foreach(object row in shpFile)
{
Assertion.AssertNotNull(row);
foreach(object row2 in shpFile2)
{
Assertion.AssertNotNull(row2);
}
}
}
示例14: Test1
public void Test1()
{
IDbConnection connection = Global.GetEPSGDatabaseConnection();
_CTfactory = new CoordinateTransformationEPSGFactory(connection);
_UKNationalGrid1 = _CTfactory.CreateFromTransformationCode("1681");
_geometryFactory = new GeometryFactory(_pm,4326);
string wkt = "POINT ( -2.0 49.0 )";
Assertion.AssertEquals("Point 1",true,Compare(wkt,"POINT (400000 -100000)"));
wkt = "MULTIPOINT( -2 49, -1 50)";
Assertion.AssertEquals("Multipoint 1",true,Compare(wkt,"MULTIPOINT (400000 -100000, 471660 11644)"));
wkt = "MULTIPOINT EMPTY";
Assertion.AssertEquals("Multipoint 2",true,Compare(wkt,"MULTIPOINT EMPTY"));
wkt = "LINESTRING(50 31, 54 31, 54 29, 50 29, 50 31 )";
Assertion.AssertEquals("LineString 1 1",true,Compare(wkt,"LINESTRING (5664915 -615242, 6117479 -308294, 6306392 -569639, 5827846 -873669, 5664915 -615242)"));
wkt = "POLYGON( ( 50 31, 54 31, 54 29, 50 29, 50 31) )";
Assertion.AssertEquals("Multipoint 3",true,Compare(wkt,"POLYGON ((5664915 -615242, 6117479 -308294, 6306392 -569639, 5827846 -873669, 5664915 -615242))"));
//wkt = "POLYGON( ( 1 1, 10 1, 10 10, 1 10, 1 1),(4 4, 5 4, 5 5, 4 5, 4 4 ))";
//Assertion.AssertEquals("Multipoint 4",true,Compare(wkt,"POLYGON ((733898 -5416388, 1744907 -5414055, 1724214 -4397377, 728899 -4420227, 733898 -5416388), "+
//"(1067192 -5082521, 1178905 -5081633, 1177832 -4970278, 1066275 -4971386, 1067192 -5082521))"));
// these tests fail because the strings are too long/ have a CR in the middle of the string. Should really fix this. awc.
//wkt = "MULTILINESTRING (( 10.05 10.28 , 20.95 20.89 ),( 20.95 20.89, 31.92 21.45)) ";
//Assertion.AssertEquals("Multipoint 5",false,Compare(wkt,"MULTILINESTRING ((1724213.5597264355 -4397376.6478565233, 2839122.2852214454 -3022771.8465291355), \n "+
// "(2839122.2852214454 -3022771.8465291355, 4095081.5366646093 -2776957.6041615554))"));
//wkt = "MULTIPOLYGON (((10 10, 10 20, 20 20, 20 15 , 10 10), (50 40, 50 50, 60 50, 60 40, 50 40)))";
//Assertion.AssertEquals("Multipoint 6",true,Compare(wkt,"MULTIPOLYGON (((1724213.5597264355 -4397376.6478565233, 1662268.9948102259 -3270049.5581512651, 2745586.9073599684 -3156174.8212744244, 2817027.1068546474 -3744257.1145197917, 1724213.5597264355 -4397376.6478565233), "+
// "(4882561.4795353347 438327.55639206013, 3970695.8611971624 1430641.0215268317, 4530976.2509158608 2096414.3039089143, 5721871.0214089518 1247465.211354611, 4882561.4795353347 438327.55639206013)))"));
//wkt = "GEOMETRYCOLLECTION(POINT ( 3 4 ),LINESTRING(50 31, 54 31, 54 29, 50 29, 50 31 ))";
//Assertion.AssertEquals("Multipoint 7",true,Compare(wkt,"GEOMETRYCOLLECTION (POINT (955682.872367636 -5083270.4404414054),"+
// "LINESTRING (-7.5557896002384908 49.766496583001434, -7.555734311078294 49.766499242352, -7.5557322582139372 49.76648133658518, -7.5557875473539609 49.7664786772363, -7.5557896002384908 49.766496583001434))"));
}
示例15: Test_CreateDataTable
public void Test_CreateDataTable()
{
PrecisionModel pm = new PrecisionModel(100,0,0);
GeometryFactory geometryFactory = new GeometryFactory(pm,-1);
string filename= Global.GetUnitTestRootDirectory()[email protected]"\IO\Shapefile\Testfiles\statepop";
DataTable table = Geotools.IO.Shapefile.CreateDataTable(filename, "State", geometryFactory);
DataSet ds = new DataSet();
ds.Tables.Add(table);
// make sure the datagrid gets the column headings.
DataGrid grid = new DataGrid();
grid.DataSource = ds;
grid.DataMember="State";
grid.DataBind();
TextWriter tempWriter = new StringWriter();
grid.RenderControl(new HtmlTextWriter(tempWriter));
string html = tempWriter.ToString();
bool same = Compare.CompareAgainstString(Global.GetUnitTestRootDirectory()[email protected]"\IO\Shapefile\Testfiles\ExpectedDataGridDataReader.txt",html);
Assertion.AssertEquals("Datagrid properties",true,same);
}