public void CSVMap(int cityID) { Database database = new Database(); StringBuilder csv = new StringBuilder(); database.connect(); // TODO: Usar uma classe diferente, pode ser melhor SVGCartography c = database.Query.SVGMap(cityID); City cityInfo = database.Query.CityInfo(cityID); database.disconnect(); csv.Append("Nome Rua;X Início;Y Início;Z Início;X Fim;Y Fim;Z Fim"); foreach (SVGRoadSegment r in c.segments) { csv.AppendFormat("{0};{1};{2};{3};{4};{5};{6}", r.name, r.begin.x, r.begin.y, r.begin.z, r.end.x, r.end.y, r.end.z); csv.AppendLine(); } HttpContext.Current.Response.ContentType = "text/csv"; HttpContext.Current.Response.AddHeader("Content-disposition", "attachment;filename=" + cityInfo.cityName + ".csv"); HttpContext.Current.Response.HeaderEncoding = Encoding.UTF8; HttpContext.Current.Response.Write(csv.ToString()); HttpContext.Current.Response.Flush(); }
/// <summary> /// /// </summary> /// <param name="cityID"></param> /// <returns></returns> public SVGCartography SVGMap(int cityID) { SqlCommand command; SVGCartography cartography = new SVGCartography(); List <SVGRoadSegment> l = new List <SVGRoadSegment>(); SVGRoadSegment s; SqlParameter p1 = new SqlParameter("@IDCidade", SqlDbType.Int); p1.Value = cityID; command = new SqlCommand("SegmentosComInterseccoes", this.connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(p1); this.reader = command.ExecuteReader(); while (this.reader.Read()) { s = new SVGRoadSegment(); s.id = Int32.Parse(reader["ID"].ToString()); s.name = reader["NOME"].ToString(); // TODO: Faz um translate no XML em vez de adicionar 50.0 para retirar as posições negativas s.begin = new Vector3D(Double.Parse(reader["XInicio"].ToString()), Double.Parse(reader["YInicio"].ToString()), Double.Parse(reader["ZInicio"].ToString())); s.end = new Vector3D(Double.Parse(reader["XFim"].ToString()), Double.Parse(reader["YFim"].ToString()), Double.Parse(reader["ZFim"].ToString())); l.Add(s); } this.reader.Close(); List <PointOfInterest> p = new List <PointOfInterest>(); p = this.PointsOfInterest(cityID, true); cartography.segments = l; cartography.pointsOfInterest = p; cartography.cityName = "Nao Implementado"; return(cartography); }
public XmlDocument SVGMap(int cityID) { Database database = new Database(); XmlDocument xmldoc = new XmlDocument(); #region Doctype // TODO: Não está a inserir o doctype correctamente XmlDocumentType doctype = xmldoc.CreateDocumentType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", ""); xmldoc.AppendChild(doctype); #endregion #region Elemento Raiz XmlElement root = xmldoc.CreateElement("svg"); root.SetAttribute("width", "100%"); root.SetAttribute("height", "100%"); root.SetAttribute("version", "1.1"); root.SetAttribute("xmlns", "http://www.w3.org/2000/svg"); #endregion database.connect(); SVGCartography c = database.Query.SVGMap(cityID); database.disconnect(); #region Criação do Mapa em SVG XmlElement g; g = xmldoc.CreateElement("g"); g.SetAttribute("transform", "scale(5) translate(60,38) rotate(-90)"); XmlElement line; foreach (SVGRoadSegment s in c.segments) { line = xmldoc.CreateElement("line"); line.SetAttribute("x1", s.begin.x.ToString()); line.SetAttribute("y1", s.begin.z.ToString()); line.SetAttribute("x2", s.end.x.ToString()); line.SetAttribute("y2", s.end.z.ToString()); line.SetAttribute("style", "stroke:rgb(99,99,99);stroke-width:1"); g.AppendChild(line); } XmlElement circle; foreach (PointOfInterest p in c.pointsOfInterest) { circle = xmldoc.CreateElement("circle"); // TODO: Aqui também deves fazer o translate circle.SetAttribute("cx", p.position.x.ToString()); circle.SetAttribute("cy", p.position.z.ToString()); circle.SetAttribute("r", "1"); circle.SetAttribute("stroke", "black"); circle.SetAttribute("stroke-width", "0.2"); circle.SetAttribute("fill", "red"); g.AppendChild(circle); } root.AppendChild(g); xmldoc.AppendChild(root); #endregion return(xmldoc); }
/// <summary> /// /// </summary> /// <param name="cityID"></param> /// <returns></returns> public SVGCartography SVGMap(int cityID) { SqlCommand command; SVGCartography cartography = new SVGCartography(); List<SVGRoadSegment> l = new List<SVGRoadSegment>(); SVGRoadSegment s; SqlParameter p1 = new SqlParameter("@IDCidade", SqlDbType.Int); p1.Value = cityID; command = new SqlCommand("SegmentosComInterseccoes", this.connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(p1); this.reader = command.ExecuteReader(); while (this.reader.Read()) { s = new SVGRoadSegment(); s.id = Int32.Parse(reader["ID"].ToString()); s.name = reader["NOME"].ToString(); // TODO: Faz um translate no XML em vez de adicionar 50.0 para retirar as posições negativas s.begin = new Vector3D(Double.Parse(reader["XInicio"].ToString()), Double.Parse(reader["YInicio"].ToString()), Double.Parse(reader["ZInicio"].ToString())); s.end = new Vector3D(Double.Parse(reader["XFim"].ToString()), Double.Parse(reader["YFim"].ToString()), Double.Parse(reader["ZFim"].ToString())); l.Add(s); } this.reader.Close(); List<PointOfInterest> p = new List<PointOfInterest>(); p = this.PointsOfInterest(cityID, true); cartography.segments = l; cartography.pointsOfInterest = p; cartography.cityName = "Nao Implementado"; return cartography; }