Example #1
0
        private static void generateLocations()
        {
            var prefectureList           = new PrefectureList();
            var municipalityNameTransfer = new MunicipalityNameTransfer();

            var postalCodeFileReader = new PostalCodeFileReader(municipalityNameTransfer, new TownAreaNameTransfer());

            foreach (var postalCode in postalCodeFileReader.ReadFile(postalCodePath))
            {
                prefectureList.Add(postalCode);
            }

            var addressFileReader = new AddressFileReader(municipalityNameTransfer);

            foreach (var address in Directory.GetFiles(addressFolder).SelectMany(x => addressFileReader.ReadFile(Path.Combine(addressFolder, x))))
            {
                prefectureList.Add(address);
            }

            var locationMatcher = new LocationMatcher();
            IReadOnlyList <LocationMatch> foundLocations = locationMatcher.FindLocations(prefectureList);
            var locationCalculator             = new LocationCalculator();
            IReadOnlyList <Location> locations = locationCalculator.Calculate(foundLocations);

            File.WriteAllText(locationPath, JsonSerializer.PrettyPrint(JsonSerializer.Serialize(locations)));
            Console.WriteLine("output Locations.json");
        }
Example #2
0
        public void DistanceCalculationWithEqualLongAndLats()
        {
            //Arrange
            const decimal propertyLat  = (decimal) - 33.69840001358826;
            const decimal propertyLong = (decimal)150.9021577216302;
            //Act
            var result = LocationMatcher.DistanceCalculator(propertyLat, propertyLong, propertyLat, propertyLong);

            //Assert
            Assert.Equal(0, result);
        }
Example #3
0
        public void DistanceCalculationWithLessThan200MDistance()
        {
            //Arrange
            const decimal propertyLat1  = (decimal) - 33.69840001358826;
            const decimal propertyLong1 = (decimal)150.9021577216302;
            const decimal propertyLat2  = (decimal) - 33.69947764869006;
            const decimal propertyLong2 = (decimal)150.90192879768415;
            //Act
            var result = LocationMatcher.DistanceCalculator(propertyLat1, propertyLong1, propertyLat2, propertyLong2);

            //Assert
            Assert.True(result < 200);
        }
Example #4
0
        public void DistanceCalculationWithMoreThan200MDistance()
        {
            //Arrange
            const decimal propertyLat1  = (decimal) - 33.69840001358826;
            const decimal propertyLong1 = (decimal)150.9021577216302;
            const decimal propertyLat2  = (decimal) - 33.69880526865836;
            const decimal propertyLong2 = (decimal)150.90490143612098;
            //Act
            var result = LocationMatcher.DistanceCalculator(propertyLat1, propertyLong1, propertyLat2, propertyLong2);

            //Assert
            Assert.True(result > 200);
        }
        public void UnrelatedJobLocationDoesNotMatch()
        {
            var job = new Job()
            {
                Locations = new List <string>()
                {
                    "Lewes"
                }
            };

            var matcher = new LocationMatcher("Crowborough");

            var result = matcher.IsMatch(job);

            Assert.IsFalse(result);
        }
        public void JobLocationMatched()
        {
            var job = new Job()
            {
                Locations = new List <string>()
                {
                    "Crowborough"
                }
            };

            var matcher = new LocationMatcher("Crowborough");

            var result = matcher.IsMatch(job);

            Assert.IsTrue(result);
        }
        protected override IPropertyMatcher MakePropertyMatcher()
        {
            IPropertyMatcher propertyMatch = new LocationMatcher();

            return(propertyMatch);
        }