Exemple #1
0
        private static void ProcessLine(string line, StreamWriter writer)
        {
            string[] chunks = line.Split(CSV_DELIMITER);

            if (IsLineValid(chunks))
            {
                string adress = chunks[6].Replace("г. ", "");
                string year   = chunks[7];

                GeoObjectCollection results = YandexGeocoder.Geocode(chunks[6], 1, LangType.ru_RU);
                if (results.Count() > 0)
                {
                    writer.WriteLine("{0},{1},{2},{3}", adress, year, results.First().Point.Lat, results.First().Point.Long);
                }
            }
        }
Exemple #2
0
        public async Task <BuildingAddress> GetBuildingAsync(GeoPoint geoPoint)
        {
            GeoObjectCollection objectCollection =
                await this.Geocoder.ReverseGeocodeAsync(geoPoint, GeoObjectKind.House, 1, LangType.RU);

            GeoObject geoObject = objectCollection.First();
            Address   address   = geoObject.GeocoderMetaData.Address;

            int buildingId =
                await this.BuildingRepository.GetBuildingIdOrDefaultAsync(geoPoint.Latitude, geoPoint.Longitude);

            if (buildingId != default(int))
            {
                return(await this.BuildingRepository.GetBuildingAsync(buildingId));
            }

            int id = await this.PolyclinicRegionProvider.GetPolyclinicRegionIdAsync(address);

            PolyclinicRegion region = await this.PolyclinicRegionService.GetRegionAsync(id);

            BuildingAddress building = new BuildingAddress
            {
                City             = $"{address.Locality}, {address.Province}, {address.Country}",
                Street           = address.Street,
                Building         = address.House,
                Latitude         = geoPoint.Latitude,
                Longitude        = geoPoint.Longitude,
                PolyclinicRegion = region
            };

            int insertedBuildingId = await this.InsertOrUpdateBuildingAsync(building);

            building.Id = insertedBuildingId;

            return(building);
        }