text:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
using gView.Framework.UI;
using gView.Framework.Carto;
using gView.Framework.Symbology;
using gView.Framework.system;
using gView.Framework.Data;
using gView.Framework.Geometry;
using gView.MapServer;
using gView.Framework.XML;
using gView.Interoperability.ArcXML.Dataset;
using gView.Framework.Carto.UI;
using gView.Framework.Carto.Rendering;
using gView.Framework.Network;

namespace gView.Interoperability.ArcXML
{
    internal class GET_FEATURES_REQUEST
    {
        public IQueryFilter Filter = null;
        public List<ITableClass> Classes = null;
        public IServiceMap ServiceMap = null;

        public string Request()
        {
            int beginrecord = 0;
            int featurelimit = 1000;
            bool envelope = false;
            bool geometry = false;
            if (Filter is IArcXmlGET_FEATURES_Attributes)
            {
                IArcXmlGET_FEATURES_Attributes attributes = Filter as IArcXmlGET_FEATURES_Attributes;
                beginrecord = attributes.beginrecord;
                featurelimit = attributes.featurelimit;
                envelope = attributes.envelope;
                geometry = attributes.geometry;
            }

            ICursor cursor = null;
            int counter = 0;
            bool hasmore = false;
            Envelope env = null;

            StringBuilder axl = new StringBuilder();
            MemoryStream ms = new MemoryStream();
            XmlTextWriter xWriter = new XmlTextWriter(ms, Encoding.UTF8);

            xWriter.WriteStartDocument();
            xWriter.WriteStartElement("ARCXML");
            xWriter.WriteAttributeString("version", "1.1");

            xWriter.WriteStartElement("RESPONSE");
            xWriter.WriteStartElement("FEATURES");

            foreach (ITableClass Class in Classes)
            {
                IQueryFilter filter = Filter.Clone() as IQueryFilter;
                if (filter == null) return String.Empty;

                if (Classes.Count > 1)
                {
                    if (!MapServerHelper.ModifyFilter(ServiceMap, Class, filter)) continue;
                }

                if (Class != null && Class.Dataset is ArcIMSDataset && filter is IArcXmlGET_FEATURES_Attributes)
                {
                    ((IArcXmlGET_FEATURES_Attributes)filter).Properties = ((ArcIMSDataset)Class.Dataset)._properties;
                }
                if (filter is IBufferQueryFilter &&
                    ((IBufferQueryFilter)filter).RootFilter is IArcXmlGET_FEATURES_Attributes &&
                    ((IBufferQueryFilter)filter).RootFeatureClass != null &&
                    ((IBufferQueryFilter)filter).RootFeatureClass.Dataset is ArcIMSDataset)
                {
                    ((IArcXmlGET_FEATURES_Attributes)((IBufferQueryFilter)filter).RootFilter).Properties =
                        ((ArcIMSDataset)((IBufferQueryFilter)filter).RootFeatureClass.Dataset)._properties;
                }

                if (Class is IFeatureClass)
                {
                    cursor = Class.Search(filter) as IFeatureCursor;
                }
                else if (Class is ITableClass)
                {
                    cursor = Class.Search(filter) as IRowCursor;
                }
                if (cursor == null) continue;

                if ((filter is ArcXMLQueryFilter || filter is ArcXMLSpatialFilter) &&
                    cursor is AXLFeatureCursor &&
                    Classes.Count == 1)
                {
                    return ((AXLFeatureCursor)cursor).ArcXML;
                }

                bool project = false;
                if (filter.FeatureSpatialReference == null &&
                    Class is IFeatureClass &&
                    ServiceMap != null &&
                    ServiceMap.Display.SpatialReference != null &&
                    !ServiceMap.Display.SpatialReference.Equals(((IFeatureClass)Class).SpatialReference))
                {
                    project = true;
                }

                IRow row;
                while ((row = ReadNext(cursor)) != null)
                {
                    if ((counter + 1) < beginrecord)
                    {
                        counter++;
                        continue;
                    }

                    if (Classes.Count > 1)
                        MapServerHelper.AppendMergedID(MapServerHelper.GetClassID(ServiceMap, Class), row);

                    if (row is IFeature && ((IFeature)row).Shape != null &&
                        ServiceMap != null && ServiceMap.Display.SpatialReference != null
                        && Class is IFeatureClass)
                    {
                        IGeometry shape = ((IFeature)row).Shape;
                        // wenn Filter kein SpatialFilter ist, Shapes Projezieren...
                        //if (!(filter is ISpatialFilter))
                        //{
                        //    ISpatialReference sRef = ((IFeatureClass)Class).SpatialReference;
                        //    if (!ServiceMap.Display.SpatialReference.Equals(sRef))
                        //    {
                        //        ((IFeature)row).Shape = GeometricTransformer.Transform2D(
                        //            shape,
                        //            sRef,
                        //            ServiceMap.Display.SpatialReference);
                        //    }
                        //}

                        // Wenn kein FeatureSpatialReference angeben ist->
                        // Features ins Kartensystemprojezieren
                        if (project)
                        {
                            ISpatialReference sRef = ((IFeatureClass)Class).SpatialReference;
                            if (sRef == null && ServiceMap is IMap)
                                sRef = ((IMap)ServiceMap).LayerDefaultSpatialReference;

                            ((Feature)row).Shape = GeometricTransformer.Transform2D(
                                shape,
                                sRef,
                                ServiceMap.Display.SpatialReference);
                        }
                    }

                    xWriter.WriteStartElement("FEATURE");
                    if (envelope && row is ArcXMLFeature && ((ArcXMLFeature)row).Envelope != null)
                    {
                        ArcXMLFeature arcXMLRow = row as ArcXMLFeature;
                        IEnvelope e = arcXMLRow.Envelope;
                        // wenn Filter kein SpatialFilter ist, Shapes Projezieren...
                        //
                        // nicht mehr Projezieren, dass sollte schon durch die
                        // FeatureSpatialReference des Filters gelöst sein
                        // es kommt sonst zu mehrfachen Projezieren!!!
                        //
                        //if (!(filter is ISpatialFilter) && Class is IFeatureClass &&
                        //    ServiceMap != null && ServiceMap.Display.SpatialReference != null)
                        //{
                        //    ISpatialReference sRef = ((IFeatureClass)Class).SpatialReference;
                        //    if (!ServiceMap.Display.SpatialReference.Equals(sRef))
                        //    {
                        //        e = GeometricTransformer.Transform2D(
                        //            e,
                        //            sRef,
                        //            ServiceMap.Display.SpatialReference).Envelope;
                        //    }
                        //}
                        AXL.ENVELOPE(xWriter, e);
                        if (env == null)
                            env = new Envelope(e);
                        else
                            env.Union(e);
                    }
                    else if (envelope && row is IFeature)
                    {
                        if (((IFeature)row).Shape != null)
                        {
                            IEnvelope e = ((IFeature)row).Shape.Envelope;
                            AXL.ENVELOPE(xWriter, e);
                            if (env == null)
                                env = new Envelope(e);
                            else
                                env.Union(e);
                        }
                    }
                    if (row.Fields != null)
                    {
                        xWriter.WriteStartElement("FIELDS");
                        foreach (FieldValue fv in row.Fields)
                        {
                            xWriter.WriteStartElement("FIELD");
                            xWriter.WriteAttributeString("name", fv.Name);
                            xWriter.WriteAttributeString("value", fv.Value != null ? fv.Value.ToString() : "");
                            xWriter.WriteEndElement(); // FIELD
                        }
                        xWriter.WriteEndElement(); // FIELDS
                    }
                    if (geometry && row is IFeature)
                    {
                        xWriter.WriteRaw(ArcXMLGeometry.Geometry2AXL(((IFeature)row).Shape));
                    }
                    xWriter.WriteEndElement(); // FEATURE
                    counter++;
                    if (counter == featurelimit + Math.Max(beginrecord - 1, 0))
                    {
                        hasmore = true;
                        counter = counter - Math.Max(beginrecord - 1, 0);
                        cursor.Dispose();
                        break;
                    }
                }
                cursor.Dispose();
            }

            xWriter.WriteStartElement("FEATURECOUNT");
            xWriter.WriteAttributeString("count", counter.ToString());
            xWriter.WriteAttributeString("hasmore", hasmore.ToString().ToLower());
            xWriter.WriteEndElement(); // FEATURECOUNT

            if (env != null)
                AXL.ENVELOPE(xWriter, env);

            xWriter.WriteEndElement();
            xWriter.WriteEndDocument();
            xWriter.Flush();

            ms.Position = 0;
            StreamReader sr = new StreamReader(ms);
            axl.Append(sr.ReadToEnd());
            sr.Close();
            ms.Close();
            xWriter.Close();

            return axl.ToString();
        }

        private IRow ReadNext(ICursor cursor)
        {
            if (cursor == null) return null;
            if (cursor is IRowCursor)
                return ((IRowCursor)cursor).NextRow;
            else if (cursor is IFeatureCursor)
                return ((IFeatureCursor)cursor).NextFeature;
            return null;
        }
    }

    internal class GET_IMAGE_REQUEST
    {
        public Envelope Envelope = null;
        public int iWidth = 0, iHeight = 0;
        public XmlNode layerDefs = null;
        public XmlNodeList LAYERS = null;
        public float symbolScaleFactor = 1f;
        private System.Drawing.Imaging.ImageFormat _imageFormat;
        private string _imageExtension;
        private bool _useTOC = true;

        public GET_IMAGE_REQUEST()
        {
            this.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
        }

        public string ImageRequest(IServiceMap map, IMapServer mapServer, bool useTOC)
        {
            string ret = "";
            _useTOC = useTOC;

            ModifyLAYERS(map);

            AXL response = new AXL("ARCXML", "1.1");

            map.Display.iWidth = iWidth;
            map.Display.iHeight = iHeight;
            map.Display.Limit = Envelope;
            map.Display.ZoomTo(Envelope);
            //map.Display.drawScaleBar = false;
            map.BeforeRenderLayers += new BeforeRenderLayersEvent(map_BeforeRenderLayers);
            map.ScaleSymbolFactor = symbolScaleFactor;
            map.Render();

            string title = map.Name.Replace(",", "_") + "_" + System.Guid.NewGuid().ToString("N") + _imageExtension;
            if (map.SaveImage(mapServer.OutputPath + @"\" + title, _imageFormat))
            {
                ret = response.IMAGE(mapServer.OutputPath, mapServer.OutputUrl, title, map.Display.Envelope);
            }

            return ret;
        }

        public System.Drawing.Imaging.ImageFormat ImageFormat
        {
            get { return _imageFormat; }
            set
            {
                _imageFormat = value;
                if (_imageFormat == System.Drawing.Imaging.ImageFormat.Jpeg)
                {
                    _imageExtension = ".jpg";
                }
                else if (_imageFormat == System.Drawing.Imaging.ImageFormat.Gif)
                {
                    _imageExtension = ".gif";
                }
                else
                {
                    _imageExtension = ".png";
                }
            }
        }

        public string LegendRequest(IServiceMap map, IMapServer mapServer, bool useTOC)
        {
            string ret = "";
            try
            {
                AXL response = new AXL("ARCXML", "1.1");
                _useTOC = useTOC;

                map.Display.iWidth = iWidth;
                map.Display.iHeight = iHeight;
                map.Display.Limit = Envelope;
                map.Display.ZoomTo(Envelope);
                map.BeforeRenderLayers += new BeforeRenderLayersEvent(map_BeforeRenderLayers);
                System.Drawing.Bitmap legend = map.Legend();
                if (legend != null)
                {
                    string title = map.Name.Replace(",", "_") + "_" + System.Guid.NewGuid().ToString("N") + ".png";
                    legend.Save(mapServer.OutputPath + @"\" + title, System.Drawing.Imaging.ImageFormat.Png);
                    ret = response.LEGEND(mapServer.OutputPath, mapServer.OutputUrl, title, map.Display.Envelope);
                }
            }
            catch { }
            return ret;
        }
        string LayerTitle(IServiceMap map, ILayer layer)
        {
            if (map.TOC != null)
            {
                // Besser layer als layer.Class verwendenden, weil Class von mehrerenen Layern
                // verwendet werden kann zB bei gesplitteten Layern...
                //ITOCElement tocElement = map.TOC.GetTOCElement(layer.Class);
                ITOCElement tocElement = map.TOC.GetTOCElement(layer);
                if (tocElement != null) return tocElement.Name;
            }

            if (layer != null)
            {
                return layer.Title;
            }

            return "";
        }

        void map_BeforeRenderLayers(IServiceMap sender, List<ILayer> layers)
        {
            if (layers == null) return;

            #region Set all layers invisible
            // ArcMap sends layerdef only for visible layers...
            foreach (ILayer layer in layers)
            {
                if (layer == null) continue;
                layer.Visible = false;
            }
            #endregion

            // Sichtbarkeit schalten
            if (layerDefs != null)
            {
                foreach (XmlNode layerDef in layerDefs)
                {
                    if (layerDef.Attributes["id"] == null ||
                        layerDef.Attributes["visible"] == null) continue;

                    try
                    {
                        foreach (ILayer layer in MapServerHelper.FindMapLayers(sender, _useTOC, layerDef.Attributes["id"].Value, layers))
                        {
                            layer.Visible = Convert.ToBoolean(layerDef.Attributes["visible"].Value);

                            if (sender.Display.refScale > 0D && layer is IFeatureLayer)
                            {
                                if (layerDef.Attributes["applyRefScale"] != null &&
                                    layerDef.Attributes["applyRefScale"].Value.ToLower() == "false")
                                    ((IFeatureLayer)layer).ApplyRefScale = false;
                                if (layerDef.Attributes["applyLabelRefScale"] != null &&
                                    layerDef.Attributes["applyLabelRefScale"].Value.ToLower() == "false")
                                    ((IFeatureLayer)layer).ApplyLabelRefScale = false;
                            }
                        }
                    }
                    catch { }
                }
            }

            // Renderer
            if (layerDefs != null)
            {
                foreach (XmlNode layerdef in layerDefs.SelectNodes("LAYERDEF[@id]"))
                {
                    MapServerHelper.Layers msLayers = MapServerHelper.FindMapLayers(sender, _useTOC, layerdef.Attributes["id"].Value, layers);

                    foreach (ILayer layer in msLayers)
                    {
                        if (layer is IFeatureLayer)
                        {
                            ArcIMSClass aClass = FindArcIMSClass(layer as IWebServiceTheme);
                            string layerID =
                                (layer is IWebServiceTheme) ?
                                ((IWebServiceTheme)layer).LayerID : "";

                            IFeatureLayer fLayer = (IFeatureLayer)layer;
                            if (fLayer.Visible == false) continue;

                            SetLayerObjects(aClass, layerID, fLayer, layerdef, layers);
                        }
                    }
                }
            }

            ILayer element = null;
            // Additional Layers (acetate, selection,...)
            if (LAYERS != null)
            {
                foreach (XmlNode LAYER in LAYERS)
                {
                    element = null;
                    if (LAYER.Attributes["type"] == null) continue;

                    if (LAYER.Attributes["type"].Value == "acetate")
                    {
                        foreach (XmlNode OBJECT in LAYER.SelectNodes("OBJECT"))
                        {
                            IGraphicElement grElement = ObjectFromAXLFactory.GraphicElement(OBJECT);
                            if (grElement != null)
                                sender.Display.GraphicsContainer.Elements.Add(grElement);
                        }
                    }
                    else if (LAYER.Attributes["type"].Value == "featureclass")
                    {
                        XmlNode datasetNode = LAYER.SelectSingleNode("DATASET[@fromlayer]");
                        if (datasetNode == null) continue;

                        XmlNode bufferNode = LAYER.SelectSingleNode("QUERY/BUFFER[@distance]");
                        bufferNode = (bufferNode != null) ?
                            bufferNode :
                            LAYER.SelectSingleNode("SPATIALQUERY/BUFFER[@distance]");
                        XmlNode targetNode = (bufferNode != null) ?
                            bufferNode.SelectSingleNode("TARGETLAYER[@id]") :
                            null;

                        MapServerHelper.Layers aLayers;
                        //IDatasetElement e = null;
                        if (targetNode != null)
                            aLayers = MapServerHelper.FindMapLayers(sender, _useTOC, targetNode.Attributes["id"].Value, layers);
                        //e = FindElement(layers, targetNode.Attributes["id"].Value);
                        else
                            aLayers = MapServerHelper.FindMapLayers(sender, _useTOC, datasetNode.Attributes["fromlayer"].Value, layers);
                        //e = FindElement(layers, datasetNode.Attributes["fromlayer"].Value);

                        foreach (ILayer e in aLayers)
                        {
                            if (e is IFeatureLayer && e.Class != null)
                            {
                                // Achtung: LAYER Node kann verändert werden...
                                // in ModifyFilter, ReplaceQueryWhereClause
                                // darum: clonen...
                                XmlNode clonedLAYER = LAYER.Clone();
                                if (_useTOC)
                                {
                                    IQueryFilter filter = ParseChildNodesForQueryFilter(LAYER, e.Class as ITableClass);
                                    if (filter != null)
                                    {
                                        if (!MapServerHelper.ModifyFilter(sender, e.Class as ITableClass, filter))
                                            continue;

                                        ReplaceQueryWhereClause(clonedLAYER, filter.WhereClause);
                                    }
                                }
                                ArcIMSClass aClass = FindArcIMSClass(e as IWebServiceTheme);
                                if (aClass != null)
                                {
                                    aClass.AppendedLayers.Add(
                                        Transform2LayerIDs(sender, aClass, layers, clonedLAYER));
                                    continue;
                                }
                                else
                                {
                                    if (targetNode == null && bufferNode != null)
                                    {
                                        // Buffer als Graphic !!
                                        IDatasetElement e1 = FindElement(layers, datasetNode.Attributes["fromlayer"].Value);
                                        if (e1 == null || e1.Class == null || !(e1 is IFeatureLayer)) continue;
                                        IFeatureLayer fLayer = LayerFactory.Create(e1.Class, e1 as IFeatureLayer) as IFeatureLayer;
                                        if (fLayer == null) continue;
                                        SetLayerObjects(null, "", fLayer, clonedLAYER, layers);
                                        if (fLayer.FilterQuery is IBufferQueryFilter &&
                                            fLayer.FeatureRenderer is SimpleRenderer)
                                        {
                                            sender.Display.GraphicsContainer.Elements.Add(
                                                ObjectFromAXLFactory.GraphicElement(
                                                    ((SimpleRenderer)fLayer.FeatureRenderer).Symbol,
                                                    (IBufferQueryFilter)fLayer.FilterQuery));
                                        }
                                        continue;
                                    }
                                    element = LayerFactory.Create(e.Class, e as IFeatureLayer);
                                    element.Visible = true;
                                    layers.Add(element);
                                }
                            }
                        }
                    }
                    if (element == null) continue;

                    if (element is IFeatureLayer)
                    {
                        IFeatureLayer fLayer = (IFeatureLayer)element;

                        SetLayerObjects(null, "", fLayer, LAYER, layers);
                    }
                }
            }
        }

        private void SetLayerObjects(ArcIMSClass aClass, string LayerID, IFeatureLayer fLayer, XmlNode layerdef, List<ILayer> layers)
        {
            if (fLayer == null || layerdef == null) return;

            foreach (XmlNode child in layerdef.ChildNodes)
            {
                if (child.Name == "QUERY" || child.Name == "SPATIALQUERY")
                {
                    IFeatureClass rootFeatureClass = null;
                    XmlNode datasetNode = layerdef.SelectSingleNode("DATASET[@fromlayer]");
                    if (datasetNode != null)
                    {
                        IDatasetElement e = FindElement(layers, datasetNode.Attributes["fromlayer"].Value);
                        if (e is IFeatureLayer)
                            rootFeatureClass = ((IFeatureLayer)e).FeatureClass;
                    }

                    IQueryFilter orig = fLayer.FilterQuery;
                    fLayer.FilterQuery = ObjectFromAXLFactory.Query(child, fLayer.FeatureClass, rootFeatureClass);
                    if (orig != null)
                    {
                        if (fLayer.FilterQuery == null)
                        {
                            fLayer.FilterQuery = orig;
                        }
                        else if (!String.IsNullOrEmpty(fLayer.FilterQuery.WhereClause) &&
                                 !String.IsNullOrEmpty(orig.WhereClause))
                        {
                            fLayer.FilterQuery.WhereClause += " AND " + orig.WhereClause;
                        }
                        else if (String.IsNullOrEmpty(fLayer.FilterQuery.WhereClause) &&
                               !String.IsNullOrEmpty(orig.WhereClause))
                        {
                            fLayer.FilterQuery.WhereClause = orig.WhereClause;
                        }
                    }
                }
                else if (child.Name == "SIMPLERENDERER")
                {
                    if (aClass != null)
                        aClass.LayerRenderer.Add(LayerID, child);
                    else
                    {
                        fLayer.FeatureRenderer = ObjectFromAXLFactory.SimpleRenderer(child);
                    }
                }
                else if (child.Name == "VALUEMAPRENDERER")
                {
                    if (aClass != null)
                        aClass.LayerRenderer.Add(LayerID, child);
                    else
                    {
                        fLayer.FeatureRenderer = ObjectFromAXLFactory.ValueMapRenderer(child);
                    }
                }
                //else if (child.Name == "SIMPLELABELRENDERER")
                //{
                //    if (aClass != null)
                //        aClass.LayerRenderer.Add(((IWebServiceTheme)element).LayerID, child);
                //    else
                //    {
                //        fLayer.LabelRenderer = ObjectFromAXLFactory.SimpleLabelRenderer(child, fLayer.FeatureClass);
                //    }
                //}
                else if (child.Name == "GROUPRENDERER")
                {
                    if (aClass != null)
                        aClass.LayerRenderer.Add(LayerID, child);
                    else
                    {
                        fLayer.FeatureRenderer = ObjectFromAXLFactory.GroupRenderer(child);
                    }
                }
            }
            ParseChildNodesForLabelRenderer(aClass, LayerID, fLayer, layerdef);
        }

        private bool ParseChildNodesForLabelRenderer(ArcIMSClass aClass, string LayerID, IFeatureLayer fLayer, XmlNode layerdef)
        {
            if (fLayer == null || layerdef == null ||
                layerdef.ChildNodes == null || layerdef.ChildNodes.Count == 0) return false;

            foreach (XmlNode child in layerdef.ChildNodes)
            {
                if (child.Name == "SIMPLELABELRENDERER")
                {
                    fLayer.LabelRenderer = ObjectFromAXLFactory.SimpleLabelRenderer(child, fLayer.FeatureClass);
                    return true;
                }
                else if (child.Name == "GROUPRENDERER")
                {
                    if (ParseChildNodesForLabelRenderer(aClass, LayerID, fLayer, child))
                    {
                        return true;
                    }
                }
            }
            return false;
        }
        private IQueryFilter ParseChildNodesForQueryFilter(XmlNode parentNode, ITableClass tc)
        {
            foreach (XmlNode child in parentNode.ChildNodes)
            {
                if (child.Name == "QUERY" || child.Name == "SPATIALQUERY")
                {
                    IQueryFilter filter = ObjectFromAXLFactory.Query(child, tc);
                    return filter;
                }
            }
            return null;
        }
        private void ReplaceQueryWhereClause(XmlNode parentNode, string newWhereClause)
        {
            foreach (XmlNode child in parentNode.ChildNodes)
            {
                if ((child.Name == "QUERY" || child.Name == "SPATIALQUERY") &&
                    child.Attributes["where"] != null)
                {
                    child.Attributes["where"].Value = newWhereClause;
                }
            }
        }
        #region Helper
        private ArcIMSClass FindArcIMSClass(IWebServiceTheme layer)
        {
            if (layer == null) return null;
            return layer.ServiceClass as ArcIMSClass;
        }

        private XmlNode Transform2LayerIDs(IServiceMap sender, ArcIMSClass aClass, List<ILayer> layers, XmlNode node)
        {
            if (aClass == null || layers == null || node == null) return null;

            XmlNode ret = node.Clone();
            foreach (XmlNode dataset in ret.SelectNodes("DATASET[@fromlayer]"))
            {
                MapServerHelper.Layers themes = MapServerHelper.FindMapLayers(sender, _useTOC, dataset.Attributes["fromlayer"].Value, layers);

                //IWebServiceTheme theme = FindElement(layers, dataset.Attributes["fromlayer"].Value) as IWebServiceTheme;
                foreach (ILayer theme in themes)
                {
                    if (!(theme is IWebServiceTheme) ||
                          ((IWebServiceTheme)theme).ServiceClass != aClass) return null;

                    dataset.Attributes["fromlayer"].Value = ((IWebServiceTheme)theme).LayerID;
                }
            }

            foreach (XmlNode target in ret.SelectNodes("SPATIALQUERY/BUFFER/TARGETLAYER[@id]"))
            {
                MapServerHelper.Layers themes = MapServerHelper.FindMapLayers(sender, _useTOC, target.Attributes["id"].Value, layers);

                //IWebServiceTheme theme = FindElement(layers, target.Attributes["id"].Value) as IWebServiceTheme;
                foreach (ILayer theme in themes)
                {
                    if (!(theme is IWebServiceTheme) ||
                          ((IWebServiceTheme)theme).ServiceClass != aClass) return null;

                    target.Attributes["id"].Value = ((IWebServiceTheme)theme).LayerID;
                }
            }

            foreach (XmlNode target in ret.SelectNodes("QUERY/BUFFER/TARGETLAYER[@id]"))
            {
                MapServerHelper.Layers themes = MapServerHelper.FindMapLayers(sender, _useTOC, target.Attributes["id"].Value, layers);

                //IWebServiceTheme theme = FindElement(layers, target.Attributes["id"].Value) as IWebServiceTheme;
                foreach (ILayer theme in themes)
                {
                    if (!(theme is IWebServiceTheme) ||
                          ((IWebServiceTheme)theme).ServiceClass != aClass) return null;

                    target.Attributes["id"].Value = ((IWebServiceTheme)theme).LayerID;
                }
            }

            return ret;
        }

        private ILayer FindElement(List<ILayer> layers, string id)
        {
            foreach (ILayer element in layers)
            {
                if (element == null) continue;

                //if (element.ID.ToString() == id)
                if (element.SID.ToString() == id)
                {
                    return element;
                }
            }
            return null;
        }

        private class GraphicsFeatureClass : FeatureLayer
        {
        }

        /// <summary>
        /// Überprüft, ob alle zusätzlichen Layer maximal einem darunterliegenden
        /// Webservice abhängen. Wenn nicht werden die Filter entsprechend umgebaut!
        /// zB beim Serviceübergreifenden Buffern...
        /// </summary>
        /// <param name="map"></param>
        private void ModifyLAYERS(IServiceMap map)
        {
            if (LAYERS == null) return;

            foreach (XmlNode LAYER in LAYERS)
            {
                if (LAYER == null || LAYER.Attributes["type"] == null) continue;

                if (LAYER.Attributes["type"].Value == "featureclass")
                {
                    XmlNode datasetNode = LAYER.SelectSingleNode("DATASET[@fromlayer]");
                    if (datasetNode == null) continue;

                    XmlNode queryNode = (LAYER.SelectSingleNode("QUERY") != null) ?
                        LAYER.SelectSingleNode("QUERY") :
                        LAYER.SelectSingleNode("SPATIALQUERY");
                    if (queryNode == null) continue;

                    XmlNode bufferNode = queryNode.SelectSingleNode("BUFFER[@distance]");
                    XmlNode targetNode = (bufferNode != null) ?
                        bufferNode.SelectSingleNode("TARGETLAYER[@id]") :
                        null;

                    if (bufferNode != null && targetNode != null)
                    {
                        MapServerHelper.Layers target = MapServerHelper.FindMapLayers(map, _useTOC, targetNode.Attributes["id"].Value);
                        MapServerHelper.Layers fromlayer = MapServerHelper.FindMapLayers(map, _useTOC, datasetNode.Attributes["fromlayer"].Value);

                        if (target.Count == 1 && fromlayer.Count == 1 &&
                            target[0] is IWebServiceTheme)
                        {
                            IWebServiceClass targetWebClass = ((IWebServiceTheme)target[0]).ServiceClass;
                            if ((fromlayer[0] is IWebServiceTheme &&
                               !((IWebServiceTheme)fromlayer[0]).ServiceClass.Equals(targetWebClass)) ||
                               !(fromlayer[0] is IWebServiceTheme))
                            {
                                IQueryFilter filter = ObjectFromAXLFactory.Query(queryNode, target[0].Class as ITableClass, fromlayer[0].Class as IFeatureClass);
                                filter.SetUserData("IServiceRequestContext", map as IServiceRequestContext);

                                if (filter is IBufferQueryFilter)
                                {
                                    ((IBufferQueryFilter)filter).RootFilter.SetUserData("IServiceRequestContext", map as IServiceRequestContext);
                                    filter = BufferQueryFilter.ConvertToSpatialFilter((IBufferQueryFilter)filter);
                                }

                                if (target[0].Class is IBeforeQueryEventHandler)
                                    ((IBeforeQueryEventHandler)target[0].Class).FireBeforeQureyEvent(ref filter);

                                string axl = AXLFromObjectFactory.Query(filter);
                                XmlDocument doc = new XmlDocument();
                                doc.LoadXml(axl);
                                LAYER.RemoveChild(queryNode);
                                LAYER.AppendChild(LAYER.OwnerDocument.ImportNode(doc.ChildNodes[0], true));

                                datasetNode.Attributes["fromlayer"].Value = targetNode.Attributes["id"].Value;

                                HatchSymbol symbol = new HatchSymbol();
                                symbol.PenColor = System.Drawing.Color.FromArgb(150, System.Drawing.Color.Red);

                                IGraphicElement grElement = new AcetateGraphicElement(symbol, ((ISpatialFilter)filter).Geometry);
                                map.Display.GraphicsContainer.Elements.Add(grElement);
                            }
                        }
                    }
                }
            }
        }

        private class AcetateGraphicElement : IGraphicElement
        {
            private ISymbol _symbol;
            private IGeometry _geometry;

            public AcetateGraphicElement(ISymbol symbol, IGeometry geometry)
            {
                _symbol = symbol;
                _geometry = geometry;
            }

            #region IGraphicElement Member

            public void Draw(IDisplay display)
            {
                if (_symbol == null || _geometry == null) return;

                display.Draw(_symbol, _geometry);
            }

            #endregion
        }
        #endregion
    }

    internal class GET_RASTER_INFO
    {
        private static IFormatProvider _nhi = System.Globalization.CultureInfo.InvariantCulture.NumberFormat;

        public List<IClass> Classes = null;
        public List<IPoint> Points = null;
        public ISpatialReference SpatialReference = null;
        public IDisplay Display = null;
        public IUserData UserData = null;
        public bool Compact = false, Grid = false;
        public int CompactRows = 0, CompactCols = 0;
        public double GridDx = 1, GridDy = 1;

        public string Request()
        {
            if (Classes == null || Points == null) return String.Empty;

            StringBuilder axl = new StringBuilder();
            MemoryStream ms = new MemoryStream();
            XmlTextWriter xWriter = new XmlTextWriter(ms, Encoding.UTF8);

            xWriter.WriteStartDocument();
            xWriter.WriteStartElement("ARCXML");
            xWriter.WriteAttributeString("version", "1.1");

            xWriter.WriteStartElement("RESPONSE");

            if (Grid)
            {
                if (Classes.Count == 1 && Classes[0] is IMultiGridIdentify)
                {
                    IMultiGridIdentify mgi = (IMultiGridIdentify)Classes[0];
                    float[] vals = mgi.MultiGridQuery(Display, Points.ToArray(), GridDx, GridDy, SpatialReference, UserData);

                    xWriter.WriteStartElement("DATA");
                    xWriter.WriteAttributeString("rows", ((int)vals[0]).ToString());
                    xWriter.WriteAttributeString("cols", ((int)vals[1]).ToString());
                    StringBuilder sb = new StringBuilder();
                    for (int i = 2; i < vals.Length; i++)
                    {
                        if (sb.Length > 0) sb.Append(" ");
                        sb.Append(vals[i].ToString());
                    }
                    xWriter.WriteRaw(sb.ToString());
                }
            }
            else
            {
                if (Compact)
                {
                    xWriter.WriteStartElement("DATA");
                    xWriter.WriteAttributeString("rows", CompactRows.ToString());
                    xWriter.WriteAttributeString("cols", CompactCols.ToString());
                }
                foreach (IClass rasterClass in Classes)
                {
                    //if (!(rasterClass is IRasterClass)) continue;

                    if (rasterClass is IMulitPointIdentify)
                    {
                        PointCollection pColl = new PointCollection(Points);
                        using (ICursor cursor = ((IMulitPointIdentify)rasterClass).MultiPointQuery(Display, pColl, SpatialReference, UserData))
                        {
                            if (Compact)
                                AddCompactRasterInfo2(xWriter, cursor, null);
                            else
                                AddRasterInfo(xWriter, cursor, null);
                        }
                    }
                    else if (rasterClass is IPointIdentify)
                    {
                        foreach (IPoint point in Points)
                        {
                            using (ICursor cursor = ((IPointIdentify)rasterClass).PointQuery(Display, point, SpatialReference, UserData))
                            {
                                if (Compact)
                                    AddCompactRasterInfo(xWriter, cursor, point);
                                else
                                    AddRasterInfo(xWriter, cursor, point);
                            }
                        }
                    }
                }
            }
            xWriter.WriteEndElement();
            xWriter.WriteEndDocument();
            xWriter.Flush();

            ms.Position = 0;
            StreamReader sr = new StreamReader(ms);
            axl.Append(sr.ReadToEnd());
            sr.Close();
            ms.Close();
            xWriter.Close();

            return axl.ToString();
        }

        private void AddRasterInfo(XmlTextWriter xWriter, ICursor cursor, IPoint point)
        {
            if (cursor == null) return;

            if (cursor is IRowCursor)
            {
                IRow row;
                while ((row = ReadNext(cursor)) != null)
                {
                    if (row.Fields != null)
                    {
                        xWriter.WriteStartElement("RASTER_INFO");
                        if (point != null)
                        {
                            xWriter.WriteAttributeString("x", point.X.ToString());
                            xWriter.WriteAttributeString("y", point.Y.ToString());
                        }
                        else
                        {
                            object x_ = row["x"], y_ = row["y"];
                            if (x_ != null)
                                xWriter.WriteAttributeString("x", x_.ToString());
                            if (y_ != null)
                                xWriter.WriteAttributeString("y", y_.ToString());
                        }
                        xWriter.WriteStartElement("BANDS");

                        int bandnumber = 0;
                        foreach (FieldValue fv in row.Fields)
                        {
                            double val;
                            if (fv != null && fv.Value != null &&
                                fv.Name.ToLower().StartsWith("band") &&
                                double.TryParse(fv.Value.ToString(), out val))
                            {
                                xWriter.WriteStartElement("BAND");
                                xWriter.WriteAttributeString("name", fv.Name);
                                xWriter.WriteAttributeString("number", bandnumber.ToString());
                                xWriter.WriteAttributeString("value", val.ToString());
                                xWriter.WriteEndElement(); // BAND
                                bandnumber++;
                            }
                            else if (fv != null && fv.Value != null)
                            {
                                xWriter.WriteStartElement("attribute");
                                xWriter.WriteAttributeString("name", fv.Name);
                                if (fv.Value != null)
                                    xWriter.WriteAttributeString("value", fv.Value.ToString());
                                else
                                    xWriter.WriteAttributeString("value", "");
                                xWriter.WriteEndElement();
                            }
                        }

                        xWriter.WriteEndElement(); // BANDS
                        xWriter.WriteEndElement(); // RASTER_INFO
                    }
                }
            }
            else if (cursor is IUrlCursor)
            {
                xWriter.WriteStartElement("gv_url_info");
                xWriter.WriteAttributeString("url", ((IUrlCursor)cursor).Url);
                xWriter.WriteEndElement();
            }
            else if (cursor is ITextCursor)
            {
                xWriter.WriteStartElement("gv_text_info");
                xWriter.WriteAttributeString("text", ((ITextCursor)cursor).Text.Replace("\r", "").Replace("\n", "\\n"));
                xWriter.WriteEndElement();
            }
        }

        private void AddCompactRasterInfo(XmlTextWriter xWriter, ICursor cursor, IPoint point)
        {
            xWriter.WriteRaw(point.X.ToString(_nhi) + "," + point.Y.ToString(_nhi));

            if (cursor != null)
            {
                if (cursor is IRowCursor)
                {
                    IRow row;
                    while ((row = ReadNext(cursor)) != null)
                    {
                        foreach (FieldValue fv in row.Fields)
                        {
                            double val;
                            if (fv != null && fv.Value != null &&
                                fv.Name.ToLower().StartsWith("band") &&
                                double.TryParse(fv.Value.ToString(), out val))
                            {
                                xWriter.WriteRaw("," + val.ToString().Replace(",", "."));
                            }
                            else
                            {
                                //xWriter.WriteRaw(",0");
                            }
                        }
                        if (point == null)
                            xWriter.WriteRaw(" ");
                    }
                }
            }
            xWriter.WriteRaw(" ");
        }

        private void AddCompactRasterInfo2(XmlTextWriter xWriter, ICursor cursor, IPoint point)
        {
            List<IPoint> clonePointList = ListOperations<IPoint>.Clone(Points);

            if (cursor is IRowCursor)
            {
                IRow row;
                while ((row = ReadNext(cursor)) != null)
                {
                    Point p = new Point((double)row["x"], (double)row["y"]);
                    double val = double.NaN;

                    foreach (FieldValue fv in row.Fields)
                    {
                        if (fv != null && fv.Value != null &&
                            fv.Name.ToLower().StartsWith("band") &&
                            double.TryParse(fv.Value.ToString(), out val))
                        {
                            break;
                        }
                    }
                    if (!double.IsNaN(val))
                    {
                        IPoint r = null;
                        foreach (IPoint c in clonePointList)
                        {
                            if (p.Equals(c))
                            {
                                c.Z = val;
                                r = c;
                                break;
                            }
                        }
                        if (r != null)
                            clonePointList.Remove(r);
                    }
                }
            }
            StringBuilder sb = new StringBuilder();
            foreach (IPoint c in Points)
            {
                sb.Append(c.X.ToString(_nhi) + "," + c.Y.ToString(_nhi) + "," + c.Z.ToString(_nhi) + " ");
            }
            xWriter.WriteRaw(sb.ToString());
        }
        private IRow ReadNext(ICursor cursor)
        {
            if (cursor == null) return null;
            if (cursor is IRowCursor)
                return ((IRowCursor)cursor).NextRow;
            else if (cursor is IFeatureCursor)
                return ((IFeatureCursor)cursor).NextFeature;
            return null;
        }
    }

    public class AXL
    {
        string _rootElement, _version;
        public AXL(string rootElement, string version)
        {
            _rootElement = rootElement;
            _version = version;
        }

        //public IServiceMap Map(IMapServer server, string serviceName)
        //{
        //    if (server == null) return null;

        //    return server[serviceName];
        //}

        public string GETCLIENTSERVICES(IMapServer server, IIdentity identity)
        {
            StringBuilder axl = new StringBuilder();
            MemoryStream ms = new MemoryStream();
            XmlTextWriter xWriter = new XmlTextWriter(ms, Encoding.UTF8);

            xWriter.WriteStartDocument();
            xWriter.WriteStartElement(_rootElement);
            xWriter.WriteAttributeString("version", _version);

            xWriter.WriteStartElement("RESPONSE");
            xWriter.WriteStartElement("SERVICES");

            foreach (IMapService map in server.Maps)
            {
                if (!server.CheckAccess(identity, map.Name)) continue;

                xWriter.WriteStartElement("SERVICE");
                xWriter.WriteAttributeString("access", "PUBLIC");
                xWriter.WriteAttributeString("ACCESS", "PUBLIC");
                xWriter.WriteAttributeString("name", map.Name);
                xWriter.WriteAttributeString("NAME", map.Name);
                xWriter.WriteAttributeString("private", "true");
                xWriter.WriteAttributeString("servicegroup", "ImageServer1");
                xWriter.WriteAttributeString("SERVICEGROUP", "ImageServer1");
                xWriter.WriteAttributeString("status", "ENABLED");
                xWriter.WriteAttributeString("STATUS", "ENABLED");
                xWriter.WriteAttributeString("type", "ImageServer");
                xWriter.WriteAttributeString("TYPE", "ImageServer");
                xWriter.WriteAttributeString("version", "");
                xWriter.WriteAttributeString("VERSION", "");
                xWriter.WriteAttributeString("servicetype", map.Type.ToString());

                xWriter.WriteStartElement("IMAGE");
                xWriter.WriteAttributeString("type", "PNG");
                xWriter.WriteEndElement(); // IMAGE

                xWriter.WriteStartElement("ENVIRONMENT");
                xWriter.WriteStartElement("LOCALE");
                xWriter.WriteAttributeString("country", "AT");
                xWriter.WriteAttributeString("language", "de");
                xWriter.WriteAttributeString("variant", "");
                xWriter.WriteEndElement(); // LOCALE
                xWriter.WriteStartElement("UIFONT");
                xWriter.WriteAttributeString("name", "Arial");
                xWriter.WriteEndElement(); // UIFONG
                xWriter.WriteEndElement(); // ENVIRONMENT

                xWriter.WriteStartElement("CLEANUP");
                xWriter.WriteAttributeString("interval", "5");
                xWriter.WriteEndElement(); // CLEANUP;

                xWriter.WriteEndElement(); // SERVICE
            }
            xWriter.WriteEndElement();
            xWriter.WriteEndDocument();
            xWriter.Flush();

            ms.Position = 0;
            StreamReader sr = new StreamReader(ms);
            axl.Append(sr.ReadToEnd());
            sr.Close();
            ms.Close();
            xWriter.Close();

            return axl.ToString();
        }

        private int GetAxlFieldType(FieldType fieldType)
        {
            switch (fieldType)
            {
                case FieldType.ID: return -99;
                case FieldType.Shape: return -98;
                case FieldType.boolean: return -7;
                case FieldType.biginteger: return -5;
                case FieldType.character: return 1;
                case FieldType.integer: return 4;
                case FieldType.smallinteger: return 5;
                case FieldType.Float: return 6;
                case FieldType.Double: return 8;
                case FieldType.NString:
                case FieldType.String:
                    return 12;
                case FieldType.Date: return 91;
            }
            return 0;
        }
        private void WriteLayerInfoTOC(XmlTextWriter xw, ILegendGroup lGroup)
        {
            if (lGroup == null) return;

            xw.WriteStartElement("TOC");
            xw.WriteStartElement("TOCGROUP");
            for (int i = 0; i < lGroup.LegendItemCount; i++)
            {
                ILegendItem lItem = lGroup.LegendItem(i);
                if (lItem == null) continue;

                xw.WriteStartElement("TOCCLASS");
                xw.WriteAttributeString("label", lItem.LegendLabel);
                xw.WriteAttributeString("description", "");

                using (System.Drawing.Bitmap bm = new System.Drawing.Bitmap(25, 14))
                {
                    using (System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bm))
                    {
                        SymbolPreview.Draw(gr, new System.Drawing.Rectangle(0, 0, 25, 14), lItem as ISymbol);
                    }
                    MemoryStream ms = new MemoryStream();
                    bm.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                    xw.WriteRaw(Convert.ToBase64String(ms.ToArray()));
                }

                xw.WriteEndElement(); // TOCCLASS
            }
            xw.WriteEndElement(); // TOCGROUP
            xw.WriteEndElement(); // TOC
        }

        public string GET_SERVICE_INFO(IServiceRequestContext context, bool fields, bool envelope, bool renderers, bool toc, bool gv_meta, bool useTOC)
        {
            if (context == null) return String.Empty;
            using (IServiceMap map = context.ServiceMap)
            {

                if (map == null) return "";

                double dpm = 96.0 / 0.0254;

                StringBuilder axl = new StringBuilder();
                MemoryStream ms = new MemoryStream();
                XmlTextWriter xWriter = new XmlTextWriter(ms, Encoding.UTF8);

                xWriter.WriteStartDocument();
                xWriter.WriteStartElement(_rootElement);

                xWriter.WriteAttributeString("version", _version);

                //xWriter.WriteStartElement("ONLINE_RES");
                //xWriter.WriteAttributeString("service_name", map.Name);
                //xWriter.WriteAttributeString("xlink_href", "http://localhost/gViewPortal/wms.aspx?ServiceName=" + map.Name + "&");
                //xWriter.WriteEndElement(); // ONLINE_RES

                xWriter.WriteStartElement("RESPONSE");
                xWriter.WriteStartElement("SERVICEINFO");
                //xWriter.WriteAttributeString("service", map.Name);
                xWriter.WriteStartElement("ENVIRONMENT");

                xWriter.WriteStartElement("LOCALE");
                string[] culture = System.Globalization.CultureInfo.CurrentCulture.Name.Split('-');
                xWriter.WriteAttributeString("language", culture[0]);
                xWriter.WriteAttributeString("country", (culture.Length > 1) ? culture[1] : culture[0]);
                xWriter.WriteEndElement(); // LOCALE

                xWriter.WriteStartElement("UIFONT");
                xWriter.WriteAttributeString("name", "Arial");
                xWriter.WriteAttributeString("color", "0,0,0");
                xWriter.WriteAttributeString("size", "12");
                xWriter.WriteAttributeString("sytle", "regular");
                xWriter.WriteEndElement(); // UIFONT

                xWriter.WriteStartElement("SEPARATORS");
                xWriter.WriteAttributeString("cs", " ");
                xWriter.WriteAttributeString("ts", ";");
                xWriter.WriteEndElement(); // SEPARATORS

                xWriter.WriteStartElement("CAPABILITIES");
                xWriter.WriteAttributeString("forbidden", "");
                xWriter.WriteAttributeString("disabledtypes", "");
                xWriter.WriteAttributeString("returngeometry", "xmlmode");
                xWriter.WriteAttributeString("displayrotation", "true");
                xWriter.WriteAttributeString("refscale", "true");
                xWriter.WriteEndElement(); // CAPABILITIES

                xWriter.WriteStartElement("SCREEN");
                xWriter.WriteAttributeString("dpi", "96");
                xWriter.WriteEndElement(); // SCREEN

                xWriter.WriteStartElement("IMAGELIMIT");
                xWriter.WriteAttributeString("pixelcount", "52428800");
                xWriter.WriteEndElement(); // IMAGELIMIT

                xWriter.WriteEndElement(); // ENVIRONMENT

                List<IDatasetElement> layers;

                xWriter.WriteStartElement("PROPERTIES");
                if (map.Display.SpatialReference != null)
                {
                    ISpatialReference sRef = map.Display.SpatialReference;
                    if (sRef.Name.ToLower().StartsWith("epsg:"))
                    {
                        xWriter.WriteStartElement("FEATURECOORDSYS");
                        xWriter.WriteAttributeString("id", sRef.Name.Split(':')[1]);
                        xWriter.WriteEndElement();
                        xWriter.WriteStartElement("FILTERCOORDSYS");
                        xWriter.WriteAttributeString("id", sRef.Name.Split(':')[1]);
                        xWriter.WriteEndElement();
                    }
                    else
                    {
                        xWriter.WriteStartElement("FEATURECOORDSYS");
                        xWriter.WriteAttributeString("string", SpatialReference.ToESRIWKT(sRef));
                        xWriter.WriteEndElement();
                        xWriter.WriteStartElement("FILTERCOORDSYS");
                        xWriter.WriteAttributeString("string", SpatialReference.ToESRIWKT(sRef));
                        xWriter.WriteEndElement();
                    }
                }
                if (envelope)
                {
                    Envelope mapEnvelope = null;
                    layers = map.MapElements;

                    foreach (IDatasetElement element in map.MapElements)
                    {
                        IEnvelope env = null;
                        if (element is IFeatureLayer)
                        {
                            if (((IFeatureLayer)element).FeatureClass == null) continue;
                            IGeometry geom = GeometricTransformer.Transform2D(((IFeatureLayer)element).FeatureClass.Envelope, ((IFeatureLayer)element).FeatureClass.SpatialReference, map.Display.SpatialReference);
                            if (geom != null) env = geom.Envelope;
                        }
                        else if (element is IRasterLayer && ((IRasterLayer)element).RasterClass != null)
                        {
                            if (((IRasterLayer)element).RasterClass.Polygon == null) continue;
                            IGeometry geom = GeometricTransformer.Transform2D(((IRasterLayer)element).RasterClass.Polygon.Envelope, ((IRasterLayer)element).RasterClass.SpatialReference, map.Display.SpatialReference);
                            if (geom != null) env = geom.Envelope;
                        }
                        else if (element is IWebServiceLayer && ((IWebServiceLayer)element).WebServiceClass != null)
                        {
                            if (((IWebServiceLayer)element).WebServiceClass.Envelope == null) continue;
                            IGeometry geom = GeometricTransformer.Transform2D(((IWebServiceLayer)element).WebServiceClass.Envelope, ((IWebServiceLayer)element).WebServiceClass.SpatialReference, map.Display.SpatialReference);
                            if (geom != null) env = geom.Envelope;
                        }
                        if (env == null) continue;
                        if (mapEnvelope == null)
                            mapEnvelope = new Envelope(env);
                        else
                            mapEnvelope.Union(env);
                    }
                    ENVELOPE(xWriter, mapEnvelope, "Initial_Extent");
                }

                /*
                if (map.Display.SpatialReference != null)
                {
                    // SpatialReference
                    xWriter.WriteStartElement("SPATIALREFERENCE");
                    xWriter.WriteAttributeString("name", map.Display.SpatialReference.Name);
                    xWriter.WriteAttributeString("param", SpatialReference.ToProj4(map.Display.SpatialReference));
                    xWriter.WriteEndElement();

                    // FEATURECOORDSYS
                    xWriter.WriteStartElement("FEATURECOORDSYS");
                    xWriter.WriteAttributeString("string", SpatialReference.ToESRIWKT(map.Display.SpatialReference));
                    xWriter.WriteEndElement();
                    // FILTERCOORDSYS
                    xWriter.WriteStartElement("FILTERCOORDSYS");
                    xWriter.WriteAttributeString("string", SpatialReference.ToESRIWKT(map.Display.SpatialReference));
                    xWriter.WriteEndElement();
                }
                */

                xWriter.WriteStartElement("MAPUNITS");
                switch (map.Display.DisplayUnits)
                {
                    case GeoUnits.Meters:
                        xWriter.WriteAttributeString("units", "meters");
                        break;
                    case GeoUnits.DecimalDegrees:
                        xWriter.WriteAttributeString("units", "decimal_degrees");
                        break;
                    case GeoUnits.Feet:
                        xWriter.WriteAttributeString("units", "feet");
                        break;
                    default:
                        xWriter.WriteAttributeString("units", "meters");
                        break;
                }
                xWriter.WriteEndElement();  // MAPUNITS

                xWriter.WriteEndElement(); // PROPERTIES

                //layers = map.MapElements;

                //StringBuilder sb = new StringBuilder();
                //DateTime t1 = DateTime.Now;
                string name = String.Empty;

                foreach (MapServerHelper.Layers Layers in MapServerHelper.MapLayers(map, useTOC))
                {
                    //if (!String.IsNullOrEmpty(name))
                    //{
                    //    sb.Append(name + " " + ((TimeSpan)(DateTime.Now - t1)).TotalMilliseconds.ToString() + "ms\n");
                    //    t1 = DateTime.Now;
                    //}
                    if (Layers == null || Layers.FirstLayer == null) continue;
                    name = Layers.Title;
                    ILayer element = Layers.FirstLayer;

                    //ITOCElement tocElement = null;
                    //if (map.TOC != null && element is ILayer)
                    //{
                    //    tocElement = map.TOC.GetTOCElement(element as ILayer);
                    //    if (tocElement != null) name = tocElement.name;
                    //}
                    if (element is IFeatureLayer)
                    {
                        IFeatureLayer fLayer = (IFeatureLayer)element;

                        IFeatureClass fClass = MapServerHelper.GetProtoFeatureClass(Layers);
                        if (fClass != null)
                        {
                            xWriter.WriteStartElement("LAYERINFO");
                            xWriter.WriteAttributeString("type", "featureclass");
                            xWriter.WriteAttributeString("name", (name != "") ? name : fLayer.Title.Replace(".", "_"));
                            xWriter.WriteAttributeString("id", Layers.ID);
                            xWriter.WriteAttributeString("visible", fLayer.Visible.ToString().ToLower());
                            if (fLayer.MinimumScale > 1)
                                xWriter.WriteAttributeString("minscale", (fLayer.MinimumScale / dpm).ToString());
                            if (fLayer.MaximumScale > 1)
                                xWriter.WriteAttributeString("maxscale", (fLayer.MaximumScale / dpm).ToString());

                            //xWriter.WriteAttributeString("aliasname", Layers.Title);
                            if (String.IsNullOrEmpty(Layers.GroupName))
                                xWriter.WriteAttributeString("group", Layers.GroupName);

                            xWriter.WriteStartElement("FCLASS");
                            switch (fClass.GeometryType)
                            {
                                case geometryType.Envelope:
                                case geometryType.Polygon:
                                    xWriter.WriteAttributeString("type", "polygon");
                                    break;
                                case geometryType.Polyline:
                                    xWriter.WriteAttributeString("type", "line");
                                    break;
                                case geometryType.Point:
                                case geometryType.Multipoint:
                                    xWriter.WriteAttributeString("type", "point");
                                    break;
                                case geometryType.Network:
                                    xWriter.WriteAttributeString("type", "network");
                                    break;
                                default:
                                    xWriter.WriteAttributeString("type", "unknown");
                                    break;
                            }
                            if (envelope)
                            {
                                IGeometry geom = GeometricTransformer.Transform2D(fClass.Envelope, fClass.SpatialReference, map.Display.SpatialReference);
                                if (geom != null)
                                {
                                    ENVELOPE(xWriter, geom.Envelope);
                                }
                            }
                            if (fields)
                            {
                                foreach (IField field in fClass.Fields.ToEnumerable())
                                {
                                    if (field.type == FieldType.Shape) continue;
                                    xWriter.WriteStartElement("FIELD");
                                    xWriter.WriteAttributeString("name", field.name);
                                    xWriter.WriteAttributeString("type", GetAxlFieldType(field.type).ToString());
                                    xWriter.WriteAttributeString("size", field.size.ToString());
                                    xWriter.WriteAttributeString("precision", field.precision.ToString());
                                    xWriter.WriteEndElement(); // FIELD
                                }
                                if (fClass.ShapeFieldName != String.Empty)
                                {
                                    xWriter.WriteStartElement("FIELD");
                                    xWriter.WriteAttributeString("name", fClass.ShapeFieldName);
                                    xWriter.WriteAttributeString("type", GetAxlFieldType(FieldType.Shape).ToString());
                                    xWriter.WriteEndElement(); // FIELD
                                }
                            }
                            xWriter.WriteEndElement(); // FCLASS
                            if (toc) this.WriteLayerInfoTOC(xWriter, fLayer.FeatureRenderer as ILegendGroup);
                            if (renderers) xWriter.WriteRaw(Renderer(element as IFeatureLayer));

                            if (gv_meta) WriteClassMeta(xWriter, fClass);

                            if (fClass.GeometryType == geometryType.Network)
                                WriteNetworkTracers(xWriter);

                            if (fClass.GeometryType == geometryType.Network)
                            {

                            }

                            xWriter.WriteEndElement(); // LAYERINFO
                        }
                        else  // Raster (und alles andere)
                        {
                            xWriter.WriteStartElement("LAYERINFO");
                            xWriter.WriteAttributeString("type", "image");
                            xWriter.WriteAttributeString("name", (name != "") ? name : element.Title.Replace(".", "_"));
                            xWriter.WriteAttributeString("id", Layers.ID);
                            xWriter.WriteAttributeString("visible", element.Visible.ToString().ToLower());

                            if (element.MinimumScale > 1)
                                xWriter.WriteAttributeString("minscale", (element.MinimumScale / dpm).ToString());
                            if (element.MaximumScale > 1)
                                xWriter.WriteAttributeString("maxscale", (element.MaximumScale / dpm).ToString());

                            if (String.IsNullOrEmpty(Layers.GroupName))
                                xWriter.WriteAttributeString("group", Layers.GroupName);

                            if (gv_meta) WriteClassMeta(xWriter, element.Class);

                            xWriter.WriteEndElement(); // LAYERINFO
                        }
                    }
                    else if (element is IRasterLayer && ((IRasterLayer)element).RasterClass != null)
                    {
                        IRasterLayer rLayer = (IRasterLayer)element;
                        xWriter.WriteStartElement("LAYERINFO");
                        xWriter.WriteAttributeString("type", "image");
                        xWriter.WriteAttributeString("name", (name != "") ? name : rLayer.Title.Replace(".", "_"));
                        xWriter.WriteAttributeString("id", Layers.ID);
                        xWriter.WriteAttributeString("visible", rLayer.Visible.ToString().ToLower());

                        if (rLayer.MinimumScale > 1)
                            xWriter.WriteAttributeString("minscale", (rLayer.MinimumScale / dpm).ToString());
                        if (rLayer.MaximumScale > 1)
                            xWriter.WriteAttributeString("maxscale", (rLayer.MaximumScale / dpm).ToString());

                        //ITOCElement tocElement = map.TOC.GetTOCElement((ILayer)element);
                        //xWriter.WriteAttributeString("aliasname", Layers.Title);
                        if (String.IsNullOrEmpty(Layers.GroupName))
                            xWriter.WriteAttributeString("group", Layers.GroupName);

                        if (envelope && rLayer.RasterClass.Polygon != null)
                        {
                            IGeometry geom = GeometricTransformer.Transform2D(rLayer.RasterClass.Polygon.Envelope, rLayer.RasterClass.SpatialReference, map.Display.SpatialReference);
                            if (geom != null)
                            {
                                ENVELOPE(xWriter, geom.Envelope);
                            }
                        }

                        if (gv_meta) WriteClassMeta(xWriter, rLayer.Class);
                        xWriter.WriteEndElement(); // LAYERINFO
                    }
                    else if (element is IGroupLayer)
                    {
                        // brauch ma net. Macht nur Probleme wenn man die als Layer mitübernimmt...
                        // Gruppen können naml. gleich wie Layer heißen und schon krachts...
                        continue;
                    }
                    else  // Raster (und alles andere)
                    {
                        xWriter.WriteStartElement("LAYERINFO");
                        xWriter.WriteAttributeString("type", "image");
                        xWriter.WriteAttributeString("name", (name != "") ? name : element.Title.Replace(".", "_"));
                        xWriter.WriteAttributeString("id", Layers.ID);
                        xWriter.WriteAttributeString("visible", element.Visible.ToString().ToLower());

                        if (element.MinimumScale > 1)
                            xWriter.WriteAttributeString("minscale", (element.MinimumScale / dpm).ToString());
                        if (element.MaximumScale > 1)
                            xWriter.WriteAttributeString("maxscale", (element.MaximumScale / dpm).ToString());

                        if (String.IsNullOrEmpty(Layers.GroupName))
                            xWriter.WriteAttributeString("group", Layers.GroupName);

                        if (gv_meta) WriteClassMeta(xWriter, element.Class);

                        xWriter.WriteEndElement(); // LAYERINFO
                    }
                }
                xWriter.WriteEndElement();
                xWriter.WriteEndDocument();
                xWriter.Flush();

                ms.Position = 0;
                StreamReader sr = new StreamReader(ms);
                axl.Append(sr.ReadToEnd());
                sr.Close();
                ms.Close();
                xWriter.Close();

                return axl.ToString();
            }
        }

        private void WriteClassMeta(XmlWriter xWriter, IClass cls)
        {
            if (xWriter == null || cls == null) return;

            xWriter.WriteStartElement("gv_meta");
            xWriter.WriteStartElement("class");

            Type type = cls.GetType();
            xWriter.WriteAttributeString("type", type.FullName);
            foreach (Type iType in type.GetInterfaces())
            {
                xWriter.WriteStartElement("implements");
                xWriter.WriteAttributeString("type", iType.FullName);
                xWriter.WriteEndElement(); // implements
            }
            xWriter.WriteEndElement(); // class
            xWriter.WriteEndElement(); // gv_meta
        }

        private void WriteNetworkTracers(XmlWriter xWriter)
        {
            if (xWriter == null) return;

            PlugInManager pluginMan = new PlugInManager();
            xWriter.WriteStartElement("gv_network_tracers");

            foreach (XmlNode tracerNode in pluginMan.GetPluginNodes(gView.Framework.system.Plugins.Type.INetworkTracer))
            {
                INetworkTracer tracer = pluginMan.CreateInstance(tracerNode) as INetworkTracer;
                if (tracer == null)
                    continue;

                xWriter.WriteStartElement("gv_network_tracer");
                xWriter.WriteAttributeString("name", tracer.Name);
                xWriter.WriteAttributeString("guid", PlugInManager.PlugInID(tracer).ToString());
                xWriter.WriteEndElement(); // gv_network_tracer
            }

            xWriter.WriteEndElement(); // gv_network_tracers
        }

        public string Renderer(IFeatureLayer layer)
        {
            if (layer == null) return "";

            StringBuilder sb = new StringBuilder();
            string fRenderer = ObjectFromAXLFactory.ConvertToAXL(layer.FeatureRenderer);
            string lRenderer = ObjectFromAXLFactory.ConvertToAXL(layer.LabelRenderer);

            if (!lRenderer.Equals(String.Empty)) // LabelRenderer immer in GroupRenderer stecken, auch wenn fRenderer NULL ist!!!
            {                                    // So wirds vom WebGIS erwartet...
                sb.Append("<GROUPRENDERER>\n");
                sb.Append(fRenderer);
                sb.Append(lRenderer);
                sb.Append("</GROUPRENDERER>\n");
            }
            else if (!fRenderer.Equals(String.Empty))
            {
                sb.Append(fRenderer);
            }
            else if (layer.Class is ArcIMSThemeFeatureClass)
            {
                ArcIMSThemeFeatureClass c = layer.Class as ArcIMSThemeFeatureClass;
                if (c.OriginalRendererNode != null)
                    return c.OriginalRendererNode.OuterXml;
            }
            return sb.ToString();
        }

        public string IMAGE(string outputPath, string outputUrl, string Title, IEnvelope envelope)
        {
            StringBuilder axl = new StringBuilder();
            MemoryStream ms = new MemoryStream();
            XmlTextWriter xWriter = new XmlTextWriter(ms, Encoding.UTF8);

            xWriter.WriteStartDocument();
            xWriter.WriteStartElement(_rootElement);
            xWriter.WriteAttributeString("version", _version);

            xWriter.WriteStartElement("RESPONSE");
            xWriter.WriteStartElement("IMAGE");
            ENVELOPE(xWriter, envelope);
            xWriter.WriteStartElement("OUTPUT");
            xWriter.WriteAttributeString("file", outputPath + @"\" + Title);
            xWriter.WriteAttributeString("url", outputUrl + "/" + Title);
            xWriter.WriteEndElement();  // OUTPUT

            xWriter.WriteEndElement();
            xWriter.WriteEndDocument();
            xWriter.Flush();

            ms.Position = 0;
            StreamReader sr = new StreamReader(ms);
            axl.Append(sr.ReadToEnd());
            sr.Close();
            ms.Close();
            xWriter.Close();

            return axl.ToString();
        }

        public string LEGEND(string outputPath, string outputUrl, string Title, IEnvelope envelope)
        {
            StringBuilder axl = new StringBuilder();
            MemoryStream ms = new MemoryStream();
            XmlTextWriter xWriter = new XmlTextWriter(ms, Encoding.UTF8);

            xWriter.WriteStartDocument();
            xWriter.WriteStartElement(_rootElement);
            xWriter.WriteAttributeString("version", _version);

            xWriter.WriteStartElement("RESPONSE");
            xWriter.WriteStartElement("IMAGE");
            ENVELOPE(xWriter, envelope);
            xWriter.WriteStartElement("LEGEND");
            xWriter.WriteAttributeString("file", outputPath + @"\" + Title);
            xWriter.WriteAttributeString("url", outputUrl + "/" + Title);
            xWriter.WriteEndElement();  // OUTPUT

            xWriter.WriteEndElement();
            xWriter.WriteEndDocument();
            xWriter.Flush();

            ms.Position = 0;
            StreamReader sr = new StreamReader(ms);
            axl.Append(sr.ReadToEnd());
            sr.Close();
            ms.Close();
            xWriter.Close();

            return axl.ToString();
        }

        static public void ENVELOPE(XmlTextWriter xWriter, IEnvelope envelope)
        {
            ENVELOPE(xWriter, envelope, String.Empty);
        }
        static public void ENVELOPE(XmlTextWriter xWriter, IEnvelope envelope, string name)
        {
            if (xWriter == null || envelope == null) return;
            xWriter.WriteStartElement("ENVELOPE");
            xWriter.WriteAttributeString("minx", envelope.minx.ToString());
            xWriter.WriteAttributeString("miny", envelope.miny.ToString());
            xWriter.WriteAttributeString("maxx", envelope.maxx.ToString());
            xWriter.WriteAttributeString("maxy", envelope.maxy.ToString());
            if (name != String.Empty)
                xWriter.WriteAttributeString("name", name);
            xWriter.WriteEndElement();
        }

        public string ErrorMessage(string message)
        {
            StringBuilder axl = new StringBuilder();
            MemoryStream ms = new MemoryStream();
            XmlTextWriter xWriter = new XmlTextWriter(ms, Encoding.UTF8);

            xWriter.WriteStartDocument();
            xWriter.WriteStartElement(_rootElement);
            xWriter.WriteAttributeString("version", _version);

            xWriter.WriteStartElement("RESPONSE");
            xWriter.WriteStartElement("ERROR");
            xWriter.WriteRaw(message);
            xWriter.WriteEndElement(); // ERROR;
            xWriter.WriteEndDocument();
            xWriter.Flush();

            ms.Position = 0;
            StreamReader sr = new StreamReader(ms);
            axl.Append(sr.ReadToEnd());
            sr.Close();
            ms.Close();
            xWriter.Close();

            return axl.ToString();
        }
    }
}

redpajama_set_name: RedPajamaGithub


With advanced technologies and facilities, strict high-quality handle, reasonable rate, superior services and close co-operation with prospects, we are devoted to furnishing the best price for our customers for Truck Crane Dwg , Truck Crane Drawing , Truck Crane PDF , all of our products have been strictly inspected before shipment.
"Our well-equipped facilities and exceptional excellent control throughout all stages of manufacturing enables us to guarantee total buyer gratification for Truck Crane Dwg , Truck Crane Drawing , Truck Crane PDF , Since our establishment we keep on improving our products and customer service. We are able to provide you with a wide range of high quality hair products at competitive prices. Also we can produce different hair products according to your samples. We insist on high quality and reasonable price. Except this we provide best OEM service. We warmly welcome OEM orders and customers all over the world to cooperate with us for mutual development in the future.


My snoring solution Anti Snoring Nose Vents/Nasal dilators for breathing aid Sleep apnea/Snore remedies Aids set of 4 Packs for Men women and Kids Snorerx.
Snore Stopper Nose Vents – Snoring Remedies to Relief Nasal Passageways. Contain 4 Anti-Snoring Aids in 2 Different Sizes To Ease Breathing. Travel Case Included!


text:
Timolaus of Palmyra (Latin: Timolaus) was reportedly a 3rd century Palmyrene nobleman, son of the king of kings Odaenathus (r. 252-267) and augustus Zenobia (r. 267-272). Little is known about him, and all the existing information comes from speculation. Such is the doubt of his existence that some scholars try to associate him with Vaballathus (r. 267-272), another of the sons of Odaenathus and Zenobia. Some authors believe he is an individual made up by the Historia Augusta, the only historical source that cites him, and some speculate that he is in fact a historical figure. He appears only in 267, at the time of his father's assassination.

Family

Timolaus was the son of Odaenathus and his second wife Zenobia, grandson of Hairan I, great-grandson of Vaballathus, and great-great-grandson of Nasor. He was the half-brother of Hairan I, the fruit of Odaenathus' relationship with a previous wife. He also had two sisters, whose names are not known. It is known, however, that they married respectively the emperor Aurelian (r. 270-275) and a Roman senator. Timolaus was also the brother of Vaballathus, Hairan II, and Septimius Antiochus. The Historia Augusta (HA) cites him as having another brother, Herodian, whose existence is questioned. Some think Herodian was a variant of Hairan II's name.

Life
There are doubts as to the existence of Timolaus. Some authors suggest that he may be a fabrication, a de facto individual (whose name, recorded here in Latinized form, has the Palmyrene variant Taimallat), or a distortion of the name Vaballathus.

Nothing is known about his life, having been mentioned only in 267, in the context of the murder of Odaenathus and Hairan I. The versions of the events are many, but in one of them, presented by the Historia Augusta (which also cites two other versions), his murderer was Maeonius, a cousin or nephew of Odaenathus, having carried out the crime at the behest of Zenobia. According to the source, Zenobia resented that Hairan II (Herenian) and Timolaus were in a lower position than her godson and therefore orders Maeonius to kill them.

The Historia Augusta mentions that Zenobia assumed the throne on their behalf, dressed them in purple, as emperors, and led them in public meetings which she attended in the likeness of Dido, Semiramis, and Cleopatra. The HA itself indicates that how they died is uncertain and presents two versions: in the first, they were killed by Aurelian at the time of the conquest of the Palmyrene Empire (272); in the second, they died of natural causes, as there were still at the time the work was written (4th century), noble descendants of Zenobia in Rome.

The HA further asserts that such was Timolaus' eagerness for Roman studies that, in a short time, he allegedly fulfilled the declaration of his professor of languages, who said that he was indeed capable of making him the greatest of Latin rhetoricians.

References

Bibliography

Palmyrene Empire
Emesene dynasty
3rd-century Arabs

redpajama_set_name: RedPajamaWikipedia


text:
Home » Notable coach hits the small screen
Notable coach hits the small screen
Luther "Uncle Luke" Campbell is known as a lot of different things to a lot of different people.
As the notorious lead singer of 2 Live Crew, he earned the label as the leader of the most profane music group of all time.
The ESPN documentary "The U" hinted at Campbell's alleged financial incentives given to Hurricane football players during their heyday of the 1980s and early 1990s.
Campbell's star status even led him to campaign for mayor of Miami. But the award-winning HBO program "Real Sports" helps shed light on the modern-day Uncle Luke. That is, coach Luke.
Today, Campbell is a defensive coordinator at Miami Northwestern, one of the country's finest high school football programs – and also the alma mater of many Canes, past and present.
Miami Northwestern's football program has been an important recruiting pipeline for Miami, producing the likes of Melvin Bratton, Brett Perriman, Vernon Carey, Jacory Harris, Sean Spence, Tommy Streeter and Marcus Fortson, as well as with current Canes Ben Jones and Kendal Thompkins.
So how did Campbell make the jump from the rap limelight to the gridiron?
The Liberty City, Fla., native, who made millions for his rap exploits and pledged to reinvest his money back into his hometown, started a youth football league.
NFL and college stars, including Chad Ochocinco, played in the program with Campbell's Pop Warner teams winning numerous national championships.
When the call came for Campbell to join the coaching ranks, he jumped on the opportunity.
"I take the whole game of football, and translate it into life," Campbell said in the "Real Sports" segment.
But as the contemplative piece details, Campbell has faced difficulty outrunning his past.
Hurricanes and rap fans alike should make a point to check the story out.
The piece will replay on HBO at 10 a.m. Saturday, as well as 7 and 11 p.m. Tuesday. It is also available on HBO On Demand and hbogo.com.
Michael Perchick
Contributing Columnist
Speak Up: How do you get energized for the day?
Corporate America alters pastime

redpajama_set_name: RedPajamaCommonCrawl


Please note that the accuracy and completeness of the mine maps vary, depending on the availability and quality of source material. Little or no information is available for many older mines because mining activity was not regulated or documented until the late 1800's. Even then, reporting requirements were minimal. Also, early mine maps were often sketched by miners working in the mine at the time, or were constructed solely form memory. However, mine maps are a good source for determining if mines are present in the general area of your property.
Also, if you are purchasing a home or starting new construction, ask the seller or developer to disclose any information about underground mining or previous mine subsidence claims in the surrounding area. Ask neighbors and business owners if they are aware of a history of mine subsidence in the neighborhood. In some areas, the County Clerk's office or a zoning board may have information about past mine subsidence incidents.


Take a ride on a bullet train, return by plane.
Have a private guide for a more personalized experience.
Overnight stay in Mount Huangshan.
Check out the impressive pavilions and ponds of Yu Garden.
See buildings with European-style architecture along the Bund and in the French Concession.
Learn more about the history of Shanghai from your informative guide.
See the Terracotta Warriors in Xi'an.
Visit a quieter section of The Great Wall.
Cruise down the Yangtze River past the Three Gorges Dam.
Beijing's Forbidden City, Tiananmen Square and Temple of Heaven Park. .
Cycle amidst Yangshou's karst mountains and rice terraces .
Walking tour of Shanghai's famous Bund area.


Here is a fine, rich, mushroom soup either for grand occasions or as the main course for a Sunday supper.
Cook the onions slowly in the butter for 8 to 10 minutes, until they are tender but not browned.
Add the flour and stir over moderate heat for 3 minutes without browning.
Off heat, beat in the boiling stock or broth and blend it thoroughly with the flour. Season to taste. Stir in the mushroom stems, and simmer partially covered for 20 minutes or more, skimming occasionally. Strain, pressing juices out of mushroom stems. Return the soup to the pan.
Melt the butter in a separate saucepan. When it is foaming, toss in the mushrooms, salt, and lemon juice. Cover and cook slowly for 5 minutes.
(*) If not to be served immediately, set aside uncovered, and film surface with a spoonful of cream or milk. Reheat to simmer just before proceeding to the step below, which will take 2 or 3 minutes.
Off heat, stir in the butter by tablespoons. Pour the soup into a tureen or soup cups, and decorate with optional mushrooms and herbs.


They got to see demonstrations from Jump, Soaring, and Powered Flight.
Jump is the only program in the entire world where the first jump is an unassisted freefall. Because of this unique difference all students, cadet or staff who go through this program will have roughly 40 hours of ground training before their first jump.
The Cadets who complete the Soaring program and get their wings are the Air Force's youngest instructor pilots.
Powered Flight is a capstone course that serves as a culmination of a cadet's aviation education.
All of these programs are available to them as cadets and we will be covering your cadets in all of them starting next summer.
These basics approved of the morning! Because they all were intermixed we put them not only in the BCT2 all gallery but they are coded into each squadron gallery as well.
Side note: A big thank you to the family from North Carolina that sent us some treats from there!
We'll be back later this evening with additional coverage. Just a heads up we won't be able to get everyone again this afternoon.


"I enjoy listening to the boom box as it has a mixture of music."
"I enjoy dancing at dinnertime because I feel like I can break free and it is more FUN when everyone joins in!!"
"I really like the boom box as I enjoy dancing at lunchtime!"
"I enjoy scootering at lunchtime!"
"The music was great and I loved dancing to it!"
"I really liked the MUSIC!!!"
"I like lunchtimes as it gives us time to socialise with our friends."
"I really enjoy playing on the space hoppers because they are jumpy and fun!"
Well done to the children who got on the 'Golden Table'.


One of the main things I was looking forward to seeing in Barcelona was the Sagrada Familia building. We had booked tickets for our second day and I was so, so glad we had. When we got to the Basílica, there was a queue right around it, it's pretty much the longest queue I had ever seen. So we walked smugly past with our time allocated ticket to the main entrance and were let in straight away!
Climbing the steps, the first thing we did was take a step back and just look up at the amazing building, it has such an amazing structure and is currently under construction. I thought the building was being reconstructed but it actually has never been finished. It has taken over 132 years and it is still going, architects today follow Gaudi's plans and it is said it could finish in the first third of the century XXI! Looking up the towers themselves stand so tall and the design is breathtaking. Then looking closer at all the detail on the front, there really are no words, so I'll let the pictures do the talking.
From the outside to the inside. You you really have to go inside. To me it looked like a spaceship. It was so futuristic it's hard to understand this was his design from way back then. It is so tall and the columns have these pods on top of them with a name and artwork. Stained glass windows surround the church and are so intricate and colourful. The centre piece of the Jesus on the cross, is quite gothic looking I felt, sort of like something from a Baz Luhrmann's Romeo & Juliet, it was really beautiful.
We said goodbye to Sagrada Familia and we decided to take the Barcelona bus tour, the hop on, hop off bus is a great way to see the city. You can choose which route to take, either East or West and get on the relevant bus. It's €27 for one day and €35 for a two-day ticket each. We just did the one day and took the East tour which went past Park Guell, Port Vell, the Torre Agbar skyscraper and many others. The West side goes past things like the Camp Nou football stadium and meets up with the East bus at the Placa Catalunya, where you can catch the start of the tour. You can do both in one day, we just never had the time.
After a full sight-seeing we built up such an appetite. One place I'd spotted on the bus was Bacoa, a burger bar not far from our hotel. This was such a great burger bar and as soon as you go in you get a small pencil and menu card, it's a bit like going to Argos but I digress. You tick what you want from the menu then hand it to the guy at the till, pay and then take a seat.
You are given these….at first I had no idea, greeted with a bit of cardboard and a sticker, but alas it's a burger holder and my origami skills came into play!
Our food came pretty quickly and looked so good! I went for the chicken burger and fries and Danny had the teriyaki burger with potatoes, we shared a bottle of white wine which was only €10. The wine in Barcelona is so cheap in most of the restaurants and always tastes so good!
My burger was so good I could have had another. There is so much choice of burger, add extras or not, it's up to you! This place was such a good find I'd definitely go back here, much better than some of the very touristy restaurants at the Port.
It really is just the most amazing building isn't it? We climbed all the way up to the roof of the place a few years ago and I was astonished to see all that detail continues right up onto the top of the cathedral…even where you imagine not many people would ever see it. Gaudi was a true artist!
Oh wow how cool! I wish we had gone up the towers, but the tickets were sold out!


text:
Doug Allen Overview
Doug Allen was an actor who had a successful Hollywood career. Allen had an early acting career in film, appearing in such titles as the Meryl Streep dramatic adaptation "One True Thing" (1998) and the dramatic adaptation "Gangster No. 1" (2002) with Malcolm McDowell. He also was featured in the miniseries "Band of Brothers" (2001). He also landed a role...
Closed Circuit 2013
The Firm 2009
Gangster No. 1 2000
See Doug Allen's Full Filmography