public int CreateTable(MG_FieldSet fieldSet, MG_GeometryType gt)
 {
     if (this.IsTableExist(fieldSet.GetName()))
         return 0;
     this.sql_CreateTable(fieldSet, gt, out m_strSQL, out m_sqlParams);
     return this.RunSQL(m_strConn, m_strSQL, m_sqlParams);
 }
Beispiel #2
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);
        }
 public int CreateTable(MG_FieldSet fieldSet, MG_GeometryType gt)
 {
     if (this.IsTableExist(fieldSet.GetName()))
     {
         return(0);
     }
     this.sql_CreateTable(fieldSet, gt, out m_strSQL, out m_sqlParams);
     return(this.RunSQL(m_strConn, m_strSQL, m_sqlParams));
 }
Beispiel #4
0
        public int CreateTable(MG_FieldSet fieldSet, MG_GeometryType gt)
        {
            if (this.IsTableExist(fieldSet.GetName()))
            {
                return(0);
            }
            string strSQL = this.sql_CreateTable(fieldSet, gt);

            return(this.Run(strSQL));
        }
Beispiel #5
0
        private string LayerPath; // null or not

        #endregion Fields

        #region Constructors

        public MG_Layer()
        {
            layerCount++;
            this.LayerName = "Layer_" + layerCount.ToString();
            this.LayerPath = null;
            this.IsVisible = true;
            this.FeatureSet = new MG_FeatureSet();
            this.FieldSet = new MG_FieldSet(this.LayerName);
            this.Extent = new MG_MapExtent();
            this.Type = MG_GeometryType.NONE;
        }
Beispiel #6
0
        public MG_GeometryType Type; // default NONE

        public MG_Layer()
        {
            layerCount++;
            this.LayerName  = "Layer_" + layerCount.ToString();
            this.LayerPath  = null;
            this.IsVisible  = true;
            this.FeatureSet = new MG_FeatureSet();
            this.FieldSet   = new MG_FieldSet(this.LayerName);
            this.Extent     = new MG_MapExtent();
            this.Type       = MG_GeometryType.NONE;
        }
Beispiel #7
0
 // feature
 public void AddFeature(MG_Feature feature)
 {
     if (this.Type == MG_GeometryType.NONE)
     {
         this.Type = feature.GetGeometry().Type;
         this.FeatureSet.Add(feature);
     }
     else if (this.Type == feature.GetGeometry().Type)
     {
         this.FeatureSet.Add(feature);
     }
 }
Beispiel #8
0
 // feature
 public void AddFeature(MG_Feature feature)
 {
     if (this.Type == MG_GeometryType.NONE)
     {
         this.Type = feature.GetGeometry().Type;
         this.FeatureSet.Add(feature);
     }
     else if (this.Type == feature.GetGeometry().Type)
     {
         this.FeatureSet.Add(feature);
     }
 }
Beispiel #9
0
 public void InitializeLayerType(MG_GeometryType type)
 {
     this.layerType = type;
     switch (type)
     {
         case MG_GeometryType.POINT:
             this.radioButton1_Point.Checked = true;
             break;
         case MG_GeometryType.LINESTRING:
             this.radioButton2_LineString.Checked = true;
             break;
         case MG_GeometryType.POLYGON:
             this.radioButton3_Polygon.Checked = true;
             break;
     }
 }
Beispiel #10
0
        public void InitializeLayerType(MG_GeometryType type)
        {
            this.layerType = type;
            switch (type)
            {
            case MG_GeometryType.POINT:
                this.radioButton1_Point.Checked = true;
                break;

            case MG_GeometryType.LINESTRING:
                this.radioButton2_LineString.Checked = true;
                break;

            case MG_GeometryType.POLYGON:
                this.radioButton3_Polygon.Checked = true;
                break;
            }
        }
Beispiel #11
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string name = this.textBox1_layerName.Text.Trim().ToString();
            if (!name.Equals(""))
            {
                this.layerName = name;
            }
            if (this.radioButton1_Point.Checked)
            {
                this.layerType = MG_GeometryType.POINT;
            }
            else if (this.radioButton2_LineString.Checked)
            {
                this.layerType = MG_GeometryType.LINESTRING;
            }
            else if (this.radioButton3_Polygon.Checked)
            {
                this.layerType = MG_GeometryType.POLYGON;
            }

            this.Close();
        }
Beispiel #12
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string name = this.textBox1_layerName.Text.Trim().ToString();

            if (!name.Equals(""))
            {
                this.layerName = name;
            }
            if (this.radioButton1_Point.Checked)
            {
                this.layerType = MG_GeometryType.POINT;
            }
            else if (this.radioButton2_LineString.Checked)
            {
                this.layerType = MG_GeometryType.LINESTRING;
            }
            else if (this.radioButton3_Polygon.Checked)
            {
                this.layerType = MG_GeometryType.POLYGON;
            }

            this.Close();
        }
Beispiel #13
0
        public static wkbGeometryType TowkbGeometryType(MG_GeometryType type)
        {
            wkbGeometryType geomType;

            switch (type)
            {
            case MG_GeometryType.POINT:
                geomType = wkbGeometryType.wkbPoint;
                break;

            case MG_GeometryType.MULTIPOINT:
                geomType = wkbGeometryType.wkbMultiPoint;
                break;

            case MG_GeometryType.LINESTRING:
                geomType = wkbGeometryType.wkbLineString;
                break;

            case MG_GeometryType.MULTILINESTRING:
                geomType = wkbGeometryType.wkbMultiLineString;
                break;

            case MG_GeometryType.POLYGON:
                geomType = wkbGeometryType.wkbPolygon;
                break;

            case MG_GeometryType.MULTIPOLYGON:
                geomType = wkbGeometryType.wkbMultiPolygon;
                break;

            default:
                geomType = wkbGeometryType.wkbUnknown;
                break;
            }
            return(geomType);
        }
Beispiel #14
0
 public void SetLayerType(MG_GeometryType type)
 {
     this.Type = type;
 }
Beispiel #15
0
 public void SetLayerType(MG_GeometryType type)
 {
     this.Type = type;
 }
        private void sql_CreateTable(MG_FieldSet fieldSet, MG_GeometryType gt, out string strSQL, out NpgsqlParameter[] sqlParams)
        {
            // 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, field.Type.ToString());
            }
            string end = "); SELECT AddGeometryColumn('public','{0}','geom',0,'{1}',2);";
            end = String.Format(end, table, gt.ToString());

            strSQL = front + mid + end;
            sqlParams = null;
        }