示例#1
0
        public frmMap(IEnvelope envelope, Topology.CoordinateSystems.ICoordinateSystem coordSys, params IProvider[] layers) : this()
        {
            m_isLoading = true;
            m_layers    = new List <IProvider>(layers);
            m_env       = m_origEnv = envelope;
            m_coordSys  = null;

            if (coordSys != null)
            {
                try
                {
                    //This fails because the XY-M projection is not supported
                    m_coordSys = new LittleSharpRenderEngine.CoordinateSystem.ActualCoordinateSystem(coordSys);
                }
                catch { }
            }

            if (m_coordSys == null && coordSys != null)
            {
                Topology.CoordinateSystems.IUnit unit = coordSys.GetUnits(0);
                if (unit is Topology.CoordinateSystems.IAngularUnit)
                {
                    double radians = (unit as Topology.CoordinateSystems.IAngularUnit).RadiansPerUnit;
                    m_coordSys = new LittleSharpRenderEngine.CoordinateSystem.DegreeBasedCoordinateSystem();
                }
                else if (unit is Topology.CoordinateSystems.ILinearUnit)
                {
                    m_coordSys = new LittleSharpRenderEngine.CoordinateSystem.MeterBasedCoordsys(((Topology.CoordinateSystems.ILinearUnit)unit).MetersPerUnit, ((Topology.CoordinateSystems.ILinearUnit)unit).MetersPerUnit);
                }
            }


            if (m_coordSys == null)
            {
                m_coordSys = new LittleSharpRenderEngine.CoordinateSystem.MeterBasedCoordsys();
            }


            foreach (IProvider l in m_layers)
            {
                LayerListBox.Items.Add(l.DatasetName, CheckState.Checked);
            }

            m_isLoading = false;
        }
示例#2
0
        private void m_RenderMapGuideButton_Click(object sender, EventArgs e)
        {
            OSGeo.MapGuide.MaestroAPI.ServerConnectionI con = MapGuideProvider.MapGuideUtil.CreateConnection(
                MapGuideURL.Text,
                MapGuideUsername.Text,
                MapGuidePassword.Text);

            IEnvelope env = MapGuideProvider.MapGuideUtil.GetMapExtent(con, MapGuideResource.Text);

            Topology.CoordinateSystems.ICoordinateSystem coordSys = null;

            try
            {
                coordSys = MapGuideProvider.MapGuideUtil.GetCoordinateSystem(con, MapGuideResource.Text);
            }
            catch { }

            List <MapGuideProvider.MapGuideLayer> layers = new List <MapGuideProvider.MapGuideLayer>();

            foreach (string s in MapGuideProvider.MapGuideUtil.EnumerateLayers(con, MapGuideResource.Text, true))
            {
                try
                {
                    layers.Add(new MapGuideProvider.MapGuideLayer(con, s));
                }
                catch
                {
                    //Don't care about broken layers
                }
            }

            layers.Reverse();

            frmMap dlg = new frmMap(env, coordSys, layers.ToArray());

            dlg.ShowDialog();
        }
示例#3
0
        public ActualCoordinateSystem(Topology.CoordinateSystems.ICoordinateSystem coordinateSystem)
        {
            if (coordinateSystem == null)
            {
                throw new ArgumentNullException("coordinateSystem");
            }

            Topology.CoordinateSystems.Transformations.CoordinateTransformationFactory f = new Topology.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            Topology.CoordinateSystems.CoordinateSystemFactory cf = new Topology.CoordinateSystems.CoordinateSystemFactory();

            /*Topology.CoordinateSystems.ICoordinateSystem local = cf.CreateLocalCoordinateSystem(
             *  "Non-Earth (Meter)",
             *  cf.CreateLocalDatum("Local Datum", Topology.CoordinateSystems.DatumType.VD_Normal),
             *  new Topology.CoordinateSystems.LinearUnit(1.0, "Meter", "", 0, "", "", ""),
             *  new List<Topology.CoordinateSystems.AxisInfo>(new Topology.CoordinateSystems.AxisInfo[] {
             *      new Topology.CoordinateSystems.AxisInfo("X", Topology.CoordinateSystems.AxisOrientationEnum.East),
             *      new Topology.CoordinateSystems.AxisInfo("Y", Topology.CoordinateSystems.AxisOrientationEnum.North)
             *  })
             * );
             *
             * string s = cf.ToString();*/

            m_transform = f.CreateFromCoordinateSystems(coordinateSystem, cf.CreateFromWkt(XY_M));
        }
        public MapGuideLayer(ServerConnectionI con, string layername)
        {
            m_con = con;

            m_layerDef = m_con.GetLayerDefinition(layername);
            if (!(m_layerDef.Item is VectorLayerDefinitionType))
                throw new Exception("The resource " + layername + " is not a vector layer");

            VectorLayerDefinitionType vldef = m_layerDef.Item as VectorLayerDefinitionType;

            m_columnnames = new Dictionary<string, string>();

            m_columnnames[vldef.Geometry] = null;

            ExtractColumnNames(vldef.Url, m_columnnames);
            ExtractColumnNames(vldef.ToolTip, m_columnnames);

            try
            {
                FeatureSource fs = m_con.GetFeatureSource(vldef.ResourceId);
                FdoSpatialContextList lst = fs.GetSpatialInfo();
                if (lst != null && lst.SpatialContext != null && lst.SpatialContext.Count > 0)
                {
                    Topology.CoordinateSystems.CoordinateSystemFactory cf = new Topology.CoordinateSystems.CoordinateSystemFactory();
                    m_coordSys = cf.CreateFromWkt(lst.SpatialContext[0].CoordinateSystemWkt);
                }
            }
            catch
            {
            }

            foreach (VectorScaleRangeType vsr in vldef.VectorScaleRange)
            {
                ScaleRange sr = new ScaleRange(vsr.MinScaleSpecified ? vsr.MinScale : 0, vsr.MaxScaleSpecified ? vsr.MaxScale : double.MaxValue);

                foreach (object style in vsr.Items)
                    if (style is PointTypeStyleType)
                    {
                        if (((PointTypeStyleType)style).PointRule != null)
                            foreach (PointRuleType rule in ((PointTypeStyleType)style).PointRule)
                            {
                                if (rule.Item != null && rule.Item.Item != null)
                                {
                                    OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames);
                                    if (rule.Label != null)
                                        ExtractColumnNames(rule.Label.Text, m_columnnames);

                                    LittleSharpRenderEngine.Style.Point p = new LittleSharpRenderEngine.Style.Point();
                                    p.Center = new System.Drawing.Point(
                                        (int)(rule.Item.Item.InsertionPointXSpecified ? rule.Item.Item.InsertionPointX : 0.5),
                                        (int)(rule.Item.Item.InsertionPointYSpecified ? rule.Item.Item.InsertionPointY : 0.5));

                                    p.Rotation = double.Parse(rule.Item.Item.Rotation, System.Globalization.CultureInfo.InvariantCulture);
                                    p.Size = new System.Drawing.Size(
                                        (int)double.Parse(rule.Item.Item.SizeX, System.Globalization.CultureInfo.InvariantCulture),
                                        (int)double.Parse(rule.Item.Item.SizeY, System.Globalization.CultureInfo.InvariantCulture));

                                    if (rule.Item.Item is MarkSymbolType)
                                    {
                                        MarkSymbolType mark = rule.Item.Item as MarkSymbolType;
                                        switch (mark.Shape)
                                        {
                                            case ShapeType.Circle:
                                                p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle;
                                                break;
                                            case ShapeType.Square:
                                                p.Type = LittleSharpRenderEngine.Style.Point.PointType.Square;
                                                break;
                                            case ShapeType.Triangle:
                                                p.Type = LittleSharpRenderEngine.Style.Point.PointType.Triangle;
                                                break;
                                            default:
                                                p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle;
                                                break;
                                        }

                                        if (mark.Fill != null)
                                        {
                                            p.Fill = new LittleSharpRenderEngine.Style.Base.Fill();
                                            p.Fill.BackgroundColor = mark.Fill.BackgroundColor;
                                            p.Fill.ForegroundColor = mark.Fill.ForegroundColor;
                                            //p.Fill.Pattern = mark.Fill.FillPattern;
                                            //TODO: Deal with unit/sizecontext
                                        }

                                        if (mark.Edge != null)
                                        {
                                            p.Outline = new LittleSharpRenderEngine.Style.Base.Outline();
                                            p.Outline.ForegroundColor = mark.Edge.Color;
                                            //p.Outline.DashStyle = mark.Edge.LineStyle;
                                            //p.Outline.Pattern = mark.Edge.LineStyle;
                                            p.Outline.Width = (int)double.Parse(mark.Edge.Thickness, System.Globalization.CultureInfo.InvariantCulture);
                                            //TODO: Deal with unit/sizecontext
                                        }
                                    }
                                    else
                                    {
                                        p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle;
                                        p.Outline = new LittleSharpRenderEngine.Style.Base.Outline();
                                        p.Fill = new LittleSharpRenderEngine.Style.Base.Fill();
                                        p.Fill.BackgroundColor = System.Drawing.Color.Red;
                                        p.Fill.ForegroundColor = System.Drawing.Color.Black;

                                        p.Outline.ForegroundColor = System.Drawing.Color.Black;
                                    }

                                    sr.PointRules.Add(new KeyValuePair<OperationOrParameter, IPointStyle>(op, p));
                                }
                            }
                    }
                    else if (style is LineTypeStyleType)
                    {
                        if (((LineTypeStyleType)style).LineRule != null)
                            foreach (LineRuleType rule in ((LineTypeStyleType)style).LineRule)
                            {
                                if (rule.Items != null && rule.Items.Count > 0)
                                {
                                    List<IOutline> lines = new List<IOutline>();
                                    OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames);
                                    if (rule.Label != null)
                                        ExtractColumnNames(rule.Label.Text, m_columnnames);

                                    foreach (StrokeType st in rule.Items)
                                    {
                                        LittleSharpRenderEngine.Style.Base.Outline outline = new LittleSharpRenderEngine.Style.Base.Outline();
                                        outline.ForegroundColor = st.Color;
                                        outline.Width = (int)double.Parse(st.Thickness, System.Globalization.CultureInfo.InvariantCulture);
                                        //outline.Pattern = st.LineStyle;
                                        //outline.DashStyle = st.LineStyle;
                                        //TODO: Deal with unit/sizecontext

                                        lines.Add(outline);
                                    }

                                    sr.LineRules.Add(new KeyValuePair<OperationOrParameter, ILineStyle>(op, new LittleSharpRenderEngine.Style.Line(lines)));
                                }

                            }
                    }
                    else if (style is AreaTypeStyleType)
                    {
                        if (((AreaTypeStyleType)style).AreaRule != null)
                            foreach (AreaRuleType rule in ((AreaTypeStyleType)style).AreaRule)
                            {
                                OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames);
                                if (rule.Label != null)
                                    ExtractColumnNames(rule.Label.Text, m_columnnames);

                                LittleSharpRenderEngine.Style.Area a = new Area();
                                if (rule.Item != null)
                                {
                                    if (rule.Item.Fill != null)
                                    {
                                        a.Fill = new LittleSharpRenderEngine.Style.Base.Fill();
                                        a.Fill.BackgroundColor = rule.Item.Fill.BackgroundColor;
                                        a.Fill.ForegroundColor = rule.Item.Fill.ForegroundColor;
                                        //p.Fill.Pattern = rule.Item.Fill.FillPattern;
                                        //TODO: Deal with unit/sizecontext
                                    }

                                    if (rule.Item.Stroke != null)
                                    {
                                        a.Outline = new LittleSharpRenderEngine.Style.Base.Outline();
                                        a.Outline.ForegroundColor = rule.Item.Stroke.Color;
                                        //p.Outline.DashStyle = rule.Item.Stroke.LineStyle;
                                        //p.Outline.Pattern = rule.Item.Stroke.LineStyle;
                                        a.Outline.Width = (int)double.Parse(rule.Item.Stroke.Thickness, System.Globalization.CultureInfo.InvariantCulture);
                                        //TODO: Deal with unit/sizecontext
                                    }

                                    sr.AreaRules.Add(new KeyValuePair<OperationOrParameter, IAreaStyle>(op, a));
                                }
                            }
                    }

                if (sr.PointRules.Count + sr.LineRules.Count + sr.AreaRules.Count > 0)
                    m_scaleRanges.Add(sr);
            }
        }
示例#5
0
        public MapGuideLayer(ServerConnectionI con, string layername)
        {
            m_con = con;

            m_layerDef = m_con.GetLayerDefinition(layername);
            if (!(m_layerDef.Item is VectorLayerDefinitionType))
            {
                throw new Exception("The resource " + layername + " is not a vector layer");
            }

            VectorLayerDefinitionType vldef = m_layerDef.Item as VectorLayerDefinitionType;

            m_columnnames = new Dictionary <string, string>();

            m_columnnames[vldef.Geometry] = null;

            ExtractColumnNames(vldef.Url, m_columnnames);
            ExtractColumnNames(vldef.ToolTip, m_columnnames);

            try
            {
                FeatureSource         fs  = m_con.GetFeatureSource(vldef.ResourceId);
                FdoSpatialContextList lst = fs.GetSpatialInfo();
                if (lst != null && lst.SpatialContext != null && lst.SpatialContext.Count > 0)
                {
                    Topology.CoordinateSystems.CoordinateSystemFactory cf = new Topology.CoordinateSystems.CoordinateSystemFactory();
                    m_coordSys = cf.CreateFromWkt(lst.SpatialContext[0].CoordinateSystemWkt);
                }
            }
            catch
            {
            }

            foreach (VectorScaleRangeType vsr in vldef.VectorScaleRange)
            {
                ScaleRange sr = new ScaleRange(vsr.MinScaleSpecified ? vsr.MinScale : 0, vsr.MaxScaleSpecified ? vsr.MaxScale : double.MaxValue);

                foreach (object style in vsr.Items)
                {
                    if (style is PointTypeStyleType)
                    {
                        if (((PointTypeStyleType)style).PointRule != null)
                        {
                            foreach (PointRuleType rule in ((PointTypeStyleType)style).PointRule)
                            {
                                if (rule.Item != null && rule.Item.Item != null)
                                {
                                    OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames);
                                    if (rule.Label != null)
                                    {
                                        ExtractColumnNames(rule.Label.Text, m_columnnames);
                                    }

                                    LittleSharpRenderEngine.Style.Point p = new LittleSharpRenderEngine.Style.Point();
                                    p.Center = new System.Drawing.Point(
                                        (int)(rule.Item.Item.InsertionPointXSpecified ? rule.Item.Item.InsertionPointX : 0.5),
                                        (int)(rule.Item.Item.InsertionPointYSpecified ? rule.Item.Item.InsertionPointY : 0.5));

                                    p.Rotation = double.Parse(rule.Item.Item.Rotation, System.Globalization.CultureInfo.InvariantCulture);
                                    p.Size     = new System.Drawing.Size(
                                        (int)double.Parse(rule.Item.Item.SizeX, System.Globalization.CultureInfo.InvariantCulture),
                                        (int)double.Parse(rule.Item.Item.SizeY, System.Globalization.CultureInfo.InvariantCulture));

                                    if (rule.Item.Item is MarkSymbolType)
                                    {
                                        MarkSymbolType mark = rule.Item.Item as MarkSymbolType;
                                        switch (mark.Shape)
                                        {
                                        case ShapeType.Circle:
                                            p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle;
                                            break;

                                        case ShapeType.Square:
                                            p.Type = LittleSharpRenderEngine.Style.Point.PointType.Square;
                                            break;

                                        case ShapeType.Triangle:
                                            p.Type = LittleSharpRenderEngine.Style.Point.PointType.Triangle;
                                            break;

                                        default:
                                            p.Type = LittleSharpRenderEngine.Style.Point.PointType.Circle;
                                            break;
                                        }

                                        if (mark.Fill != null)
                                        {
                                            p.Fill = new LittleSharpRenderEngine.Style.Base.Fill();
                                            p.Fill.BackgroundColor = mark.Fill.BackgroundColor;
                                            p.Fill.ForegroundColor = mark.Fill.ForegroundColor;
                                            //p.Fill.Pattern = mark.Fill.FillPattern;
                                            //TODO: Deal with unit/sizecontext
                                        }

                                        if (mark.Edge != null)
                                        {
                                            p.Outline = new LittleSharpRenderEngine.Style.Base.Outline();
                                            p.Outline.ForegroundColor = mark.Edge.Color;
                                            //p.Outline.DashStyle = mark.Edge.LineStyle;
                                            //p.Outline.Pattern = mark.Edge.LineStyle;
                                            p.Outline.Width = (int)double.Parse(mark.Edge.Thickness, System.Globalization.CultureInfo.InvariantCulture);
                                            //TODO: Deal with unit/sizecontext
                                        }
                                    }
                                    else
                                    {
                                        p.Type    = LittleSharpRenderEngine.Style.Point.PointType.Circle;
                                        p.Outline = new LittleSharpRenderEngine.Style.Base.Outline();
                                        p.Fill    = new LittleSharpRenderEngine.Style.Base.Fill();
                                        p.Fill.BackgroundColor = System.Drawing.Color.Red;
                                        p.Fill.ForegroundColor = System.Drawing.Color.Black;

                                        p.Outline.ForegroundColor = System.Drawing.Color.Black;
                                    }

                                    sr.PointRules.Add(new KeyValuePair <OperationOrParameter, IPointStyle>(op, p));
                                }
                            }
                        }
                    }
                    else if (style is LineTypeStyleType)
                    {
                        if (((LineTypeStyleType)style).LineRule != null)
                        {
                            foreach (LineRuleType rule in ((LineTypeStyleType)style).LineRule)
                            {
                                if (rule.Items != null && rule.Items.Count > 0)
                                {
                                    List <IOutline>      lines = new List <IOutline>();
                                    OperationOrParameter op    = ExtractColumnNames(rule.Filter, m_columnnames);
                                    if (rule.Label != null)
                                    {
                                        ExtractColumnNames(rule.Label.Text, m_columnnames);
                                    }

                                    foreach (StrokeType st in rule.Items)
                                    {
                                        LittleSharpRenderEngine.Style.Base.Outline outline = new LittleSharpRenderEngine.Style.Base.Outline();
                                        outline.ForegroundColor = st.Color;
                                        outline.Width           = (int)double.Parse(st.Thickness, System.Globalization.CultureInfo.InvariantCulture);
                                        //outline.Pattern = st.LineStyle;
                                        //outline.DashStyle = st.LineStyle;
                                        //TODO: Deal with unit/sizecontext

                                        lines.Add(outline);
                                    }

                                    sr.LineRules.Add(new KeyValuePair <OperationOrParameter, ILineStyle>(op, new LittleSharpRenderEngine.Style.Line(lines)));
                                }
                            }
                        }
                    }
                    else if (style is AreaTypeStyleType)
                    {
                        if (((AreaTypeStyleType)style).AreaRule != null)
                        {
                            foreach (AreaRuleType rule in ((AreaTypeStyleType)style).AreaRule)
                            {
                                OperationOrParameter op = ExtractColumnNames(rule.Filter, m_columnnames);
                                if (rule.Label != null)
                                {
                                    ExtractColumnNames(rule.Label.Text, m_columnnames);
                                }

                                LittleSharpRenderEngine.Style.Area a = new Area();
                                if (rule.Item != null)
                                {
                                    if (rule.Item.Fill != null)
                                    {
                                        a.Fill = new LittleSharpRenderEngine.Style.Base.Fill();
                                        a.Fill.BackgroundColor = rule.Item.Fill.BackgroundColor;
                                        a.Fill.ForegroundColor = rule.Item.Fill.ForegroundColor;
                                        //p.Fill.Pattern = rule.Item.Fill.FillPattern;
                                        //TODO: Deal with unit/sizecontext
                                    }

                                    if (rule.Item.Stroke != null)
                                    {
                                        a.Outline = new LittleSharpRenderEngine.Style.Base.Outline();
                                        a.Outline.ForegroundColor = rule.Item.Stroke.Color;
                                        //p.Outline.DashStyle = rule.Item.Stroke.LineStyle;
                                        //p.Outline.Pattern = rule.Item.Stroke.LineStyle;
                                        a.Outline.Width = (int)double.Parse(rule.Item.Stroke.Thickness, System.Globalization.CultureInfo.InvariantCulture);
                                        //TODO: Deal with unit/sizecontext
                                    }

                                    sr.AreaRules.Add(new KeyValuePair <OperationOrParameter, IAreaStyle>(op, a));
                                }
                            }
                        }
                    }
                }

                if (sr.PointRules.Count + sr.LineRules.Count + sr.AreaRules.Count > 0)
                {
                    m_scaleRanges.Add(sr);
                }
            }
        }