Ejemplo n.º 1
0
 public Geocoder()
 {
     cultureInfo = new System.Globalization.CultureInfo("tr-TR");
     addressLevel = new AddressLevel();
     geocoderService = new GeocoderService();
     hierarchy = new string[7, 2];
 }
Ejemplo n.º 2
0
        private void FillScreen(AddressLevel addressLevel)
        {
            if (addressLevel.XCoor == string.Empty || addressLevel.XCoor == "0")
            {
                MessageBox.Show("Adres bulunamadı");
                return;
            }

            lblIl.Text = addressLevel.Il;
            lblIlce.Text = addressLevel.Ilçe;
            lblMahalle.Text = addressLevel.Mahalle;
            lblCadde.Text = addressLevel.Cadde;
            lblSokak.Text = addressLevel.Sokak;
            lblBulvar.Text = addressLevel.Bulvar;
            lblPoi.Text = addressLevel.Poi;
            lblBina.Text = addressLevel.Bina;
            lblBlok.Text = addressLevel.Blok;
            lblDaire.Text = addressLevel.Daire;
            lblKapı.Text = addressLevel.Kapı;
            lblKat.Text = addressLevel.Kat;
            lblKöy.Text = addressLevel.Köy;
            lblXcoor.Text = addressLevel.XCoor;
            lblYcoor.Text = addressLevel.YCoor;
            lblLevel.Text = GetLevel(addressLevel);

            LoadMap(addressLevel);
        }
Ejemplo n.º 3
0
        private List <HINTTOWNGEOTOWNCR> GetTown(AddressLevel addressLevel, HINTCITYGEOCITYCR city)
        {
            var townList =
                geocoderEntities.
                HINTTOWNGEOTOWNCR.
                Where(x =>
                      x.ILCE_ADI == addressLevel.Ilçe &&
                      x.IL_ID == city.IL_ID).ToList();

            return(townList);
        }
Ejemplo n.º 4
0
        private List <ILCE> GetTown(AddressLevel addressLevel, IL city)
        {
            var townList =
                geocoderEntities.
                ILCE.
                Where(x =>
                      x.ILCE_ADI == addressLevel.Ilçe &&
                      x.IL_ID == city.IL_ID)
                .ToList();

            return(townList);
        }
Ejemplo n.º 5
0
        private static List<string> CheckForTown(IEnumerable<string> notParsedList, ref AddressLevel addressLevel)
        {
            List<string> result = new List<string>();
            decimal ilId = addressLevel.IlId;

            foreach (var item in notParsedList)
            {
                var town = entities.HINTTOWNGEOTOWNCR.FirstOrDefault(x => x.ILCE_ADI == item.Trim() && x.IL_ID == ilId);

                if (town != null)
                    addressLevel.Ilçe = item.Trim();
                else
                    result.Add(item);
            }

            return result;
        }
Ejemplo n.º 6
0
        private List<string> CheckForCity(IEnumerable<string> notParsedList, ref AddressLevel addressLevel)
        {
            List<string> result = new List<string>();

            foreach (var item in notParsedList)
            {
                var city = geocoderService.GetCityByName(item.Trim());

                if (city != null)
                {
                    addressLevel.Il = item.Trim();
                    addressLevel.IlId = city.IL_ID;
                }
                else
                    result.Add(item);
            }

            return result;
        }
Ejemplo n.º 7
0
        static List<string> CheckForCity(List<string> notParsedList, ref AddressLevel addressLevel)
        {
            List<string> result = new List<string>();

            foreach (var item in notParsedList)
            {
                //var city = GetCityByName(item.Trim());
                var city = entities.HINTCITYGEOCITYCR.FirstOrDefault(x => x.IL_ADI == item.Trim());

                if (city != null)
                {
                    addressLevel.Il = item.Trim();
                    addressLevel.IlId = city.IL_ID;
                }
                else
                    result.Add(item);
            }

            return result;
        }
Ejemplo n.º 8
0
        public static GeocoderAPIResultModel ConvertAddressLevelToGeocoderAPIResultModel(AddressLevel model)
        {
            GeocoderAPIResultModel result = new GeocoderAPIResultModel();

            result.Bina = model.Bina;
            result.Blok = model.Blok;
            result.Bulvar = model.Bulvar;
            result.Bulvar1 = model.Bulvar1;
            result.Bulvar2 = model.Bulvar2;
            result.BulvarS = model.BulvarS;
            result.Cadde = model.Cadde;
            result.Cadde1 = model.Cadde1;
            result.Cadde2 = model.Cadde2;
            result.CaddeS = model.CaddeS;
            result.CoordinateLevel = model.CoordinateLevel;
            result.Daire = model.Daire;
            result.Il = model.Il;
            result.Ilçe = model.Ilçe;
            result.Kapı = model.Kapı;
            result.Kat = model.Kat;
            result.Köy = model.Köy;
            result.Mahalle = model.Mahalle;
            result.OriginalAddress = model.OriginalAddress;
            result.Poi = model.Poi;
            result.Poi1 = model.Poi1;
            result.Poi2 = model.Poi2;
            result.Poi3 = model.Poi3;
            result.PoiS = model.PoiS;
            result.PostaKodu = model.PostaKodu;
            result.Sokak = model.Sokak;
            result.Sokak1 = model.Sokak1;
            result.Sokak2 = model.Sokak2;
            result.SokakS = model.SokakS;
            result.XCoor = model.XCoor;
            result.YCoor = model.YCoor;
            result.Yolu = model.Yolu;

            return result;
        }
Ejemplo n.º 9
0
        public AddressLevel ParseAddress(string address)
        {
            int counter = 0;
             int index = 0;

            NotParsedList = new List<string>();

            string[] tokens = Regex.Split(address, " ");

            AddressLevel addressLevel = new AddressLevel();
            addressLevel.OriginalAddress = address;

            while (counter < tokens.Length)
            {
                string tempAddress = " " + tokens[counter] + " ";

                int type = CheckType(tempAddress, counter, tokens);
                string token = string.Empty;

                switch (type)
                {
                    case (int)Enums.ParsingAdress.Mahalle:
                        for (int i = index; i < counter; i++)
                        {
                            token += " " + tokens[i] + " ";
                        }
                        addressLevel.Mahalle = token.Replace("  ", " ").TrimStart().TrimEnd();
                        index = counter + 1;
                        ClearNotParsedList(token);
                        break;
                    case (int)Enums.ParsingAdress.Cadde:
                        if (addressLevel.Cadde == "")
                        {
                            for (int i = index; i < counter; i++)
                            {
                                token += " " + tokens[i] + " ";
                            }
                            addressLevel.Cadde = token.Replace("  ", " ").TrimStart().TrimEnd();
                            ClearNotParsedList(token);

                            string[] caddeLength = Regex.Split(token.Replace("  ", " ").TrimStart().TrimEnd(), " ");

                            if (caddeLength.Length > 1)
                            {
                                for (int i = 0; i < caddeLength.Length; i++)
                                {
                                    ClearNotParsedList(caddeLength[i]);

                                    if (i == 0)
                                    {
                                        addressLevel.Cadde1 = caddeLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                    else if (i == 1)
                                    {
                                        addressLevel.Cadde2 = caddeLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                    else if (i > 1)
                                    {
                                        addressLevel.CaddeS += " " + caddeLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                }
                            }
                        }
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.Sokak:
                        if (addressLevel.Sokak == "")
                        {
                            for (int i = index; i < counter; i++)
                            {
                                token += " " + tokens[i] + " ";
                            }
                            addressLevel.Sokak = token.Replace("  ", " ").TrimStart().TrimEnd();
                            ClearNotParsedList(token);

                            string[] sokakLength = Regex.Split(token.Replace("  ", " ").TrimStart().TrimEnd(), " ");

                            if (sokakLength.Length > 1)
                            {
                                for (int i = 0; i < sokakLength.Length; i++)
                                {
                                    ClearNotParsedList(sokakLength[i]);

                                    if (i == 0)
                                    {
                                        addressLevel.Sokak1 = sokakLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                    else if (i == 1)
                                    {
                                        addressLevel.Sokak2 = sokakLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                    else if (i > 1)
                                    {
                                        addressLevel.SokakS += " " + sokakLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                }
                            }
                        }
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.POI:
                        if (addressLevel.Poi == "")
                        {
                            for (int i = index; i <= counter; i++)
                            {
                                token += " " + tokens[i] + " ";
                            }

                            token = token.Replace(" İŞ.MRK. ", " İŞ MERKEZİ ");
                            token = token.Replace(" TİC.MRK. ", " TİCARET MERKEZİ ");
                            token = token.Replace(" TİC.AŞ. ", " TİCARET ");
                            token = token.Replace(" ORG.SAN. ", " ORGANİZE SANAYİ ");
                            token = token.Replace(" RENT.A.CAR ", " RENT A CAR ");
                            token = token.Replace(" TATİL.KÖYÜ ", " TATİL KÖYÜ ");
                            token = token.Replace(" VİLLALARİ ", " VİLLALARI ");

                            addressLevel.Poi = token.Replace("  ", " ").TrimStart().TrimEnd();
                            ClearNotParsedList(token);

                            string[] poiLength = Regex.Split(token.Replace("  ", " ").TrimStart().TrimEnd(), " ");

                            if (poiLength.Length > 1)
                            {
                                for (int i = poiLength.Length - 1; i >= 0; i--) //Sondan kırpma işlemi
                                {
                                    ClearNotParsedList(poiLength[i]);

                                    if (i == 0)
                                    {
                                        addressLevel.Poi1 = poiLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                    else if (i == 1)
                                    {
                                        addressLevel.Poi2 = poiLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                    else if (i == 2)
                                    {
                                        addressLevel.Poi3 = poiLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                    else if (i > 2)
                                    {
                                        addressLevel.PoiS += " " + poiLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                }
                            }
                        }
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.Yolu:
                        for (int i = index; i <= counter; i++)
                        {
                            token += " " + tokens[i] + " ";
                        }
                        addressLevel.Yolu = token.Replace(".GİRİŞİ", "").Replace(".KAVŞAĞI", " KAVŞAĞI").Replace("MEVKİİ", "MEVKİ").Replace(".ÜZERİ", "").Replace("  ", " ").TrimStart().TrimEnd();
                        ClearNotParsedList(token);
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.Köy:
                        for (int i = index; i < counter; i++)
                        {
                            token += " " + tokens[i] + " ";
                        }
                        addressLevel.Köy = token.Replace("  ", " ").TrimStart().TrimEnd();
                        ClearNotParsedList(token);
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.Bulvar:
                        if (addressLevel.Bulvar == "")
                        {
                            for (int i = index; i < counter; i++)
                            {
                                token += " " + tokens[i] + " ";
                            }

                            addressLevel.Bulvar = token.Replace("  ", " ").TrimStart().TrimEnd();
                            ClearNotParsedList(token);

                            string[] bulvarLength = Regex.Split(token.Replace("  ", " ").TrimStart().TrimEnd(), " ");

                            if (bulvarLength.Length > 1)
                            {
                                for (int i = 0; i < bulvarLength.Length; i++)
                                {
                                    ClearNotParsedList(bulvarLength[i]);

                                    if (i == 0)
                                    {
                                        addressLevel.Bulvar1 = bulvarLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                    else if (i == 1)
                                    {
                                        addressLevel.Bulvar2 = bulvarLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                    else if (i > 1)
                                    {
                                        addressLevel.BulvarS += " " + bulvarLength[i].Replace("  ", " ").TrimStart().TrimEnd();
                                    }
                                }
                            }
                        }
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.Kapı:
                        addressLevel.Kapı = tokens[counter].Replace("NO:", "").Replace("  ", " ").TrimStart().TrimEnd();
                        ClearNotParsedList(token);
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.Kat:

                        tokens[counter] = tokens[counter].Replace("K:", "").Replace("  ", " ").TrimStart().TrimEnd();

                        string patternK = @"(-)|(/)";
                        string[] Ks = Regex.Split(tokens[counter], patternK);

                        addressLevel.Kat = Ks[0];
                        ClearNotParsedList(Ks[0]);
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.Daire:

                        tokens[counter] = tokens[counter].Replace("D:", "").Replace("  ", " ").TrimStart().TrimEnd();

                        string patternD = @"(-)|(/)";
                        string[] Ds = Regex.Split(tokens[counter], patternD);

                        addressLevel.Daire = Ds[0];
                        ClearNotParsedList(Ds[0]);
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.Blok:
                        for (int i = index; i < counter; i++)
                        {
                            token += " " + tokens[i] + " ";
                        }
                        addressLevel.Blok = token.Replace("  ", " ").TrimStart().TrimEnd();
                        ClearNotParsedList(token);
                        index = counter + 1;
                        break;
                    case (int)Enums.ParsingAdress.Bina:
                        for (int i = index; i <= counter; i++)
                        {
                            token += " " + tokens[i] + " ";
                        }
                        addressLevel.Bina = token.Replace("  ", " ").TrimStart().TrimEnd();
                        ClearNotParsedList(token.Replace(" APT. ", ""));
                        index = counter + 1;
                        break;
                    default:
                        if (!tempAddress.Equals(string.Empty))
                        {
                            NotParsedList.Add(tempAddress);
                        }
                        break;
                }

                counter ++;
            }

            return addressLevel;
        }
Ejemplo n.º 10
0
        public List<string> CheckForTown(IEnumerable<string> notParsedList, ref AddressLevel addressLevel)
        {
            List<string> result = new List<string>();
            decimal ilId = addressLevel.IlId;

            foreach (var item in notParsedList)
            {
                var town = geocoderService.GetTownByNameAndCityId(item.Trim(), addressLevel.IlId);

                if (town != null)
                    addressLevel.Ilçe = item.Trim();
                else
                    result.Add(item);
            }

            return result;
        }
Ejemplo n.º 11
0
        public AddressLevel Geocode(AddressLevel addressLevel)
        {
            this.addressLevel = addressLevel;

            try
            {
                AddressGeocode();
            }
            catch (Exception ex)
            {
                //throw;
                Log(ex);
            }

            for (var i = 6; i >= 0; i--)
            {
                if (hierarchy[i, 0] != "9999999")
                {
                    addressLevel.XCoor = hierarchy[i, 0];
                    addressLevel.YCoor = hierarchy[i, 1];
                    addressLevel.CoordinateLevel = i;
                    break;
                }
            }

            return addressLevel;
        }
Ejemplo n.º 12
0
        private List<HINTTOWNGEOTOWNCR> GetTown(AddressLevel addressLevel, HINTCITYGEOCITYCR city)
        {
            var townList =
                 geocoderEntities.
                 HINTTOWNGEOTOWNCR.
                 Where( x =>
                     x.ILCE_ADI == addressLevel.Ilçe
                     && x.IL_ID == city.IL_ID).ToList();

            return townList;
        }
Ejemplo n.º 13
0
 private HINTCITYGEOCITYCR GetCity(AddressLevel addressLevel)
 {
     var city = geocoderEntities.HINTCITYGEOCITYCR.FirstOrDefault(x => x.IL_ADI == addressLevel.Il);
     return city;
 }
Ejemplo n.º 14
0
        private List<ILCE> GetTown(AddressLevel addressLevel, IL city)
        {
            var townList =
                 geocoderEntities.
                    ILCE.
                        Where(x =>
                            x.ILCE_ADI == addressLevel.Ilçe
                            && x.IL_ID == city.IL_ID)
                                .ToList();

            return townList;
        }
Ejemplo n.º 15
0
        private HINTCITYGEOCITYCR GetCity(AddressLevel addressLevel)
        {
            var city = geocoderEntities.HINTCITYGEOCITYCR.FirstOrDefault(x => x.IL_ADI == addressLevel.Il);

            return(city);
        }
Ejemplo n.º 16
0
 private string GetLevel(AddressLevel addressLevel)
 {
     switch (addressLevel.CoordinateLevel)
     {
         case 0:
             return "İL";
         case 1:
             return "İLÇE";
         case 2:
             return "MAHALLE";
         case 3:
             return "CADDE";
         case 4:
             return "SOKAK";
         case 5:
             return "POI";
         case 6:
             return "KAPI";
         default:
             return "";
     }
 }
Ejemplo n.º 17
0
 public AddressLevel Geocoder(AddressLevel addressLevel)
 {
     return geocoder.Geocode(addressLevel);
 }
Ejemplo n.º 18
0
        private void LoadMap(AddressLevel addressLevel)
        {
            string geocoderSampleName = "Sample";

            //string url = string.Format("https://www.google.com/maps/place//@{0},{1},15z", addressLevel.YCoor, addressLevel.XCoor);
            string url = string.Format("http://www.openstreetmap.org/?mlat={0}&mlon={1}#map=19/{0}/{1}", addressLevel.YCoor, addressLevel.XCoor);
            //string url = string.Format("http://www.bing.com/maps/default.aspx?sp=point.{0}_{1}_{2}_{3}_{4}_{5}",
            //    addressLevel.YCoor,
            //    addressLevel.XCoor,
            //    "MUSTAFA", //title,
            //    "NOT", //note,
            //    "www.google.com", //linkUrl,
            //    "");  //photoUrl);

            webBrowser1.Url = new Uri(url);
            webBrowser1.Show();
        }