Ejemplo n.º 1
0
        private void goSdfForMountains()
        {
            if (System.IO.File.Exists(this.fileName.Text) && !string.IsNullOrEmpty(this.tableName.Text) && System.IO.File.Exists(this.sdfFileLocation.Text))
            {
                IRI.Ket.DataManagement.Infrastructure.SqlServerCeInfrastructure provider =
                    new IRI.Ket.DataManagement.Infrastructure.SqlServerCeInfrastructure(this.sdfFileLocation.Text);

                IRI.Ket.DataManagement.ShapefileDataSource <object> dataSource =
                    new IRI.Ket.DataManagement.ShapefileDataSource <object>(this.fileName.Text, "Geo", 4326, false);

                DataTable table = dataSource.GetEntireFeature();

                string createTable =
                    "CREATE TABLE " + this.tableName.Text + " (Id INT IDENTITY(1,1) PRIMARY KEY, Column1 IMAGE, Column2 IMAGE)";

                provider.CreateTable(createTable);

                provider.Insert(this.tableName.Text,
                                table,
                                new List <string>()
                {
                    "Column1", "Column2"
                },
                                new List <Func <DataRow, object> >()
                {
                    i => ((Microsoft.SqlServer.Types.SqlGeography)i["Geo"]).GeodeticToMercator().STAsBinary().Buffer,
                    i => IRI.Ket.IO.BinaryStream.StructureToByteArray(
                        new MountainStructure()
                    {
                        Name                = ArabicToFarsi(i["نام_كوه"].ToString()),
                        SecondaryName       = ArabicToFarsi(i["نام_ديگر"].ToString()),
                        Longitude           = double.Parse(i["طول"].ToString()),
                        Latitude            = double.Parse(i["عرض"].ToString()),
                        Height              = double.Parse(i["ارتفاع"].ToString()),
                        Orientation         = ArabicToFarsi(i["جهت_كوه"].ToString()),
                        NearestCity         = ArabicToFarsi(i["نزديكترين"].ToString()),
                        DistanceToCity      = double.Parse(i["فاصله_تانز"].ToString()),
                        CityRelatedPosition = ArabicToFarsi(i["موقعيت_نسب"].ToString()),
                        Mountains           = ArabicToFarsi(i["ازرشته_كوه"].ToString()),
                        OriginatingRiver    = ArabicToFarsi(i["سرچشمه_رود"].ToString()),
                        CrossingRiver       = ArabicToFarsi(i["مسيرعبوررو"].ToString()),
                        Note                = ArabicToFarsi(i["توضيحات"].ToString()),
                        Province            = ArabicToFarsi(i["استان"].ToString()),
                        IsEdgy              = i["کوه_مرزي_2"].ToString().Length > 0,
                    })
                });

                MessageBox.Show("Done Sucessfully");
            }
        }
Ejemplo n.º 2
0
        private void goSdfForVillages()
        {
            if (System.IO.File.Exists(this.fileName.Text) && !string.IsNullOrEmpty(this.tableName.Text) && System.IO.File.Exists(this.sdfFileLocation.Text))
            {
                IRI.Ket.DataManagement.Infrastructure.SqlServerCeInfrastructure provider =
                    new IRI.Ket.DataManagement.Infrastructure.SqlServerCeInfrastructure(this.sdfFileLocation.Text);

                IRI.Ket.DataManagement.ShapefileDataSource <object> dataSource =
                    new IRI.Ket.DataManagement.ShapefileDataSource <object>(this.fileName.Text, "WkbPosition", 4326, false);

                DataTable table = dataSource.GetEntireFeature();

                string createTable =
                    "CREATE TABLE " + this.tableName.Text + " (Id INT IDENTITY(1,1) PRIMARY KEY, Column1 IMAGE, Column2 IMAGE)";

                provider.CreateTable(createTable);

                provider.Insert(
                    this.tableName.Text,
                    table,
                    new List <string>()
                {
                    "Column1", "Column2"
                },
                    new List <Func <DataRow, object> >()
                {
                    i => ((Microsoft.SqlServer.Types.SqlGeography)i["WkbPosition"]).GeodeticToMercator().STAsBinary().Buffer,
                    i => IRI.Ket.IO.BinaryStream.StructureToByteArray(
                        new OldVillage(
                            ArabicToFarsi(i["ابادي"].ToString()),
                            ArabicToFarsi(i["شهرستان"].ToString()),
                            ArabicToFarsi(i["استان"].ToString()),
                            int.Parse(i["وضعيت_طبيع"].ToString()),
                            int.Parse(i["نوع_راه"].ToString()),
                            int.Parse(i["جمعيت_كل"].ToString()),
                            !string.IsNullOrEmpty(i["پاسگاه_انت"].ToString()),
                            !string.IsNullOrEmpty(i["برق"].ToString()),
                            !string.IsNullOrEmpty(i["تلفن"].ToString()),
                            !string.IsNullOrEmpty(i["موج_FM"].ToString()),
                            !string.IsNullOrEmpty(i["پزشك"].ToString()),
                            !string.IsNullOrEmpty(i["داروخانه"].ToString())))
                }
                    );
                MessageBox.Show("Done Sucessfully");
            }
        }
Ejemplo n.º 3
0
        private void goSdfForCountyCenter()
        {
            if (System.IO.File.Exists(this.fileName.Text) && !string.IsNullOrEmpty(this.tableName.Text) && System.IO.File.Exists(this.sdfFileLocation.Text))
            {
                IRI.Ket.DataManagement.Infrastructure.SqlServerCeInfrastructure provider =
                    new IRI.Ket.DataManagement.Infrastructure.SqlServerCeInfrastructure(this.sdfFileLocation.Text);

                IRI.Ket.DataManagement.ShapefileDataSource <object> dataSource =
                    new IRI.Ket.DataManagement.ShapefileDataSource <object>(this.fileName.Text, "Geo", 4326, false);

                DataTable table = dataSource.GetEntireFeature();

                string createTable =
                    "CREATE TABLE IRICountyCenter (County NVARCHAR(25) NOT NULL, CountyCenter NVARCHAR(25) NOT NULL, EstablishYear INT NOT NULL, Code INT NOT NULL, Province NVARCHAR(25) NOT NULL, Latitude FLOAT NOT NULL, Longitude FLOAT NOT NULL, Geo IMAGE NOT NULL)";

                provider.CreateTable(createTable);

                provider.Insert(this.tableName.Text,
                                table,
                                new List <string>()
                {
                    "Geo", "County", "CountyCenter", "EstablishYear", "Code", "Province", "Latitude", "Longitude"
                },
                                new List <Func <DataRow, object> >()
                {
                    i => ((Microsoft.SqlServer.Types.SqlGeography)i["Geo"]).GeodeticToMercator().STAsBinary().Buffer,
                    i => ArabicToFarsi(i[0].ToString()),
                    i => ArabicToFarsi(i[1].ToString()),
                    i => int.Parse(i[2].ToString()),
                    i => int.Parse(i[3].ToString()),
                    i => ArabicToFarsi(i[4].ToString()),
                    i => double.Parse(i[5].ToString()),
                    i => double.Parse(i[6].ToString()),
                });

                MessageBox.Show("Done Sucessfully");
            }
        }