private void AfricaInitilization()
    {
        string name = "Afrique";
        Debug.Log("Initialization of Africa continent start");
        Indicator pop = new Indicator("Population", 100.0, 0.99, 50.0, 1.0);
        Indicator foodNeed = new Indicator("Hunger", 100.0, 0.99, 50.0, 1.0);
        Indicator foodProd = new Indicator("Food", 100.0, 0.99, 50.0, 1.0);
        Indicator airQuality = new Indicator("Air", 100.0, 0.99, 50.0, 1.0);
        Indicator earthQuality = new Indicator("Earth", 100.0, 0.99, 50.0, 1.0);
        Indicator seaQuality = new Indicator("Sea", 100.0, 0.99, 50.0, 1.0);
        Indicator biodiversity = new Indicator("Biodiversity", 10000000, 0.99, 10000000, 1.0);

        Continent continentAfrica = new Continent(name, pop, foodNeed, foodProd, airQuality, earthQuality, seaQuality, biodiversity);

        Global.instance.continents.Add(name, continentAfrica);
        Debug.Log("Initialization of Africa continent end");
    }
Exemple #2
0
        public static RContinentOut FromContinentToRContinentOut(Continent continent, string apiUrl)
        {
            RContinentOut rOut = new RContinentOut()
            {
                Id         = apiUrl + "api/Continent/" + continent.Id,
                Name       = continent.Name,
                Population = (long)continent.Population
            };
            //countries toevoegen
            List <string> countriesToAdd = new List <string>();

            foreach (Country country in continent.Countries)
            {
                countriesToAdd.Add(rOut.Id + "/Country/" + country.Id);
            }
            rOut.Countries = countriesToAdd;
            return(rOut);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractCityResponse"/> class.
 /// </summary>
 public AbstractCityResponse(
     City city                             = null,
     Continent continent                   = null,
     Country country                       = null,
     Location location                     = null,
     Model.MaxMind maxMind                 = null,
     Postal postal                         = null,
     Country registeredCountry             = null,
     RepresentedCountry representedCountry = null,
     List <Subdivision> subdivisions       = null,
     Traits traits                         = null)
     : base(continent, country, maxMind, registeredCountry, representedCountry, traits)
 {
     City         = city ?? new City();
     Location     = location ?? new Location();
     Postal       = postal ?? new Postal();
     Subdivisions = subdivisions ?? new List <Subdivision>();
 }
Exemple #4
0
        public async Task <bool> AddContinentAsync(Continent continent)
        {
            var isSucceeded = false;

            using (var client = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(continent), Encoding.UTF8, "application/json");
                using (var response = await client.PostAsync($"http://{continentServer}:{continentPort}/api/Continents", content))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        isSucceeded = true;
                    }
                }
            }

            return(isSucceeded);
        }
Exemple #5
0
        private void SeedContinets()
        {
            if (!this.Continents.Any())
            {
                var asia = new Continent()
                {
                    Name = "Asia"
                };
                var africa = new Continent()
                {
                    Name = "Africa"
                };
                var europe = new Continent()
                {
                    Name = "Europe"
                };
                var southAmerica = new Continent()
                {
                    Name = "South America"
                };
                var northAmerica = new Continent()
                {
                    Name = "North America"
                };
                var oceania = new Continent()
                {
                    Name = "Oceania"
                };
                var antartica = new Continent()
                {
                    Name = "Antartica"
                };

                this.Continents.Add(asia);
                this.Continents.Add(africa);
                this.Continents.Add(europe);
                this.Continents.Add(southAmerica);
                this.Continents.Add(northAmerica);
                this.Continents.Add(oceania);
                this.Continents.Add(antartica);

                this.SaveChanges();
            }
        }
        private static List <Location> ReturnMap(Continent continent, List <coordinate> map)
        {
            List <Location>   listOfLocations = new List <Location>();
            List <coordinate> cleanedList     = continent.SurfaceArea.Where(x => x != null).ToList();

            cleanedList = cleanedList.Where(x => x.X != 1 && x.X != continent.MapXSize && x.Y != 1 && x.Y != continent.MapYSize).ToList();
            List <coordinate> continentalLand = new List <coordinate>();

            foreach (coordinate coordinate in cleanedList)
            {
                if (!continentalLand.Contains(coordinate))
                {
                    continentalLand.Add(coordinate);
                }
            }

            foreach (coordinate coordinate in continentalLand)
            {
                listOfLocations.Add(new Plains(coordinate.X, coordinate.Y));
            }

            for (int x = 1; x <= continent.MapXSize; x++)
            {
                for (int y = 1; y <= continent.MapYSize; y++)
                {
                    if (listOfLocations.Where(r => r.XCoord == x && r.YCoord == y).Count() < 1)
                    {
                        listOfLocations.Add(new Ocean(x, y));
                    }
                }
            }

            List <Location> newMap = new List <Location>();

            foreach (Location location in listOfLocations)
            {
                if (newMap.Where(x => x.XCoord == location.XCoord && x.YCoord == location.YCoord).ToList().Count < 1)
                {
                    newMap.Add(location);
                }
            }

            return(newMap);
        }
Exemple #7
0
        public int GetContinentCode(Continent Countrytype)
        // Do a Test Case with return by 0
        {
            switch (Countrytype)
            {
            case Continent.Asia:
                return(1);

                break;

            case Continent.Africa:
                return(2);

                break;

            case Continent.NorthAmericaCentral:
                return(3);

                break;

            case Continent.SouthAmerica:
                return(4);

                break;

            case Continent.Host:
                return(7);

                break;

            case Continent.Europe:
                return(6);

                break;

            case Continent.Australia:
                return(5);

                break;

            default:
                return(0);
            }
        }
        public Continent GetContinent(int id)
        {
            GeoContext ctx = new GeoContext();

            if (ExistsContinent(id))
            {
                List <CountryMapping> cms = new List <CountryMapping>();
                var c = ctx.Continents
                        .Where(c => c.ContinentId == id)
                        .Join(ctx.CountryMappings,
                              c => new { c.ContinentId },
                              cm => new { cm.ContinentId },
                              (c, cm) => new
                {
                    Name        = c.Name,
                    ContinentId = c.ContinentId,
                    Population  = c.Population,
                    CountryId   = cm.CountryId
                });

                foreach (var cm in c)
                {
                    CountryMapping cmData = new CountryMapping {
                        ContinentId = id, CountryId = cm.CountryId
                    };
                    cms.Add(cmData);
                }

                if (cms.Count == 0)
                {
                    return(ctx.Continents.Where(c => c.ContinentId == id).First());
                }

                Continent continent = new Continent {
                    ContinentId = id, Name = c.First().Name, Population = c.First().Population, CountryMappings = cms
                };

                return(continent);
            }
            else
            {
                throw new GeoException("Continent does not exist in db.");
            }
        }
 public Continent VUpdateObject(Continent continent, IContinentService _continentService)
 {
     VObject(continent, _continentService);
     if (!isValid(continent))
     {
         return(continent);
     }
     VName(continent, _continentService);
     if (!isValid(continent))
     {
         return(continent);
     }
     VAbbrevation(continent, _continentService);
     if (!isValid(continent))
     {
         return(continent);
     }
     return(continent);
 }
Exemple #10
0
        private List <Continent> GetContinents(List <Country> Paises)
        {
            List <Continent> Continents = new List <Continent>();
            Continent        continent;

            foreach (var pais in Paises)
            {
                if (Continents.Find(x => x.Name == pais.region) == null)
                {
                    if (string.IsNullOrEmpty(pais.region))
                    {
                        if (Continents.Find(x => x.Name == "Others") == null)
                        {
                            continent = new Continent {
                                Name = "Others"
                            };
                            continent.CountriesList.Add(pais);

                            Continents.Add(continent);
                        }
                        else
                        {
                            Continents.First(x => x.Name == "Others").CountriesList.Add(pais);
                        }
                    }
                    else
                    {
                        continent = new Continent {
                            Name = pais.region
                        };
                        continent.CountriesList.Add(pais);

                        Continents.Add(continent);
                    }
                }
                else
                {
                    Continents.First(x => x.Name == pais.region).CountriesList.Add(pais);
                }
            }

            return(Continents);
        }
 public ActionResult <RCountryOut> PutCountry(int continentId, int id, [FromBody] RCountryIn rCountryIn)
 {
     try
     {
         if (dc.IsInCountry(continentId, id))
         {
             Country updated = dc.UpdateCountry(continentId, id, Mapper.FromRCountryInToCountry(rCountryIn, dc.GetContinent(continentId)));
             return(Ok(Mapper.FromCountryToRCountryOut(updated, apiUrl)));
         }
         Continent continent = dc.GetContinent(continentId);
         Country   added     = dc.AddCountry(continentId, Mapper.FromRCountryInToCountry(rCountryIn, continent));
         int       countryId = (int)added.Id;
         return(CreatedAtAction(nameof(GetCountry), new { continentId, countryId }, Mapper.FromCountryToRCountryOut(added, apiUrl)));
     }
     catch (Exception ex)
     {
         return(NotFound(ex.Message));
     }
 }
        public void EntityContinentToDictionary()
        {
            int        continentId   = 1;
            string     name          = "Tyria";
            Size2D     continentDims = new Size2D(500, 1000);
            int        minZoom       = 2;
            int        maxZoom       = 8;
            List <int> floors        = new List <int>()
            {
                3, 5
            };

            var expected = new Dictionary <string, object>()
            {
                { "continent_id", continentId },
                { "name", name },
                { "continent_dims", new Dictionary <string, double>()
                  {
                      { "width", continentDims.Width },
                      { "height", continentDims.Height }
                  } },
                { "min_zoom", minZoom },
                { "max_zoom", maxZoom },
                { "floors", floors },
            };

            Continent continent = new Continent()
            {
                ContinentId         = continentId,
                Name                = name,
                ContinentDimensions = continentDims,
                MinimumZoom         = minZoom,
                MaximumZoom         = maxZoom,
                FloorIds            = floors
            };

            var actual = continent.ToDictionary();

            Assert.AreEqual(expected, actual, "Continent");
            CollectionAssert.AreEquivalent((IDictionary <string, double>)expected["continent_dims"],
                                           (IDictionary <string, double>)actual["continent_dims"], "Continent Dims");
            CollectionAssert.AreEqual((IList <int>)expected["floors"], (IList <int>)actual["floors"], "Floors");
        }
Exemple #13
0
        private void cbStartYear_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Continent continent = (Continent)cbContinent.SelectedItem;

            if (continent == null)
            {
                cbContinent.SelectedIndex = 0;
                continent = (Continent)cbContinent.SelectedItem;
            }

            Region region = (Region)cbRegion.SelectedItem;

            if (region == null)
            {
                cbRegion.SelectedIndex = 0;
                region = (Region)cbRegion.SelectedItem;
            }

            int year = (int)cbStartYear.SelectedItem;

            var source = cbAirline.Items as ICollectionView;

            source.Filter = delegate(object item)
            {
                var airline = item as Airline;
                return((airline.Profile.Country.Region == region || (region.Uid == "100" && continent.Uid == "100") || (region.Uid == "100" && continent.hasRegion(airline.Profile.Country.Region))) && airline.Profile.Founded <= year && airline.Profile.Folded > year);
            };

            source.Refresh();

            cbAirline.SelectedIndex = 0;

            setAirportsView(year, ((Airline)cbAirline.SelectedItem).Profile.Country);

            cbOpponents.Items.Clear();

            for (int i = 0; i < cbAirline.Items.Count; i++)
            {
                cbOpponents.Items.Add(i);
            }

            cbOpponents.SelectedIndex = Math.Min(cbOpponents.Items.Count - 1, 3);
        }
Exemple #14
0
        public async Task <Continent> GetOrAddContinent(IPDetails ipDetails)
        {
            var continent = await _dbContext.Continents.FirstOrDefaultAsync(z => z.Name == ipDetails.Continent);

            if (continent != null)
            {
                return(continent);
            }

            var continentInserted = new Continent {
                Name = ipDetails.Continent
            };

            await _dbContext.Continents.AddAsync(continentInserted);

            await _dbContext.SaveChangesAsync();

            return(continentInserted);
        }
Exemple #15
0
        public int AddContinent(Continent continent)
        {
            if (uow.Continents.IsInDatabase(continent.Name))
            {
                throw new DomainException("Er is al een continent met de gegeven naam.");
            }

            uow.Complete();

            uow.Continents.AddContinent(continent);

            uow.Complete();

            var toReturn = uow.Continents.GetContinent(continent.Name).Id;

            uow.Complete();

            return(toReturn);
        }
Exemple #16
0
        public void RemoveCity(int continentId, int countryId, int cityId)
        {
            GeoContext ctx = new GeoContext();
            if (ctx.Cities.Any(c => c.CityId == cityId))
            {
                City city = ctx.Cities.Where(c => c.CityId == cityId).First();
                Country country = ctx.Countries.Where(c => c.CountryId == countryId).First();
                Continent continent = ctx.Continents.Where(c => c.ContinentId == continentId).First();

                country.Population -= city.Population;
                continent.Population -= city.Population;

                ctx.Continents.Update(continent);
                ctx.Countries.Update(country);
                ctx.Cities.Remove(city);
                ctx.SaveChanges();
            }
            else throw new GeoException("City does not exist in db.");
        }
        /// <summary>
        /// Get Continent
        /// </summary>
        /// <param name="countries"></param>
        /// <returns></returns>
        private List <Continent> GetContinents(List <Country> countries)
        {
            List <Continent> Continents = new List <Continent>();
            Continent        continent;

            foreach (var country in countries)
            {
                if (Continents.Find(x => x.Name == country.Region) == null)
                {
                    if (string.IsNullOrEmpty(country.Region) || country.Region == "Unassigned")
                    {
                        if (Continents.Find(x => x.Name == "Unassigned") == null)
                        {
                            continent = new Continent
                            {
                                Name = "Unassigned",
                            };
                            continent.CountriesList.Add(country);
                            Continents.Add(continent);
                        }
                        else
                        {
                            Continents.Find(x => x.Name == "Unassigned").CountriesList.Add(country);
                        }
                    }
                    else
                    {
                        continent = new Continent
                        {
                            Name = country.Region,
                        };
                        continent.CountriesList.Add(country);
                        Continents.Add(continent);
                    }
                }
                else
                {
                    Continents.Find(x => x.Name == country.Region).CountriesList.Add(country);
                }
            }

            return(Continents.ToList());
        }
        public void PostContinent_ReturnsContinentBody()
        {
            Continent c = new Continent("bla");

            mockManager.Setup(repo => repo.AddContinent(c)).Returns(1);
            c.Id = 1;
            mockManager.Setup(repo => repo.GetContinent(1)).Returns(c);

            var result = geographyController.PostContinent(new RContinentInput()
            {
                Name = "bla"
            }).Result as CreatedAtActionResult;

            Assert.IsType <RContinentOutput>(result.Value);
            Assert.Equal("http://localhost:5051" + "/api/continent/1", (result.Value as RContinentOutput).Id);
            Assert.Equal(c.Population, (result.Value as RContinentOutput).Population);
            Assert.Equal(c.Name, (result.Value as RContinentOutput).Name);
            Assert.Empty((result.Value as RContinentOutput).Countries);
        }
        private bool areSameGoal(List <RiskPlayer> players, string player, Continent continent1, Continent continent2)
        {
            ConquerGoal goal   = null;
            bool        result = false;

            foreach (RiskPlayer p in players)
            {
                if (!p.getName().Equals(player) && p.getGoal() != null && p.getGoal().GetType() == typeof(ConquerGoal))
                {
                    goal = (ConquerGoal)p.getGoal();
                    if (goal.areEqualContinents(continent1, continent2) && !result)
                    {
                        result = true;
                    }
                }
            }

            return(result);
        }
Exemple #20
0
        public ActionResult KiesLand(Leerling leerling, Continent continent, KlimatogramKiezenLandViewModel kVM)
        {
            if (!ModelState.IsValid)
            {
                return(null);
            }
            Land land = continent.GeefLand(kVM.Land);

            if (land != null && (kVM.Land == null || !land.HeeftKlimatogrammen()))
            {
                TempData["Error"] = "Er zijn geen gegevens beschikbaar voor het geselecteerde land.";
                return(JavaScript("window.location = '" + Url.Action("Index") + "'"));
            }
            if (HttpContext != null && HttpContext.Session != null)
            {
                HttpContext.Session["land"] = land;
            }
            return(PartialView("_KiesLocatie", new KlimatogramKiezenLocatieViewModel(land.Klimatogrammen)));
        }
 public Continent getById(int id)
 {
     try
     {
         Continent temp = context.ContinentData.FirstOrDefault(s => s.ID == id);
         if (temp == null)
         {
             throw new Exception("Continent not found");
         }
         else
         {
             return(temp);
         }
     }
     catch (Exception e)
     {
         throw new Exception("Something went wrong : ContinentRepo getById " + e.Message);
     }
 }
Exemple #22
0
        public void ShouldGetSpecificMap()
        {
            Continent continent = GW2Api.V2().Continents.GetById(1);
            Floor floor = continent.Floors[2].Value;
            Region region = floor.Regions["1"];
            Map map = region.Maps["26"];

            Assert.AreEqual(19456, map.ContinentRectangle.X.X);
            Assert.AreEqual(14976, map.ContinentRectangle.X.Y);
            Assert.AreEqual(21760, map.ContinentRectangle.Y.X);
            Assert.AreEqual(18176, map.ContinentRectangle.Y.Y);
            Assert.AreEqual(50, map.MaxLevel);
            Assert.AreEqual(40, map.MinLevel);
            Assert.AreEqual("Dredgehaunt Cliffs", map.Name);
            Assert.GreaterOrEqual(map.Objectives.Count(), 11);
            Assert.GreaterOrEqual(map.PointsOfInterest.Count(), 51);
            Assert.GreaterOrEqual(map.Sectors.Count(), 28);
            Assert.GreaterOrEqual(map.SkillChallenges.Count(), 6);
        }
        public async Task GetContinentAsync_ContinentNotExistInCache_GraphQLThrowException_LogErrorAndThrowException()
        {
            #region Arrange
            var expectedContinent = new Continent
            {
                code      = "AF",
                name      = "Africa",
                countries = new List <Country> {
                    new Country
                    {
                        code = "test",
                    }
                }
            };
            Mock <ICacheContinentRepository> cacheRepositoryMock = GenerateCacheRepositoryMock(continent: expectedContinent, isContinentInCache: false);
            Mock <IGraphQLRepository>        graphQLMock         = new Mock <IGraphQLRepository>();
            graphQLMock.Setup(g => g.GetContinentByCodeAsync(It.Is <string>(s => s == expectedContinent.code)))
            .ThrowsAsync(new Exception("test exception"));
            var continentRepository = new ContinentRepository(_logger, cacheRepositoryMock.Object, graphQLMock.Object);
            #endregion


            #region Act
            bool      isExceptionThrow = false;
            Continent result           = null;
            try
            {
                result = await continentRepository.GetContinentByCodeAsync(expectedContinent.code);
            }
            catch (Exception e)
            {
                isExceptionThrow = e.Message == ContinentRepository.GetDataFromGraphQLError;
            }
            #endregion


            #region Assert
            result.Should().BeNull();
            isExceptionThrow.Should().BeTrue();
            InMemorySink.Instance.Should().HaveMessage(ContinentRepository.GetDataFromGraphQLError)
            .WithLevel(Serilog.Events.LogEventLevel.Error);
            #endregion
        }
Exemple #24
0
        public Continent AddContinent(Continent continent)
        {
            if (continent == null)
            {
                throw new ContinentManagerException("Add Continent - continent cannot be null");
            }
            if (Find(continent.Name) != null)
            {
                throw new ContinentManagerException($"Add Continent - Continent with name: {continent.Name} already exist.");
            }

            Continent continentWithId = uow.Continents.AddContinent(continent);

            UpdateCountries(continentWithId, continent.Countries);

            uow.Complete();
            continentWithId = Find(continentWithId.Id);
            return(continentWithId);
        }
Exemple #25
0
        public void MapperFunction_ToContinent_FunctionalityTest()
        {
            string    continentName = "Continent";
            Continent continent     = new Continent(continentName);

            string  countryName       = "Country";
            int     countryPopulation = 14000;
            float   countrySurface    = 7500.50f;
            Country country           = new Country(countryPopulation, countryName, countrySurface, continent);

            string  countryName2       = "Country 2";
            int     countryPopulation2 = 18000;
            float   countrySurface2    = 7500.50f;
            Country country2           = new Country(countryPopulation2, countryName2, countrySurface2, continent);

            continent.AddCountry(country);
            continent.AddCountry(country2);

            DContinent dContinent     = Mapper.ToDContinent(continent);
            int        newContinentId = 1;
            int        newCountryId   = 2;
            int        newCountryId2  = 5;

            dContinent.Id = newContinentId;
            dContinent.Countries[0].Id = newCountryId;
            dContinent.Countries[1].Id = newCountryId2;

            Continent mappedContinent = Mapper.ToContinent(dContinent);

            mappedContinent.Id.Should().Be(newContinentId);
            mappedContinent.Name.Should().Be(continentName);
            mappedContinent.Population.Should().Be(countryPopulation + countryPopulation2);

            mappedContinent.Countries.Count.Should().Be(2);
            mappedContinent.Countries[0].Id.Should().Be(newCountryId);
            mappedContinent.Countries[0].Name.Should().Be(countryName);
            mappedContinent.Countries[0].Surface.Should().Be(countrySurface);
            mappedContinent.Countries[0].Population.Should().Be(countryPopulation);
            mappedContinent.Countries[1].Id.Should().Be(newCountryId2);
            mappedContinent.Countries[1].Name.Should().Be(countryName2);
            mappedContinent.Countries[1].Surface.Should().Be(countrySurface2);
            mappedContinent.Countries[1].Population.Should().Be(countryPopulation2);
        }
        public void AddandGetCountryNormalTest()
        {
            UnitOfWork uow       = new UnitOfWork(new GeoServiceTestContext(false));
            Continent  continent = new Continent("Azië");
            Country    country   = new Country("vietnam", 95540000, 331.212f, continent);

            uow.Continents.AddContinent(continent);
            uow.Complete();
            uow.Continents.AddCountry(1, country);
            uow.Complete();
            Continent returned = uow.Continents.GetContinent(1);

            returned.Name.Should().Be("Azië");
            returned.Countries.Count.Should().Be(1);
            returned.Countries[0].Id.Should().Be(0);
            returned.Countries[0].Name.Should().Be("vietnam");
            returned.Countries[0].Population.Should().Be(95540000);
            returned.Countries[0].Surface.Should().Be(331.212f);
        }
Exemple #27
0
        protected static void ParseContinents()
        {
            Continents = new Dictionary <int, Continent>();

            foreach (var cnt in DC.GetMainObjectsByName("AreaList"))
            {
                foreach (var data in (List <Dictionary <string, object> >)DC.GetValues(cnt)["Continent"])
                {
                    Continent continent = new Continent
                    {
                        Id          = int.Parse(data["id"].ToString()),
                        Description = data["desc"].ToString(),
                        OriginZoneX = int.Parse(data["originZoneX"].ToString()),
                        OriginZoneY = int.Parse(data["originZoneY"].ToString()),
                        Areas       = new List <Area>()
                    };

                    foreach (Dictionary <string, object> dictionary in (List <Dictionary <string, object> >)data["Area"])
                    {
                        Area area = new Area();

                        if (dictionary.ContainsKey("Zones"))
                        {
                            area.Zones = new List <KeyValuePair <int, int> >();

                            foreach (Dictionary <string, object> keyValuePair in (List <Dictionary <string, object> >)dictionary["Zones"])
                            {
                                KeyValuePair <int, int> zone = new KeyValuePair <int, int>();

                                foreach (Dictionary <string, object> valuePair in (List <Dictionary <string, object> >)keyValuePair["Zone"])
                                {
                                    zone = new KeyValuePair <int, int>(int.Parse(valuePair["x"].ToString()), int.Parse(valuePair["y"].ToString()));
                                }
                                area.Zones.Add(zone);
                            }
                        }
                    }

                    Continents.Add(continent.Id, continent);
                }
            }
        }
Exemple #28
0
        public async Task <IActionResult> Create([FromBody] Country country)
        {
            dynamic response = new ExpandoObject();

            if (ModelState.IsValid)
            {
                response.status        = 1;
                response.extra         = new ExpandoObject();
                response.extra.country = country;
                Continent c = await _context.Continent.Where(l => l.ContinentID == country.ContinentID).FirstOrDefaultAsync();

                if (c == null)
                {
                    await _context.Continent.AddAsync(new Continent()
                    {
                        ContinentID = country.ContinentID
                    });

                    await _context.SaveChangesAsync();
                }
                try{
                    country.Continent = c;
                    await _context.Countries.AddAsync(country);

                    await _context.SaveChangesAsync();
                }
                catch (Exception) {
                    response.status        = 0;
                    response.extra.message = "country exsist";
                    return(BadRequest(response));
                }
                return(Ok(response));
            }
            else
            {
                response.status             = 0;
                response.extra              = new ExpandoObject();
                response.extra.country      = country;
                response.extra.errorMessage = _modelS.GetErrorMessage(ModelState);
                return(BadRequest(response));
            }
        }
Exemple #29
0
        public List <Continent> getWorld(MapData data)
        {
            List <StateData> statesData    = data.getWorldData();
            List <Continent> realWorld     = new List <Continent>();
            List <string>    continentData = data.getContinents();

            //creating continents
            foreach (string continentName in continentData)
            {
                Continent continentBuffer = new Continent(continentName);
                realWorld.Add(continentBuffer);
                Debug.Log("Continent added " + continentName);
            }

            //creating lands
            foreach (StateData stateData in statesData)
            {
                Land landBuffer = new Land(stateData.getName(), 1);
                foreach (Continent continent in realWorld)
                {
                    if (continent.getName().Equals(stateData.getContinent()))
                    {
                        continent.addLand(landBuffer);
                        Debug.Log("Land added " + continent.getName());
                    }
                }
            }

            //making the connection
            foreach (StateData stateData in statesData)
            {
                Land     landBuffer = getLandFromWorld(realWorld, stateData.getName());
                string[] neighbors  = stateData.getConnection();
                for (int i = 0; i < neighbors.Length; i++)
                {
                    Land neighborBuffer = getLandFromWorld(realWorld, neighbors[i]);
                    Debug.Log("Test " + neighborBuffer.getName() + "-" + landBuffer.getName());
                    landBuffer.addNeighbor(neighborBuffer);
                }
            }
            return(realWorld);
        }
Exemple #30
0
        public async Task AsyncData()
        {
            using (var context = new WorldContext())
            {
                await context.Database.EnsureDeletedAsync();

                await context.Database.EnsureCreatedAsync();

                var america = new Continent {
                    Code = "AM", Name = "America"
                };
                var europe = new Continent {
                    Code = "EU", Name = "Europe"
                };
                var asia = new Continent {
                    Code = "AS", Name = "Asia"
                };
                var africa = new Continent {
                    Code = "AF", Name = "Africa"
                };

                await context.AddAsync(america);

                await context.AddRangeAsync(europe, asia, africa);

                var result = context.SaveChangesAsync();
                result.Wait(30_000);
                Assert.Null(result.Exception);
                Assert.Equal(4, result.Result);
            }

            using (var context = new WorldContext())
            {
                var continent = await context.FindAsync <Continent>("AS");

                Assert.Equal("Asia", continent.Name);

                var continents = await context.Continents.ToListAsync();

                Assert.Equal(4, continents.Count);
            }
        }
Exemple #31
0
        public ActionResult Index(Leerling leerling, KlimatogramKiezenIndexViewModel kVM)
        {
            if (!ModelState.IsValid)
            {
                return(null);
            }

            Continent continent = leerling.GeefContinent(kVM.Werelddeel);

            if (!continent.Landen.Any())
            {
                TempData["Error"] = "Er zijn geen gegevens beschikbaar voor het geselecteerde continent.";
                return(JavaScript("window.location = '" + Url.Action("Index") + "'"));
            }
            if (HttpContext != null && HttpContext.Session != null)
            {
                HttpContext.Session["continent"] = continent;
            }
            return(PartialView("_KiesLand", new KlimatogramKiezenLandViewModel(continent.Landen)));
        }
 public ContinentViewModel(Continent c)
 {
     this.Naam = c.Naam;
     this.ContinentCode = c.ContinentCode;
 }
Exemple #33
0
        private void CreateWorld()
        {
            offset = new Vector2(0, 0);
            scale = 1.0f;
            territories = new Dictionary<string, Country>();
            doodads = new List<Doodad>();

            // import graphics
            Country c;
            //c = new Country(new Vector2(609.9492f, 358.1009f), new Vector2(0f, 0f), content.Load<Texture2D>("worldmap"), noone, 4);
            //territories.Add("worldmap", c);

            #region LoadDoodads
            doodads.Add(new Doodad(new Vector2(-14.69687f, 191.6566f), content.Load<Texture2D>("doodads/alaskaToKamchatka1"), "alaskaToKamchatka1", Color.White));
            doodads.Add(new Doodad(new Vector2(1266.268f, 191.0086f), content.Load<Texture2D>("doodads/alaskaToKamchatka2"), "alaskaToKamchatka2", Color.White));
            doodads.Add(new Doodad(new Vector2(516.4464f, 394.6735f), content.Load<Texture2D>("doodads/brazilToWestAfrica"), "brazilToWestAfrica", Color.White));
            doodads.Add(new Doodad(new Vector2(687.2501f, 292.322f), content.Load<Texture2D>("doodads/centralEuropeToEgypt"), "centralEuropeToEgypt", Color.White));
            doodads.Add(new Doodad(new Vector2(632.7992f, 273.3663f), content.Load<Texture2D>("doodads/centralEuropeToNorthAfrica"), "centralEuropeToNorthAfrica", Color.White));
            doodads.Add(new Doodad(new Vector2(980.6555f, 389.7321f), content.Load<Texture2D>("doodads/chinaToIndonesia"), "chinaToIndonesia", Color.White));
            doodads.Add(new Doodad(new Vector2(550.7408f, 193.8686f), content.Load<Texture2D>("doodads/greenlandToCentralEurope"), "greenlandToCentralEurope", Color.White));
            doodads.Add(new Doodad(new Vector2(1044.322f, 439.598f), content.Load<Texture2D>("doodads/indonesiaToEasternAustralia"), "indonesiaToEasternAustralia", Color.White));
            doodads.Add(new Doodad(new Vector2(1019.372f, 443.377f), content.Load<Texture2D>("doodads/indonesiaToWesternAustralia"), "indonesiaToWesternAustralia", Color.White));
            doodads.Add(new Doodad(new Vector2(424.5769f, 209.475f), content.Load<Texture2D>("doodads/montrealToGreenland"), "montrealToGreenland", Color.White));
            doodads.Add(new Doodad(new Vector2(635.3635f, 221.1855f), content.Load<Texture2D>("doodads/scandenaviaToCentralEurope"), "scandenaviaToCentralEurope", Color.White));
            doodads.Add(new Doodad(new Vector2(674.8361f, 216.3632f), content.Load<Texture2D>("doodads/scandenaviaToUkraine"), "scandenaviaToUkraine", Color.White));
            doodads.Add(new Doodad(new Vector2(614.2961f, 280.9735f), content.Load<Texture2D>("doodads/spainToNorthAfrica"), "spainToNorthAfrica", Color.White));
            doodads.Add(new Doodad(new Vector2(568.4507f, 516.1575f), content.Load<Texture2D>("doodads/compass"), "compass", Color.Lerp(OCEAN, Color.White, 0.3f)));
            doodads.Add(new Doodad(new Vector2(167.4364f, 497.0134f), content.Load<Texture2D>("doodads/briskBox"), "briskBox", Color.Lerp(OCEAN, Color.White, 0.3f)));
            //Color.Lerp(OCEAN, Color.White, 0.3f)
            //c = new Country(new Vector2(0f, 0f), content.Load<Texture2D>("doodads/briskBox"), noone, 4);
            //territories.Add("briskBox", c);

            #endregion

            #region InitializeCountries
            c = new Country(new Vector2(107.8508f, 200.828f), new Vector2(7.7f, -10.85f), content.Load<Texture2D>("territories/alaska"), noone, 4);
            territories.Add("alaska", c);
            c = new Country(new Vector2(222.2292f, 197.246f), new Vector2(-3.85f, 8.75f), content.Load<Texture2D>("territories/northwest"), noone, 4);
            territories.Add("northwest", c);
            c = new Country(new Vector2(343.4084f, 205.0364f), new Vector2(25.67739f, 27.60754f), content.Load<Texture2D>("territories/montreal"), noone, 4);
            territories.Add("montreal", c);
            c = new Country(new Vector2(457.0038f, 155.9649f), new Vector2(8.75f, -2.1f), content.Load<Texture2D>("territories/greenland"), noone, 4);
            territories.Add("greenland", c);
            c = new Country(new Vector2(237.4706f, 273.7477f), new Vector2(-1.75f, -2.45f), content.Load<Texture2D>("territories/westernUS"), noone, 4);
            territories.Add("westernUS", c);
            c = new Country(new Vector2(316.1926f, 296.1198f), new Vector2(-6.444972f, -11.69498f), content.Load<Texture2D>("territories/easternUS"), noone, 4);
            territories.Add("easternUS", c);
            c = new Country(new Vector2(280.1385f, 342.6657f), new Vector2(-12.95f, -7f), content.Load<Texture2D>("territories/mexico"), noone, 4);
            territories.Add("mexico", c);
            c = new Country(new Vector2(622.2657f, 313.593f), new Vector2(-2.594975f, 0.9050255f), content.Load<Texture2D>("territories/algeria"), noone, 4);
            territories.Add("algeria", c);
            c = new Country(new Vector2(389.8989f, 534.776f), new Vector2(6.897489f, -21.24749f), content.Load<Texture2D>("territories/argentina"), noone, 4);
            territories.Add("argentina", c);
            c = new Country(new Vector2(432.2558f, 456.1035f), new Vector2(9.432415f, -8.382415f), content.Load<Texture2D>("territories/brazil"), noone, 4);
            territories.Add("brazil", c);
            c = new Country(new Vector2(650.299f, 390.926f), new Vector2(8.569845f, -12.41985f), content.Load<Texture2D>("territories/congo"), noone, 4);
            territories.Add("congo", c);
            c = new Country(new Vector2(737.0989f, 384.7761f), new Vector2(-6.589952f, -6.589952f), content.Load<Texture2D>("territories/eastAfrica"), noone, 4);
            territories.Add("eastAfrica", c);
            c = new Country(new Vector2(688.9121f, 321.4395f), new Vector2(0f, 0f), content.Load<Texture2D>("territories/egypt"), noone, 4);
            territories.Add("egypt", c);
            c = new Country(new Vector2(587.9989f, 351.676f), new Vector2(-10.85f, 0.7f), content.Load<Texture2D>("territories/northAfrica"), noone, 4);
            territories.Add("northAfrica", c);
            c = new Country(new Vector2(717.1432f, 467.7557f), new Vector2(-16.1f, -1.75f), content.Load<Texture2D>("territories/southAfrica"), noone, 4);
            territories.Add("southAfrica", c);
            c = new Country(new Vector2(681.8353f, 246.2907f), new Vector2(-0.9801524f, -3.830152f), content.Load<Texture2D>("territories/centralEurope"), noone, 4);
            territories.Add("centralEurope", c);
            c = new Country(new Vector2(382.8569f, 419.208f), new Vector2(-17.58493f, -15.48492f), content.Load<Texture2D>("territories/venezuela"), noone, 4);
            territories.Add("venezuela", c);
            c = new Country(new Vector2(614.4059f, 246.7881f), new Vector2(3.955023f, 6.594975f), content.Load<Texture2D>("territories/westernEurope"), noone, 4);
            territories.Add("westernEurope", c);
            c = new Country(new Vector2(816.2734f, 277.6501f), new Vector2(5.587434f, -9.837434f), content.Load<Texture2D>("territories/afghanistan"), noone, 4);
            territories.Add("afghanistan", c);
            c = new Country(new Vector2(951.755f, 322.0817f), new Vector2(7.399749f, -7.919597f), content.Load<Texture2D>("territories/china"), noone, 4);
            territories.Add("china", c);
            c = new Country(new Vector2(1133.865f, 489.2401f), new Vector2(-41.7774f, 9.577386f), content.Load<Texture2D>("territories/easternAustralia"), noone, 4);
            territories.Add("easternAustralia", c);
            c = new Country(new Vector2(878.7529f, 328.2307f), new Vector2(-1.852512f, 0.9474875f), content.Load<Texture2D>("territories/india"), noone, 4);
            territories.Add("india", c);
            c = new Country(new Vector2(982.8348f, 403.5369f), new Vector2(14.39246f, 5.992463f), content.Load<Texture2D>("territories/indonesia"), noone, 4);
            territories.Add("indonesia", c);
            c = new Country(new Vector2(1135.609f, 193.1856f), new Vector2(-5.6f, -5.95f), content.Load<Texture2D>("territories/kamchatka"), noone, 4);
            territories.Add("kamchatka", c);
            c = new Country(new Vector2(765.4097f, 317.237f), new Vector2(-4.5897f, -8.039698f), content.Load<Texture2D>("territories/middleEast"), noone, 4);
            territories.Add("middleEast", c);
            c = new Country(new Vector2(1028.929f, 224.3549f), new Vector2(-5.684923f, -1.484924f), content.Load<Texture2D>("territories/moreSiberia"), noone, 4);
            territories.Add("moreSiberia", c);
            c = new Country(new Vector2(671.1532f, 194.2956f), new Vector2(-12.95f, 4.9f), content.Load<Texture2D>("territories/scandinavia"), noone, 4);
            territories.Add("scandinavia", c);
            c = new Country(new Vector2(907.4369f, 210.014f), new Vector2(28.39246f, 5.292463f), content.Load<Texture2D>("territories/siberia"), noone, 4);
            territories.Add("siberia", c);
            c = new Country(new Vector2(803.3606f, 208.4472f), new Vector2(-7.127388f, -3.977386f), content.Load<Texture2D>("territories/westRussia"), noone, 4);
            territories.Add("westRussia", c);
            c = new Country(new Vector2(1035.703f, 493.5189f), new Vector2(-6.939949f, 5.189949f), content.Load<Texture2D>("territories/westernAustralia"), noone, 4);
            territories.Add("westernAustralia", c);
            #endregion

            #region CreateContinents
            continents = new List<Continent>();
            Continent cont = new Continent("North America", 2);
            territories.TryGetValue("alaska", out c);
            cont.Add(c);
            territories.TryGetValue("northwest", out c);
            cont.Add(c);
            territories.TryGetValue("montreal", out c);
            cont.Add(c);
            territories.TryGetValue("greenland", out c);
            cont.Add(c);
            territories.TryGetValue("westernUS", out c);
            cont.Add(c);
            territories.TryGetValue("easternUS", out c);
            cont.Add(c);
            territories.TryGetValue("mexico", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("South America", 1);
            territories.TryGetValue("venezuela", out c);
            cont.Add(c);
            territories.TryGetValue("argentina", out c);
            cont.Add(c);
            territories.TryGetValue("brazil", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("Africa", 2);
            territories.TryGetValue("northAfrica", out c);
            cont.Add(c);
            territories.TryGetValue("congo", out c);
            cont.Add(c);
            territories.TryGetValue("southAfrica", out c);
            cont.Add(c);
            territories.TryGetValue("eastAfrica", out c);
            cont.Add(c);
            territories.TryGetValue("egypt", out c);
            cont.Add(c);
            territories.TryGetValue("algeria", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("Europe", 2);
            territories.TryGetValue("westernEurope", out c);
            cont.Add(c);
            territories.TryGetValue("centralEurope", out c);
            cont.Add(c);
            territories.TryGetValue("scandinavia", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("Asia", 3);
            territories.TryGetValue("westRussia", out c);
            cont.Add(c);
            territories.TryGetValue("middleEast", out c);
            cont.Add(c);
            territories.TryGetValue("afghanistan", out c);
            cont.Add(c);
            territories.TryGetValue("siberia", out c);
            cont.Add(c);
            territories.TryGetValue("moreSiberia", out c);
            cont.Add(c);
            territories.TryGetValue("kamchatka", out c);
            cont.Add(c);
            territories.TryGetValue("india", out c);
            cont.Add(c);
            territories.TryGetValue("china", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("Australia", 1);
            territories.TryGetValue("indonesia", out c);
            cont.Add(c);
            territories.TryGetValue("easternAustralia", out c);
            cont.Add(c);
            territories.TryGetValue("westernAustralia", out c);
            cont.Add(c);
            continents.Add(cont);
            #endregion

            // Adjacency lists
            Country n;

            #region NorthAmericaNeighbors
            territories.TryGetValue("alaska", out c);
            territories.TryGetValue("northwest", out n);
            c.addNeighbor(n);
            territories.TryGetValue("kamchatka", out n);
            c.addNeighbor(n);

            territories.TryGetValue("northwest", out c);
            territories.TryGetValue("alaska", out n);
            c.addNeighbor(n);
            territories.TryGetValue("montreal", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernUS", out n);
            c.addNeighbor(n);

            territories.TryGetValue("montreal", out c);
            territories.TryGetValue("northwest", out n);
            c.addNeighbor(n);
            territories.TryGetValue("greenland", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("easternUS", out n);
            c.addNeighbor(n);

            territories.TryGetValue("greenland", out c);
            territories.TryGetValue("montreal", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernEurope", out n);
            c.addNeighbor(n);

            territories.TryGetValue("westernUS", out c);
            territories.TryGetValue("northwest", out n);
            c.addNeighbor(n);
            territories.TryGetValue("montreal", out n);
            c.addNeighbor(n);
            territories.TryGetValue("easternUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("mexico", out n);
            c.addNeighbor(n);

            territories.TryGetValue("easternUS", out c);
            territories.TryGetValue("montreal", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("mexico", out n);
            c.addNeighbor(n);

            territories.TryGetValue("mexico", out c);
            territories.TryGetValue("easternUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("venezuela", out n);
            c.addNeighbor(n);
            #endregion

            #region SouthAmericaNeighbors
            territories.TryGetValue("venezuela", out c);
            territories.TryGetValue("mexico", out n);
            c.addNeighbor(n);
            territories.TryGetValue("brazil", out n);
            c.addNeighbor(n);
            territories.TryGetValue("argentina", out n);
            c.addNeighbor(n);

            territories.TryGetValue("argentina", out c);
            territories.TryGetValue("venezuela", out n);
            c.addNeighbor(n);
            territories.TryGetValue("brazil", out n);
            c.addNeighbor(n);

            territories.TryGetValue("brazil", out c);
            territories.TryGetValue("venezuela", out n);
            c.addNeighbor(n);
            territories.TryGetValue("argentina", out n);
            c.addNeighbor(n);
            territories.TryGetValue("northAfrica", out n);
            c.addNeighbor(n);
            #endregion

            #region AfricaNeighbors
            territories.TryGetValue("northAfrica", out c);
            territories.TryGetValue("brazil", out n);
            c.addNeighbor(n);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);

            territories.TryGetValue("congo", out c);
            territories.TryGetValue("northAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("eastAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("southAfrica", out n);
            c.addNeighbor(n);

            territories.TryGetValue("southAfrica", out c);
            territories.TryGetValue("eastAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);

            territories.TryGetValue("eastAfrica", out c);
            territories.TryGetValue("southAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);

            territories.TryGetValue("egypt", out c);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);
            territories.TryGetValue("eastAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);

            territories.TryGetValue("algeria", out c);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);
            territories.TryGetValue("northAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            #endregion

            #region EuropeNeighbors
            territories.TryGetValue("westernEurope", out c);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("scandinavia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("centralEurope", out c);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);
            territories.TryGetValue("scandinavia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("scandinavia", out c);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);
            #endregion

            #region AsiaNeighbors
            territories.TryGetValue("westRussia", out c);
            territories.TryGetValue("scandinavia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("afghanistan", out n);
            c.addNeighbor(n);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);

            territories.TryGetValue("middleEast", out c);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("eastAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("afghanistan", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("afghanistan", out c);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("india", out n);
            c.addNeighbor(n);

            territories.TryGetValue("siberia", out c);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("afghanistan", out n);
            c.addNeighbor(n);
            territories.TryGetValue("india", out n);
            c.addNeighbor(n);
            territories.TryGetValue("china", out n);
            c.addNeighbor(n);
            territories.TryGetValue("moreSiberia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("moreSiberia", out c);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("china", out n);
            c.addNeighbor(n);
            territories.TryGetValue("kamchatka", out n);
            c.addNeighbor(n);

            territories.TryGetValue("kamchatka", out c);
            territories.TryGetValue("moreSiberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("alaska", out n);
            c.addNeighbor(n);

            territories.TryGetValue("india", out c);
            territories.TryGetValue("afghanistan", out n);
            c.addNeighbor(n);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("china", out n);
            c.addNeighbor(n);

            territories.TryGetValue("china", out c);
            territories.TryGetValue("india", out n);
            c.addNeighbor(n);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("moreSiberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("indonesia", out n);
            c.addNeighbor(n);
            #endregion

            #region AustraliaNeighbors
            territories.TryGetValue("indonesia", out c);
            territories.TryGetValue("china", out n);
            c.addNeighbor(n);
            territories.TryGetValue("easternAustralia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernAustralia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("easternAustralia", out c);
            territories.TryGetValue("indonesia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernAustralia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("westernAustralia", out c);
            territories.TryGetValue("indonesia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("easternAustralia", out n);
            c.addNeighbor(n);
            #endregion
        }
        private void InitializeObjects()
        {
            /*
                 * ==================================================================
                 * Continenten aanmaken
                 * ==================================================================
                 */
            //Europa
            Continent europa = new Continent("Europa");

            //Afrika
            Continent afrika = new Continent("Afrika");

            //Azië
            Continent azie = new Continent("Azië");

            //Oceanië
            Continent oceanie = new Continent("Oceanië");

            //Noord Amerika
            Continent noordAmerika = new Continent("Noord-Amerika");

            //Zuid Amerika
            Continent zuidAmerika = new Continent("Zuid-Amerika");

            /*
             * ==================================================================
             * Landen aanmaken
             * ==================================================================
             */
            //België
            Land belgie = new Land("België");

            //Frankrijk
            Land frankrijk = new Land("Frankrijk");

            //Ivoorkust
            Land ivoorkust = new Land("Ivoorkust");

            //China
            Land china = new Land("China");

            //Nieuw Zeeland
            Land nieuwZeeland = new Land("Nieuw Zeeland");

            //Verenigde Staten
            Land verenigdeStaten = new Land("Verenigde Staten");

            //Peru
            Land peru = new Land("Peru");

            /*
             * ==================================================================
             * Locaties aanmaken
             * klimatogram aanmaken
             * Koppelen
             * ==================================================================
             */
            //Eerste 2 lijsten aanmaken voor de temperaturen en neerslagen
            IList<double> temperaturen;
            IList<int> neerslagen;
            Klimatogram klimatogram;

            //Ukkel
            Locatie ukkel = new Locatie("Ukkel");
            temperaturen = new[] { 2.5, 3.2, 5.7, 8.7, 12.7, 15.5, 17.2, 17, 14.4, 10.4, 6, 3.4 };
            neerslagen = new[] { 67, 54, 73, 57, 70, 78, 75, 63, 59, 71, 78, 76 };
            klimatogram = new Klimatogram(temperaturen, neerslagen, 50.802398, 4.340670, 1961, 1990);
            ukkel.Klimatogram = klimatogram;

            //Gent-Melle
            Locatie gentMelle = new Locatie("Gent-Melle");
            temperaturen = new[] { 2.4, 3, 5.2, 8.4, 12.1, 15.1, 16.8, 16.6, 14.3, 10.3, 6.2, 3.2 };
            neerslagen = new[] { 51, 42, 46, 50, 59, 65, 72, 74, 72, 72, 64, 59 };
            klimatogram = new Klimatogram(temperaturen, neerslagen, 51.003672, 3.800314, 1960, 1996);
            gentMelle.Klimatogram = klimatogram;

            //Abidjan
            Locatie abidjan = new Locatie("Abidjan");
            temperaturen = new[] { 26.8, 27.7, 27.9, 27.7, 26.9, 25.8, 24.7, 24.5, 25.6, 26.8, 27.4, 27 };
            neerslagen = new[] { 16, 49, 107, 141, 294, 562, 206, 37, 81, 138, 143, 75 };
            klimatogram = new Klimatogram(temperaturen, neerslagen, 5.316667, -4.033333, 1961, 1990);
            abidjan.Klimatogram = klimatogram;

            //Parijs
            Locatie parijs = new Locatie("Parijs");
            temperaturen = new[] { 3.5, 4.5, 6.8, 9.7, 13.3, 16.4, 18.4, 18.2, 15.7, 11.8, 6.9, 4.3 };
            neerslagen = new[] { 54, 46, 54, 47, 63, 58, 54, 52, 54, 56, 56, 56 };
            klimatogram = new Klimatogram(temperaturen, neerslagen, 48.856614, 2.352222, 1960, 1990);
            parijs.Klimatogram = klimatogram;

            //Peking
            Locatie peking = new Locatie("Peking");
            temperaturen = new[] { -4.3, -1.9, 5.1, 13.6, 20.0, 24.2, 25.9, 24.6, 19.6, 12.7, 4.3, -2.2 };
            neerslagen = new[] { 3, 6, 9, 26, 29, 71, 176, 182, 49, 19, 6, 2 };
            klimatogram = new Klimatogram(temperaturen, neerslagen, 39.904211, 116.407395, 1961, 1990);
            peking.Klimatogram = klimatogram;

            //Wellington
            Locatie wellington = new Locatie("Wellington");
            temperaturen = new[] { 17.8, 17.7, 16.6, 14.3, 11.9, 10.1, 9.2, 9.8, 11.2, 12.8, 14.5, 16.4 };
            neerslagen = new[] { 67, 48, 76, 87, 99, 113, 111, 106, 82, 81, 74, 74 };
            klimatogram = new Klimatogram(temperaturen, neerslagen, -41.286460, 174.776236, 1961, 1990);
            wellington.Klimatogram = klimatogram;

            //Oklahoma City
            Locatie oklahomaCity = new Locatie("Oklahoma City");
            temperaturen = new[] { 2.2, 4.9, 10.2, 15.8, 20.2, 24.8, 27.8, 27.3, 22.8, 16.7, 9.8, 4.1 };
            neerslagen = new[] { 29, 40, 69, 70, 133, 110, 66, 66, 98, 82, 50, 36 };
            klimatogram = new Klimatogram(temperaturen, neerslagen, 35.467560, -97.516428, 1961, 1990);
            oklahomaCity.Klimatogram = klimatogram;

            //
            Locatie lima = new Locatie("Lima");
            temperaturen = new[] { 22.7, 23.3, 22.9, 21.2, 19.2, 17.8, 17.1, 16.8, 17.0, 17.9, 19.3, 21.3 };
            neerslagen = new[] { 1, 0, 0, 0, 0, 1, 1, 2, 1, 0, 0, 0 };
            klimatogram = new Klimatogram(temperaturen, neerslagen, -12.046374, -77.042793, 1961, 1990);
            lima.Klimatogram = klimatogram;

            /*
                 * ==================================================================
                 * Locaties aan landen koppelen
                 * ==================================================================
                 */
            //Aan Belgie
            belgie.VoegLocatieToe(ukkel);
            belgie.VoegLocatieToe(gentMelle);

            //Aan Frankrijk
            frankrijk.VoegLocatieToe(parijs);

            //Aan Ivoorkust
            ivoorkust.VoegLocatieToe(abidjan);

            //Aan China
            china.VoegLocatieToe(peking);

            //Aan Nieuw Zeeland
            nieuwZeeland.VoegLocatieToe(wellington);

            //Aan Verenigde Staten
            verenigdeStaten.VoegLocatieToe(oklahomaCity);

            //Aan Peru
            peru.VoegLocatieToe(lima);

            /*
             * ==================================================================
             * Landen aan continenten koppelen
             * ==================================================================
             */
            //Aan Europa
            europa.VoegLandToe(belgie);
            europa.VoegLandToe(frankrijk);

            //Aan Afrika
            afrika.VoegLandToe(ivoorkust);

            //Aan Azië
            azie.VoegLandToe(china);

            //Aan Oceanië
            oceanie.VoegLandToe(nieuwZeeland);

            //Aan Noord-Amerika
            noordAmerika.VoegLandToe(verenigdeStaten);

            //Aan Zuid-Amerika
            zuidAmerika.VoegLandToe(peru);

            /*
             * ===================================================================
             * Kenmerken aanmaken
             *
             * Moet in juiste volgorde gemaakt zijn zodat determinatietabel
             * klopt.
             * ===================================================================
             */

            /*
             * ==================================================================
             * Proberen opslaan zeker?
             * ==================================================================
             */
            continenten = (new Continent[] {europa, afrika}).ToList();
        }
Exemple #35
0
        /// <summary>
        /// Contructor of Animalworld
        /// </summary>
        /// <param name="continent">Continent of the animal world that is created.</param>
        public AnimalWorld(Continent continent)
        {
            // Get fully qualified factory name
            string name = this.GetType().Namespace + "." +
                continent.ToString() + "Factory";

            // Dynamic factory creation
            IContinentFactory factory =
                (IContinentFactory)System.Activator.CreateInstance
                (Type.GetType(name));

            // Factory creates carnivores and herbivores
            _carnivore = factory.CreateCarnivore();
            _herbivore = factory.CreateHerbivore();
        }
 public CountryInfo(Continent _continent, string _abrev, string _name)
     : this()
 {
     this.Contin = _continent;
     this.Abrev = _abrev;
     this.Name = _name;
 }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape) && isZoomFinished && isZoomed) // Si l'o appuie sur la touche "Echap", que nous ne sommes pas en pleine annimation et en vue zoomée
        {
            isZoomed = !isZoomed; // On annonce qu'on passe en vue globale
            isZoomFinished = false; // Que l'annimation commence
            DesabledContinentIndicators(); // On cache les indicateurs du contient séléctionné
            continentSelected = null; // On désélectionne le continent
        }

        if (isZoomed && !isZoomFinished) // Si on est en en vue zoomée mais que l'annimation n'est pas fini (donc qu'on est en transition vers une vue zoomée)
        {
            ZoomInContinent(); // Permet de s'approcher de la position zoomée (appelé environ 33 fois pour une transition)

        }
        else if (!isZoomed && !isZoomFinished) // Sinon, si on est en transition vers la vue globale
        {
            ZoomOutContinent(); // Permet de s'approcher de la position dézoomée (appelé environ 33 fois pour une transition)
        }
    }
 public ContinentArea(Continent cont,List<Transport> trans,List<uint> areaIds,Vector2[] areaDefinition):base(areaDefinition)
 {
     Continent = cont;
     Transports = trans;
     AreaIdList = areaIds;
 }
Exemple #39
0
 void Start()
 {
     continent = (Continent)this.transform.parent.gameObject.GetComponent(typeof(Continent));
 }
        public void Returns_correct_document_for_resource()
        {
            // Arrange
            var city1 = new City
            {
                Id = "10",
                Name = "Madrid"
            };

            var city2 = new City
            {
                Id = "11",
                Name = "Barcelona"
            };

            var city3 = new City
            {
                Id = "12",
                Name = "Badajoz"
            };

            var province1 = new Province
            {
                Id = "506",
                Name = "Badajoz",
                Capital = city3
            };

            var province2 = new Province
            {
                Id = "507",
                Name = "Cuenca",
                Capital = null // Leaving null to test a null to-one
            };

            var continent = new Continent
            {
                Id = "1",
                Name = "Europe"
            };

            var country = new Country
            {
                Id = "4",
                Name = "Spain",
                Continent = continent,
                Provinces = new List<Province> { province1, province2 },
                Cities = new List<City> { city1, city2, city3 }
            };


            // Country registration
            var countryName =
                new ResourceTypeAttribute(
                    new PrimitiveTypeAttributeValueConverter<string>(typeof(Country).GetProperty("Name")), null, "name");
            var countryCities =
                new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Cities"), "cities", typeof(City), null, null);
            var countryProvinces =
                new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Provinces"), "provinces", typeof(Province), null, null);
            var countryContinent =
                new ToOneResourceTypeRelationship(typeof(Country).GetProperty("Continent"), "continent", typeof(Continent), null, null);
            var countryRegistration = new Mock<IResourceTypeRegistration>(MockBehavior.Strict);
            countryRegistration.Setup(m => m.GetIdForResource(It.IsAny<Country>())).Returns((Country c) => country.Id);
            countryRegistration.Setup(m => m.ResourceTypeName).Returns("countries");
            countryRegistration.Setup(m => m.Attributes).Returns(new[] { countryName });
            countryRegistration
                .Setup(m => m.Relationships)
                .Returns(() => new ResourceTypeRelationship[] { countryCities, countryProvinces, countryContinent });


            // City registration
            var cityName =
                new ResourceTypeAttribute(
                    new PrimitiveTypeAttributeValueConverter<string>(typeof(City).GetProperty("Name")), null, "name");
            var cityRegistration = new Mock<IResourceTypeRegistration>(MockBehavior.Strict);
            cityRegistration.Setup(m => m.ResourceTypeName).Returns("cities");
            cityRegistration.Setup(m => m.GetIdForResource(It.IsAny<City>())).Returns((City c) => c.Id);
            cityRegistration.Setup(m => m.Attributes).Returns(new[] { cityName });
            cityRegistration.Setup(m => m.Relationships).Returns(new ResourceTypeRelationship[] { });


            // Province registration
            var provinceName =
                new ResourceTypeAttribute(
                    new PrimitiveTypeAttributeValueConverter<string>(typeof(Province).GetProperty("Name")), null, "name");
            var provinceCapital = new ToOneResourceTypeRelationship(typeof(Province).GetProperty("Capital"), "capital", typeof(City), null, null);
            var provinceRegistration = new Mock<IResourceTypeRegistration>(MockBehavior.Strict);
            provinceRegistration.Setup(m => m.ResourceTypeName).Returns("provinces");
            provinceRegistration.Setup(m => m.GetIdForResource(It.IsAny<Province>())).Returns((Province c) => c.Id);
            provinceRegistration.Setup(m => m.Attributes).Returns(new[] { provinceName });
            provinceRegistration
                .Setup(m => m.Relationships)
                .Returns(() => new ResourceTypeRelationship[] { provinceCapital });


            // Continent registration
            var continentName =
                new ResourceTypeAttribute(
                    new PrimitiveTypeAttributeValueConverter<string>(typeof(Continent).GetProperty("Name")), null, "name");
            var continentCountries =
                new ToManyResourceTypeRelationship(typeof(Continent).GetProperty("Countries"), "countries", typeof(Country), null, null);
            var continentRegistration = new Mock<IResourceTypeRegistration>(MockBehavior.Strict);
            continentRegistration.Setup(m => m.ResourceTypeName).Returns("continents");
            continentRegistration.Setup(m => m.GetIdForResource(It.IsAny<Continent>())).Returns((Continent c) => c.Id);
            continentRegistration.Setup(m => m.Attributes).Returns(new[] { continentName });
            continentRegistration
                .Setup(m => m.Relationships)
                .Returns(() => new ResourceTypeRelationship[] { continentCountries });

            var mockRegistry = new Mock<IResourceTypeRegistry>(MockBehavior.Strict);
            mockRegistry.Setup(r => r.GetRegistrationForType(typeof(Country))).Returns(countryRegistration.Object);
            mockRegistry.Setup(r => r.GetRegistrationForType(typeof(City))).Returns(cityRegistration.Object);
            mockRegistry.Setup(r => r.GetRegistrationForType(typeof(Province))).Returns(provinceRegistration.Object);
            mockRegistry.Setup(r => r.GetRegistrationForType(typeof(Continent))).Returns(continentRegistration.Object);

            var linkConventions = new DefaultLinkConventions();

            var metadataObject = new JObject();
            metadataObject["baz"] = "qux";
            var metadata = new BasicMetadata(metadataObject);

            // Act
            var documentBuilder = new RegistryDrivenSingleResourceDocumentBuilder(mockRegistry.Object, linkConventions);
            var document = documentBuilder.BuildDocument(country, "http://www.example.com", new[] { "provinces.capital", "continent" }, metadata);

            // Assert
            document.PrimaryData.Id.Should().Be("4");
            document.PrimaryData.Type.Should().Be("countries");
            ((string) document.PrimaryData.Attributes["name"]).Should().Be("Spain");
            document.PrimaryData.Relationships.Count.Should().Be(3);

            var citiesRelationship = document.PrimaryData.Relationships.First();
            citiesRelationship.Key.Should().Be("cities");
            citiesRelationship.Value.SelfLink.Href.Should().Be("http://www.example.com/countries/4/relationships/cities");
            citiesRelationship.Value.RelatedResourceLink.Href.Should().Be("http://www.example.com/countries/4/cities");
            citiesRelationship.Value.Linkage.Should().BeNull();

            var provincesRelationship = document.PrimaryData.Relationships.Skip(1).First();
            provincesRelationship.Key.Should().Be("provinces");
            provincesRelationship.Value.SelfLink.Href.Should().Be("http://www.example.com/countries/4/relationships/provinces");
            provincesRelationship.Value.RelatedResourceLink.Href.Should().Be("http://www.example.com/countries/4/provinces");
            provincesRelationship.Value.Linkage.IsToMany.Should().BeTrue();
            provincesRelationship.Value.Linkage.Identifiers[0].Type.Should().Be("provinces");
            provincesRelationship.Value.Linkage.Identifiers[0].Id.Should().Be("506");
            provincesRelationship.Value.Linkage.Identifiers[1].Type.Should().Be("provinces");
            provincesRelationship.Value.Linkage.Identifiers[1].Id.Should().Be("507");

            var continentRelationship = document.PrimaryData.Relationships.Skip(2).First();
            AssertToOneRelationship(continentRelationship, "continent",
                "http://www.example.com/countries/4/relationships/continent",
                "http://www.example.com/countries/4/continent",
                "continents", "1");

            document.RelatedData.Length.Should().Be(4); // 2 provinces, 1 city, and 1 continent

            var province1RelatedData = document.RelatedData[0];
            province1RelatedData.Id.Should().Be("506");
            province1RelatedData.Attributes["name"].Value<string>().Should().Be("Badajoz");
            province1RelatedData.Type.Should().Be("provinces");
            province1RelatedData.Relationships.Count.Should().Be(1);

            var province1CapitalRelationship = province1RelatedData.Relationships.First();
            AssertToOneRelationship(province1CapitalRelationship, "capital",
                "http://www.example.com/provinces/506/relationships/capital",
                "http://www.example.com/provinces/506/capital",
                "cities", "12");

            var province2RelatedData = document.RelatedData[1];
            province2RelatedData.Id.Should().Be("507");
            province2RelatedData.Type.Should().Be("provinces");
            province2RelatedData.Attributes["name"].Value<string>().Should().Be("Cuenca");

            var province2CapitalRelationship = province2RelatedData.Relationships.First();
            AssertEmptyToOneRelationship(province2CapitalRelationship, "capital",
                "http://www.example.com/provinces/507/relationships/capital",
                "http://www.example.com/provinces/507/capital");

            var city3RelatedData = document.RelatedData[2];
            city3RelatedData.Id.Should().Be("12");
            city3RelatedData.Type.Should().Be("cities");
            city3RelatedData.Attributes["name"].Value<string>().Should().Be("Badajoz");

            var continentRelatedData = document.RelatedData[3];
            continentRelatedData.Id.Should().Be("1");
            continentRelatedData.Type.Should().Be("continents");
            continentRelatedData.Attributes["name"].Value<string>().Should().Be("Europe");
            continentRelatedData.Relationships.Count.Should().Be(1);
            var continentCountriesRelationship = continentRelatedData.Relationships.First();
            continentCountriesRelationship.Key.Should().Be("countries");
            continentCountriesRelationship.Value.SelfLink.Href.Should().Be("http://www.example.com/continents/1/relationships/countries");
            continentCountriesRelationship.Value.RelatedResourceLink.Href.Should().Be("http://www.example.com/continents/1/countries");
            continentCountriesRelationship.Value.Linkage.Should().BeNull();

            ((string) document.Metadata.MetaObject["baz"]).Should().Be("qux");
        }
        public void AddCountry(string continent, string region, string countryname, string iso)
        {
            ISOToCountryName[String.Intern(iso)] = String.Intern(countryname);
            CountryNameToISO[String.Intern(countryname)] = String.Intern(iso);

            var c = (Continent) Continents[continent];
            if (c == null)
            {
                c = new Continent();
                Continents[continent] = c;
            }

            var r = (Region) c.Regions[region];
            if (r == null)
            {
                r = new Region();
                c.Regions[region] = r;
            }
            r.CountryNames[countryname] = iso;
        }