private LineShape GetTangentForLinePosition(LineShape lineShape, double stationKM) { const double OFFSET_KM = 0.000000001; PointShape tangentPointShape1, tangentPointShape2; double offsetTangentStart = OFFSET_KM; double offsetTangentEnd = OFFSET_KM; LineShape tangentLineShape; if (stationKM == 0.0) { offsetTangentStart = 0.0; } if (stationKM == lineShape.GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer)) { offsetTangentEnd = 0.0; } tangentPointShape1 = lineShape.GetPointOnALine(StartingPoint.FirstPoint, stationKM - offsetTangentStart, GeographyUnit.Meter, DistanceUnit.Kilometer); tangentPointShape2 = lineShape.GetPointOnALine(StartingPoint.FirstPoint, stationKM + offsetTangentEnd, GeographyUnit.Meter, DistanceUnit.Kilometer); tangentLineShape = new LineShape(new Vertex[] { new Vertex(tangentPointShape1), new Vertex(tangentPointShape2) }); return(tangentLineShape); }
protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, Collection <SimpleCandidate> labelsInThisLayer, Collection <SimpleCandidate> labelsInAllLayers) { PointStyle pointStyle = new PointStyle(geoImage); foreach (Feature feature in features) { MultilineShape lineShape = (MultilineShape)feature.GetShape(); lineStyle.Draw(new BaseShape[] { lineShape }, canvas, labelsInThisLayer, labelsInAllLayers); List <Vertex> allVertices = lineShape.Lines.SelectMany(l => l.Vertices).ToList(); double totalDistance = 0; for (int i = 0; i < allVertices.Count - 1; i++) { PointShape pointShape1 = new PointShape(allVertices[i]); PointShape pointShape2 = new PointShape(allVertices[i + 1]); LineShape tempLineShape = new LineShape(); tempLineShape.Vertices.Add(allVertices[i]); tempLineShape.Vertices.Add(allVertices[i + 1]); double angle = GetAngleFromTwoVertices(allVertices[i], allVertices[i + 1]); // Left side if (imageDirection == ImageDirection.Left) { if (angle >= 270) { angle -= 180; } } // Right side else { if (angle <= 90) { angle += 180; } } pointStyle.RotationAngle = (float)angle; float screenDistance = ExtentHelper.GetScreenDistanceBetweenTwoWorldPoints(canvas.CurrentWorldExtent, pointShape1, pointShape2, canvas.Width, canvas.Height); double currentDistance = Math.Round(pointShape1.GetDistanceTo(pointShape2, canvas.MapUnit, DistanceUnit.Meter), 2); double worldInterval = (currentDistance * imageSpacing) / screenDistance; while (totalDistance <= currentDistance) { PointShape tempPointShape = tempLineShape.GetPointOnALine(StartingPoint.FirstPoint, totalDistance, canvas.MapUnit, DistanceUnit.Meter); pointStyle.Draw(new BaseShape[] { tempPointShape }, canvas, labelsInThisLayer, labelsInAllLayers); totalDistance = totalDistance + worldInterval; } totalDistance = totalDistance - currentDistance; } } }
protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, Collection <SimpleCandidate> labelsInThisLayer, Collection <SimpleCandidate> labelsInAllLayers) { PointStyle[] pointStyles = geoImages.Select(geoImage => { return(new PointStyle(geoImage) { DrawingLevel = DrawingLevel.LevelThree }); }).ToArray(); foreach (Feature feature in features) { LineShape lineShape = (LineShape)feature.GetShape(); lineStyle.Draw(new BaseShape[] { lineShape }, canvas, labelsInThisLayer, labelsInAllLayers); int index = 0; double totalDist = 0; for (int i = 0; i < lineShape.Vertices.Count - 1; i++) { PointShape pointShape1 = new PointShape(lineShape.Vertices[i]); PointShape pointShape2 = new PointShape(lineShape.Vertices[i + 1]); LineShape tempLineShape = new LineShape(); tempLineShape.Vertices.Add(lineShape.Vertices[i]); tempLineShape.Vertices.Add(lineShape.Vertices[i + 1]); double angle = GetAngleFromTwoVertices(lineShape.Vertices[i], lineShape.Vertices[i + 1]); //Left side if (side == SymbolSide.Left) { if (angle >= 270) { angle = angle - 180; } } //Right side else { if (angle <= 90) { angle = angle + 180; } } //pointStyle.RotationAngle = (float)angle; foreach (var pointStyle in pointStyles) { pointStyle.RotationAngle = (float)angle; } float screenDist = ExtentHelper.GetScreenDistanceBetweenTwoWorldPoints(canvas.CurrentWorldExtent, pointShape1, pointShape2, canvas.Width, canvas.Height); double currentDist = Math.Round(pointShape1.GetDistanceTo(pointShape2, canvas.MapUnit, DistanceUnit.Meter), 2); double worldInterval = (currentDist * spacing) / screenDist; while (totalDist <= currentDist) { PointStyle pointStyle = pointStyles[index % pointStyles.Length]; PointShape tempPointShape = tempLineShape.GetPointOnALine(StartingPoint.FirstPoint, totalDist, canvas.MapUnit, DistanceUnit.Meter); pointStyle.Draw(new BaseShape[] { tempPointShape }, canvas, labelsInThisLayer, labelsInAllLayers); totalDist = totalDist + worldInterval; index++; } totalDist = totalDist - currentDist; } } }