本文整理汇总了C#中IGeometry.AsText方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.AsText方法的具体用法?C# IGeometry.AsText怎么用?C# IGeometry.AsText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometry
的用法示例。
在下文中一共展示了IGeometry.AsText方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
protected override byte[] Write(IGeometry gIn)
{
var geoWriter = new MsSql2008GeometryWriter();
var b = geoWriter.WriteGeometry(gIn);
var b2 = geoWriter.Write(gIn);
using( var conn = new SqlConnection(ConnectionString))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "INSERT INTO [nts_io_geometry] VALUES(@P1, @P2, @P3);";
var p1 = new SqlParameter("P1", SqlDbType.Int) { SqlValue = Counter };
var p2 = new SqlParameter("P2", SqlDbType.Text) { SqlValue = gIn.AsText() };
var p3 = new SqlParameter("P3", SqlDbType.Udt) { UdtTypeName = "geometry", SqlValue = b };
cmd.Parameters.AddRange(new[] { p1, p2, p3 });
cmd.ExecuteNonQuery();
/*
p1.SqlValue = 100000 + Counter;
cmd.Parameters.Remove(p3);
p3 = new SqlParameter("P3", SqlDbType.Image) { SqlValue = b };
cmd.Parameters.Add(p3);
p3.SqlValue = b2;
cmd.ExecuteNonQuery();
*/
}
}
return b2;
}
示例2: TestValid
private static void TestValid(IGeometry geom)
{
if (!geom.IsValid)
{
var ivop = new NetTopologySuite.Operation.Valid.IsValidOp(geom);
if (!ivop.IsValid)
{
Console.WriteLine(geom.AsText());
Console.Write(ivop.ValidationError);
}
Assert.True(false);
}
}
示例3: Write
protected override byte[] Write(IGeometry gIn)
{
PostGisWriter pgWriter = new PostGisWriter();
byte[] b = pgWriter.Write(gIn);
using (NpgsqlConnection cn = new NpgsqlConnection(this.ConnectionString))
{
cn.Open();
using (NpgsqlCommand cmd = cn.CreateCommand())
{
cmd.CommandText = "INSERT INTO \"nts_io_postgis_2d\" VALUES(@P1, @P2, @P3);";
NpgsqlParameter p1 = new NpgsqlParameter("P1", NpgsqlDbType.Integer) {NpgsqlValue = this.Counter};
NpgsqlParameter p2 = new NpgsqlParameter("P2", NpgsqlDbType.Text) { NpgsqlValue = gIn.AsText() };
NpgsqlParameter p3 = new NpgsqlParameter("P3", NpgsqlDbType.Bytea) { NpgsqlValue = b };
cmd.Parameters.AddRange(new[] { p1, p2, p3 });
cmd.ExecuteNonQuery();
}
}
return b;
}
示例4: CheckEquality
protected override void CheckEquality(IGeometry gIn, IGeometry gParsed, WKTWriter writer)
{
var res = gIn.EqualsExact(gParsed);
if (res) return;
if (Compressed)
{
var discreteHausdorffDistance =
Algorithm.Distance.DiscreteHausdorffDistance.Distance(gIn, gParsed);
if (discreteHausdorffDistance > 0.05)
{
Console.WriteLine();
Console.WriteLine(gIn.AsText());
Console.WriteLine(gParsed.AsText());
Console.WriteLine("DiscreteHausdorffDistance=" + discreteHausdorffDistance);
}
Assert.IsTrue(discreteHausdorffDistance < 0.001);
}
else
Assert.IsTrue(false);
}
示例5: Write
protected override byte[] Write(IGeometry gIn)
{
var writer = new GaiaGeoWriter();
writer.HandleOrdinates = Ordinates;
writer.UseCompressed = Compressed;
var b = writer.Write(gIn);
using (SQLiteConnection conn = new SQLiteConnection("Data Source=\"" + Name + "\""))
{
conn.Open();
using (SQLiteCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "INSERT INTO \"nts_io_spatialite\" VALUES(@P1, @P3, @P2);";
SQLiteParameter p1 = new SQLiteParameter("P1", DbType.Int32) { Value = this.Counter };
SQLiteParameter p2 = new SQLiteParameter("P2", DbType.String) { Value = gIn.AsText() };
SQLiteParameter p3 = new SQLiteParameter("P3", DbType.Binary) { Value = b };
cmd.Parameters.AddRange(new[] { p1, p2, p3 });
cmd.ExecuteNonQuery();
}
}
return b;
}
示例6: OnExecuteIntersectionQuery
/// <summary>
/// Returns the features that intersects with 'geom'
/// </summary>
/// <param name="geom"></param>
/// <param name="ds">FeatureDataSet to fill data into</param>
protected override void OnExecuteIntersectionQuery(IGeometry geom, FeatureDataSet ds)
{
//List<Geometry> features = new List<Geometry>();
using (var conn = new SqlConnection(ConnectionString))
{
//TODO: Convert to SQL Server
string strGeom = _spatialObject + "::STGeomFromText('" + geom.AsText() + "', #SRID#)";
strGeom = strGeom.Replace("#SRID#", SRID > 0 ? SRID.ToString() : "0");
strGeom = GeometryColumn + ".STIntersects(" + strGeom + ") = 1";
string strSQL = "SELECT g.* , g." + GeometryColumn + ".STAsBinary() As sharpmap_tempgeometry FROM " + Table + " g " + BuildTableHints() + " WHERE ";
if (!String.IsNullOrEmpty(_definitionQuery))
strSQL += DefinitionQuery + " AND ";
strSQL += strGeom;
string extraOptions = GetExtraOptions();
if (!string.IsNullOrEmpty(extraOptions))
strSQL += " " + extraOptions;
using (SqlDataAdapter adapter = new SqlDataAdapter(strSQL, conn))
{
conn.Open();
adapter.Fill(ds);
conn.Close();
if (ds.Tables.Count > 0)
{
FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
foreach (System.Data.DataColumn col in ds.Tables[0].Columns)
if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
{
FeatureDataRow fdr = fdt.NewRow();
foreach (System.Data.DataColumn col in ds.Tables[0].Columns)
if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
fdr[col.ColumnName] = dr[col];
fdr.Geometry = Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"], Factory);
fdt.AddRow(fdr);
}
ds.Tables.Add(fdt);
}
}
}
}
示例7: OnExecuteIntersectionQuery
/// <summary>
/// Returns the features that intersects with 'geom'
/// </summary>
/// <param name="geom"></param>
/// <param name="fcs">FeatureCollectionSet to fill data into</param>
protected override void OnExecuteIntersectionQuery(IGeometry geom, IFeatureCollectionSet fcs, CancellationToken? cancellationToken=null)
{
using (var conn = new OracleConnection(ConnectionString))
{
var strGeom = "MDSYS.SDO_GEOMETRY('" + geom.AsText() + "', #SRID#)";
strGeom = strGeom.Replace("#SRID#", SRID > 0 ? SRID.ToString(Map.NumberFormatEnUs) : "NULL");
strGeom = "SDO_RELATE(g." + GeometryColumn + ", " + strGeom +
", 'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'";
var strSQL = "SELECT g.* , g." + GeometryColumn + ").Get_WKB() As sharpmap_tempgeometry FROM " +
Table + " g WHERE ";
if (!String.IsNullOrEmpty(_definitionQuery))
strSQL += DefinitionQuery + " AND ";
strSQL += strGeom;
var ds = new FeatureDataSet();
using (var adapter = new OracleDataAdapter(strSQL, conn))
{
conn.Open();
adapter.Fill(ds);
conn.Close();
if (ds.Tables.Count <= 0)
{
return;
}
var fdt = new FeatureDataTable(ds.Tables[0]);
foreach (DataColumn col in ds.Tables[0].Columns)
{
if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
{
fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
}
}
foreach (DataRow dr in ds.Tables[0].Rows)
{
var fdr = fdt.NewRow();
foreach (DataColumn col in ds.Tables[0].Columns)
if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
fdr[col.ColumnName] = dr[col];
fdr.Geometry = GeometryFromWKB.Parse((byte[]) dr["sharpmap_tempgeometry"], Factory);
fdt.AddRow(fdr);
}
fcs.Add(fdt);
}
}
}
示例8: ExecuteIntersectionQuery
/// <summary>
/// Returns the features that intersects with 'geom'
/// </summary>
/// <param name="geom"></param>
/// <param name="ds">FeatureDataSet to fill data into</param>
public void ExecuteIntersectionQuery(IGeometry geom, FeatureDataSet ds)
{
//List<IGeometry> features = new List<IGeometry>();
using (PgConnection conn = new PgConnection(_ConnectionString))
{
string strGeom = "GeomFromText('" + geom.AsText() + "')";
if (this.SRID > 0)
strGeom = "setSRID(" + strGeom + "," + this.SRID.ToString() + ")";
string strSQL = "SELECT * , AsBinary(" + this.GeometryColumn + ") As sharpmap_tempgeometry FROM " + this.Table + " WHERE ";
if (!String.IsNullOrEmpty(_defintionQuery))
strSQL += this.DefinitionQuery + " AND ";
strSQL += this.GeometryColumn + " && " + strGeom + " AND distance(" + this.GeometryColumn + ", " + strGeom + ")<0";
using (PgDataAdapter adapter = new PgDataAdapter(strSQL, conn))
{
conn.Open();
adapter.Fill(ds);
conn.Close();
if (ds.Tables.Count > 0)
{
FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
foreach (System.Data.DataColumn col in ds.Tables[0].Columns)
if (col.ColumnName != this.GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
{
SharpMap.Data.FeatureDataRow fdr = fdt.NewRow();
foreach (System.Data.DataColumn col in ds.Tables[0].Columns)
if (col.ColumnName != this.GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
fdr[col.ColumnName] = dr[col];
fdr.Geometry = SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"]);
fdt.AddRow(fdr);
}
ds.Tables.Add(fdt);
}
}
}
}
示例9: ExecuteIntersectionQuery
/// <summary>
/// Returns the features that intersects with 'geom'
/// </summary>
/// <param name="geom"></param>
/// <param name="ds">FeatureDataSet to fill data into</param>
public void ExecuteIntersectionQuery(IGeometry geom, FeatureDataSet ds)
{
List<IGeometry> features = new List<IGeometry>();
using (OracleConnection conn = new OracleConnection(_ConnectionString))
{
string strGeom = "MDSYS.SDO_GEOMETRY('" + geom.AsText() + "', #SRID#)";
if (this.SRID > 0) {
strGeom = strGeom.Replace("#SRID#", this.SRID.ToString(Map.numberFormat_EnUS));
} else {
strGeom = strGeom.Replace("#SRID#", "NULL");
}
strGeom = "SDO_RELATE(g." + this.GeometryColumn + ", " + strGeom + ", 'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'";
string strSQL = "SELECT g.* , g." + this.GeometryColumn + ").Get_WKB() As sharpmap_tempgeometry FROM " + this.Table + " g WHERE ";
if (!String.IsNullOrEmpty(_defintionQuery))
strSQL += this.DefinitionQuery + " AND ";
strSQL += strGeom;
using (OracleDataAdapter adapter = new OracleDataAdapter(strSQL, conn))
{
conn.Open();
adapter.Fill(ds);
conn.Close();
if (ds.Tables.Count > 0)
{
FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
foreach (System.Data.DataColumn col in ds.Tables[0].Columns)
if (col.ColumnName != this.GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
{
SharpMap.Data.FeatureDataRow fdr = fdt.NewRow();
foreach (System.Data.DataColumn col in ds.Tables[0].Columns)
if (col.ColumnName != this.GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
fdr[col.ColumnName] = dr[col];
fdr.Geometry = SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"]);
fdt.AddRow(fdr);
}
ds.Tables.Add(fdt);
}
}
}
}
示例10: OnExecuteIntersectionQuery
/// <summary>
/// Returns the features that intersects with 'geom'
/// </summary>
/// <param name="geom"></param>
/// <param name="ds">FeatureDataSet to fill data into</param>
protected override void OnExecuteIntersectionQuery(IGeometry geom, IFeatureCollectionSet fcs, CancellationToken? cancellationToken=null)
{
using (var conn = new OracleConnection(ConnectionString))
{
string strGeom = "MDSYS.SDO_GEOMETRY('" + geom.AsText() + "', #SRID#)";
strGeom = strGeom.Replace("#SRID#", SRID > 0 ? SRID.ToString(Map.NumberFormatEnUs) : "NULL");
strGeom = "SDO_RELATE(g." + GeometryColumn + ", " + strGeom +
", 'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'";
string strSql = "SELECT * FROM " +
Table + " g WHERE ";
if (!String.IsNullOrEmpty(_definitionQuery))
strSql += DefinitionQuery + " AND ";
strSql += strGeom;
var ds = (DataSet) new FeatureDataSet();
using (var adapter = new OracleDataAdapter(strSql, conn))
{
conn.Open();
adapter.Fill(ds);
conn.Close();
if (ds.Tables.Count > 0)
{
var fdt = new FeatureDataTable(ds.Tables[0]);
foreach (DataColumn col in ds.Tables[0].Columns)
if (string.Compare(col.ColumnName, GeometryColumn, CultureInfo.InvariantCulture, CompareOptions.OrdinalIgnoreCase) != 0)
fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
foreach (DataRow dr in ds.Tables[0].Rows)
{
var fdr = fdt.NewRow();
foreach (DataColumn col in ds.Tables[0].Columns)
if (string.Compare(col.ColumnName, GeometryColumn, CultureInfo.InvariantCulture, CompareOptions.OrdinalIgnoreCase) != 0)
fdr[col.ColumnName] = dr[col];
var sdoGeometry = dr[GeometryColumn] as SdoGeometry;
if (sdoGeometry != null)
{
fdr.Geometry = sdoGeometry.AsGeometry();
}
fdt.AddRow(fdr);
}
ds.Tables.Add(fdt);
}
}
}
}
示例11: QueryFeatures
public SharpMap.Data.FeatureDataTable QueryFeatures(IGeometry geom, double distance)
{
//Collection<IGeometry> features = new Collection<IGeometry>();
using (Npgsql.NpgsqlConnection conn = new Npgsql.NpgsqlConnection(_ConnectionString))
{
string strGeom = "GeomFromText('" + geom.AsText() + "')";
if (this.SRID > 0)
strGeom = "setSRID(" + strGeom + "," + this.SRID.ToString() + ")";
string strSQL = "SELECT * , AsBinary(" + this.GeometryColumn + ") As sharpmap_tempgeometry FROM " + this.Table + " WHERE ";
if (!String.IsNullOrEmpty(_defintionQuery))
strSQL += this.DefinitionQuery + " AND ";
strSQL += this.GeometryColumn + " && " + "buffer(" + strGeom + "," + distance.ToString(Map.numberFormat_EnUS) + ")";
strSQL += " AND distance(" + this.GeometryColumn + ", " + strGeom + ")<" + distance.ToString(Map.numberFormat_EnUS);
using (Npgsql.NpgsqlDataAdapter adapter = new Npgsql.NpgsqlDataAdapter(strSQL, conn))
{
System.Data.DataSet ds = new System.Data.DataSet();
conn.Open();
adapter.Fill(ds);
conn.Close();
if (ds.Tables.Count > 0)
{
FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
foreach (System.Data.DataColumn col in ds.Tables[0].Columns)
if (col.ColumnName != this.GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
fdt.Columns.Add(col.ColumnName,col.DataType,col.Expression);
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
{
SharpMap.Data.FeatureDataRow fdr = fdt.NewRow();
foreach(System.Data.DataColumn col in ds.Tables[0].Columns)
if (col.ColumnName != this.GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
fdr[col.ColumnName] = dr[col];
fdr.Geometry = SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"]);
fdt.AddRow(fdr);
}
return fdt;
}
else return null;
}
}
}