public Polygon GetPolygon(QLeaf leaf) { var id = GetPolygonId(leaf.Index.Y, leaf.Index.X); var pol = new Polygon(id, GetColor(leaf.Valor, leaf.Locked)); pol.AddPoint(new Point("0", leaf.Posicion.Longitud, leaf.Posicion.Latitud)); pol.AddPoint(new Point("1", leaf.Posicion.Longitud + HorizontalResolution, leaf.Posicion.Latitud)); pol.AddPoint(new Point("2", leaf.Posicion.Longitud + HorizontalResolution, leaf.Posicion.Latitud - VerticalResolution)); pol.AddPoint(new Point("3", leaf.Posicion.Longitud, leaf.Posicion.Latitud - VerticalResolution)); pol.AddPoint(new Point("4", leaf.Posicion.Longitud, leaf.Posicion.Latitud)); return(pol); }
private string SerializeQtree(QLeaf x, double hres, double vres) { return (string.Format("{{'id':'{0}','lon':{1},'lat':{2},'hres':{3},'vres':{4},'color':'{5}'}}", x.Index.Y.ToString() + "-" + x.Index.X.ToString(), x.Posicion.Longitud.ToString(CultureInfo.InvariantCulture), x.Posicion.Latitud.ToString(CultureInfo.InvariantCulture), hres.ToString(CultureInfo.InvariantCulture), vres.ToString(CultureInfo.InvariantCulture), System.Web.HttpUtility.JavaScriptStringEncode(HexColorUtil.ColorToHex(BaseQtree.GetColorForLevel(x.Valor))) ).Replace("'", "\"")); //return string.Format("{{ \"id\": '{0}{1}', \"lon\": {2}, \"lat\": {3}, \"hres\": {4}, \"vres\": {5}, \"color\": \"{6}\" }}", // x.Index.Y, // x.Index.X, // x.Posicion.Longitud.ToString(CultureInfo.InvariantCulture), // x.Posicion.Latitud.ToString(CultureInfo.InvariantCulture), // hres.ToString(CultureInfo.InvariantCulture), // vres.ToString(CultureInfo.InvariantCulture), // HexColorUtil.ColorToHex(BaseQtree.GetColorForLevel(x.Valor)) // ); }