예제 #1
0
 public MG_Feature(MG_FieldSet fs)
 {
     this.FieldSet = fs;
     this.ValueSet = new MG_ValueSet();
     this.Geometry = new MG_Geometry();
     this.Symbol   = new MG_Symbol();
 }
예제 #2
0
        private MG_FieldSet FieldSet; // same as Layer.FieldSet

        #endregion Fields

        #region Constructors

        public MG_Feature(MG_FieldSet fs)
        {
            this.FieldSet = fs;
            this.ValueSet = new MG_ValueSet();
            this.Geometry = new MG_Geometry();
            this.Symbol = new MG_Symbol();
        }
 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);
 }
예제 #4
0
        public MG_Feature(MG_Feature f)
        {
            this.FieldSet = new MG_FieldSet();
            this.ValueSet = new MG_ValueSet();
            this.Geometry = new MG_Geometry();
            this.Symbol   = new MG_Symbol();

            for (int i = 0; i < f.GetFieldCount(); i++)
            {
                MG_Field field    = f.GetFieldSet().GetAt(i);
                MG_Field newField = new MG_Field(field);
                this.FieldSet.Add(newField);

                MG_Value value    = f.GetValue(i);
                MG_Value newValue = new MG_Value(value);
                this.ValueSet.Add(newValue);
            }
            MG_Geometry g       = f.GetGeometry();
            MG_Geometry newGeom = new MG_Geometry();

            switch (g.Type)
            {
            case MG_GeometryType.NONE:
                break;

            case MG_GeometryType.POINT:
                newGeom = new MG_Point(g as MG_Point);
                break;

            case MG_GeometryType.MULTIPOINT:
                newGeom = new MG_MultiPoint(g as MG_MultiPoint);
                break;

            case MG_GeometryType.LINESTRING:
                newGeom = new MG_LineString(g as MG_LineString);
                break;

            case MG_GeometryType.MULTILINESTRING:
                newGeom = new MG_MultiLineString(g as MG_MultiLineString);
                break;

            case MG_GeometryType.POLYGON:
                newGeom = new MG_Polygon(g as MG_Polygon);
                break;

            case MG_GeometryType.MULTIPOLYGON:
                newGeom = new MG_MultiPolygon(g as MG_MultiPolygon);
                break;
            }
            this.Geometry = newGeom;
            MG_Symbol newSymbol = new MG_Symbol(f.GetSymbol());

            this.Symbol = newSymbol;
        }
예제 #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;
        }
예제 #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;
        }
예제 #7
0
        public MG_Feature(MG_Feature f)
        {
            this.FieldSet = new MG_FieldSet();
            this.ValueSet = new MG_ValueSet();
            this.Geometry = new MG_Geometry();
            this.Symbol = new MG_Symbol();

            for (int i = 0; i < f.GetFieldCount();i++ )
            {
                MG_Field field = f.GetFieldSet().GetAt(i);
                MG_Field newField = new MG_Field(field);
                this.FieldSet.Add(newField);

                MG_Value value = f.GetValue(i);
                MG_Value newValue = new MG_Value(value);
                this.ValueSet.Add(newValue);
            }
            MG_Geometry g = f.GetGeometry();
            MG_Geometry newGeom = new MG_Geometry();
            switch (g.Type)
            {
                case MG_GeometryType.NONE:
                    break;
                case MG_GeometryType.POINT:
                    newGeom = new MG_Point(g as MG_Point);
                    break;
                case MG_GeometryType.MULTIPOINT:
                    newGeom = new MG_MultiPoint(g as MG_MultiPoint);
                    break;
                case MG_GeometryType.LINESTRING:
                    newGeom = new MG_LineString(g as MG_LineString);
                    break;
                case MG_GeometryType.MULTILINESTRING:
                    newGeom = new MG_MultiLineString(g as MG_MultiLineString);
                    break;
                case MG_GeometryType.POLYGON:
                    newGeom = new MG_Polygon(g as MG_Polygon);
                    break;
                case MG_GeometryType.MULTIPOLYGON:
                    newGeom = new MG_MultiPolygon(g as MG_MultiPolygon);
                    break;
            }
            this.Geometry = newGeom;
            MG_Symbol newSymbol = new MG_Symbol(f.GetSymbol());
            this.Symbol = newSymbol;
        }
예제 #8
0
 public void SetFieldSet(MG_FieldSet fs)
 {
     this.FieldSet = fs;
 }
예제 #9
0
 public void SetFieldSet(MG_FieldSet fs)
 {
     this.FieldSet = fs;
 }
예제 #10
0
 public void SetFieldSet(MG_FieldSet fieldSet)
 {
     this.FieldSet = fieldSet;
 }
예제 #11
0
 public void SetFieldSet(MG_FieldSet fieldSet)
 {
     this.FieldSet = fieldSet;
 }
        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;
        }
예제 #13
0
        protected MG_FieldSet GetFieldSet(string table)
        {
            ArrayList columns = this.GetColumnNames(table);
            ArrayList types = this.GetColumnTypes(table);
            if (columns == null || types == null)
                return null;
            int columnCount = columns.Count;
            int typeCount = types.Count;
            if (columnCount != typeCount)
                return null;
            MG_FieldSet fieldSet = new MG_FieldSet(table);

            // oid .... geom
            for (int i = 0; i < columnCount;i++ )
            {
                string column = columns[i].ToString();
                string type = types[i].ToString();
                if (!column.Equals("oid") && !column.Equals("geom"))
                {
                    // oid      name                geom         no       length
                    // integer character varying  USER-DEFINED  integer double precision
                    MG_FieldDBType dbType = MG_FieldDBType.VARCHAR;
                    if (type.Equals("integer"))
                    {
                        dbType = MG_FieldDBType.INTEGER;
                    }
                    else if (type.Equals("character varying"))
                    {
                        dbType = MG_FieldDBType.VARCHAR;
                    }
                    else if (type.Equals("double precision"))
                    {
                        dbType = MG_FieldDBType.FLOAT8;
                    }

                    MG_Field field = new MG_Field(column,dbType);
                    fieldSet.Add(field);
                }
            }

            return fieldSet;
        }
예제 #14
0
        protected MG_FeatureSet GetFeatureSet(MG_FieldSet fieldSet,string table)
        {
            NpgsqlDataReader reader = this.SelectAll(table);
            if (reader == null || !reader.HasRows)
            return null;

            MG_FeatureSet featureSet = new MG_FeatureSet();
            int fc = reader.FieldCount; // 4
            while (reader.Read())
            {// oid f1,f2,f3... geom
                MG_Feature f = new MG_Feature(fieldSet);
                MG_ValueSet valueSet = new MG_ValueSet();
                string oid = reader["oid"].ToString();
                string geom = reader["geomtext"].ToString();

                for (int i = 1; i < fc-1; i++)
                {
                    string str = reader[i].ToString();
                    MG_Value value = new MG_Value(i - 1, str);
                    valueSet.Add(value);
                }
                f.ValueSet = valueSet;
                f.Geometry = MG_ShapeFileOper.AsGeometry(geom);
                featureSet.Add(f);
            }
            reader.Close();
            reader.Dispose();
            return featureSet;
        }