Exemplo n.º 1
0
        public Way Process(string Input, Config ConfigFile)
        {
            XmlDocument _document = new XmlDocument();
            _document.LoadXml(Input);

            if (_document.FirstChild.NodeType == XmlNodeType.XmlDeclaration)
                _document.RemoveChild(_document.FirstChild);

            string json = JsonConvert.SerializeXmlNode(_document);

            CommonDataProcessor _cProcessor = new CommonDataProcessor(ConfigFile);

            List<Dictionary<string, object>> _output = ConvertToCorrect(_document);

            Way _out = new Way(null, _cProcessor.ConvertData(_output), null);

            return _out;
        }
Exemplo n.º 2
0
        private XmlDocument ConvertOSMXML(Way _data)
        {
            Console.WriteLine("Convert common data to JSOM file format...");

            XmlDocument doc = new XmlDocument();

            //XML 宣告
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            doc.AppendChild(dec);

            //XML OpenStreetMap標頭
            XmlElement osm = doc.CreateElement("osm");
            osm.SetAttribute("version", "0.6");
            osm.SetAttribute("generator", "kagami");

            //TODO: 處理Way和Relation
            //先處理POI
            for(int i = 0; i < _data.Nodes.Count; ++i)
            {
                XmlElement node = doc.CreateElement("node");

                Node _tmpNode = _data.Nodes[i];

                node.SetAttribute("id", _tmpNode.CommonAttributes.ID + (i + 1).ToString());
                node.SetAttribute("lat", _tmpNode.YAxis);
                node.SetAttribute("lon", _tmpNode.XAxis);
                node.SetAttribute("visible", _tmpNode.CommonAttributes.Visible.ToString());
                node.SetAttribute("version", _tmpNode.CommonAttributes.Version.ToString());

                for(int j = 0; j < _tmpNode.Tags.Count; ++j)
                {
                    XmlElement keyvaluePair = doc.CreateElement("tag");
                    keyvaluePair.SetAttribute("k", _tmpNode.Tags[j].Key);
                    keyvaluePair.SetAttribute("v", _tmpNode.Tags[j].Value);

                    node.AppendChild(keyvaluePair);
                }

                osm.AppendChild(node);
            }

            doc.AppendChild(osm);

            return doc;
        }
Exemplo n.º 3
0
        public Way Process(string Input, Config ConfigFile)
        {
            CommonDataProcessor _cProcessor = new CommonDataProcessor(ConfigFile);

            List<Dictionary<string, object>> _output = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(Input);

            Way _out = new Way(null, _cProcessor.ConvertData(_output), null);

            return _out;
        }
Exemplo n.º 4
0
 public void MakeXMLFile(Way OriginData , Config _config)
 {
     SaveFile(ConvertOSMXML(OriginData), _config);
 }
Exemplo n.º 5
0
        public Way Process(string Input, Config ConfigFile)
        {
            CommonDataProcessor _cProcessor = new CommonDataProcessor(ConfigFile);

            List<Dictionary<string, object>> _output = CSVReader.Read(Input);

            Way _out = new Way(null, _cProcessor.ConvertData(_output), null);

            return _out;
        }