Ejemplo n.º 1
0
        public void OSMDatabaseSaveCanSaveDataToOSMFile()
        {
            OSMDB target = new OSMDB();

            target.Load(new MemoryStream(OSMUtils.Tests.TestData.real_osm_file));

            MemoryStream writtenDb = new MemoryStream();
            target.Save(writtenDb);

            writtenDb.Seek(0, 0);
            OSMDB readDB = new OSMDB();
            readDB.Load(writtenDb);

            Assert.Equal(408, readDB.Nodes.Count);
            Assert.Equal(22, readDB.Ways.Count);
            Assert.Equal(2, readDB.Relations.Count);
        }
Ejemplo n.º 2
0
        public static void SaveCandidateIncomingConnections(CandidatePoint candidate, string filename)
        {
            int counter = -1;
            OSMDB result = new OSMDB();

            OSMNode osmCandidate = new OSMNode(counter--, candidate.MapPoint.Latitude, candidate.MapPoint.Longitude);
            osmCandidate.Tags.Add(new OSMTag("observation", candidate.ObservationProbability.ToString()));
            osmCandidate.Tags.Add(new OSMTag("time", candidate.Layer.TrackPoint.Time.ToString()));
            result.Nodes.Add(osmCandidate);
            foreach (var connection in candidate.IncomingConnections) {
                OSMNode from = new OSMNode(counter--, connection.From.MapPoint.Latitude, connection.From.MapPoint.Longitude);
                from.Tags.Add(new OSMTag("observation", connection.From.ObservationProbability.ToString()));
                from.Tags.Add(new OSMTag("time", connection.From.Layer.TrackPoint.Time.ToString()));
                result.Nodes.Add(from);

                OSMWay osmConnection = new OSMWay(counter--, new int[] { from.ID, osmCandidate.ID });
                osmConnection.Tags.Add(new OSMTag("transmission", connection.TransmissionProbability.ToString()));

                result.Ways.Add(osmConnection);
            }

            result.Save(filename);
        }