本文整理汇总了C#中GeoAPI类的典型用法代码示例。如果您正苦于以下问题:C# GeoAPI类的具体用法?C# GeoAPI怎么用?C# GeoAPI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeoAPI类属于命名空间,在下文中一共展示了GeoAPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRenderInternal
/// <summary>
/// Method to place the street direction symbols
/// </summary>
/// <param name="map"></param>
/// <param name="lineString"></param>
/// <param name="graphics"></param>
private void OnRenderInternal(SharpMap.Map map, GeoAPI.Geometries.ILineString lineString,
System.Drawing.Graphics graphics)
{
var length = lineString.Length;
var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString);
if (length < RepeatInterval + ArrowLength)
{
var start = System.Math.Max(0, (length - ArrowLength)/2);
var end = System.Math.Min(length, (length + ArrowLength)/2);
var arrow = (GeoAPI.Geometries.ILineString) lil.ExtractLine(start, end);
RenderArrow(map, graphics, arrow);
return;
}
var numArrows = (int) ((lineString.Length - ArrowLength)/RepeatInterval);
var offset = (lineString.Length - numArrows*RepeatInterval - ArrowLength)*0.5;
while (offset + ArrowLength < lineString.Length)
{
var arrow = (GeoAPI.Geometries.ILineString) lil.ExtractLine(offset, offset + ArrowLength);
RenderArrow(map, graphics, arrow);
offset += RepeatInterval;
}
}
示例2: RenderArrow
/// <summary>
/// Method to render the arrow
/// </summary>
/// <param name="map">The map</param>
/// <param name="graphics">The graphics object</param>
/// <param name="arrow">The arrow</param>
private void RenderArrow(SharpMap.Map map, System.Drawing.Graphics graphics, GeoAPI.Geometries.ILineString arrow)
{
var pts = new System.Drawing.PointF[arrow.Coordinates.Length];
for (var i = 0; i < pts.Length; i++)
pts[i] = map.WorldToImage(arrow.GetCoordinateN(i));
graphics.DrawLines(ArrowPen, pts);
}
示例3: OnRenderInternal
protected override void OnRenderInternal(SharpMap.Map map, GeoAPI.Geometries.IPolygon polygon, System.Drawing.Graphics g)
{
var pt = polygon.Centroid;
g.RenderingOrigin =
System.Drawing.Point.Truncate(SharpMap.Utilities.Transform.WorldtoMap(pt.Coordinate, map));
base.OnRenderInternal(map, polygon, g);
}
示例4: GetPieChart
/// <summary>
/// Method for creating pie chart symbols
/// </summary>
/// <remarks>
/// <para>In this example we just create some random pie charts,
/// but it probably should be based on attributes read from the row.</para>
/// <para>Credits goes to gonzalo_ar for posting this in the forum</para></remarks>
/// <param name="row"></param>
/// <returns></returns>
private static Bitmap GetPieChart(GeoAPI.Features.IFeature row)
{
// Replace polygon with a center point (this is where we place the symbol
row.Geometry = row.Geometry.Centroid;
// Just for the example I use random values
int size = rand.Next(20, 35);
int angle1 = rand.Next(60, 180);
int angle2 = rand.Next(angle1 + 60, 300);
RectangleF rect = new RectangleF(0, 0, size, size);
Bitmap b = new Bitmap(size, size);
using (IGraphics g = Graphics.FromImage(b).G())
{
// Draw Pie
g.FillPie(Brushes.LightGreen, rect, 0, angle1);
g.FillPie(Brushes.Pink, rect, angle1, angle2 - angle1);
g.FillPie(Brushes.PeachPuff, rect, angle2, 360 - angle2);
// Draw Borders
g.DrawPie(Pens.Green, rect, 0, angle1);
g.DrawPie(Pens.Red, rect, angle1, angle2 - angle1);
g.DrawPie(Pens.Orange, rect, angle2, 360 - angle2);
}
return b;
}
示例5: PointsFromXml
/// <summary>
/// Creates an enumeration of <see cref="GeoAPI.Geometries.Coordinate"/>s from an xml string
/// </summary>
/// <param name="factory"></param>
/// <param name="xml">the xml string</param>
/// <returns>Coordinates</returns>
public static System.Collections.Generic.IEnumerable<GeoAPI.Geometries.IGeometry> PointsFromXml(
GeoAPI.Geometries.IGeometryFactory factory,
System.IO.Stream xml)
{
foreach (var coordinate in CoordinatesFromXml(xml))
yield return factory.CreatePoint(coordinate);
}
示例6: OnMouseUp
public void OnMouseUp(GeoAPI.Geometries.ICoordinate worldPosition, System.Windows.Forms.MouseEventArgs e)
{
if (enabled)
{
MessageBox.Show("Hallo Rob", "Demo MapTool");
}
}
示例7: FindGeoNearPoint
public static FeatureDataRow FindGeoNearPoint(GeoAPI.Geometries.IPoint point, VectorLayer layer, double amountGrow)
{
var box = new Envelope(point.Coordinate);
box.ExpandBy(amountGrow);
var fds = new FeatureDataSet();
layer.DataSource.ExecuteIntersectionQuery(box, fds);
FeatureDataRow result = null;
var minDistance = double.MaxValue;
foreach (FeatureDataTable fdt in fds.Tables)
{
foreach (FeatureDataRow fdr in fdt.Rows)
{
if (fdr.Geometry != null)
{
var distance = point.Distance(fdr.Geometry);
if (distance < minDistance)
{
result = fdr;
minDistance = distance;
}
}
}
}
return result;
}
示例8: GetCountryStyle
/// <summary>
/// This method is used for determining the style
/// It is used as a delegate for the CustomTheme class.
/// </summary>
/// <param name="row"></param>
/// <returns></returns>
private VectorStyle GetCountryStyle(GeoAPI.Features.IFeature row)
{
VectorStyle s = new VectorStyle();
s.Fill = new SolidBrush(Color.Green);
s.Symbol = GetPieChart(row);
return s;
}
示例9: JustTracks
public static bool JustTracks(GeoAPI.Features.IFeature fdr)
{
//System.Console.WriteLine(fdr [0] + ";"+ fdr[4]);
var s = fdr.Attributes[4] as string;
if (s != null)
return s == "track";
return true;
}
示例10: ToPolygon
internal static GeoAPI.Geometries.IGeometry ToPolygon(GeoAPI.Geometries.Envelope queryWindow)
{
return new NetTopologySuite.Geometries.Polygon(new NetTopologySuite.Geometries.LinearRing(new[] {
new GeoAPI.Geometries.Coordinate(queryWindow.MinX, queryWindow.MinY),
new GeoAPI.Geometries.Coordinate(queryWindow.MinX, queryWindow.MaxY),
new GeoAPI.Geometries.Coordinate(queryWindow.MaxX, queryWindow.MaxY),
new GeoAPI.Geometries.Coordinate(queryWindow.MaxX, queryWindow.MinY),
new GeoAPI.Geometries.Coordinate(queryWindow.MinX, queryWindow.MinY)}));
}
示例11: Geometry
public Geometry(GeoAPI.Geometries.IGeometry shape)
{
this.coordinates = new decimal[shape.Coordinates.Length][];
for(var i = 0; i < shape.Coordinates.Length; i++)
{
var coordinate = shape.Coordinates[i];
this.coordinates[i] = new decimal[2] { System.Convert.ToDecimal(coordinate.X), System.Convert.ToDecimal(coordinate.Y) };
}
}
示例12: mapBox1_GeometryDefined
void mapBox1_GeometryDefined(GeoAPI.Geometries.IGeometry geometry)
{
MessageBox.Show("Geometry defined!\r\n"+geometry);
geoProvider.Geometries.Add(geometry);
this.mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;
this.mapBox1.Refresh();
}
示例13: GetRotatedSymol
public SharpMap.Styles.VectorStyle GetRotatedSymol(GeoAPI.Features.IFeature row)
{
if (!System.String.IsNullOrEmpty(StyleRotationColumn))
try
{
SharpMap.Styles.VectorStyle dataStyle = CloneStyle(DefaultStyle);
dataStyle.SymbolRotation = System.Convert.ToSingle(row.Attributes[StyleRotationColumn]);
return dataStyle;
}
catch { }
return null;
}
示例14: CreateRectangle
public static GeoAPI.Geometries.ILinearRing CreateRectangle(GeoAPI.Geometries.IGeometryFactory factory,
GeoAPI.Geometries.Coordinate leftTop, GeoAPI.Geometries.Coordinate rightBottom)
{
var pts = new[]
{
leftTop,
new GeoAPI.Geometries.Coordinate(rightBottom.X, leftTop.Y),
rightBottom,
new GeoAPI.Geometries.Coordinate(leftTop.X, rightBottom.Y),
leftTop
};
return factory.CreateLinearRing(pts);
}
示例15: TransformBox
/// <summary>
/// Transforms a <see cref="Envelope"/>.
/// </summary>
/// <param name="box">BoundingBox to transform</param>
/// <param name="transform">Math Transform</param>
/// <returns>Transformed object</returns>
public static GeoAPI.Geometries.IEnvelope TransformBox(GeoAPI.Geometries.IEnvelope box, IMathTransform transform)
{
if (box == null)
return null;
double[][] corners = new double[4][];
corners[0] = transform.Transform(ToLightStruct(box.MinX, box.MinY)); //LL
corners[1] = transform.Transform(ToLightStruct(box.MaxX, box.MaxY)); //UR
corners[2] = transform.Transform(ToLightStruct(box.MinX, box.MaxY)); //UL
corners[3] = transform.Transform(ToLightStruct(box.MaxX, box.MinY)); //LR
IEnvelope result = GeometryFactory.CreateEnvelope();
foreach (double[] p in corners)
result.ExpandToInclude(p[0], p[1]);
return result;
}