Пример #1
0
        private void LoadGeoData(string dbFile)
        {
            WkbReader geoReader = new WkbReader();

            Geo.GeoContext.Current.LongitudeWrapping = true;

            using (var vectorConn = new SQLiteConnection(dbFile, SQLiteOpen.READONLY))
            {
                using (var cmd = vectorConn.Prepare(
                           "SELECT geometry_hi, geometry_low, name_long, continent, long_wrap, z_index, tolerance_low, tolerance_hi FROM countries_v"))
                {
                    while (cmd.Step() == SQLiteResult.ROW)
                    {
                        var name = cmd.GetText(2).Trim();

                        IGeometry geometry = null;
                        using (var geo = new MemoryStream(cmd.GetBlob(_settings.IsLowMemory ? 1 : 0)))
                            geometry = geoReader.Read(geo);

                        var continent = Continent.Unspecified;
                        Enum.TryParse <Continent>(cmd.GetText(3).Replace(" ", string.Empty), out continent);

                        var longWrap = cmd.GetInteger(4) != 0;
                        var zIndex   = (int)cmd.GetInteger(5);

                        var toleranceLow = cmd.GetFloat(6);
                        var toleranceHi  = cmd.GetFloat(7);

                        var fileName = NormalizeName(name);

                        var country = new CountryInfo(continent, name, geometry,
                                                      new Uri(string.Format(_settings.SmallFlagFileNameFormat, fileName), UriKind.Relative),
                                                      new Uri(string.Format(_settings.LargeFlagFileNameFormat, fileName), UriKind.Relative),
                                                      longWrap, zIndex, toleranceLow, toleranceHi);

                        _countries[name.ToLower()] = country;
                    }
                }
            }
        }
Пример #2
0
 public void AddBorder(CountryInfo neighbor, bool hasLandBorder, bool hasMaritimeBorder, bool excluded)
 {
     Borders.Add(new BorderInfo(neighbor, hasLandBorder, hasMaritimeBorder, excluded));
 }