/// <summary> Flag indicates if this active reader/writer needs to append schema reference information /// to the METS XML header by analyzing the contents of the division </summary> /// <param name="MetsDivision"> Division from the overall package into which to read the metadata</param> /// <returns> TRUE if the schema should be attached, otherwise fALSE </returns> public bool Schema_Reference_Required_Division(abstract_TreeNode MetsDivision) { // GEt the geo-spatial information if it exists GeoSpatial_Information geoInfo = MetsDivision.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if ((geoInfo == null) || (!geoInfo.hasData)) { return(false); } return(true); }
/// <summary> Flag indicates if this active reader/writer will write a dmdSec for this node </summary> /// <param name="MetsDivision"> Division to check if a dmdSec will be written </param> /// <param name="Options"> Dictionary of any options which this METS section writer may utilize</param> /// <returns> TRUE if the package has data to be written, otherwise fALSE </returns> public bool Include_dmdSec(abstract_TreeNode MetsDivision, Dictionary <string, object> Options) { // GEt the geo-spatial information if it exists GeoSpatial_Information geoInfo = MetsDivision.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if ((geoInfo == null) || (!geoInfo.hasData)) { return(false); } return(true); }
/// <summary> Reads the dmdSec at the current position in the XmlTextReader and associates it with /// one subsection/division from the METS structure map </summary> /// <param name="Input_XmlReader"> Open XmlReader from which to read the metadata </param> /// <param name="MetsDivision"> Division from the overall package into which to read the metadata</param> /// <param name="Options"> Dictionary of any options which this METS section writer may utilize</param> /// <returns> TRUE if successful, otherwise FALSE</returns> public bool Read_dmdSec(XmlReader Input_XmlReader, abstract_TreeNode MetsDivision, Dictionary <string, object> Options) { // Get the geo-spatial information if it exists or create a new one GeoSpatial_Information geoInfo = MetsDivision.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if (geoInfo == null) { geoInfo = new GeoSpatial_Information(); MetsDivision.Add_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY, geoInfo); } return(Read_Metadata_Section(Input_XmlReader, geoInfo, Options)); }
private void recurse_through_nodes(SobekCM_Item thisPackage, abstract_TreeNode node, List <Page_TreeNode> pages_encountered) { if (node.Page) { Page_TreeNode pageNode = (Page_TreeNode)node; if (!pages_encountered.Contains(pageNode)) { pageseq++; // Add each of the files view codes to the list bool page_added = false; foreach (SobekCM_File_Info thisFile in pageNode.Files) { string upper_name = thisFile.System_Name.ToUpper(); if ((upper_name.IndexOf("SOUNDFILESONLY") < 0) && (upper_name.IndexOf("FILMONLY") < 0) && (upper_name.IndexOf("MULTIMEDIA") < 0) && (upper_name.IndexOf("THM.JPG") < 0)) { if (!page_added) { // Add this to the simple page collection thisPackage.Web.Add_Pages_By_Sequence(pageNode); pages_encountered.Add(pageNode); page_added = true; } View_Object thisViewer = thisFile.Get_Viewer(); if (thisViewer != null) { string[] codes = thisViewer.Viewer_Codes; if ((codes.Length > 0) && (codes[0].Length > 0)) { thisPackage.Web.Viewer_To_File[pageseq.ToString() + codes[0]] = thisFile; } } } } } } else { divseq++; Division_TreeNode divNode = (Division_TreeNode)node; foreach (abstract_TreeNode childNode in divNode.Nodes) { recurse_through_nodes(thisPackage, childNode, pages_encountered); } } }
private void recurse_through_nodes(abstract_TreeNode Node, List <Page_TreeNode> PagesEncountered) { if (Node.Page) { Page_TreeNode pageNode = (Page_TreeNode)Node; if (!PagesEncountered.Contains(pageNode)) { pageseq++; } } else { Division_TreeNode divNode = (Division_TreeNode)Node; foreach (abstract_TreeNode childNode in divNode.Nodes) { recurse_through_nodes(childNode, PagesEncountered); } } }
private void recurse_through_nodes(abstract_TreeNode Node, List <string> Extensions) { // Was this node a page? if (Node.Page) { // Cast back to the PAGE node Page_TreeNode pageNode = (Page_TreeNode)Node; // If no files, do not add this back if (pageNode.Files.Count == 0) { return; } // Add a filenode for each file foreach (SobekCM_File_Info thisFile in pageNode.Files) { string extension = thisFile.File_Extension.ToLower(); if (!Extensions.Contains(extension)) { Extensions.Add(extension); } } } else { // This was a division node Division_TreeNode divNode = (Division_TreeNode)Node; // Look for children nodes foreach (abstract_TreeNode childNode in divNode.Nodes) { // Visit each child node recurse_through_nodes(childNode, Extensions); } } }
/// <summary> Method performs the actual search against the polygon/coordinates /// in the METS file for the current item </summary> protected void Perform_Coordinate_Search() { mapBuilder = new StringBuilder(); if (CurrentMode.ViewerCode == "mapsearch") { googleItemSearch = true; } // If coordinates were passed in, pull the actual coordinates out of the URL validCoordinateSearchFound = false; if (CurrentMode.Coordinates.Length > 0) { string[] splitter = CurrentMode.Coordinates.Split(",".ToCharArray()); if (((splitter.Length > 1) && (splitter.Length < 4)) || ((splitter.Length == 4) && (splitter[2].Length == 0) && (splitter[3].Length == 0))) { if ((Double.TryParse(splitter[0], out providedMaxLat)) && (Double.TryParse(splitter[1], out providedMaxLong))) { validCoordinateSearchFound = true; } providedMinLat = providedMaxLat; providedMinLong = providedMaxLong; } else if (splitter.Length >= 4) { if ((Double.TryParse(splitter[0], out providedMaxLat)) && (Double.TryParse(splitter[1], out providedMaxLong)) && (Double.TryParse(splitter[2], out providedMinLat)) && (Double.TryParse(splitter[3], out providedMinLong))) { validCoordinateSearchFound = true; } } } // Get the google map API mapBuilder.AppendLine("<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>"); mapBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/sobekcm_map_search.js\"></script>"); mapBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/sobekcm_map_tool.js\"></script>"); // Set some values for the map key string search_type = "geographic"; bool areas_shown = false; bool points_shown = false; string areas_name = "Sheet"; if (CurrentItem.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Aerial) { areas_name = "Tile"; } // Load the map mapBuilder.AppendLine("<script type=\"text/javascript\">"); mapBuilder.AppendLine(" //<![CDATA["); mapBuilder.AppendLine(" function load() {"); mapBuilder.AppendLine(googleItemSearch ? " load_search_map(6, 19.5, 3, \"map1\");" : " load_map(6, 19.5, 3, \"map1\");"); // Keep track of any matching tiles matchingTilesList = new List <string>(); // Add the points if (CurrentItem != null) { allPolygons = new List <Coordinate_Polygon>(); allPoints = new List <Coordinate_Point>(); allLines = new List <Coordinate_Line>(); // Add the search rectangle first if ((validCoordinateSearchFound) && (!googleItemSearch)) { if ((providedMaxLat != providedMinLat) || (providedMaxLong != providedMinLong)) { search_type = "rectangle"; mapBuilder.AppendLine(" add_rectangle(" + providedMaxLat + ", " + providedMaxLong + ", " + providedMinLat + ", " + providedMinLong + ");"); } else { search_type = "point"; } } // Build the matching polygon HTML to overlay the matches over the non-matches StringBuilder matchingPolygonsBuilder = new StringBuilder(); // Collect all the polygons, points, and lines GeoSpatial_Information geoInfo = CurrentItem.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if ((geoInfo != null) && (geoInfo.hasData)) { if (geoInfo.Polygon_Count > 0) { foreach (Coordinate_Polygon thisPolygon in geoInfo.Polygons) { allPolygons.Add(thisPolygon); } } if (geoInfo.Line_Count > 0) { foreach (Coordinate_Line thisLine in geoInfo.Lines) { allLines.Add(thisLine); } } if (geoInfo.Point_Count > 0) { foreach (Coordinate_Point thisPoint in geoInfo.Points) { allPoints.Add(thisPoint); } } } List <abstract_TreeNode> pages = CurrentItem.Divisions.Physical_Tree.Pages_PreOrder; for (int i = 0; i < pages.Count; i++) { abstract_TreeNode pageNode = pages[i]; GeoSpatial_Information geoInfo2 = pageNode.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if ((geoInfo2 != null) && (geoInfo2.hasData)) { if (geoInfo2.Polygon_Count > 0) { foreach (Coordinate_Polygon thisPolygon in geoInfo2.Polygons) { thisPolygon.Page_Sequence = (ushort)(i + 1); allPolygons.Add(thisPolygon); } } if (geoInfo2.Line_Count > 0) { foreach (Coordinate_Line thisLine in geoInfo2.Lines) { allLines.Add(thisLine); } } if (geoInfo2.Point_Count > 0) { foreach (Coordinate_Point thisPoint in geoInfo2.Points) { allPoints.Add(thisPoint); } } } } // Add all the polygons now if ((allPolygons.Count > 0) && (allPolygons[0].Edge_Points_Count > 1)) { areas_shown = true; // Determine a base URL for pointing for any polygons that correspond to a page sequence string currentViewerCode = CurrentMode.ViewerCode; CurrentMode.ViewerCode = "XXXXXXXX"; string redirect_url = CurrentMode.Redirect_URL(); CurrentMode.ViewerCode = currentViewerCode; // Add each polygon foreach (Coordinate_Polygon itemPolygon in allPolygons) { // Determine if this polygon is within the search bool in_coordinates_search = false; if ((validCoordinateSearchFound) && (!googleItemSearch)) { // Was this a point search or area search? if ((providedMaxLong == providedMinLong) && (providedMaxLat == providedMinLat)) { // Check this point if (itemPolygon.is_In_Bounding_Box(providedMaxLat, providedMaxLong)) { in_coordinates_search = true; } } else { // Chieck this area search if (itemPolygon.is_In_Bounding_Box(providedMaxLat, providedMaxLong, providedMinLat, providedMinLong)) { in_coordinates_search = true; } } } // Look for a link for this item string link = String.Empty; if ((itemPolygon.Page_Sequence > 0) && (!googleItemSearch)) { link = redirect_url.Replace("XXXXXXXX", itemPolygon.Page_Sequence.ToString()); } // If this is an item search, don't show labels (too distracting) string label = itemPolygon.Label; if (googleItemSearch) { label = String.Empty; } if (in_coordinates_search) { // Start to call the add polygon method matchingPolygonsBuilder.AppendLine(" add_polygon(["); foreach (Coordinate_Point thisPoint in itemPolygon.Edge_Points) { matchingPolygonsBuilder.AppendLine(" new google.maps.LatLng(" + thisPoint.Latitude + ", " + thisPoint.Longitude + "),"); } matchingPolygonsBuilder.Append(" new google.maps.LatLng(" + itemPolygon.Edge_Points[0].Latitude + ", " + itemPolygon.Edge_Points[0].Longitude + ")],"); matchingPolygonsBuilder.AppendLine("true, '" + label + "', '" + link + "' );"); // Also add to the list of matching titles matchingTilesList.Add("<a href=\"" + link + "\">" + itemPolygon.Label + "</a>"); } else { // Start to call the add polygon method mapBuilder.AppendLine(" add_polygon(["); foreach (Coordinate_Point thisPoint in itemPolygon.Edge_Points) { mapBuilder.AppendLine(" new google.maps.LatLng(" + thisPoint.Latitude + ", " + thisPoint.Longitude + "),"); } mapBuilder.Append(" new google.maps.LatLng(" + itemPolygon.Edge_Points[0].Latitude + ", " + itemPolygon.Edge_Points[0].Longitude + ")],"); // If just one polygon, still show the red outline if (allPolygons.Count == 1) { mapBuilder.AppendLine("true, '', '" + link + "' );"); } else { mapBuilder.AppendLine("false, '" + label + "', '" + link + "' );"); } } } // Add any matching polygons last mapBuilder.Append(matchingPolygonsBuilder.ToString()); } // Draw all the single points if (allPoints.Count > 0) { points_shown = true; for (int point = 0; point < allPoints.Count; point++) { mapBuilder.AppendLine(" add_point(" + allPoints[point].Latitude + ", " + allPoints[point].Longitude + ", '" + allPoints[point].Label + "' );"); } } // If this was a point search, also add the point if (validCoordinateSearchFound) { if ((providedMaxLat == providedMinLat) && (providedMaxLong == providedMinLong)) { search_type = "point"; mapBuilder.AppendLine(" add_selection_point(" + providedMaxLat + ", " + providedMaxLong + ", 8 );"); } } // Add the searchable, draggable polygon last (if in search mode) if ((validCoordinateSearchFound) && (googleItemSearch)) { if ((providedMaxLat != providedMinLat) || (providedMaxLong != providedMinLong)) { mapBuilder.AppendLine(" add_selection_rectangle(" + providedMaxLat + ", " + providedMaxLong + ", " + providedMinLat + ", " + providedMinLong + " );"); } } // Add the map key if (!googleItemSearch) { mapBuilder.AppendLine(" add_key(" + search_type + ", " + areas_shown.ToString().ToLower() + ", " + points_shown.ToString().ToLower() + ", '" + areas_name + "');"); } // Zoom appropriately mapBuilder.AppendLine(matchingPolygonsBuilder.Length > 0 ? " zoom_to_selected();" : " zoom_to_bounds();"); } mapBuilder.AppendLine(" }"); mapBuilder.AppendLine(" //]]>"); mapBuilder.AppendLine("</script>"); }
private void recursively_add_div_page_text(string SourceDirectory, abstract_TreeNode ThisNode, TextWriter Output_Stream, ref int PageCount) { if (ThisNode.Page) { Page_TreeNode pageNode = (Page_TreeNode)ThisNode; if (pageNode.Files.Count > 0) { string pageimage = String.Empty; string textfilename = pageNode.Files[0].File_Name_Sans_Extension + ".txt"; foreach (SobekCM_File_Info thisFile in pageNode.Files) { if (thisFile.File_Extension.ToLower() == "txt") { textfilename = thisFile.System_Name; } if ((thisFile.File_Extension.ToLower() == "jpg") && (thisFile.System_Name.ToLower().IndexOf("thm.jpg") < 0)) { pageimage = thisFile.System_Name; } } // Add the page break first Output_Stream.Write("<pb n=\"" + PageCount + "\""); if (pageimage.Length > 0) { Output_Stream.Write(" facs=\"" + Convert_String_To_XML_Safe(pageimage) + "\""); } Output_Stream.WriteLine(" />"); // Does the text file exist? string text_file = SourceDirectory + "\\" + textfilename; try { if (File.Exists(text_file)) { Output_Stream.WriteLine(Convert_String_To_XML_Safe(File.ReadAllText(text_file))); } } catch { } } PageCount++; } else { Division_TreeNode divNode = (Division_TreeNode)ThisNode; if (ThisNode.Type != "main") { Output_Stream.WriteLine("<div type=\"" + ThisNode.Type + "\">"); if ((ThisNode.Label.Length > 0) && (ThisNode.Label != ThisNode.Type)) { Output_Stream.WriteLine("<head>" + Convert_String_To_XML_Safe(ThisNode.Label) + "</head>"); } } // Now, step through child nodes foreach (abstract_TreeNode childNode in divNode.Nodes) { recursively_add_div_page_text(SourceDirectory, childNode, Output_Stream, ref PageCount); } if (ThisNode.Type != "main") { Output_Stream.WriteLine("</div>"); } } }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Attempt to pull the top-level geo-spatial data from the source object GeoSpatial_Information geoInfo = Original.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; // If there was geo-spatial data here, add it to the new item if ((geoInfo != null) && (geoInfo.hasData) && ((geoInfo.Point_Count > 0) || (geoInfo.Polygon_Count > 0))) { // Ensure the brief item has a geospatial object if (New.GeoSpatial == null) { New.GeoSpatial = new BriefItem_GeoSpatial(); } // Add each point first into the description ReadOnlyCollection <Coordinate_Point> origPoints = geoInfo.Points; foreach (Coordinate_Point thisPoint in origPoints) { if (!String.IsNullOrEmpty(thisPoint.Label)) { New.Add_Description("Coordinates", thisPoint.Latitude + " x " + thisPoint.Longitude + " ( " + thisPoint.Label + " )"); } else { New.Add_Description("Coordinates", thisPoint.Latitude + " x " + thisPoint.Longitude); } // Also add each point into the object itself if (New.GeoSpatial.Points == null) { New.GeoSpatial.Points = new List <BriefItem_Coordinate_Point>(); } // Create the new point BriefItem_Coordinate_Point cPoint = new BriefItem_Coordinate_Point { Latitude = thisPoint.Latitude, Longitude = thisPoint.Longitude, Altitude = thisPoint.Altitude, Label = thisPoint.Label, FeatureType = thisPoint.FeatureType }; // Add it New.GeoSpatial.Points.Add(cPoint); } // Add the polygons to the description, if there is only one. if (geoInfo.Polygon_Count == 1) { for (int i = 0; i < geoInfo.Polygon_Count; i++) { Coordinate_Polygon polygon = geoInfo.Get_Polygon(i); StringBuilder polygonBuilder = new StringBuilder(); foreach (Coordinate_Point thisPoint in polygon.Edge_Points) { if (polygonBuilder.Length > 0) { polygonBuilder.Append(", " + thisPoint.Latitude + " x " + thisPoint.Longitude); } else { polygonBuilder.Append(thisPoint.Latitude + " x " + thisPoint.Longitude); } } if (polygon.Label.Length > 0) { polygonBuilder.Append(" ( " + polygon.Label + " )"); } if (polygonBuilder.ToString().Trim().Length > 0) { New.Add_Description("Polygon", polygonBuilder.ToString()); } } } // Map each polygon over now as well if (geoInfo.Polygon_Count > 0) { // Ensure the polygon collection is defined if (New.GeoSpatial.Polygons == null) { New.GeoSpatial.Polygons = new List <BriefItem_Coordinate_Polygon>(); } // Get the collection of polygons and step through them ReadOnlyCollection <Coordinate_Polygon> origPolys = geoInfo.Polygons; foreach (Coordinate_Polygon thisPoly in origPolys) { // Start to build the new poly BriefItem_Coordinate_Polygon cPoly = new BriefItem_Coordinate_Polygon { Label = thisPoly.Label, FeatureType = thisPoly.FeatureType, Page_Sequence = thisPoly.Page_Sequence, Rotation = thisPoly.Rotation, PolygonType = thisPoly.PolygonType }; // Copy over all the vertices if (thisPoly.Edge_Points_Count > 0) { // Ensure the edge points collection is defined if (cPoly.Edge_Points == null) { cPoly.Edge_Points = new List <BriefItem_Coordinate_Point>(); } // Copy over all the vertices ReadOnlyCollection <Coordinate_Point> origVertices = thisPoly.Edge_Points; foreach (Coordinate_Point thisPoint in origVertices) { // Create the new point BriefItem_Coordinate_Point cPoint = new BriefItem_Coordinate_Point { Latitude = thisPoint.Latitude, Longitude = thisPoint.Longitude, Altitude = thisPoint.Altitude, Label = thisPoint.Label, FeatureType = thisPoint.FeatureType }; // Add it cPoly.Edge_Points.Add(cPoint); } } // Add this poly New.GeoSpatial.Polygons.Add(cPoly); } } // Map each line over now as well if (geoInfo.Line_Count > 0) { // Ensure the line collection is defined if (New.GeoSpatial.Lines == null) { New.GeoSpatial.Lines = new List <BriefItem_Coordinate_Line>(); } // Get the collection of lines and step through them ReadOnlyCollection <Coordinate_Line> origLines = geoInfo.Lines; foreach (Coordinate_Line thisLine in origLines) { // Start to build the new line BriefItem_Coordinate_Line cLine = new BriefItem_Coordinate_Line { Label = thisLine.Label, FeatureType = thisLine.FeatureType }; // Copy over all the vertices if (thisLine.Point_Count > 0) { // Ensure the points collection is defined if (cLine.Points == null) { cLine.Points = new List <BriefItem_Coordinate_Point>(); } // Copy over all the vertices ReadOnlyCollection <Coordinate_Point> origVertices = thisLine.Points; foreach (Coordinate_Point thisPoint in origVertices) { // Create the new point BriefItem_Coordinate_Point cPoint = new BriefItem_Coordinate_Point { Latitude = thisPoint.Latitude, Longitude = thisPoint.Longitude, Altitude = thisPoint.Altitude, Label = thisPoint.Label, FeatureType = thisPoint.FeatureType }; // Add it cLine.Points.Add(cPoint); } } // Add this poly New.GeoSpatial.Lines.Add(cLine); } } } // Now, copy over all the geo-spatial information at the page level List <abstract_TreeNode> pages = Original.Divisions.Physical_Tree.Pages_PreOrder; for (int i = 0; i < pages.Count; i++) { abstract_TreeNode pageNode = pages[i]; GeoSpatial_Information geoInfo2 = pageNode.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if ((geoInfo2 != null) && (geoInfo2.hasData)) { // Since some data was found, make sure the geospatial object exists // Ensure the brief item has a geospatial object if (New.GeoSpatial == null) { New.GeoSpatial = new BriefItem_GeoSpatial(); } // Any polygons exist at this page level? if (geoInfo2.Polygon_Count > 0) { foreach (Coordinate_Polygon thisPolygon in geoInfo2.Polygons) { thisPolygon.Page_Sequence = (ushort)(i + 1); // Ensure the polygon collection is defined if (New.GeoSpatial.Polygons == null) { New.GeoSpatial.Polygons = new List <BriefItem_Coordinate_Polygon>(); } // Get the collection of polygons and step through them ReadOnlyCollection <Coordinate_Polygon> origPolys = geoInfo2.Polygons; foreach (Coordinate_Polygon thisPoly in origPolys) { // Start to build the new poly BriefItem_Coordinate_Polygon cPoly = new BriefItem_Coordinate_Polygon { Label = thisPoly.Label, FeatureType = thisPoly.FeatureType, Page_Sequence = thisPoly.Page_Sequence, Rotation = thisPoly.Rotation, PolygonType = thisPoly.PolygonType }; // Copy over all the vertices if (thisPoly.Edge_Points_Count > 0) { // Ensure the edge points collection is defined if (cPoly.Edge_Points == null) { cPoly.Edge_Points = new List <BriefItem_Coordinate_Point>(); } // Copy over all the vertices ReadOnlyCollection <Coordinate_Point> origVertices = thisPoly.Edge_Points; foreach (Coordinate_Point thisPoint in origVertices) { // Create the new point BriefItem_Coordinate_Point cPoint = new BriefItem_Coordinate_Point { Latitude = thisPoint.Latitude, Longitude = thisPoint.Longitude, Altitude = thisPoint.Altitude, Label = thisPoint.Label, FeatureType = thisPoint.FeatureType }; // Add it cPoly.Edge_Points.Add(cPoint); } } // Add this poly New.GeoSpatial.Polygons.Add(cPoly); } } } if (geoInfo2.Line_Count > 0) { // Ensure the line collection is defined if (New.GeoSpatial.Lines == null) { New.GeoSpatial.Lines = new List <BriefItem_Coordinate_Line>(); } // Add each line foreach (Coordinate_Line thisLine in geoInfo2.Lines) { // Start to build the new line BriefItem_Coordinate_Line cLine = new BriefItem_Coordinate_Line { Label = thisLine.Label, FeatureType = thisLine.FeatureType }; // Copy over all the vertices if (thisLine.Point_Count > 0) { // Ensure the points collection is defined if (cLine.Points == null) { cLine.Points = new List <BriefItem_Coordinate_Point>(); } // Copy over all the vertices ReadOnlyCollection <Coordinate_Point> origVertices = thisLine.Points; foreach (Coordinate_Point thisPoint in origVertices) { // Create the new point BriefItem_Coordinate_Point cPoint = new BriefItem_Coordinate_Point { Latitude = thisPoint.Latitude, Longitude = thisPoint.Longitude, Altitude = thisPoint.Altitude, Label = thisPoint.Label, FeatureType = thisPoint.FeatureType }; // Add it cLine.Points.Add(cPoint); } } // Add this poly New.GeoSpatial.Lines.Add(cLine); } } if (geoInfo2.Point_Count > 0) { // Ensure the points collection was defined if (New.GeoSpatial.Points == null) { New.GeoSpatial.Points = new List <BriefItem_Coordinate_Point>(); } // Add each point, from the page foreach (Coordinate_Point thisPoint in geoInfo2.Points) { // Create the new point BriefItem_Coordinate_Point cPoint = new BriefItem_Coordinate_Point { Latitude = thisPoint.Latitude, Longitude = thisPoint.Longitude, Altitude = thisPoint.Altitude, Label = thisPoint.Label, FeatureType = thisPoint.FeatureType }; // Add it New.GeoSpatial.Points.Add(cPoint); } } } } return(true); }
private bool recurse_through_nodes(abstract_TreeNode Node, List <BriefItem_FileGrouping> Groupings, List <BriefItem_TocElement> Toc, Stack <BriefItem_TocElement> CurrDivStack, int Level) { // Was this node a page? if (Node.Page) { // Cast back to the PAGE node Page_TreeNode pageNode = (Page_TreeNode)Node; // If no files, do not add this back if (pageNode.Files.Count == 0) { return(false); } // Create the file grouping object for this BriefItem_FileGrouping newNode = new BriefItem_FileGrouping(pageNode.Label); // Add a filenode for each file foreach (SobekCM_File_Info thisFile in pageNode.Files) { BriefItem_File newFile = new BriefItem_File(thisFile.System_Name); if (thisFile.Width > 0) { newFile.Width = thisFile.Width; } if (thisFile.Height > 0) { newFile.Height = thisFile.Height; } newNode.Files.Add(newFile); } // Add this to the list of images Groupings.Add(newNode); // Since this was a page with files, return TRUE return(true); } else { // Get what will be the sequence (if it turned out to have pages under it) int sequence = Groupings.Count + 1; // This was a division node Division_TreeNode divNode = (Division_TreeNode)Node; // Create the brief item TOC element BriefItem_TocElement divToc = new BriefItem_TocElement { Level = Level, Name = divNode.Label }; if (string.IsNullOrEmpty(divToc.Name)) { divToc.Name = divNode.Type; } // Add to the stack CurrDivStack.Push(divToc); // Look for children nodes bool some_files_under = false; foreach (abstract_TreeNode childNode in divNode.Nodes) { // Visit each child node if (recurse_through_nodes(childNode, Groupings, Toc, CurrDivStack, Level + 1)) { some_files_under = true; } } // Were there some files under here? if (some_files_under) { // Now, pop-up all the nodes in the queue and add them if (CurrDivStack.Count > 0) { IEnumerable <BriefItem_TocElement> reversed = CurrDivStack.Reverse(); foreach (BriefItem_TocElement revDiv in reversed) { revDiv.Sequence = sequence; Toc.Add(revDiv); } CurrDivStack.Clear(); } } else { // If this division (with NO pages under it apparently) is on the stack, // just pop it off if ((CurrDivStack.Count > 0) && (CurrDivStack.Peek() == divToc)) { CurrDivStack.Pop(); } } // Return whether there were any files under this return(some_files_under); } }