本文整理汇总了C#中SqlGeometry类的典型用法代码示例。如果您正苦于以下问题:C# SqlGeometry类的具体用法?C# SqlGeometry怎么用?C# SqlGeometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlGeometry类属于命名空间,在下文中一共展示了SqlGeometry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Distance
public static SqlNumber Distance(SqlGeometry geometry, SqlGeometry other)
{
if (geometry == null || geometry.IsNull)
return SqlNumber.Null;
return geometry.Distance(other);
}
示例2: Envelope
public static SqlGeometry Envelope(SqlGeometry geometry)
{
if (geometry.IsNull)
return SqlGeometry.Null;
return geometry.Envelope;
}
示例3: QueryIntersectionsAsync
public async Task<ResponseContainer<IntersectResponse>> QueryIntersectionsAsync(SqlGeometry geometry, string category)
{
category = category.ToLower();
// include stream miles because it's aquatic
if (category == "aquatic/riparian treatment area")
{
_criteria["15"] = new[] { "fcode_text" }; // nhd
}
// send geometry to soe for calculations
var url = string.Format(
"http://{0}/Reference/MapServer/exts/wri_soe/ExtractIntersections",
Settings.Default.gisServerBaseUrl);
var uri = new Uri(url);
var base64Geometry = Convert.ToBase64String(geometry.STAsBinary().Value);
var formContent = new[]
{
new KeyValuePair<string, string>("geometry", base64Geometry),
new KeyValuePair<string, string>("criteria",
JsonConvert.SerializeObject(_criteria)),
new KeyValuePair<string, string>("f", "json")
}.AsFormContent();
var request = await _httpClient.PostAsync(uri, formContent);
return await request.Content.ReadAsAsync<ResponseContainer<IntersectResponse>>(
new[]
{
new TextPlainResponseFormatter()
});
}
示例4: CutZoomedPixelPolygonByZeroTile
/// <summary>
/// Cuts already pixeled geometry by the frame of a tile
/// </summary>
/// <param name="poly"></param>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <returns></returns>
private List<SqlGeometry> CutZoomedPixelPolygonByZeroTile(SqlGeometry poly)
{
List<SqlGeometry> result = new List<SqlGeometry>();
SqlGeometry stroke = null;
SqlGeometry contour;
SqlGeometry tileLineString;
SqlGeometry tobecut;
SqlGeometry tile = _conv.GetTilePixelBound(0, 0, 1);
var tiled = poly.STIntersection(tile);
result.Add(tiled);
switch (GetOpenGisGeometryType(tiled))
{
case OpenGisGeometryType.Polygon:
// Получаем контур полигона и внутренние кольца в виде MULTILINESTRING
contour = PolygonToMultiLineString(tiled);
// удаляем линии среза геометрии по границе тайла
tileLineString = tile.ToLineString();
tobecut = contour.STIntersection(tileLineString);
stroke = contour.STDifference(tobecut);
break;
case OpenGisGeometryType.MultiPolygon:
// Получаем контур полигона и внутренние кольца в виде MULTILINESTRING
contour = MultiPolygonToMultiLineString(tiled);
// удаляем линии среза геометрии по границе тайла
tileLineString = tile.ToLineString();
tobecut = contour.STIntersection(tileLineString);
stroke = contour.STDifference(tobecut);
break;
}
result.Add(stroke);
return result;
}
示例5: AssignPlotOfLand
public AssignPlotOfLand()
{
assignedUnion = null;
startingPoint = null;
outerBoundary = null;
assigned = new List<SqlGeometry>();
}
示例6: SqlGeometryToGeometry
public static IGeometry SqlGeometryToGeometry(SqlGeometry geom, GeometryFactory factory)
{
if (geom.STIsEmpty())
return factory.CreateGeometryCollection(null);
OpenGisGeometryType geometryType = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), geom.STGeometryType().Value);
switch (geometryType)
{
case OpenGisGeometryType.Point:
return SqlGeometryToGeometryPoint(geom, factory);
case OpenGisGeometryType.LineString:
return SqlGeometryToGeometryLineString(geom, factory);
case OpenGisGeometryType.Polygon:
return SqlGeometryToGeometryPolygon(geom, factory);
case OpenGisGeometryType.MultiPoint:
return SqlGeometryToGeometryMultiPoint(geom, factory);
case OpenGisGeometryType.MultiLineString:
return SqlGeometryToGeometryMultiLineString(geom, factory);
case OpenGisGeometryType.MultiPolygon:
return SqlGeometryToGeometryMultiPolygon(geom, factory);
case OpenGisGeometryType.GeometryCollection:
return SqlGeometryToGeometryGeometryCollection(geom, factory);
}
throw new ArgumentException(string.Format("Cannot convert SqlServer '{0}' to Geometry", geom.STGeometryType()), "geom");
}
示例7: CutZoomedPixelMultiLineStringByTile
private SqlGeometry CutZoomedPixelMultiLineStringByTile(SqlGeometry poly, int X, int Y)
{
SqlGeometry result;
SqlGeometry tile = _conv.GetTilePixelBound(X, Y, 1);
result = poly.STIntersection(tile);
return result;
}
示例8: Assign
public SqlGeometry Assign(int wishedArea, int srid, List<Adopter> adopters)
{
foreach (var adopter in adopters)
{
var g = SqlGeometry.STGeomFromText(new SqlChars(adopter.geom), Constants.SRID_INT);
assignedUnion = assignedUnion == null ? g : assignedUnion.STUnion(g);
}
SqlGeometry newStartingPoint = GenerateStartingPoint(wishedArea);
if (newStartingPoint != null)
{
double x = Math.Floor(newStartingPoint.STX.Value);
double y = Math.Floor(newStartingPoint.STY.Value);
SqlGeometry assigned = generate(x, y, wishedArea, srid);
// Defensive check
if (Math.Abs(assigned.STArea().Value - wishedArea) > epsilon)
{
//throw new Exception("Incorrect area");
return null;
}
return assigned;
}
return null;
}
示例9: AppendGeometryToSQLSource
private void AppendGeometryToSQLSource(SqlGeometry geom, string label)
{
if (_ACTIVATE_CLIPBOARD == false) return;
if (_geomSqlSrcBuilder == null)
{
ResetSQLSource();
_geomSqlSrcBuilder = new StringBuilder();
_geomSqlSrcBuilderSELECT = new StringBuilder();
}
else
{
_geomSqlSrcBuilder.AppendLine();
_geomSqlSrcBuilderSELECT.AppendLine();
_geomSqlSrcBuilderSELECT.Append("UNION ALL ");
}
_geomSqlSrcBuilder.AppendFormat("DECLARE @g{0} geometry = geometry::STGeomFromText('{1}',{2})", ++_geomSqlSourceCount, geom.ToString(), geom.STSrid.Value);
// TODO: Prevent SQL injection with the label param
//SqlCommand com = new SqlCommand(string.Format("SELECT @g{0} AS geom, @Label AS Label", _geomSqlSourceCount));
//label = label ?? "Geom 'cool' " + _geomSqlSourceCount.ToString();
//com.Parameters.AddWithValue("@Label", label);
label = label ?? "Geometry " + _geomSqlSourceCount.ToString();
_geomSqlSrcBuilderSELECT.AppendFormat("SELECT @g{0} AS geom, '{1}' AS Label", _geomSqlSourceCount, label.Replace("'", "''"));
}
示例10: ToSharpMapGeometry
public static SMGeometry ToSharpMapGeometry(SqlGeometry geometry, Factory factory)
{
if (geometry == null) return null;
var fact = factory ?? Services.CreateGeometryFactory((int) geometry.STSrid);
if (geometry.STIsEmpty())
return fact.CreateGeometryCollection(null);
if (!geometry.STIsValid())
geometry.MakeValid();
OpenGisGeometryType geometryType = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), (string)geometry.STGeometryType());
switch (geometryType)
{
case OpenGisGeometryType.Point:
return SqlGeometryToSharpMapPoint(geometry, fact);
case OpenGisGeometryType.LineString:
return SqlGeometryToSharpMapLineString(geometry, fact);
case OpenGisGeometryType.Polygon:
return SqlGeometryToSharpMapPolygon(geometry, fact);
case OpenGisGeometryType.MultiPoint:
return SqlGeometryToSharpMapMultiPoint(geometry, fact);
case OpenGisGeometryType.MultiLineString:
return SqlGeometryToSharpMapMultiLineString(geometry, fact);
case OpenGisGeometryType.MultiPolygon:
return SqlGeometryToSharpMapMultiPolygon(geometry, fact);
case OpenGisGeometryType.GeometryCollection:
return SqlGeometryToSharpMapGeometryCollection(geometry, fact);
}
throw new ArgumentException(string.Format("Cannot convert SqlServer '{0}' to Sharpmap.Geometry", geometry.STGeometryType()), "geometry");
}
示例11: Area
public static SqlNumber Area(SqlGeometry geometry)
{
if (geometry == null || geometry.IsNull)
return SqlNumber.Null;
return geometry.Area;
}
示例12: getSectorCoverage
private void getSectorCoverage()
{
dc_tmap.ExecuteCommand(HandleTable.createCellTracing);
Console.WriteLine(dc_oss.SITE.Count());
foreach (var site in dc_oss.SITE)
{
if (site.latitude == null) continue;
CellCoverage cc = new CellCoverage();
#region 这里的算法复杂度高,仿真的过程比较复杂
cc.pre_rxlev = -94;
#endregion
sgeog = cc.MergePoint(site);
sgeom = SqlGeometry.STGeomFromWKB(sgeog.STAsBinary(), 4326).STConvexHull();
pencolor = HandleTable.getRandomPenColor(false, false, false);
CellTracing ct = new CellTracing();
ct.cell = site.cell;
ct.MI_STYLE = "Pen (1, 60," + pencolor.ToString() + ")";
ct.SP_GEOMETRY = sgeom;
sql = @" INSERT INTO [CELLTRACING]([cell],[MI_STYLE],[SP_GEOMETRY]) VALUES ('"
+ ct.cell + "','" + ct.MI_STYLE + "','" + ct.SP_GEOMETRY + "')";
dc_tmap.ExecuteCommand(sql);
}
}
示例13: SqlGeometryToGeometryMultiPoint
private static IGeometry SqlGeometryToGeometryMultiPoint(SqlGeometry geometry, GeometryFactory factory)
{
IPoint[] points = new IPoint[geometry.STNumGeometries().Value];
for (int i = 1; i <= points.Length; i++)
points[i - 1] = SqlGeometryToGeometryPoint(geometry.STGeometryN(i), factory);
return factory.CreateMultiPoint(points);
}
示例14: Contains
public static SqlBoolean Contains(SqlGeometry geometry, SqlGeometry other)
{
if (geometry == null || geometry.IsNull)
return SqlBoolean.Null;
return geometry.Contains(other);
}
示例15: SqlGeometryToGeometryMultiLineString
private static IMultiLineString SqlGeometryToGeometryMultiLineString(SqlGeometry geometry, GeometryFactory factory)
{
ILineString[] lineStrings = new ILineString[geometry.STNumGeometries().Value];
for (int i = 1; i <= lineStrings.Length; i++)
lineStrings[i - 1] = SqlGeometryToGeometryLineString(geometry.STGeometryN(i), factory);
return factory.CreateMultiLineString(lineStrings);
}