Exemple #1
0
        private string sql_CreateTable(MG_FieldSet fieldSet, MG_GeometryType gt)
        {// oid, field1, field2, field3, field4,...fieldN, geom
         //CREATE TABLE point2 ( oid SERIAL PRIMARY KEY, name1 VARCHAR, name2 VARCHAR); SELECT AddGeometryColumn('public','point2','geom',0,'POINT',2);
         // table name, column name must be lowercase, e.g.   pointTABLE --->pointtable

            string front = "CREATE TABLE {0} ( oid SERIAL PRIMARY KEY";
            string table = fieldSet.GetName().ToLower();

            front = String.Format(front, table);

            string m   = ", {0} {1}";
            string mid = "";

            for (int i = 0; i < fieldSet.Count(); i++)
            {
                MG_Field field = fieldSet.GetAt(i);
                mid += String.Format(m, field.Name.ToLower(), field.Type.ToString());
            }
            string end = "); SELECT AddGeometryColumn('public','{0}','geom',0,'{1}',2);";

            end = String.Format(end, table, gt.ToString());

            string strSQL = front + mid + end;

            return(strSQL);
        }
Exemple #2
0
        public static FeatureDefn ToFeatureDefn(MG_FieldSet fieldSet)
        {
            FeatureDefn def = new FeatureDefn(null);

            for (int i = 0; i < fieldSet.Count(); i++)
            {
                MG_Field  field = fieldSet.GetAt(i);
                FieldDefn fdef  = ToFieldDefn(field);
                def.AddFieldDefn(fdef);
            }
            return(def);
        }