Data transfer object for Coordinate Systems
Exemplo n.º 1
0
        /// <summary>
        /// Adds a new coordinate system to the database
        /// </summary>
        /// <param name="cs"></param>
        public void AddProjection(CoordinateSystemDefinition cs)
        {
            using (var conn = CreateSqliteConnection())
            {
                conn.Open();
                using (IInsert cmd = (IInsert)conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Insert))
                {
                    cmd.SetFeatureClassName("Projections");
                    cmd.PropertyValues.Add(new OSGeo.FDO.Commands.PropertyValue("Name", new StringValue(cs.Name)));
                    cmd.PropertyValues.Add(new OSGeo.FDO.Commands.PropertyValue("Description", new StringValue(cs.Description)));
                    cmd.PropertyValues.Add(new OSGeo.FDO.Commands.PropertyValue("WKT", new StringValue(cs.Wkt)));

                    int affected = 0;
                    using(var reader = cmd.Execute())
                    {
                        while(reader.ReadNext())
                        {
                            affected++;
                        }
                        reader.Close();
                    }

                    if (affected == 1)
                    {
                        _Projections.Add(cs);
                        LoggingService.InfoFormatted("Coordinate System {0} added to database", cs.Name);
                    }
                }
                conn.Close();
            }
        }
 public static bool EditCoordinateSystem(CoordinateSystemDefinition cs)
 {
     CoordinateSystemDialog diag = new CoordinateSystemDialog();
     _editing = true;
     diag.txtName.Text = cs.Name;
     diag.txtName.Enabled = false;
     diag.txtDescription.Text = cs.Description;
     diag.txtWKT.Text = cs.Wkt;
     if (diag.ShowDialog() == DialogResult.OK)
     {
         cs.Name = diag.txtName.Text;
         cs.Description = diag.txtDescription.Text;
         cs.Wkt = diag.txtWKT.Text;
         return true;
     }
     return false;
 }
        public void SetCoordinateSystem(CoordinateSystemDefinition cs)
        {
            if (cs != null)
            {
                if (_view.NameEnabled)
                    _view.ContextName = cs.Name;

                _view.Description = cs.Description;
                _view.CoordinateSystem = cs.Wkt;
                _view.CoordinateSystemWkt = cs.Wkt;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Deletes a coordinate system from the database
 /// </summary>
 /// <param name="cs"></param>
 /// <returns></returns>
 public bool DeleteProjection(CoordinateSystemDefinition cs)
 {
     using (var conn = CreateSqliteConnection())
     {
         conn.Open();
         using (IDelete delete = (IDelete)conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Delete))
         {
             delete.SetFeatureClassName("Projections");
             delete.SetFilter("Name = '" + cs.Name + "'");
             if (delete.Execute() == 1)
             {
                 LoggingService.InfoFormatted("Coordinate System {0} deleted from database", cs.Name);
                 _Projections.Remove(cs);
                 return true;
             }
         }
         conn.Close();
     }
     return false;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Updates an existing coordinate system in the database
        /// </summary>
        /// <param name="cs"></param>
        /// <param name="oldName"></param>
        /// <returns></returns>
        public bool UpdateProjection(CoordinateSystemDefinition cs, string oldName)
        {
            using (var conn = CreateSqliteConnection())
            {
                conn.Open();
                using(IUpdate update = (IUpdate)conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Update))
                {
                    update.SetFeatureClassName("Projections");
                    update.PropertyValues.Add(new OSGeo.FDO.Commands.PropertyValue("Name", new StringValue(cs.Name)));
                    update.PropertyValues.Add(new OSGeo.FDO.Commands.PropertyValue("Description", new StringValue(cs.Description)));
                    update.PropertyValues.Add(new OSGeo.FDO.Commands.PropertyValue("WKT", new StringValue(cs.Wkt)));

                    update.SetFilter("Name = '" + oldName + "'");

                    if (update.Execute() == 1)
                    {
                        LoggingService.InfoFormatted("Coordinate System {0} updated in database", oldName);
                        return true;
                    }
                }
                conn.Close();
            }
            return false;
        }
 public void Delete(CoordinateSystemDefinition cs)
 {
     _catalog.DeleteProjection(cs);
 }
 public void Update(string oldName, CoordinateSystemDefinition cs)
 {
     _catalog.UpdateProjection(cs, oldName);
 }
 public void AddNew(CoordinateSystemDefinition cs)
 {
     _catalog.AddProjection(cs);
 }