public void MarkContour(OsmWay isohypseWay, Isohypse isohypse) { if (isohypseWay == null) { throw new ArgumentNullException("isohypseWay"); } if (isohypse == null) { throw new ArgumentNullException("isohypse"); } firstMarker.MarkContour(isohypseWay, isohypse); double elevation = Math.Round(isohypse.Elevation / elevationUnits); string contourValue = null; if (elevation % majorFactor == 0) { contourValue = "elevation_major"; } else if (elevation % mediumFactor == 0) { contourValue = "elevation_medium"; } else { contourValue = "elevation_minor"; } isohypseWay.SetTag("contour_ext", contourValue); }
public void MarkContour(OsmWay isohypseWay, Isohypse isohypse) { if (isohypseWay == null) { throw new ArgumentNullException("isohypseWay"); } if (isohypse == null) { throw new ArgumentNullException("isohypse"); } double elevation = Math.Round(isohypse.Elevation / elevationUnits); isohypseWay.SetTag("ele", elevation.ToString(System.Globalization.CultureInfo.InvariantCulture)); isohypseWay.SetTag("contour", "elevation"); }
abstract public void ProcessIsohypse(Isohypse isohypse, NextIdCallback nodeCallback, NextIdCallback wayCallback);
public override void ProcessIsohypse(Isohypse isohypse, NextIdCallback nodeCallback, NextIdCallback wayCallback) { if (writer == null) { throw new InvalidOperationException("The Begin method must be called before calling ProcessIsohypse."); } if (isohypse == null) { throw new ArgumentNullException("isohypse"); } foreach (Polyline polyline in isohypse.Segments) { OsmUtils.OsmSchema.osmWay way = new osmWay(); settings.ContourMarker.MarkContour(way, isohypse); way.Id = wayCallback(); way.Nd = new List <osmWayND> (); way.Timestamp = DateTime.UtcNow.ToString("o", System.Globalization.CultureInfo.InvariantCulture); way.Version = 1; way.User = settings.UserName; way.Uid = settings.UserId; way.Changeset = settings.ChangesetId; long firstWayNodeId = 0; for (int i = 0; i < polyline.Vertices.Count; i++) { Point3 <double> point = polyline.Vertices[i]; OsmUtils.OsmSchema.osmNode node = new osmNode(); node.Id = nodeCallback(); node.Lat = point.Y + settings.LatitudeCorrection; node.Lon = point.X + settings.LongitudeCorrection; node.Timestamp = DateTime.UtcNow.ToString("o", System.Globalization.CultureInfo.InvariantCulture); node.Version = 1; node.User = settings.UserName; node.Uid = settings.UserId; node.Changeset = settings.ChangesetId; // Do explicity set the Lat- / LonSpecified properties. // Otherwise the lat / lon XML attributes would not get written, if the node has // a latitude or longitude of exactly 0°. node.LatSpecified = true; node.LonSpecified = true; if (i == 0) { firstWayNodeId = node.Id; } nodeSerializer.Serialize(writer, node, ns); way.Nd.Add(new osmWayND(node.Id, true)); // Split the way if the maximum node count per way is reached. if (way.Nd.Count == settings.MaxWayNodes && polyline.VerticesCount > settings.MaxWayNodes) { // Don't create a new way if already at the end of the *unclosed* polyline if (i == polyline.VerticesCount - 1 && !polyline.IsClosed) { continue; } // first, serialize old way waySerializer.Serialize(writer, way, ns); way = new osmWay(); way.Id = wayCallback(); way.Nd = new List <osmWayND> (); way.Timestamp = DateTime.UtcNow.ToString("o", System.Globalization.CultureInfo.InvariantCulture); way.Version = 1; way.User = settings.UserName; way.Uid = settings.UserId; way.Changeset = settings.ChangesetId; settings.ContourMarker.MarkContour(way, isohypse); way.Nd.Add(new osmWayND(node.Id, true)); } } // if the isohypse segment is closed, add the first node as the final node of the way if (polyline.IsClosed) { way.Nd.Add(new osmWayND(firstWayNodeId, true)); } waySerializer.Serialize(writer, way, ns); } }
public override void ProcessIsohypse(Isohypse isohypse, NextIdCallback nodeCallback, NextIdCallback wayCallback) { foreach (Polyline polyline in isohypse.Segments) { OsmWay isohypseWay = new OsmWay(wayCallback()); isohypseWay.Visible = true; isohypseWay.Timestamp = DateTime.UtcNow; isohypseWay.User = this.user; isohypseWay.ChangesetId = settings.ChangesetId; settings.ContourMarker.MarkContour(isohypseWay, isohypse); osmDb.AddWay(isohypseWay); long firstWayNodeId = 0; for (int i = 0; i < polyline.VerticesCount; i++) { Point3 <double> point = polyline.Vertices[i]; OsmNode node = new OsmNode(nodeCallback(), point.Y + settings.LongitudeCorrection, point.X + settings.LatitudeCorrection); node.Visible = true; node.Timestamp = DateTime.UtcNow; node.User = this.user; node.ChangesetId = settings.ChangesetId; osmDb.AddNode(node); if (i == 0) { firstWayNodeId = node.ObjectId; } isohypseWay.AddNode(node.ObjectId); // Split the polyline if the maximum node count per way is reached. if (isohypseWay.NodesList.Count == settings.MaxWayNodes && polyline.VerticesCount > settings.MaxWayNodes) { // Don't create a new way if already at the end of the *unclosed* polyline if (i == polyline.VerticesCount - 1 && !polyline.IsClosed) { continue; } isohypseWay = new OsmWay(wayCallback()); isohypseWay.Visible = true; isohypseWay.Timestamp = DateTime.UtcNow; isohypseWay.User = this.user; isohypseWay.ChangesetId = settings.ChangesetId; settings.ContourMarker.MarkContour(isohypseWay, isohypse); osmDb.AddWay(isohypseWay); isohypseWay.AddNode(node.ObjectId); } } // if the isohypse segment is closed, add the first node as the final node of the way if (polyline.IsClosed) { isohypseWay.AddNode(firstWayNodeId); } } }