本文整理匯總了C#中OsmSharp.Math.Geo.GeoCoordinateBox類的典型用法代碼示例。如果您正苦於以下問題:C# GeoCoordinateBox類的具體用法?C# GeoCoordinateBox怎麽用?C# GeoCoordinateBox使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GeoCoordinateBox類屬於OsmSharp.Math.Geo命名空間,在下文中一共展示了GeoCoordinateBox類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Succes
public override void Succes()
{
var poisPoint = (this.FinalMessages[this.FinalMessages.Count - 1] as MicroPlannerMessagePoint).Point;
var previousArc = (this.FinalMessages[this.FinalMessages.Count - 2] as MicroPlannerMessageArc).Arc;
// get the pois list.
var pois = (this.FinalMessages[this.FinalMessages.Count - 1] as MicroPlannerMessagePoint).Point.Points;
// get the angle from the pois point.
var direction = poisPoint.Angle;
// calculate the box.
var coordinates = new List<GeoCoordinate>();
foreach (Routing.ArcAggregation.Output.PointPoi poi in pois)
{
coordinates.Add(poi.Location);
}
coordinates.Add(poisPoint.Location);
var box = new GeoCoordinateBox(coordinates.ToArray());
// let the scentence planner generate the correct information.
var metaData = new Dictionary<string, object>();
metaData["direction"] = direction;
metaData["pois"] = pois;
metaData["type"] = "poi";
this.Planner.SentencePlanner.GenerateInstruction(metaData, poisPoint.EntryIdx, box, pois);
}
示例2: GenerateInstruction
/// <summary>
/// Generates an instruction from the given meta data and given pois.
/// </summary>
/// <param name="metaData"></param>
/// <param name="firstSegmentIdx"></param>
/// <param name="lastSegmentIdx"></param>
/// <param name="box"></param>
/// <param name="pois"></param>
public void GenerateInstruction(Dictionary<string, object> metaData, int firstSegmentIdx, int lastSegmentIdx, GeoCoordinateBox box, List<PointPoi> pois)
{
string text;
if (_generator.Generate(metaData, out text))
{ // add the instruction to the instructions list.
_instructions.Add(new Instruction(metaData, firstSegmentIdx, lastSegmentIdx, box, text, pois));
}
}
示例3: Test
/// <summary>
/// Tests the live routing.
/// </summary>
public static void Test()
{
var box = new GeoCoordinateBox(
new GeoCoordinate(51.20190, 4.66540),
new GeoCoordinate(51.30720, 4.89820));
LiveRoutingTest.TestSerializedRouting("LiveRouting",
"kempen-big.osm.pbf", box, 2500);
}
示例4: Test
/// <summary>
/// Tests routing from a serialized routing file.
/// </summary>
public static void Test(Stream stream, int testCount)
{
GeoCoordinateBox box = new GeoCoordinateBox(
new GeoCoordinate(51.20190, 4.66540),
new GeoCoordinate(51.30720, 4.89820));
CHSerializedRoutingTest.TestSerializedRouting("CHSerializedRouting",
stream, box, testCount);
}
示例5: TestResolved
/// <summary>
/// Tests routing from a serialized routing file.
/// </summary>
public static void TestResolved(string name, string osmPbfFile, GeoCoordinateBox box, int testCount)
{
var testFile = new FileInfo(string.Format(@".\TestFiles\{0}", osmPbfFile));
var stream = testFile.OpenRead();
RoutingResolveTest.TestResolved(name, stream, box, testCount);
stream.Dispose();
}
示例6: OsmStreamFilterPoly
/// <summary>
/// Creates a new polygon filter.
/// </summary>
public OsmStreamFilterPoly(OsmSharp.Geo.Geometries.LineairRing poly)
: base()
{
if (poly == null) { throw new ArgumentNullException("poly"); }
_poly = poly;
_box = new GeoCoordinateBox(poly.Coordinates);
this.Meta.Add("poly", OsmSharp.Geo.Streams.GeoJson.GeoJsonConverter.ToGeoJson(_poly));
}
示例7: Instruction
/// <summary>
/// Creates a new instruction with a location and points of interest.
/// </summary>
/// <param name="metaData"></param>
/// <param name="segmentIdx"></param>
/// <param name="location"></param>
/// <param name="text"></param>
/// <param name="pois"></param>
public Instruction(Dictionary<string, object> metaData, int segmentIdx, GeoCoordinateBox location, string text, List<PointPoi> pois)
{
this.SegmentIdx = segmentIdx;
this.Location = location;
this.Pois = pois;
this.MetaData = metaData;
this.Text = text;
this.Pois = new List<PointPoi>();
}
示例8: Succes
public override void Succes()
{
OsmSharp.Routing.ArcAggregation.Output.AggregatedPoint poisPoint = (this.FinalMessages[this.FinalMessages.Count - 1] as MicroPlannerMessagePoint).Point;
List<Routing.ArcAggregation.Output.PointPoi> pois =
(this.FinalMessages[this.FinalMessages.Count - 1] as MicroPlannerMessagePoint).Point.Points;
// construct the box indicating the location of the resulting find by this machine.
GeoCoordinate point1 = pois[0].Location;
GeoCoordinateBox box = new GeoCoordinateBox(
new GeoCoordinate(point1.Latitude - 0.001f, point1.Longitude - 0.001f),
new GeoCoordinate(point1.Latitude + 0.001f, point1.Longitude + 0.001f));
// let the scentence planner generate the correct information.
this.Planner.SentencePlanner.GeneratePoi(poisPoint.EntryIdx, box, pois, null);
}
示例9: TestRenderScene
/// <summary>
/// Tests rendering the given serialized scene.
/// </summary>
/// <param name="stream"></param>
/// <param name="box"></param>
/// <param name="testCount"></param>
public static void TestRenderScene(Stream stream, GeoCoordinateBox box, int testCount)
{
WebMercator projection = new WebMercator();
// build a map.
Map map = new Map();
IScene2DPrimitivesSource sceneSource = Scene2DLayered.Deserialize(stream, true);
LayerScene layerScene = map.AddLayerScene(sceneSource);
// build the target to render to.
Bitmap imageTarget = new Bitmap(TargetWidth, TargetHeight);
Graphics target = Graphics.FromImage(imageTarget);
target.SmoothingMode = SmoothingMode.HighQuality;
target.PixelOffsetMode = PixelOffsetMode.HighQuality;
target.CompositingQuality = CompositingQuality.HighQuality;
target.InterpolationMode = InterpolationMode.HighQualityBicubic;
MapRenderer<Graphics> mapRenderer = new MapRenderer<Graphics>(
new GraphicsRenderer2D());
// render the map.
PerformanceInfoConsumer performanceInfo = new PerformanceInfoConsumer("Scene2DLayeredRendering");
performanceInfo.Start();
performanceInfo.Report("Rendering {0} random images...", testCount);
while (testCount > 0)
{
// randomize view.
int zoom = OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(10) + 10;
GeoCoordinate center = box.GenerateRandomIn();
View2D view = mapRenderer.Create(TargetWidth, TargetHeight, map,
(float)projection.ToZoomFactor(zoom), center, false, true);
layerScene.ViewChanged(map, (float)projection.ToZoomFactor(zoom), center, view);
mapRenderer.Render(target, map, view);
if (WriteResults)
{
imageTarget.Save(Guid.NewGuid().ToString() + ".png", ImageFormat.Png);
}
testCount--;
}
performanceInfo.Stop();
}
示例10: AddPoint
/// <summary>
/// Adds a point.
/// </summary>
public void AddPoint(GeoCoordinate coordinate, float sizePixels, int color)
{
if (coordinate == null) { throw new ArgumentNullException(); }
// update envelope.
if (_envelope == null)
{ // create initial envelope.
_envelope = new GeoCoordinateBox(coordinate, coordinate);
}
// also include the current point.
_envelope.ExpandWith(coordinate);
double[] projectedCoordinates = _projection.ToPixel(coordinate);
uint pointId = _scene.AddPoint(projectedCoordinates[0], projectedCoordinates[1]);
_scene.AddStylePoint(pointId, 0, float.MinValue, float.MaxValue, color, sizePixels);
this.RaiseLayerChanged();
}
示例11: TestSerializedRouting
/// <summary>
/// Tests routing from a serialized routing file.
/// </summary>
/// <param name="name"></param>
/// <param name="stream"></param>
/// <param name="box"></param>
/// <param name="testCount"></param>
public static void TestSerializedRouting(string name, Stream stream,
GeoCoordinateBox box, int testCount)
{
var router = Router.CreateLiveFrom(new OsmSharp.Osm.PBF.Streams.PBFOsmStreamSource(stream),
new OsmRoutingInterpreter());
var performanceInfo = new PerformanceInfoConsumer("LiveRouting");
performanceInfo.Start();
performanceInfo.Report("Routing {0} routes...", testCount);
int successCount = 0;
int totalCount = testCount;
float latestProgress = -1;
while (testCount > 0)
{
var from = box.GenerateRandomIn();
var to = box.GenerateRandomIn();
var fromPoint = router.Resolve(Vehicle.Car, from);
var toPoint = router.Resolve(Vehicle.Car, to);
if (fromPoint != null && toPoint != null)
{
var route = router.Calculate(Vehicle.Car, fromPoint, toPoint);
if (route != null)
{
successCount++;
}
}
testCount--;
// report progress.
float progress = (float)System.Math.Round(((double)(totalCount - testCount) / (double)totalCount) * 100);
if (progress != latestProgress)
{
OsmSharp.Logging.Log.TraceEvent("LiveEdgePreprocessor", TraceEventType.Information,
"Routing... {0}%", progress);
latestProgress = progress;
}
}
performanceInfo.Stop();
OsmSharp.Logging.Log.TraceEvent("LiveRouting", OsmSharp.Logging.TraceEventType.Information,
string.Format("{0}/{1} routes successfull!", successCount, totalCount));
}
示例12: Succes
public override void Succes()
{
var poisPoint = (this.FinalMessages[this.FinalMessages.Count - 1] as MicroPlannerMessagePoint).Point;
var pois = (this.FinalMessages[this.FinalMessages.Count - 1] as MicroPlannerMessagePoint).Point.Points;
// construct the box indicating the location of the resulting find by this machine.
var point1 = pois[0].Location;
var box = new GeoCoordinateBox(
new GeoCoordinate(point1.Latitude - 0.001f, point1.Longitude - 0.001f),
new GeoCoordinate(point1.Latitude + 0.001f, point1.Longitude + 0.001f));
// let the scentence planner generate the correct information.
var metaData = new Dictionary<string, object>();
metaData["direction"] = null;
metaData["pois"] = pois;
metaData["type"] = "poi";
this.Planner.SentencePlanner.GenerateInstruction(metaData, poisPoint.EntryIdx, box, pois);
}
示例13: Succes
public override void Succes()
{
OsmSharp.Routing.ArcAggregation.Output.AggregatedPoint poisPoint = (this.FinalMessages[this.FinalMessages.Count - 1] as MicroPlannerMessagePoint).Point;
OsmSharp.Routing.ArcAggregation.Output.AggregatedArc previousArc = (this.FinalMessages[this.FinalMessages.Count - 2] as MicroPlannerMessageArc).Arc;
// get the pois list.
List<Routing.ArcAggregation.Output.PointPoi> pois = (this.FinalMessages[this.FinalMessages.Count - 1] as MicroPlannerMessagePoint).Point.Points;
// get the angle from the pois point.
RelativeDirection direction = poisPoint.Angle;
// calculate the box.
List<GeoCoordinate> coordinates = new List<GeoCoordinate>();
foreach (Routing.ArcAggregation.Output.PointPoi poi in pois)
{
coordinates.Add(poi.Location);
}
coordinates.Add(poisPoint.Location);
GeoCoordinateBox box = new GeoCoordinateBox(coordinates.ToArray());
// let the scentence planner generate the correct information.
this.Planner.SentencePlanner.GeneratePoi(poisPoint.EntryIdx, box, pois, direction);
}
示例14: BuildScene
/// <summary>
/// Builds the scene.
/// </summary>
/// <param name="map"></param>
/// <param name="zoomFactor"></param>
/// <param name="center"></param>
/// <param name="view"></param>
private void BuildScene(Map map, float zoomFactor, GeoCoordinate center, View2D view)
{
// build the boundingbox.
var viewBox = view.OuterBox;
var box = new GeoCoordinateBox (map.Projection.ToGeoCoordinates (viewBox.Min [0], viewBox.Min [1]),
map.Projection.ToGeoCoordinates (viewBox.Max [0], viewBox.Max [1]));
var zoomLevel = (int)map.Projection.ToZoomLevel (zoomFactor);
if (_lastBox != null && _lastBox.Contains (box) &&
zoomLevel == _lastZoom) {
return;
}
_lastBox = box;
_lastZoom = zoomLevel;
// reset the scene.
_scene2DSimple = new Scene2DSimple();
// get from the index.
this.Scene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
lock (_sync) {
_index.Get (_scene2DSimple, view, zoomFactor);
}
}
示例15: AddPolygon
/// <summary>
/// Adds a polyline.
/// </summary>
/// <param name="points"></param>
/// <param name="color"></param>
/// <param name="width"></param>
/// <param name="fill"></param>
/// <returns></returns>
public void AddPolygon(GeoCoordinate[] points, int color, float width, bool fill)
{
var x = new double[points.Length];
var y = new double[points.Length];
for (int idx = 0; idx < points.Length; idx++)
{
// update envelope.
if (_envelope == null)
{ // create initial envelope.
_envelope = new GeoCoordinateBox(points[idx], points[idx]);
}
// also include the current point.
_envelope.ExpandWith(points[idx]);
var projected = _projection.ToPixel(points[idx]);
x[idx] = projected[0];
y[idx] = projected[1];
}
var pointsId = _scene.AddPoints(x, y);
if (pointsId.HasValue)
{
_scene.AddStylePolygon(pointsId.Value, 0, float.MinValue, float.MaxValue, color, width, fill);
this.RaiseLayerChanged();
}
}