void Monitor_ContextMenuPostback(object sender, PostbackEventArgs e) { if (!Directory.Exists(QtreeFullPath)) { return; } if (e.CommandArguments == "Info" && btInfo.Enabled) { ChangeState(QtreeEditorState.Info); ShowLeafInfo(e.Latitud, e.Longitud); } else if (e.CommandArguments == "ColorPick" && btPickColor.Enabled) { SelectColor(e.Latitud, e.Longitud); } else if (e.CommandArguments == "Lock" && btEdit.Enabled) { ToggleLock(e.Latitud, e.Longitud); } else if (e.CommandArguments == "Paint" && btEdit.Enabled) { using (var qtree = BaseQtree.Open(QtreeFullPath, Format)) { var leaf = qtree.GetQLeaf(e.Latitud, e.Longitud); Monitor.AddGeometries(LayerGeocercas, GetPolygon(leaf)); } } }
private QLeaf GetQleaf(double latitud, double longitud) { using (var qtree = BaseQtree.Open(QtreeFullPath, Format)) { return(qtree.GetQLeaf(latitud, longitud)); } }
private void DrawPolygon(List <PointF> points) { using (var qtree = BaseQtree.Open(QtreeFullPath, Format)) { var changed = qtree.PaintPolygon(points, SelectedNivel, LockCells); AddLeaves(changed); } }
private void DrawPoint(double latitud, double longitud) { using (var qtree = BaseQtree.Open(QtreeFullPath, Format)) { var changed = qtree.Paint(latitud, longitud, SelectedBrushSize, SelectedNivel, LockCells); AddLeaves(changed); } }
public void Generate(BaseQtree qtree) { var cartografia = new Cartografia(Config.Map.MapFilesDirectory); foreach (var mapa in cartografia.Mapas) { Generate(qtree, mapa); } }
public Box(double top, double bottom, double left, double right, BaseQtree qtree) { var newTl = qtree.GetIndex(top, left); var newBr = qtree.GetIndex(bottom, right); Top = newTl.Y + 1; Bottom = newBr.Y; Left = newTl.X; Right = newBr.X + 1; }
private void ToggleLock(double latitud, double longitud) { using (var qtree = BaseQtree.Open(QtreeFullPath, Format)) { var leaf = qtree.GetQLeaf(latitud, longitud); leaf = qtree.SetLock(latitud, longitud, !leaf.Locked); if (leaf != null) { AddLeaves(new [] { leaf }); } } }
private static bool IsIncludedInQtree(Mapa mapa, BaseQtree qtree) { var header = mapa.Header; var minlat = Util.LatitudFromWorldCoord(header.YMin); var maxlat = Util.LatitudFromWorldCoord(header.YMax); var minlon = Util.LongitudFromWorldCoord(header.XMin); var maxlon = Util.LongitudFromWorldCoord(header.XMax); var bottom = Math.Min(minlat, maxlat); var top = Math.Max(minlat, maxlat); var left = Math.Min(minlon, maxlon); var right = Math.Max(minlon, maxlon); return(qtree.IsInsideQtree(top, bottom, left, right)); }
protected Box[] SetBounds(Bounds newBounds, out Box[] toDelete) { using (var qtree = BaseQtree.Open(QtreeFullPath, Format)) { var oldBounds = Bounds; Bounds = newBounds; toDelete = new Box[0]; var newBox = qtree.GetBoxFromBounds(newBounds.Top, newBounds.Bottom, newBounds.Left, newBounds.Right); if (oldBounds == null) { return new[] { newBox } } ; var oldBox = qtree.GetBoxFromBounds(oldBounds.Top, oldBounds.Bottom, oldBounds.Left, oldBounds.Right); var bounds = new List <Box>(4); var boundsToDelete = new List <Box>(4); if (newBounds.Top > oldBounds.Top) { bounds.Add(new Box(newBox.Top, oldBox.Top, newBox.Left, newBox.Right)); boundsToDelete.Add(new Box(newBox.Bottom, oldBox.Bottom, oldBox.Left, oldBox.Right)); } if (newBounds.Bottom < oldBounds.Bottom) { bounds.Add(new Box(oldBox.Bottom, newBox.Bottom, newBox.Left, newBox.Right)); boundsToDelete.Add(new Box(oldBox.Top, newBox.Top, oldBox.Left, oldBox.Right)); } if (newBounds.Left < oldBounds.Left) { bounds.Add(new Box(Math.Min(oldBox.Top, newBox.Top), Math.Max(newBox.Bottom, oldBox.Bottom), newBox.Left, oldBox.Left)); boundsToDelete.Add(new Box(Math.Min(oldBox.Top, newBox.Top), Math.Max(newBox.Bottom, oldBox.Bottom), newBox.Right, oldBox.Right)); } if (newBounds.Right > oldBounds.Right) { bounds.Add(new Box(Math.Min(oldBox.Top, newBox.Top), Math.Max(newBox.Bottom, oldBox.Bottom), oldBox.Right, newBox.Right)); boundsToDelete.Add(new Box(Math.Min(oldBox.Top, newBox.Top), Math.Max(newBox.Bottom, oldBox.Bottom), oldBox.Left, newBox.Left)); } toDelete = boundsToDelete.ToArray(); return(bounds.ToArray()); } }
protected void btnGenerarOnClick(object sender, EventArgs e) { var vehicle = DAOFactory.CocheDAO.FindById(ddlMovil.Selected); if (vehicle.Dispositivo == null) { return; } var qtreeDir = DAOFactory.DetalleDispositivoDAO.GetQtreeFileNameValue(vehicle.Dispositivo.Id); var qtreeType = DAOFactory.DetalleDispositivoDAO.GetQtreeTypeValue(vehicle.Dispositivo.Id); if (string.IsNullOrEmpty(qtreeType) || !Enum.IsDefined(typeof(QtreeFormats), qtreeType)) { return; } var qtreeFormat = (QtreeFormats)Enum.Parse(typeof(QtreeFormats), qtreeType); qtreeDir = Path.Combine(qtreeFormat.Equals(QtreeFormats.Gte) ? Config.Qtree.QtreeGteDirectory : Config.Qtree.QtreeTorinoDirectory, qtreeDir); var maxMonths = vehicle.Empresa.MesesConsultaPosiciones; var positions = DAOFactory.RoutePositionsDAO.GetPositions(vehicle.Id, dtDesde.SelectedDate.Value.ToDataBaseDateTime(), dtHasta.SelectedDate.Value.ToDataBaseDateTime(), maxMonths); using (var qtree = BaseQtree.Open(qtreeDir, qtreeFormat)) { for (var i = 1; i < positions.Count; i++) { var ini = positions[i - 1]; var fin = positions[i]; var qs = qtree.MakeLeafLine(ini.Longitude, ini.Latitude, fin.Longitude, fin.Latitude, 2); foreach (var item in qs) { var latlon = qtree.GetCenterLatLon(item.Posicion); qtree.SetValue(latlon.Latitud, latlon.Longitud, lvlSel.SelectedLevel); qtree.Commit(); } } qtree.Close(); } btnSearch_Click(sender, e); }
private void Generate(BaseQtree qtree, Mapa mapa) { if (!IsIncludedInQtree(mapa, qtree)) { return; } for (var j = mapa.Poligonales.Count - 1; j >= 0; j--) { var poligonal = mapa.Poligonales[j]; if (!Drawable(poligonal.Nivel)) { continue; } var vertices = mapa.Poligonales.GetVertices(j); LonLat last = null; var drawNext = true; foreach (var vertice in vertices) { var lonlat = new LonLat(mapa.Coords[Math.Abs(vertice)]); if (last != null && drawNext) { var qs = qtree.MakeLeafLine(last.Longitud, last.Latitud, lonlat.Longitud, lonlat.Latitud, GetNivel(poligonal.Nivel).BrushSize); for (var i = 0; i < qs.Count; i++) { var leaf = qs[i]; if (!leaf.Locked && CanOverwrite(poligonal.Nivel, leaf.Valor) && qtree.IsInsideQtree(leaf.Posicion.Latitud, leaf.Posicion.Longitud)) { var latlon = qtree.GetCenterLatLon(leaf.Posicion); qs[i] = qtree.SetValue(latlon.Latitud, latlon.Longitud, GetNivel(poligonal.Nivel).NivelQtree); qtree.Commit(); } } } last = lonlat; drawNext = vertice > 0; } } }
protected void ShowQTree(Box box) { using (var qtree = BaseQtree.Open(QtreeFullPath, Format)) { for (var i = box.Bottom; i < box.Top; i++) { for (var j = box.Left; j < box.Right; j++) { var latlon = qtree.GetCenterLatLon(new QIndex { Y = i, X = j }); var leaf = qtree.GetQLeaf(latlon.Latitud, latlon.Longitud); if (leaf == null) { continue; } Monitor.AddGeometries(LayerGeocercas, GetPolygon(leaf)); } } } }
protected void btAutoGen_Click(object sender, EventArgs e) { if (!Directory.Exists(QtreeFullPath)) { return; } Box box = null; using (var qtree = BaseQtree.Open(QtreeFullPath, Format)) { qtree.AutoGenerator.Niveles = autoGenConfig.GetNiveles(); qtree.Generate(); if (Bounds != null) { box = qtree.GetBoxFromBounds(Bounds.Top, Bounds.Bottom, Bounds.Left, Bounds.Right); } } if (Bounds != null) { ShowQTree(box); } }
private void InitializeQtree() { Format = SelectedFormat; SelectQtree(QtreeName); if (!Directory.Exists(QtreeFullPath)) { return; } using (var qtree = BaseQtree.Open(QtreeFullPath, Format)) { HorizontalResolution = qtree.HorizontalResolution; VerticalResolution = qtree.VerticalResolution; lblQtreeName.Text = QtreeName; lblPosicionLat.Text = qtree.Top.ToString("0.0000000"); lblPosicionLon.Text = qtree.Left.ToString("0.0000000"); //lblGridSize.Text = string.Format("{0} x {1}", qtree.Width, qtree.Height); lblCellWidth.Text = (qtree.HorizontalResolution * 10000000).ToString(); lblCellHeight.Text = (qtree.VerticalResolution * 10000000).ToString(); //lblSectorCount.Text = qtree.FileSectorCount.ToString("0"); } Monitor.ZoomTo(InitialZoomLevel); ChangeState(QtreeEditorState.None); }
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)) // ); }
private void Monitor_ContextMenuPostback(object sender, PostbackEventArgs e) { if (Mobile.Get() <= 0) { return; } var vehicle = DAOFactory.CocheDAO.FindById(Mobile.Get()); if (vehicle.Dispositivo == null) { return; } var qtreeDir = DAOFactory.DetalleDispositivoDAO.GetQtreeFileNameValue(vehicle.Dispositivo.Id); var qtreeType = DAOFactory.DetalleDispositivoDAO.GetQtreeTypeValue(vehicle.Dispositivo.Id); if (string.IsNullOrEmpty(qtreeType) || !Enum.IsDefined(typeof(QtreeFormats), qtreeType)) { return; } var qtreeFormat = (QtreeFormats)Enum.Parse(typeof(QtreeFormats), qtreeType); qtreeDir = Path.Combine(qtreeFormat.Equals(QtreeFormats.Gte) ? Config.Qtree.QtreeGteDirectory : Config.Qtree.QtreeTorinoDirectory, qtreeDir); if (String.IsNullOrEmpty(qtreeDir) || !Directory.Exists(qtreeDir)) { return; } var leafs = new List <QLeaf>(); double hres = 0, vres = 0; using (var qtree = BaseQtree.Open(qtreeDir, qtreeFormat)) { var index = qtree.GetIndex(e.Latitud, e.Longitud); hres = qtree.HorizontalResolution; vres = qtree.VerticalResolution; for (var i = index.Y - 10; i < index.Y + 10; i++) { for (var j = index.X - 10; j < index.X + 10; j++) { var latlon = qtree.GetCenterLatLon(new QIndex { Y = i, X = j }); var leaf = qtree.GetQLeaf(latlon.Latitud, latlon.Longitud); if (leaf == null) { continue; } leafs.Add(leaf); } } } var leafsParam = leafs.Count > 0 ? string.Join(",", leafs.Select(x => SerializeQtree(x, hres, vres)).ToArray()) : string.Empty; Monitor.ExecuteScript("processGeocercas( { \"qtree\": [" + leafsParam + "] });"); }
private List <QLeaf> GetQtree(int vehiculo, List <RoutePosition> positions, out double hres, out double vres) { hres = 0; vres = 0; if (positions.Count <= 1) { return(null); } var vehicle = DAOFactory.CocheDAO.FindById(vehiculo); if (vehicle.Dispositivo == null) { return(null); } var qtreeDir = DAOFactory.DetalleDispositivoDAO.GetQtreeFileNameValue(vehicle.Dispositivo.Id); var qtreeType = DAOFactory.DetalleDispositivoDAO.GetQtreeTypeValue(vehicle.Dispositivo.Id); if (string.IsNullOrEmpty(qtreeType) || !Enum.IsDefined(typeof(QtreeFormats), qtreeType)) { return(null); } var qtreeFormat = (QtreeFormats)Enum.Parse(typeof(QtreeFormats), qtreeType); qtreeDir = Path.Combine(qtreeFormat.Equals(QtreeFormats.Gte) ? Config.Qtree.QtreeGteDirectory : Config.Qtree.QtreeTorinoDirectory, qtreeDir); if (String.IsNullOrEmpty(qtreeDir)) { return(null); } if (!Directory.Exists(qtreeDir)) { return(null); } var toAdd = new List <QLeaf>(); var added = new Dictionary <string, bool>(); using (var qtree = BaseQtree.Open(qtreeDir, qtreeFormat)) { hres = qtree.HorizontalResolution; vres = qtree.VerticalResolution; for (var i = 1; i < positions.Count; i++) { var ini = positions[i - 1]; var fin = positions[i]; var qs = qtree.MakeLeafLine(ini.Longitude, ini.Latitude, fin.Longitude, fin.Latitude, 2); foreach (var leaf in qs) { var key = leaf.Index.X + "," + leaf.Index.Y; if (added.ContainsKey(key)) { continue; } toAdd.Add(leaf); added.Add(key, true); } } } return(toAdd); }
public Color GetColorForLevel(int level) { return(BaseQtree.GetColorForLevel(level)); }