コード例 #1
0
ファイル: OsmDataSource.cs プロジェクト: jorik041/osmsharp
        /// <summary>
        /// Writes to the osm document.
        /// </summary>
        private void WriteToDocument()
        {
            _read = true;

            // collect all needed data.
            _bb = this.BoundingBox;

            // generate osm document.
            OsmSharp.Osm.Xml.v0_6.osm osm = new OsmSharp.Osm.Xml.v0_6.osm();

            // dimension the arrays.
            osm.node = new node[_nodes.Count];
            osm.way = new way[_ways.Count];
            osm.relation = new relation[_relations.Count];

            // iterate over all objects and convert them.
            IList<Node> nodes = _nodes.Values.ToList<Node>();
            for(int idx = 0;idx < nodes.Count;idx++)
            {
                node xml_obj = nodes[idx].ConvertTo();
                osm.node[idx] = xml_obj;
            }
            IList<Way> ways = _ways.Values.ToList<Way>();
            for (int idx = 0; idx < ways.Count; idx++)
            {
                way xml_obj = ways[idx].ConvertTo();
                osm.way[idx] = xml_obj;
            }
            IList<Relation> relations = _relations.Values.ToList<Relation>();
            for (int idx = 0; idx < relations.Count; idx++)
            {
                relation xml_obj = relations[idx].ConvertTo();
                osm.relation[idx] = xml_obj;
            }

            // convert the bounds as well.
            osm.bounds = _bb.ConvertTo();

            _document.Osm = osm;
            _document.Save();
        }