Beispiel #1
0
        public GeoDb Load()
        {
            if (_db == null)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                byte[]    bytes     = File.ReadAllBytes(_filePath);
                stopwatch.Stop();
                Debug.WriteLine($"Db loaded in {stopwatch.ElapsedMilliseconds} ms.");

                using (var dbReader = new FileDbReader(bytes))
                {
                    Header header = dbReader.ReadHeader();
                    IReadOnlyCollection <IPRange>  ranges    = dbReader.ReadIpRanges(header.Records);
                    IReadOnlyCollection <Location> locations = dbReader.ReadIpLocations(header.Records);
                    uint[] indexes = dbReader.ReadSortedLocationIndexes(header.OffsetLocations, header.Records);

                    _db = new GeoDb(header,
                                    ranges,
                                    locations,
                                    indexes);
                }
            }

            return(_db);
        }
Beispiel #2
0
        public void PlaceDbTest(double latitude, double longitude, string placeName)
        {
            var geoDb = new GeoDb(CitiesDbPath);

            IReverseGeocoder geocoder = new ReverseGeocoder(geoDb);
            var place = geocoder.GetNearestPlace(latitude, longitude);

            Assert.NotNull(place);
            Assert.AreEqual(placeName, place.Name);
        }
 public ItemsController(GeoDb db, IConfiguration configuration, IBlobService blobService)
 {
     _context       = db;
     _configuration = configuration;
     _blobService   = blobService;
 }
Beispiel #4
0
 public GeoRepository(FileDbManager dbManager)
 {
     _db = dbManager.Load();
 }