Beispiel #1
0
        /// <summary> Prepares the bib object for the save, by clearing the
        /// existing data in this element's related field. </summary>
        /// <param name="Bib"> Existing Bib object </param>
        public override void Prepare_For_Save(SobekCM_Item Bib)
        {
            GeoSpatial_Information coordInfo = Bib.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information;

            if (coordInfo != null)
            {
                coordInfo.Clear_Points();
            }
        }
Beispiel #2
0
        /// <summary> Prepares the bib object for the save, by clearing any existing data in this element's related field(s) </summary>
        /// <param name="Bib"> Existing digital resource object which may already have values for this element's data field(s) </param>
        /// <param name="Current_User"> Current user, who's rights may impact the way an element is rendered </param>
        /// <remarks> This clears any preexisting coordinate points </remarks>
        public override void Prepare_For_Save(SobekCM_Item Bib, User_Object Current_User)
        {
            // GEt the geospatial metadata module
            GeoSpatial_Information geoInfo = Bib.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information;

            if (geoInfo != null)
            {
                geoInfo.Clear_Points();
            }
        }
        private void saveButton_Button_Pressed(object sender, EventArgs e)
        {
            if (!read_only)
            {
                saved = true;

                coords.KML_Reference = kmlTextBox.Text.Trim();

                coords.Clear_Points();

                try
                {
                    if ((point1LatitudeTextBox.Text.Trim().Length > 0) && (point1LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        coords.Add_Point(Convert.ToDouble(point1LatitudeTextBox.Text.Trim()), Convert.ToDouble(point1LongitudeTextBox.Text.Trim()), point1LabelTextBox.Text.Trim());
                    }

                    if ((point2LatitudeTextBox.Text.Trim().Length > 0) && (point2LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        coords.Add_Point(Convert.ToDouble(point2LatitudeTextBox.Text.Trim()), Convert.ToDouble(point2LongitudeTextBox.Text.Trim()), point2LabelTextBox.Text.Trim());
                    }

                    if ((point3LatitudeTextBox.Text.Trim().Length > 0) && (point3LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        coords.Add_Point(Convert.ToDouble(point3LatitudeTextBox.Text.Trim()), Convert.ToDouble(point3LongitudeTextBox.Text.Trim()), point3LabelTextBox.Text.Trim());
                    }

                    if ((point4LatitudeTextBox.Text.Trim().Length > 0) && (point4LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        coords.Add_Point(Convert.ToDouble(point4LatitudeTextBox.Text.Trim()), Convert.ToDouble(point4LongitudeTextBox.Text.Trim()), point4LabelTextBox.Text.Trim());
                    }

                    if ((point5LatitudeTextBox.Text.Trim().Length > 0) && (point5LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        coords.Add_Point(Convert.ToDouble(point5LatitudeTextBox.Text.Trim()), Convert.ToDouble(point5LongitudeTextBox.Text.Trim()), point5LabelTextBox.Text.Trim());
                    }
                }
                catch
                {
                }

                Coordinate_Polygon polygon = new Coordinate_Polygon();
                bool added     = false;
                bool hasPoints = false;
                if (coords.Polygon_Count > 0)
                {
                    added   = true;
                    polygon = coords.Get_Polygon(0);
                }

                polygon.Clear_Edge_Points();

                // Check for semicolons and blank longitudes
                if ((poly1LatitudeTextBox.Text.IndexOf(";") > 0) && (poly1LongitudeTextBox.Text.Trim().Length == 0))
                {
                    string[] split = poly1LatitudeTextBox.Text.Split(";".ToCharArray());
                    if (split.Length > 1)
                    {
                        poly1LatitudeTextBox.Text  = split[0];
                        poly1LongitudeTextBox.Text = split[1];
                    }
                }
                if ((poly2LatitudeTextBox.Text.IndexOf(";") > 0) && (poly2LongitudeTextBox.Text.Trim().Length == 0))
                {
                    string[] split = poly2LatitudeTextBox.Text.Split(";".ToCharArray());
                    if (split.Length > 1)
                    {
                        poly2LatitudeTextBox.Text  = split[0];
                        poly2LongitudeTextBox.Text = split[1];
                    }
                }
                if ((poly3LatitudeTextBox.Text.IndexOf(";") > 0) && (poly3LongitudeTextBox.Text.Trim().Length == 0))
                {
                    string[] split = poly3LatitudeTextBox.Text.Split(";".ToCharArray());
                    if (split.Length > 1)
                    {
                        poly3LatitudeTextBox.Text  = split[0];
                        poly3LongitudeTextBox.Text = split[1];
                    }
                }
                if ((poly4LatitudeTextBox.Text.IndexOf(";") > 0) && (poly4LongitudeTextBox.Text.Trim().Length == 0))
                {
                    string[] split = poly4LatitudeTextBox.Text.Split(";".ToCharArray());
                    if (split.Length > 1)
                    {
                        poly4LatitudeTextBox.Text  = split[0];
                        poly4LongitudeTextBox.Text = split[1];
                    }
                }
                if ((poly5LatitudeTextBox.Text.IndexOf(";") > 0) && (poly5LongitudeTextBox.Text.Trim().Length == 0))
                {
                    string[] split = poly5LatitudeTextBox.Text.Split(";".ToCharArray());
                    if (split.Length > 1)
                    {
                        poly5LatitudeTextBox.Text  = split[0];
                        poly5LongitudeTextBox.Text = split[1];
                    }
                }
                if ((poly6LatitudeTextBox.Text.IndexOf(";") > 0) && (poly6LongitudeTextBox.Text.Trim().Length == 0))
                {
                    string[] split = poly6LatitudeTextBox.Text.Split(";".ToCharArray());
                    if (split.Length > 1)
                    {
                        poly6LatitudeTextBox.Text  = split[0];
                        poly6LongitudeTextBox.Text = split[1];
                    }
                }

                try
                {
                    // Now assign any values that are present to the polygon
                    if ((poly1LatitudeTextBox.Text.Trim().Length > 0) && (poly1LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        hasPoints = true;
                        polygon.Add_Edge_Point(Convert.ToDouble(poly1LatitudeTextBox.Text.Trim()), Convert.ToDouble(poly1LongitudeTextBox.Text.Trim()), String.Empty);
                    }

                    if ((poly2LatitudeTextBox.Text.Trim().Length > 0) && (poly2LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        hasPoints = true;
                        polygon.Add_Edge_Point(Convert.ToDouble(poly2LatitudeTextBox.Text.Trim()), Convert.ToDouble(poly2LongitudeTextBox.Text.Trim()), String.Empty);
                    }

                    if ((poly3LatitudeTextBox.Text.Trim().Length > 0) && (poly3LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        hasPoints = true;
                        polygon.Add_Edge_Point(Convert.ToDouble(poly3LatitudeTextBox.Text.Trim()), Convert.ToDouble(poly3LongitudeTextBox.Text.Trim()), String.Empty);
                    }

                    if ((poly4LatitudeTextBox.Text.Trim().Length > 0) && (poly4LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        hasPoints = true;
                        polygon.Add_Edge_Point(Convert.ToDouble(poly4LatitudeTextBox.Text.Trim()), Convert.ToDouble(poly4LongitudeTextBox.Text.Trim()), String.Empty);
                    }

                    if ((poly5LatitudeTextBox.Text.Trim().Length > 0) && (poly5LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        hasPoints = true;
                        polygon.Add_Edge_Point(Convert.ToDouble(poly5LatitudeTextBox.Text.Trim()), Convert.ToDouble(poly5LongitudeTextBox.Text.Trim()), String.Empty);
                    }

                    if ((poly6LatitudeTextBox.Text.Trim().Length > 0) && (poly6LongitudeTextBox.Text.Trim().Length > 0))
                    {
                        hasPoints = true;
                        polygon.Add_Edge_Point(Convert.ToDouble(poly6LatitudeTextBox.Text.Trim()), Convert.ToDouble(poly6LongitudeTextBox.Text.Trim()), String.Empty);
                    }
                }
                catch
                {
                }

                polygon.Label = polyLabelTextBox.Text.Trim();
                if ((polygon.Label.Length == 0) && (isMap))
                {
                    polygon.Label = "Map Coverage";
                }

                // Are there just two points in this polygon?
                if (polygon.Edge_Points_Count == 2)
                {
                    Coordinate_Point first_point  = polygon.Edge_Points[0];
                    Coordinate_Point second_point = polygon.Edge_Points[1];

                    polygon.Clear_Edge_Points();

                    polygon.Add_Edge_Point(first_point);
                    polygon.Add_Edge_Point(first_point.Latitude, second_point.Longitude);
                    polygon.Add_Edge_Point(second_point);
                    polygon.Add_Edge_Point(second_point.Latitude, first_point.Longitude);
                }

                // If this has not been added and has points, add it
                if ((!added) && (hasPoints))
                {
                    coords.Add_Polygon(polygon);
                }
            }

            Close();
        }