예제 #1
0
파일: OSMDB.cs 프로젝트: wsgan001/TPM
        /// <summary>
        /// Loads OSM entities from the specific Stream
        /// </summary>
        /// <param name="stream">Stream with the OSM file</param>
        public virtual void Load(Stream stream)
        {
            OSMXmlDataReader xmlReader = new OSMXmlDataReader();

            xmlReader.NodeRead     += new OSMNodeReadHandler(node => _nodes.Add(node));
            xmlReader.WayRead      += new OSMWayReadHandler(way => _ways.Add(way));
            xmlReader.RelationRead += new OSMRelationReadHandler(relation => _relations.Add(relation));

            xmlReader.Read(stream);
        }
예제 #2
0
        /// <summary>
        /// Load OSM file, and filters out ways that do not match specific road types
        /// </summary>
        /// <param name="acceptedRoads">Accepted road types</param>
        /// <param name="input">Stream with OSM file</param>
        public void Load(IEnumerable <RoadType> acceptedRoads, Stream input)
        {
            _acceptedRoads = acceptedRoads;

            OSMXmlDataReader reader = new OSMXmlDataReader();

            reader.WayRead += WayRead;
            reader.Read(input);

            reader.WayRead  -= WayRead;
            reader.NodeRead += NodeRead;
            input.Seek(0, 0);
            reader.Read(input);
        }