示例#1
0
        private void LoadStars(SearchZone zone, double limitMag, List<IStar> starsFromThisZone)
        {
            List<LoadPosition> searchIndexes = m_Index.GetLoadPositions(zone);

            IntPtr buffer = Marshal.AllocHGlobal(UCAC4Entry.Size);
            try
            {
                foreach (LoadPosition pos in searchIndexes)
                {
                    string fileName;
                    fileName = Path.Combine(m_CatalogLocation, string.Format("z{0}", pos.ZoneId.ToString("000")));

                    long positionFrom = (pos.FromRecordId - 1) * UCAC4Entry.Size;
                    uint firstStarNoToRead = pos.FirstStarNoInBin + pos.FromRecordId;
                    uint numRecords = pos.ToRecordId - pos.FromRecordId;

                    using (FileStream str = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        using (BinaryReader rdr = new BinaryReader(str))
                        {
                            rdr.BaseStream.Position = positionFrom;

                            for (int i = 0; i <= numRecords; i++, firstStarNoToRead++)
                            {
                                UCAC4Entry entry = new UCAC4Entry();
                                byte[] rawData = rdr.ReadBytes(UCAC4Entry.Size);

                                Marshal.Copy(rawData, 0, buffer, UCAC4Entry.Size);
                                entry = (UCAC4Entry)Marshal.PtrToStructure(buffer, typeof(UCAC4Entry));

                                entry.InitUCAC4Entry((ushort)pos.ZoneId, firstStarNoToRead);

                                if (entry.Mag > limitMag) continue;

                                if (entry.RAJ2000 < zone.RAFrom) continue;
                                if (entry.RAJ2000 > zone.RATo) continue;
                                if (entry.DEJ2000 < zone.DEFrom) continue;
                                if (entry.DEJ2000 > zone.DETo) continue;

                                starsFromThisZone.Add(entry);
                            }
                        }
                    }
                }
            }
            finally
            {
                Marshal.FreeHGlobal(buffer);
            }
        }
示例#2
0
        private void LoadStars(SearchZone zone, double limitMag, List <IStar> starsFromThisZone)
        {
            List <LoadPosition> searchIndexes = m_Index.GetLoadPositions(zone);

            IntPtr buffer = Marshal.AllocHGlobal(UCAC4Entry.Size);

            try
            {
                foreach (LoadPosition pos in searchIndexes)
                {
                    string fileName;
                    fileName = Path.Combine(m_CatalogLocation, string.Format("z{0}", pos.ZoneId.ToString("000")));

                    long positionFrom      = (pos.FromRecordId - 1) * UCAC4Entry.Size;
                    uint firstStarNoToRead = pos.FirstStarNoInBin + pos.FromRecordId;
                    uint numRecords        = pos.ToRecordId - pos.FromRecordId;

                    using (FileStream str = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        using (BinaryReader rdr = new BinaryReader(str))
                        {
                            rdr.BaseStream.Position = positionFrom;

                            for (int i = 0; i <= numRecords; i++, firstStarNoToRead++)
                            {
                                UCAC4Entry entry   = new UCAC4Entry();
                                byte[]     rawData = rdr.ReadBytes(UCAC4Entry.Size);

                                Marshal.Copy(rawData, 0, buffer, UCAC4Entry.Size);
                                entry = (UCAC4Entry)Marshal.PtrToStructure(buffer, typeof(UCAC4Entry));

                                entry.InitUCAC4Entry((ushort)pos.ZoneId, firstStarNoToRead);

                                if (entry.Mag > limitMag)
                                {
                                    continue;
                                }

                                if (entry.RAJ2000 < zone.RAFrom)
                                {
                                    continue;
                                }
                                if (entry.RAJ2000 > zone.RATo)
                                {
                                    continue;
                                }
                                if (entry.DEJ2000 < zone.DEFrom)
                                {
                                    continue;
                                }
                                if (entry.DEJ2000 > zone.DETo)
                                {
                                    continue;
                                }

                                starsFromThisZone.Add(entry);
                            }
                        }
                    }
                }
            }
            finally
            {
                Marshal.FreeHGlobal(buffer);
            }
        }