Exemplo 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");
            }
        }
Exemplo 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");
            }
        }
Exemplo 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");
            }
        }
Exemplo n.º 4
0
        private void goPostgres()
        {
            if (System.IO.File.Exists(this.fileName.Text) && !string.IsNullOrEmpty(this.tableName.Text))
            {
                IRI.Ket.DataManagement.Infrastructure.PostgreSqlInfrastructure provider =
                    new IRI.Ket.DataManagement.Infrastructure.PostgreSqlInfrastructure("localhost", "postgres", "sa123456", "FarsiDatabase", "5432");

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

                DataTable table = dataSource.GetEntireFeature();

                //provider.CreateTable("CREATE TABLE " + this.tableName.Text + "(Id INT IDENTITY(1,1), Name NVARCHAR(100), Longitude FLOAT, Latitude FLOAT, Height FLOAT, Note NVARCHAR(500), WkbPosition IMAGE, Province NVARCHAR(50))");

                //D:\NGO\Data\Export_Output_2.shp

                string createTable =
                    "CREATE TABLE " + this.tableName.Text + " (WkbPosition VARBINARY, X FLOAT, Y FLOAT, name VARCHAR(250), county VARCHAR(200), province VARCHAR(100), natureType BOOLEAN, roadType BOOLEAN, population BOOLEAN, police BOOLEAN, electricity BOOLEAN, phone BOOLEAN, FM BOOLEAN, doctor BOOLEAN, pharmacy BOOLEAN)";

                provider.CreateTable(createTable);

                //provider.CreateTable("CREATE TABLE " + this.tableName.Text + "(Name NVARCHAR(300), WkbPosition IMAGE, X FLOAT, Y FLOAT)");

                //provider.ExecuteNonQuery("CREATE INDEX spatialIndex ON "+ this.tableName.Text + " (\"Y\" ASC, \"X\" ASC)");
                //provider.Insert(this.tableName.Text,

                //                    table,
                //                    new List<string>() { "Name", "WkbPosition" },
                //                    new List<Func<DataRow, object>>() {
                //                        i=>i["ابادي"],
                //                        i => ((Microsoft.SqlServer.Types.SqlGeography)i["Geo"]).GeodeticToMercator().STAsBinary().Buffer
                //                    });

                provider.Insert(
                    this.tableName.Text,
                    table,
                    new List <string>()
                {
                    "WkbPosition", "X", "Y", "name", "county", "province", "natureType", "roadType", "population", "police", "electricity", "phone", "FM", "doctor", "pharmacy"
                },
                    new List <DbType>()
                {
                    DbType.AnsiString, DbType.Double, DbType.Double, DbType.String,
                    DbType.String, DbType.String, DbType.Int32, DbType.Int32, DbType.Double,
                    DbType.Boolean, DbType.Boolean, DbType.Boolean, DbType.Boolean, DbType.Boolean, DbType.Boolean
                }
                    ,
                    new List <Func <DataRow, object> >()
                {
                    i => ((Microsoft.SqlServer.Types.SqlGeography)i["Geo"]).GeodeticToMercator().STAsText().Value,
                    i => ((Microsoft.SqlServer.Types.SqlGeography)i["Geo"]).GeodeticToMercator().STX.Value,
                    i => ((Microsoft.SqlServer.Types.SqlGeography)i["Geo"]).GeodeticToMercator().STY.Value,
                    i => i["ابادي"], i => i["شهرستان"], i => i["استان"], i => int.Parse(i["وضعيت_طبيع"].ToString()),
                    i => int.Parse(i["نوع_راه"].ToString()), i => i[5], i => !string.IsNullOrEmpty(i["پاسگاه_انت"].ToString()),
                    i => !string.IsNullOrEmpty(i["برق"].ToString()), i => !string.IsNullOrEmpty(i["داروخانه"].ToString()),
                    i => !string.IsNullOrEmpty(i[9].ToString()), i => !string.IsNullOrEmpty(i["موج_FM"].ToString()),
                    i => !string.IsNullOrEmpty(i["تلفن"].ToString())
                });

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