Esempio n. 1
0
        private void InsertFeatureClassRow(IDbCommand cmd, string name, string displayName, string description, string spatialRef,
                                           int mapscale, string source, string annotable,
                                           Envelope envelope, enumShapeType shapeType, int fetCount)
        {
            string sql = "insert into BGIS_FeatureClass(ID,DATASETID,NAME,DATATABLE,SPATIALREF,CREATETIME," +
                         "MAPSCALE,SOURCE,DESCRIPTION,ANNOTABLE,ENVELOPE,SHAPETYPE,FEATURECOUNT) " +
                         "values('{0}','{1}','{2}','{3}','{4}',{5},{6},'{7}','{8}','{9}',{10},'{11}',{12})";

            if (envelope == null)
            {
                envelope = new Envelope();//empty
            }
            cmd.CommandText = string.Format(sql,
                                            Guid.NewGuid().ToString(),
                                            _datasetId,
                                            displayName,
                                            name,
                                            spatialRef,
                                            _adapter.DateTimeToSql(DateTime.Now),
                                            mapscale.ToString(),
                                            source,
                                            description,
                                            (string.IsNullOrEmpty(annotable)?string.Empty:annotable),
                                            _adapter.GeometryToSQL(envelope.ToPolygon(), SpatialRefToSRID()),
                                            shapeType.ToString(),
                                            fetCount.ToString()
                                            );
            cmd.ExecuteNonQuery();
        }
Esempio n. 2
0
 private string FieldValueToSqlExp(Type fieldType, object fieldValue)
 {
     if (fieldType.Equals(typeof(string)))
     {
         return("'" + (fieldValue != null ? fieldValue.ToString() : string.Empty) + "'");
     }
     else if (fieldType.Equals(typeof(DateTime)))
     {
         return(_adapter.DateTimeToSql((DateTime)fieldValue));
     }
     else if (fieldType.Equals(typeof(Int16)) || fieldType.Equals(typeof(Int32)) || fieldType.Equals(typeof(Int64)) || fieldType.Equals(typeof(Byte)))
     {
         return(fieldValue.ToString());
     }
     else if (fieldType.Equals(typeof(enumShapeType)))
     {
         return("'" + fieldValue.ToString() + "'");
     }
     else if (fieldType.Equals(typeof(Envelope)))
     {
         Envelope evp = fieldValue as Envelope;
         if (evp != null)
         {
             return(_adapter.GeometryToSQL(evp.ToPolygon(), 4326)); //fdc+fixed
         }
     }
     throw new NotSupportedException("不支持的字段类型\"" + fieldType.ToString() + "\"。");
 }
Esempio n. 3
0
        private void InsertFeatureClassRow(IDbCommand cmd, MetaFeatureClassDef fetclassdef)
        {
            string sql = "insert into BGIS_FeatureClass(ID,DATASETID,NAME,DATATABLE,SPATIALREF,CREATETIME,MAPSCALE,SOURCE,DESCRIPTION) " +
                         "values('{0}','{1}','{2}','{3}','{4}',{5},{6},'{7}','{8}')";

            cmd.CommandText = string.Format(sql,
                                            Guid.NewGuid().ToString(),
                                            fetclassdef.DatasetId,
                                            fetclassdef.Name,
                                            fetclassdef.DataTable,
                                            fetclassdef.SpatialRef,
                                            _adapter.DateTimeToSql(fetclassdef.DataTime),
                                            fetclassdef.MapScale.ToString(),
                                            fetclassdef.Source,
                                            fetclassdef.Description);
            cmd.ExecuteNonQuery();
        }