當前位置: 首頁>>代碼示例>>C#>>正文


C# CoordinateTransformationFactory.Transform方法代碼示例

本文整理匯總了C#中ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory.Transform方法的典型用法代碼示例。如果您正苦於以下問題:C# CoordinateTransformationFactory.Transform方法的具體用法?C# CoordinateTransformationFactory.Transform怎麽用?C# CoordinateTransformationFactory.Transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory的用法示例。


在下文中一共展示了CoordinateTransformationFactory.Transform方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SaveToOsm

        static void SaveToOsm(Dictionary<Coordinate, int> nodes, Dictionary<int, Calle> calles, string path)
        {
            var trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(
                ProjectedCoordinateSystem.WGS84_UTM(21, false),
                GeographicCoordinateSystem.WGS84).MathTransform;

            XmlDocument osmDoc = new XmlDocument();
            osmDoc.InsertBefore(osmDoc.CreateXmlDeclaration("1.0","utf-8",null), osmDoc.DocumentElement);
            var rootNode  = osmDoc.CreateElement("osm");
            rootNode.SetAttribute("version", "0.6");
               osmDoc.AppendChild(rootNode);

            foreach(var node in nodes)
            {
                var nodeEl = osmDoc.CreateElement("node");
                rootNode.AppendChild(nodeEl);
                nodeEl.SetAttribute("id", OsmId(node.Value).ToString());
                nodeEl.SetAttribute("visible", "true");
                var latlon = trans.Transform(new[]{node.Key.X, node.Key.Y});
                nodeEl.SetAttribute("lat", latlon[1].ToString(CultureInfo.InvariantCulture));
                nodeEl.SetAttribute("lon", latlon[0].ToString(CultureInfo.InvariantCulture));
            }

            int wayId = nodes.Count;
            foreach(var calle in calles)
            {
                foreach(var way in calle.Value.Ways)
                {
                    var wayEl = osmDoc.CreateElement("way");
                    rootNode.AppendChild(wayEl);
                    wayEl.SetAttribute("id", OsmId(wayId++).ToString());
                    wayEl.SetAttribute("visible", "true");
                    wayEl.SetAttribute("action", "modify");
                    foreach(var node in way.Nodes)
                    {
                        var ndEl = osmDoc.CreateElement("nd");
                        wayEl.AppendChild(ndEl);
                        ndEl.SetAttribute("ref", OsmId(node).ToString());
                    }
                    var name = calle.Value.Nombre;
                    AddTag(wayEl, "name", PrettifyName(name));
                    AddTag(wayEl, "highway", name.Contains("PEATONAL") || name.Contains("PNAL")? "footway" : "residential");
                    AddTag(wayEl, "source", "http://intgis.montevideo.gub.uy");
                    AddTag(wayEl, "mvdgis:cod_nombre", calle.Key);
                    if(way.OneWay)
                    {
                        AddTag(wayEl, "oneway", "yes");
                    }
                }
            }
            osmDoc.Save(path);
        }
開發者ID:maxm,項目名稱:osmuy,代碼行數:52,代碼來源:Main.cs


注:本文中的ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory.Transform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。