当前位置: 首页>>代码示例>>C#>>正文


C# MgResourceIdentifier.ToString方法代码示例

本文整理汇总了C#中MgResourceIdentifier.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MgResourceIdentifier.ToString方法的具体用法?C# MgResourceIdentifier.ToString怎么用?C# MgResourceIdentifier.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MgResourceIdentifier的用法示例。


在下文中一共展示了MgResourceIdentifier.ToString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateBufferLayer

        public MgdLayer CreateBufferLayer(MgResourceService resourceService, MgResourceIdentifier bufferFeatureResId, String sessionId)
        {
            // Load the layer definition template into
            // a XmlDocument object, find the "ResourceId" element, and
            // modify its content to reference the temporary
            // feature source.

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(Layers.BufferLayerDefinition);
            XmlNode featureSourceNode = doc.GetElementsByTagName("ResourceId")[0];
            featureSourceNode.InnerText = bufferFeatureResId.ToString();

            // Get the updated layer definition from the XmlDocument
            // and save it to the session repository using the
            // ResourceService object.

            MgByteSource byteSource = null;
            using (MemoryStream ms = new MemoryStream())
            {
                doc.Save(ms);
                ms.Position = 0L;

                //Note we do this to ensure our XML content is free of any BOM characters
                byte[] layerDefinition = ms.ToArray();
                Encoding utf8 = Encoding.UTF8;
                String layerDefStr = new String(utf8.GetChars(layerDefinition));
                layerDefinition = new byte[layerDefStr.Length - 1];
                int byteCount = utf8.GetBytes(layerDefStr, 1, layerDefStr.Length - 1, layerDefinition, 0);

                byteSource = new MgByteSource(layerDefinition, layerDefinition.Length);
                byteSource.SetMimeType(MgMimeType.Xml);
            }

            MgResourceIdentifier tempLayerResId = new MgResourceIdentifier("Session:" + sessionId + "//Buffer.LayerDefinition");

            resourceService.SetResource(tempLayerResId, byteSource.GetReader(), null);

            // Create an MgLayer object based on the new layer definition
            // and return it to the caller.

            MgdLayer bufferLayer = new MgdLayer(tempLayerResId, resourceService);
            bufferLayer.SetName("Buffer");
            bufferLayer.SetLegendLabel("Buffer");
            bufferLayer.SetDisplayInLegend(true);
            bufferLayer.SetSelectable(false);

            return bufferLayer;
        }
开发者ID:kanbang,项目名称:Colt,代码行数:48,代码来源:BufferHelper.cs

示例2: ShowSpatialFilter

    public bool ShowSpatialFilter()
    {
        bool result = true;
        MgUserInformation userInfo = new MgUserInformation(Request["SESSION"]);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);

        MgResourceIdentifier sdfResId = new MgResourceIdentifier("Session:" + Request["SESSION"] + "//Filter.FeatureSource");

        MgResourceService resourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService;
        MgFeatureService featureService = siteConnection.CreateService(MgServiceType.FeatureService) as MgFeatureService;

        MgFeatureCommandCollection updateCommands = new MgFeatureCommandCollection();

        MgMap map = new MgMap();
        map.Open(resourceService, Request["MAPNAME"]);

        MgLayer layer = null;
        MgLayerCollection layers = map.GetLayers();
        if (layers.Contains("_QuerySpatialFilter"))
        {
            layer = (MgLayer)layers.GetItem("_QuerySpatialFilter");
            //updateCommands.Add(new MgDeleteFeatures("Filter", "ID > 0"));
        }
        else
        {
            // Create the Feature Source (SDF)

            MgFeatureSchema sdfSchema = this.CreateFilterSchema();
            MgCreateSdfParams sdfParams = new MgCreateSdfParams("MAPCS", map.GetMapSRS(), sdfSchema);
            featureService.CreateFeatureSource(sdfResId, sdfParams);

            // Create the Layer

            MgResourceIdentifier layerResId = new MgResourceIdentifier("Session:" + Request["SESSION"] + "//Filter.LayerDefinition");
            String layerDefinition = File.ReadAllText(GetQueryXmlTemplatePath());
            layerDefinition = layerDefinition.Replace("%s", sdfResId.ToString());

            MgByteReader reader = new MgByteReader(layerDefinition, "text/xml");
            resourceService.SetResource(layerResId, reader, null);

            layer = new MgLayer(layerResId, resourceService);

            layer.SetName("_QuerySpatialFilter");
            layer.SetLegendLabel("תחום זמני");
            layer.SetDisplayInLegend(true);
            layer.SetSelectable(true);
            layer.ForceRefresh();
            layer.NeedsRefresh();

            layers.Insert(0, layer);
        }

        // Make the layer visible

        layer.SetVisible(true);
        map.Save(resourceService);

        // Add the geometry to the filter feature source
        MgPolygon polygon = this.CreatePolygonFromGeomText(Request["GEOMTEXT"].ToString());
        MgAgfReaderWriter agfWriter = new MgAgfReaderWriter();
        MgByteReader byteReader = agfWriter.Write(polygon);

        MgPropertyCollection propertyValues = new MgPropertyCollection();
        propertyValues.Add(new MgGeometryProperty("Geometry", byteReader));
        try
        {
            updateCommands.Add(new MgInsertFeatures("Filter", propertyValues));

            featureService.UpdateFeatures(sdfResId, updateCommands, false);
        }
        catch { }

        return result;
    }
开发者ID:ranyaof,项目名称:Meuhedet,代码行数:75,代码来源:CreateGeometry.aspx.cs

示例3: GetAvailableMarkup

        public Hashtable GetAvailableMarkup()
        {
            Hashtable markup = new Hashtable();

            MgResourceService resourceService = (MgResourceService)this.site.CreateService(MgServiceType.ResourceService);
            MgResourceIdentifier resourceID = new MgResourceIdentifier(libraryPath);

            try
            {
                MgByteReader byteReader = resourceService.EnumerateResources(resourceID, 1, "LayerDefinition");
                String resourceListXML = byteReader.ToString();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(resourceListXML);
                XmlNodeList nodeList = doc.GetElementsByTagName("ResourceId");

                foreach (XmlElement element in nodeList)
                {
                    MgResourceIdentifier resourceId = new MgResourceIdentifier(element.InnerText);
                    markup[resourceId.ToString()] = resourceId.GetName();
                }
            }
            catch (MgResourceNotFoundException mge)
            {
                // If the Library://Markup folder does not exist, create it.
                resourceService.SetResource(resourceID, null, null);
            }

            return markup;
        }
开发者ID:ranyaof,项目名称:Meuhedet,代码行数:30,代码来源:MarkupManager.cs

示例4: CreateMarkup

        public void CreateMarkup(string mgSessionId,string  mgMap)
        {
            //Response.Write("CreateMarkup" );
            MgUserInformation userInfo = new MgUserInformation(mgSessionId);
            MgSiteConnection siteConnection = new MgSiteConnection();
            siteConnection.Open(userInfo);

            MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
            MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);

            MgMap map = new MgMap();
            map.Open(resourceService, mgMap);
            //    map.Open(resourceService, GetParameter(args, "MAPNAME"));

            // Create the Markup Feature Source (SDF)

            MgResourceIdentifier markupSdfResId = new MgResourceIdentifier(libraryPath + GetParameter(this.args, "MARKUPNAME") + ".FeatureSource");

            MgFeatureSchema markupSchema = MarkupSchemaFactory.CreateMarkupSchema();
            MgCreateSdfParams sdfParams = new MgCreateSdfParams("XY-M", map.MapSRS, markupSchema);
            featureService.CreateFeatureSource(markupSdfResId, sdfParams);

            String url = "concat('" + GetParameter(this.args, "MARKUPURL") + "', concat('?key=', "ID"))";
            //Link to ProjectManager
              /*  if (GetParameter(this.args, "LINKTOPROJECTMANAGER").ToLower() == "on"
                && !String.IsNullOrEmpty(GetParameter(this.args, "ProjectCollectionName"))
                && GetParameter(this.args, "ProjectCollectionName") != "áçø îøùéîä")
            {
                string projectCollectionName = GetParameter(this.args, "ProjectCollectionName");
                if (projectCollectionName == "àçø...")
                {
                    projectCollectionName = GetParameter(this.args, "ProjectCollectionOtherName");
                }
                int projectId = 0;
                using (var conn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["ProjectManagerConnectionString"].ConnectionString))
                {
                    var cmd = conn.CreateCommand();
                    cmd.CommandText = "INSERT INTO ProjectCollections(LayoutId, FeatureId, ProjectCollectionName) VALUES(@LayoutId, @FeatureId, @ProjectCollectionName); SELECT @@IDENTITY AS [NEWID]";
                    cmd.CommandType = System.Data.CommandType.Text;

                    var layoutIdParam = new System.Data.SqlClient.SqlParameter("@LayoutId", System.Data.SqlDbType.NVarChar, 255);
                    layoutIdParam.Value = GetParameter(args, "LAYOUT");
                    cmd.Parameters.Add(layoutIdParam);

                    var featureIdParam = new System.Data.SqlClient.SqlParameter("@FeatureId", System.Data.SqlDbType.NVarChar, 255);
                    featureIdParam.Value = markupSdfResId.ToString();
                    cmd.Parameters.Add(featureIdParam);

                    var pcNameParam = new System.Data.SqlClient.SqlParameter("@ProjectCollectionName", System.Data.SqlDbType.NVarChar, 50);
                    pcNameParam.Value = projectCollectionName;
                    cmd.Parameters.Add(pcNameParam);

                    conn.Open();
                    //projectId = (int)cmd.ExecuteScalar();
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            projectId = Convert.ToInt32(reader[0]);
                        }
                    }
                }
                string host = HttpContext.Current.Request.Url.Host;
                url = String.Format("concat('http://{0}/MgExtensions/ProjectManager/default.aspx?ProjectId={1}&UID=', \"UID\")", host, projectId);
            }
            */
            // Create the Markup Layer Definition

            String hexFgTransparency = String.Format("{0:X2}", 255 * (100 - Int32.Parse(GetParameter(this.args, "FILLTRANSPARENCY"))) / 100); // Convert % to an alpha value
            String hexBgTransparency = GetParameter(this.args, "FILLBACKTRANS").Length > 0 ? "FF" : "00";							 // All or nothing
            String bold = GetParameter(this.args, "LABELBOLD").Length > 0 ? "true" : "false";
            String italic = GetParameter(this.args, "LABELITALIC").Length > 0 ? "true" : "false";
            String underline = GetParameter(this.args, "LABELUNDERLINE").Length > 0 ? "true" : "false";

            String markupLayerDefinition = File.ReadAllText(HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"] + "Extensions\\markup\\templates\\markuplayerdefinition.xml");
            markupLayerDefinition = String.Format(markupLayerDefinition,
                markupSdfResId.ToString(),						                //<ResourceId> - Feature Source
                GetParameter(this.args, "LABELSIZEUNITS"),						//<Unit> - Mark Label
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeX> - Mark Label Size
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeY> - Mark Label Size
                "FF" + GetParameter(this.args, "LABELFORECOLOR"),				//<ForegroundColor> - Mark Label
                "FF" + GetParameter(this.args, "LABELBACKCOLOR"),				//<BackgroundColor> - Mark Label
                GetParameter(this.args, "LABELBACKSTYLE"),						//<BackgroundStyle> - Mark Label
                bold,												            //<Bold> - Mark Label
                italic,											                //<Bold> - Mark Label
                underline,											            //<Underlined> - Mark Label
                GetParameter(this.args, "MARKERSIZEUNITS"),						//<Unit> - Mark
                GetParameter(this.args, "MARKERSIZE"),							//<SizeX> - Mark
                GetParameter(this.args, "MARKERSIZE"),							//<SizeY> - Mark
                GetParameter(this.args, "MARKERTYPE"),							//<Shape> - Mark
                "FF" + GetParameter(this.args, "MARKERCOLOR"),					//<ForegroundColor> - Mark
                "FF" + GetParameter(this.args, "MARKERCOLOR"),					//<Color> - Mark
                GetParameter(this.args, "LABELSIZEUNITS"),						//<Unit> - Line Label
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeX> - Line Label Size
                GetParameter(this.args, "LABELFONTSIZE"),						//<SizeY> - Line Label Size
                "FF" + GetParameter(this.args, "LABELFORECOLOR"),				//<ForegroundColor> - Line Label
                "FF" + GetParameter(this.args, "LABELBACKCOLOR"),				//<BackgroundColor> - Line Label
                GetParameter(this.args, "LABELBACKSTYLE"),						//<BackgroundStyle> - Line Label
                bold,												            //<Bold> - Line Label
                italic,											                //<Bold> - Line Label
//.........这里部分代码省略.........
开发者ID:ranyaof,项目名称:Meuhedet,代码行数:101,代码来源:MarkupManager.cs

示例5: btnCreate_Click

        private void btnCreate_Click(object sender, EventArgs e)
        {
            btnCreate.Enabled = false;
            try
            {
                var layerName = txtBufferLayer.Text.Trim();
                if (string.IsNullOrEmpty(layerName))
                {
                    MessageBox.Show(Strings.MsgEnterNameForLayer);
                    return;
                }

                if (lstLayers.SelectedItems.Count == 0)
                {
                    MessageBox.Show(Strings.MsgIncludeLayersToBuffer);
                    return;
                }

                var map = _viewer.GetMap();
                var layers = map.GetLayers();
                var provider = _viewer.GetProvider();

                //From here, it's the same logic as buffer.aspx in .net MapGuide AJAX viewer
                MgResourceIdentifier fsId = new MgResourceIdentifier("Session:" + _sessionId + "//" + txtBufferLayer.Text + "_Buffer.FeatureSource"); //NOXLATE
                MgResourceIdentifier ldfId = new MgResourceIdentifier("Session:" + _sessionId + "//" + txtBufferLayer.Text + "_Buffer.LayerDefinition"); //NOXLATE

                MgLayerBase layer = Util.FindLayer(layers, txtBufferLayer.Text);
                string[] layerNames = GetLayerNames();

                double distance = Convert.ToDouble(numBufferDistance.Value);
                MeasurementUnit bUnits = (MeasurementUnit)cmbUnits.SelectedItem;
                switch (bUnits)
                {
                    case MeasurementUnit.Feet:
                        distance *= 0.30480;
                        break;
                    case MeasurementUnit.Kilometers:
                        distance *= 1000;
                        break;
                    case MeasurementUnit.Miles:
                        distance *= 1609.35;
                        break;
                }

                String srsDefMap = Util.GetMapSrs(map);
                MgCoordinateSystem srsMap = provider.GetMapCoordinateSystem();
                string mapSrsUnits = "";
                bool arbitraryMapSrs = (srsMap.GetType() == MgCoordinateSystemType.Arbitrary);
                if (arbitraryMapSrs)
                    mapSrsUnits = srsMap.GetUnits();

                String xtrans = String.Format("{0:x2}", ((int)(255 * Convert.ToInt32(numFillTransparency.Value) / 100))); //NOXLATE
                var lineColor = Util.ToHtmlColor(pnlBorderColor.BackColor);
                var foreColor = Util.ToHtmlColor(pnlFillColor.BackColor);
                var backColor = Util.ToHtmlColor(pnlFillBackColor.BackColor);
                String layerTempl = string.Format(Properties.Resources.AreaLayerDef,
                        fsId.ToString(),
                        "BufferSchema:Buffer", //NOXLATE
                        "GEOM", //NOXLATE
                        cmbFillPattern.SelectedItem,
                        xtrans + foreColor,
                        ((0 != 1/*transparent*/) ? "ff" : "00") + backColor, //NOXLATE
                        cmbBorderPattern.SelectedItem,
                        numLineThickness.Value.ToString(NumberFormatInfo.InvariantInfo),
                        lineColor
                );
                byte[] bytes = Encoding.UTF8.GetBytes(layerTempl);
                MgByteSource src = new MgByteSource(bytes, bytes.Length);
                MgByteReader layerDefContent = src.GetReader();
                _resSvc.SetResource(ldfId, layerDefContent, null);

                bool newBuffer = false;
                if (layer == null)
                {
                    newBuffer = true;

                    //Targetting a new layer. create a data source for it
                    //
                    MgClassDefinition classDef = new MgClassDefinition();

                    classDef.SetName("Buffer"); //NOXLATE
                    classDef.SetDescription("Feature class for buffer layer"); //NOXLATE
                    classDef.SetDefaultGeometryPropertyName("GEOM"); //NOXLATE

                    //Set KEY property
                    MgDataPropertyDefinition prop = new MgDataPropertyDefinition("KEY"); //NOXLATE
                    prop.SetDataType(MgPropertyType.Int32);
                    prop.SetAutoGeneration(true);
                    prop.SetReadOnly(true);
                    classDef.GetIdentityProperties().Add(prop);
                    classDef.GetProperties().Add(prop);

                    //Set ID property. Hold this segment ID
                    prop = new MgDataPropertyDefinition("ID"); //NOXLATE
                    prop.SetDataType(MgPropertyType.Int32);
                    classDef.GetProperties().Add(prop);

                    //Set geometry property
                    MgGeometricPropertyDefinition geomProp = new MgGeometricPropertyDefinition("GEOM"); //NOXLATE
                    //prop.SetGeometryTypes(MgFeatureGeometricType.mfgtSurface); //TODO use the constant when exposed
//.........这里部分代码省略.........
开发者ID:kanbang,项目名称:Colt,代码行数:101,代码来源:MgBufferControlImpl.cs

示例6: CreateLocationMarkerLayer

    // Create a temporary Layer to display geocode results.
    public MgLayer CreateLocationMarkerLayer(MgResourceService resourceService, MgResourceIdentifier locationMarkerDataResId, String sessionId)
    {
        // Load the AddressMarker layer definition template into
        // a ASPX XML object, find the "ResourceId" element, and
        // modify it's content to reference the temporary
        // feature source.

        XmlDocument doc = new XmlDocument();
        doc.PreserveWhitespace = true;
        string path =HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"] + "Extensions/findlocation/templates/locationmarker.xml";
        doc.Load(path);
        XmlNode featureSourceNode = doc.GetElementsByTagName("ResourceId").Item(0);
        XmlNode resContent = doc.CreateTextNode(locationMarkerDataResId.ToString());
        featureSourceNode.AppendChild(resContent);

        // Get the updated layer definition from the DOM object
        // and save it to the session repository using the
        // ResourceService object.
        MemoryStream xmlStream = new MemoryStream();
        doc.Save(xmlStream);
        byte[] layerDefinition = xmlStream.ToArray();
        Encoding utf8 = Encoding.UTF8;
        String layerDefStr = new String(utf8.GetChars(layerDefinition));
        layerDefinition = new byte[layerDefStr.Length - 1];
        int byteCount = utf8.GetBytes(layerDefStr, 1, layerDefStr.Length - 1, layerDefinition, 0);
        MgByteSource byteSource = new MgByteSource(layerDefinition, layerDefinition.Length);
        byteSource.SetMimeType(MgMimeType.Xml);

        MgResourceIdentifier tempLayerResId = new MgResourceIdentifier("Session:" + sessionId + "//LocationMarker.LayerDefinition");
        //MgResourceIdentifier tempLayerResId = new MgResourceIdentifier("Library://findLocation/" + sessionId + "/LocationMarker.LayerDefinition");
        resourceService.SetResource(tempLayerResId, byteSource.GetReader(), null);

        // Create an MgLayer object based on the new layer definition
        // and return it to the caller.

        MgLayer locationLayer = new MgLayer(tempLayerResId, resourceService);
        locationLayer.SetName("LocationMarker");
        locationLayer.SetLegendLabel("LocationMarker");
        locationLayer.SetDisplayInLegend(false);
        locationLayer.SetSelectable(false);

        return locationLayer;
    }
开发者ID:ranyaof,项目名称:Meuhedet,代码行数:44,代码来源:findlocationfunctions.cs

示例7: MaintenanceForFeatureExists

        private bool MaintenanceForFeatureExists(MgResourceIdentifier featureSourceId, MgResourceIdentifier maintenanceResId)
        {
            bool result = false;
            if (_resourceService.ResourceExists(maintenanceResId))
            {
                MgFeatureQueryOptions opt = new MgFeatureQueryOptions();
                opt.SetFilter(String.Format("FeatureSource='{0}' AND UID = {1}", featureSourceId.ToString(), GetParameter(this.args, "MARKUPFEATURE")));

                MgFeatureReader reader = _featureService.SelectFeatures(maintenanceResId, "Maintenance:Maintenance", opt);
                if (reader.ReadNext())
                {
                    result = true;
                }
            }
            return result;
        }
开发者ID:ranyaof,项目名称:Meuhedet,代码行数:16,代码来源:MarkupEditor.cs

示例8: createTempParcelLayer

    //---------------------------------------------------------------------------------------
    //
    //        ���ܣ�����Ԥ�����XML������
    //
    //         ���ߣ�
    //
    //         ���ڣ� 2007.5.23
    //        
    //         �޸���ʷ����
    //        
    //---------------------------------------------------------------------------------------
    private MgLayer createTempParcelLayer(MgResourceService resService, MgResourceIdentifier resId, string sessionId)
    {
        MgLayer tempParcelLayer = null;

        // ����XML�ĵ�
        XmlDocument doc = new XmlDocument();
        doc.PreserveWhitespace = false;
        doc.Load(@"C:\inetpub\wwwroot\MapguideTutorial\CH05-2\tempParcels.xml");
        // ��XML�ĵ��е�ResourceId���滻Ϊ�������ԴID���˴�ӦΪ�������ĻỰ�ִ��е���ʱ��ԴID
        XmlNode featureSourceNode = doc.GetElementsByTagName("ResourceId").Item(0);
        XmlNode resContent = doc.CreateTextNode(resId.ToString());
        featureSourceNode.AppendChild(resContent);
        // ����XML
        MemoryStream xmlStream = new MemoryStream();
        doc.Save(xmlStream);
        byte[] layerDef = xmlStream.ToArray();
        Encoding utf8 = Encoding.UTF8;
        string layerDefStr = new string(utf8.GetChars(layerDef));
        layerDef = new byte[layerDefStr.Length - 1];
        int byteCount = utf8.GetBytes(layerDefStr, 1, layerDefStr.Length - 1, layerDef, 0);

        MgByteSource byteSource = new MgByteSource(layerDef, layerDef.Length);
        byteSource.SetMimeType(MgMimeType.Xml);
        // ������Դ
        MgResourceIdentifier tempParcelLayerId = new MgResourceIdentifier("Session:" + sessionId + "//TempParcel.LayerDefinition");
        resService.SetResource(tempParcelLayerId, byteSource.GetReader(), null);
        //������ʱ��
        tempParcelLayer = new MgLayer(tempParcelLayerId, resService);
        tempParcelLayer.SetName("TempParcels");
        tempParcelLayer.SetLegendLabel("New Parcels");
        tempParcelLayer.SetDisplayInLegend(true);
        tempParcelLayer.SetSelectable(false);

        return tempParcelLayer;
    }
开发者ID:guchanghai,项目名称:Cut,代码行数:46,代码来源:UtilityClass.cs

示例9: CreateDebugFeatureSource

        private void CreateDebugFeatureSource()
        {
            var id = new MgDataPropertyDefinition("ID"); //NOXLATE
            id.DataType = MgPropertyType.Int32;
            id.Nullable = false;
            id.SetAutoGeneration(true);

            var geom = new MgGeometricPropertyDefinition("Geometry"); //NOXLATE
            geom.GeometryTypes = MgFeatureGeometricType.Point;
            geom.SpatialContextAssociation = "MapCs"; //NOXLATE

            var cls = new MgClassDefinition();
            cls.Name = "Debug"; //NOXLATE
            var props = cls.GetProperties();
            props.Add(id);
            props.Add(geom);

            var idProps = cls.GetIdentityProperties();
            idProps.Add(id);

            cls.DefaultGeometryPropertyName = "Geometry"; //NOXLATE

            var schema = new MgFeatureSchema("Default", "Default schema"); //NOXLATE
            var classes = schema.GetClasses();
            classes.Add(cls);

            //We can make anything up here, there's no real concept of sessions
            var sessionId = Guid.NewGuid().ToString();

            var debugFsId = new MgResourceIdentifier("Session:" + sessionId + "//Debug" + Guid.NewGuid().ToString() + ".FeatureSource"); //NOXLATE
            var createSdf = new MgCreateSdfParams("MapCs", _map.GetMapSRS(), schema); //NOXLATE
            var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
            var resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
            featureSvc.CreateFeatureSource(debugFsId, createSdf);

            byte[] bytes = Encoding.UTF8.GetBytes(string.Format(Debug.DebugLayer, debugFsId.ToString(), "Default:Debug", "Geometry")); //NOXLATE
            var source = new MgByteSource(bytes, bytes.Length);

            var debugLayerId = new MgResourceIdentifier("Session:" + sessionId + "//" + debugFsId.Name + ".LayerDefinition"); //NOXLATE
            var breader = source.GetReader();
            resSvc.SetResource(debugLayerId, breader, null);
            
            _debugLayer = new MgdLayer(debugLayerId, resSvc);
            _debugLayer.SetLegendLabel("Debug Layer"); //NOXLATE
            _debugLayer.SetVisible(true);
            _debugLayer.SetDisplayInLegend(true);

            var mapLayers = _map.GetLayers();
            mapLayers.Insert(0, _debugLayer);

            UpdateCenterDebugPoint();
        }
开发者ID:kanbang,项目名称:Colt,代码行数:52,代码来源:MgMapViewer.cs

示例10: CheckRedlineLayer

        private void CheckRedlineLayer()
        {
            if (_redlineLayer == null)
            {
                MgdMap map = (MgdMap)_viewer.GetMap();
                MgMapViewerProvider provider = _viewer.GetProvider();
                MgdFeatureService featSvc = (MgdFeatureService)provider.CreateService(MgServiceType.FeatureService);
                MgResourceService resSvc = (MgResourceService)provider.CreateService(MgServiceType.ResourceService);

                string sessionId = Guid.NewGuid().ToString();
                MgResourceIdentifier fsId = new MgResourceIdentifier("Session:" + sessionId + "//Redline.FeatureSource");
                MgResourceIdentifier ldfId = new MgResourceIdentifier("Session:" + sessionId + "//Redline.LayerDefinition");
                string featureClass = "Default:Redline";
                string geometry = "Geometry";
                string xml = string.Format(Layers.Redline, fsId.ToString(), featureClass, geometry);

                //Construct our schema for the redline data store
                MgFeatureSchema schema = new MgFeatureSchema("Default", "Redline schema");
                MgClassDefinition cls = new MgClassDefinition();
                cls.Name = "Redline";

                MgDataPropertyDefinition id = new MgDataPropertyDefinition("ID");
                id.DataType = MgPropertyType.Int32;
                id.SetAutoGeneration(true);

                MgGeometricPropertyDefinition geom = new MgGeometricPropertyDefinition(geometry);
                geom.SpatialContextAssociation = "Default";
                geom.GeometryTypes = MgFeatureGeometricType.Curve | MgFeatureGeometricType.Point | MgFeatureGeometricType.Solid | MgFeatureGeometricType.Surface;

                MgPropertyDefinitionCollection clsProps = cls.GetProperties();
                clsProps.Add(id);
                clsProps.Add(geom);

                MgPropertyDefinitionCollection idProps = cls.GetIdentityProperties();
                idProps.Add(id);

                cls.DefaultGeometryPropertyName = geometry;
                MgClassDefinitionCollection classes = schema.GetClasses();
                classes.Add(cls);

                //Create the feature source
                MgCreateSdfParams create = new MgCreateSdfParams("Default", map.GetMapSRS(), schema);
                featSvc.CreateFeatureSource(fsId, create);

                //Then the layer definition
                byte[] bytes = Encoding.UTF8.GetBytes(xml);
                MgByteSource source = new MgByteSource(bytes, bytes.Length);
                resSvc.SetResource(ldfId, source.GetReader(), null);

                //Now create the runtime layer and add to map
                _redlineLayer = new MgdLayer(ldfId, resSvc);
                _redlineLayer.LegendLabel = "Redlining";
                _redlineLayer.Name = "Redline";
                _redlineLayer.Visible = true;
                _redlineLayer.Selectable = true;
                _redlineLayer.DisplayInLegend = true;

                MgLayerCollection layers = map.GetLayers();
                layers.Insert(0, _redlineLayer);
            }
        }
开发者ID:kanbang,项目名称:Colt,代码行数:61,代码来源:DigitizingAndRedlining.cs

示例11: Preview

        public void Preview(IResource res, IEditorService edSvc, string locale)
        {
            IMapDefinition mapDef = null;
            var conn = res.CurrentConnection;

            if (res.ResourceType == ResourceTypes.LayerDefinition)
            {
                var ldf = (ILayerDefinition)res;
                string wkt;
                var env = ldf.GetSpatialExtent(true, out wkt);
                if (env == null)
                    throw new ApplicationException(Strings.CouldNotComputeExtentsForPreview);
                mapDef = ObjectFactory.CreateMapDefinition(conn, "Preview");
                mapDef.CoordinateSystem = wkt;
                mapDef.SetExtents(env.MinX, env.MinY, env.MaxX, env.MaxY);
                string resId = "Session:" + edSvc.SessionID + "//" + Guid.NewGuid() + "." + res.ResourceType.ToString();
                edSvc.ResourceService.SetResourceXmlData(resId, ResourceTypeRegistry.Serialize(res));
                mapDef.AddLayer(null, "PreviewLayer", resId);
            }
            else if (res.ResourceType == ResourceTypes.MapDefinition)
            {
                mapDef = (IMapDefinition)res;
            }
            else if (res.ResourceType == ResourceTypes.WatermarkDefinition)
            {
                string resId = "Session:" + edSvc.SessionID + "//" + Guid.NewGuid() + "." + res.ResourceType.ToString();
                edSvc.ResourceService.SetResourceXmlData(resId, ResourceTypeRegistry.Serialize(res));

                var csFact = new MgCoordinateSystemFactory();
                var arbXY = csFact.ConvertCoordinateSystemCodeToWkt("XY-M");
                mapDef = ObjectFactory.CreateMapDefinition(conn, new Version(2, 3, 0), "Preview");
                mapDef.CoordinateSystem = arbXY;
                mapDef.SetExtents(-100000, -100000, 100000, 100000);
                var wm = ((IMapDefinition2)mapDef).AddWatermark(((IWatermarkDefinition)res));
                wm.ResourceId = resId;
            }

            var mapResId = new MgResourceIdentifier("Session:" + edSvc.SessionID + "//" + mapDef.ResourceType.ToString() + "Preview" + Guid.NewGuid() + "." + mapDef.ResourceType.ToString());
            edSvc.ResourceService.SetResourceXmlData(mapResId.ToString(), ResourceTypeRegistry.Serialize(mapDef));

            //MgdMap map = new MgdMap(mapResId);

            //var diag = new MapPreviewWindow(map, conn);
            //diag.ShowDialog();

            var diag = new UI.MapPreviewWindow(conn);
            diag.Init(mapResId);
            diag.ShowDialog();
        }
开发者ID:kanbang,项目名称:Colt,代码行数:49,代码来源:LocalPreviewer.cs

示例12: CreateRedlineLayer

        private void CreateRedlineLayer()
        {
            MgMapBase map = mgMapViewer1.GetMap();
            MgdServiceFactory fact = new MgdServiceFactory();
            MgdFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
            MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

            //Note that mg-desktop does not have a concept of sessions like the
            //official MapGuide API, but it *does* allow session-based resources 
            //as a way of having temporary resources. Such resources will reside
            //in a special directory for session resources (specified in Platform.ini)
            //
            //You can plug whatever string as the session id, but the resource identifier
            //must satisfy the session id pattern:
            //
            // Session:<session id string>//Path/To/Your.ResourceType
            //
            //These files are removed with MgPlatform.Terminate(), which is called in this
            //application as part of the exiting process.
            string sessionId = Guid.NewGuid().ToString();
            MgResourceIdentifier fsId = new MgResourceIdentifier("Session:" + sessionId + "//Redline.FeatureSource");
            MgResourceIdentifier ldfId = new MgResourceIdentifier("Session:" + sessionId + "//Redline.LayerDefinition");

            //Create our point redline schema. It looks like this:
            //
            // Default
            //    Redline
            //        ID (int32, autogenerated)
            //        Geometry (coordinate system same as map
            string featureClass = "Default:Redline";
            string geometry = "Geometry";

            MgFeatureSchema schema = new MgFeatureSchema("Default", "Redline schema");
            MgClassDefinition cls = new MgClassDefinition();
            cls.Name = "Redline";

            MgDataPropertyDefinition id = new MgDataPropertyDefinition("ID");
            id.DataType = MgPropertyType.Int32;
            id.SetAutoGeneration(true);

            MgGeometricPropertyDefinition geom = new MgGeometricPropertyDefinition(geometry);
            geom.SpatialContextAssociation = "Default";
            geom.GeometryTypes = MgFeatureGeometricType.Curve | MgFeatureGeometricType.Point | MgFeatureGeometricType.Solid | MgFeatureGeometricType.Surface;

            MgPropertyDefinitionCollection clsProps = cls.GetProperties();
            clsProps.Add(id);
            clsProps.Add(geom);

            MgPropertyDefinitionCollection idProps = cls.GetIdentityProperties();
            idProps.Add(id);

            cls.DefaultGeometryPropertyName = geometry;
            MgClassDefinitionCollection classes = schema.GetClasses();
            classes.Add(cls);

            //Create the feature source with this schema. We use the map's
            //coordinate system for the feature source to ensure features
            //that we create, will line up with the map
            MgCreateSdfParams create = new MgCreateSdfParams("Default", map.GetMapSRS(), schema);
            featSvc.CreateFeatureSource(fsId, create);

            //Then create the layer definition. RedlineLayer.xml contains the template
            string xml = string.Format(File.ReadAllText("RedlineLayer.xml"), fsId.ToString(), featureClass, geometry);
            var bytes = Encoding.UTF8.GetBytes(xml);
            MgByteSource source = new MgByteSource(bytes, bytes.Length);
            resSvc.SetResource(ldfId, source.GetReader(), null);

            //Now create the runtime layer and add to map
            _pointLayer = new MgdLayer(ldfId, resSvc);
            _pointLayer.LegendLabel = "Redlining";
            _pointLayer.Name = "Redline";
            _pointLayer.Visible = true;
            _pointLayer.Selectable = true;
            _pointLayer.DisplayInLegend = true;

            var layers = map.GetLayers();
            layers.Insert(0, _pointLayer);
        }
开发者ID:kanbang,项目名称:Colt,代码行数:78,代码来源:MainForm.cs


注:本文中的MgResourceIdentifier.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。