private IEnumerable <T> GetEntities <T>(string xpath, Action <XmlNode, T> action = null) where T : PowerEntity, new() { var entityList = new List <T>(); foreach (XmlNode item in _doc.DocumentElement.SelectNodes(xpath)) { long id = long.Parse(item.SelectSingleNode("Id").InnerText); string name = item.SelectSingleNode("Name").InnerText; double utmX = double.Parse(item.SelectSingleNode("X").InnerText, CultureInfo.InvariantCulture); double utmY = double.Parse(item.SelectSingleNode("Y").InnerText, CultureInfo.InvariantCulture); CoordinateConversion.ToLatLon(utmX, utmY, _zoneUtm, out double x, out double y); if (!LatitudeRange.IsInRange(x) || !LongitudeRange.IsInRange(y)) { continue; } var entity = new T() { Id = id, Name = name, X = x, Y = y }; action?.Invoke(item, entity); entityList.Add(entity); } return(entityList); }
public IEnumerable <LineEntity> GetLineEntities(string xpath = "/NetworkModel/Lines/LineEntity") { var lineEntities = new List <LineEntity>(); foreach (XmlNode node in _doc.DocumentElement.SelectNodes(xpath)) { var line = new LineEntity { Id = long.Parse(node.SelectSingleNode("Id").InnerText), Name = node.SelectSingleNode("Name").InnerText, IsUnderground = node.SelectSingleNode("IsUnderground").InnerText.Equals("true"), R = float.Parse(node.SelectSingleNode("R").InnerText), ConductorMaterial = node.SelectSingleNode("ConductorMaterial").InnerText, LineType = node.SelectSingleNode("LineType").InnerText, ThermalConstantHeat = long.Parse(node.SelectSingleNode("ThermalConstantHeat").InnerText), FirstEnd = long.Parse(node.SelectSingleNode("FirstEnd").InnerText), SecondEnd = long.Parse(node.SelectSingleNode("SecondEnd").InnerText) }; foreach (XmlNode pointNode in node.ChildNodes[LineEntityVerticesIndex].ChildNodes) { var p = new Point { X = double.Parse(pointNode.SelectSingleNode("X").InnerText), Y = double.Parse(pointNode.SelectSingleNode("Y").InnerText) }; CoordinateConversion.ToLatLon(p.X, p.Y, _zoneUtm, out var vertX, out var vertY); if (!LatitudeRange.IsInRange(vertX) || !LongitudeRange.IsInRange(vertY)) { continue; } line.Vertices.Add(new Point(vertX, vertY)); } lineEntities.Add(line); } return(lineEntities); }
public IGeographicMbr Intersection(IGeographicMbr other) { if (!LatitudeRange.Intersects(other.LatitudeRange)) { return(null); } var longitude = LongitudeRange.Intersection(other.LongitudeRange); if (longitude == null) { return(null); } var latitude = new Range( Math.Max(LatitudeRange.Low, other.LatitudeRange.Low), Math.Min(LatitudeRange.High, other.LatitudeRange.High)); return(new IntersectionResult { LatitudeRange = latitude, LongitudeRange = longitude }); }
public bool Within(IGeographicMbr other) { return(LongitudeRange.Within(other.LongitudeRange) && LatitudeRange.Within(other.LatitudeRange)); }
public bool Contains(EpsgArea other) { return(LongitudeRange.Contains(other.LongitudeRange) && LatitudeRange.Contains(other.LatitudeRange)); }
public bool Contains(IGeographicMbr other) { return(LongitudeRange.Contains(other.LongitudeRange) && LatitudeRange.Contains(other.LatitudeRange)); }
public bool Intersects(EpsgArea other) { return(LongitudeRange.Intersects(other.LongitudeRange) && LatitudeRange.Intersects(other.LatitudeRange)); }
public bool Intersects(IGeographicMbr other) { return(LongitudeRange.Intersects(other.LongitudeRange) && LatitudeRange.Intersects(other.LatitudeRange)); }
public bool Within(EpsgArea other) { return(LongitudeRange.Within(other.LongitudeRange) && LatitudeRange.Within(other.LatitudeRange)); }