Ejemplo n.º 1
0
        /// <summary>
        /// Fills the scene with objects from the given datasource that existing inside the given boundingbox with the given projection.
        /// </summary>
        /// <param name="dataSource"></param>
        /// <param name="box"></param>
        /// <param name="projection"></param>
        public void FillScene(IDataSourceReadOnly dataSource, GeoCoordinateBox box, IProjection projection)
        {
            foreach (var osmGeo in dataSource.Get(box, null))
            { // translate each object into scene object.
                LongIndex index = null;
                switch (osmGeo.Type)
                {
                case Osm.OsmGeoType.Node:
                    index = _interpretedNodes;
                    break;

                case Osm.OsmGeoType.Way:
                    index = _interpretedWays;
                    break;

                case Osm.OsmGeoType.Relation:
                    index = _interpretedRelations;
                    break;
                }
                if (!index.Contains(osmGeo.Id.Value))
                { // object was not yet interpreted.
                    index.Add(osmGeo.Id.Value);

                    _interpreter.Translate(_scene, projection, dataSource, osmGeo);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tests a few boundingbox queries.
        /// </summary>
        protected void TestBoundingBoxQueries()
        {
            this.NotifyEmptyExpected(); // empty test database.

            // create the target and pull the data from the test-file into the sqlite database.
            OsmStreamTarget    target = this.CreateDataStreamTarget();
            PBFOsmStreamSource source = new PBFOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Data.Test.Unittests.Data.Osm.test.osm.pbf"));

            target.RegisterSource(source);
            target.Pull();

            IDataSourceReadOnly dataSource   = this.CreateDataSource();
            MemoryDataSource    memorySource = MemoryDataSource.CreateFrom(source);

            // get reference data and compare to the real thing!
            GeoCoordinateBox box = memorySource.BoundingBox;
            IList <OsmGeo>   referenceBoxData = memorySource.Get(box, null);
            IList <OsmGeo>   boxData          = dataSource.Get(box, null);

            this.CompareResults(referenceBoxData, boxData);

            // increase box size and compare again.
            box = memorySource.BoundingBox.Resize(0.1);
            referenceBoxData = memorySource.Get(box, null);
            boxData          = dataSource.Get(box, null);
            this.CompareResults(referenceBoxData, boxData);

            // descrese box size and compare again.
            box = memorySource.BoundingBox.Scale(0.5);
            referenceBoxData = memorySource.Get(box, null);
            boxData          = dataSource.Get(box, null);
            this.CompareResults(referenceBoxData, boxData);

            // descrese box size and compare again.
            box = memorySource.BoundingBox.Scale(0.25);
            referenceBoxData = memorySource.Get(box, null);
            boxData          = dataSource.Get(box, null);
            this.CompareResults(referenceBoxData, boxData);

            // descrese box size and compare again.
            box = memorySource.BoundingBox.Scale(0.1);
            referenceBoxData = memorySource.Get(box, null);
            boxData          = dataSource.Get(box, null);
            this.CompareResults(referenceBoxData, boxData);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns all data in the given bounding box.
        /// </summary>
        /// <param name="box"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public override IList <OsmGeo> Get(GeoCoordinateBox box, Filter filter)
        {
            IList <OsmGeo> objects = _source.Get(box, filter);

            foreach (OsmGeo osmGeo in objects)
            {
                switch (osmGeo.Type)
                {
                case OsmGeoType.Node:
                    _nodesCache.Add(osmGeo.Id.Value, osmGeo as Node);
                    break;

                case OsmGeoType.Way:
                    _waysCache.Add(osmGeo.Id.Value, osmGeo as Way);
                    break;

                case OsmGeoType.Relation:
                    _relationsCache.Add(osmGeo.Id.Value, osmGeo as Relation);
                    break;
                }
            }
            return(objects);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Fills the scene with objects from the given datasource that existing inside the given boundingbox with the given projection.
        /// </summary>
        /// <param name="dataSource"></param>
        /// <param name="box"></param>
        /// <param name="projection"></param>
        public void FillScene(IDataSourceReadOnly dataSource, GeoCoordinateBox box, IProjection projection)
        {
            IList<Osm.OsmGeo> osmGeos = dataSource.Get(box, null);
            foreach (var osmGeo in osmGeos)
            { // translate each object into scene object.
                LongIndex index = null;
                switch (osmGeo.Type)
                {
                    case Osm.OsmGeoType.Node:
                        index = _interpretedNodes;
                        break;
                    case Osm.OsmGeoType.Way:
                        index = _interpretedWays;
                        break;
                    case Osm.OsmGeoType.Relation:
                        index = _interpretedRelations;
                        break;
                }
                if (!index.Contains(osmGeo.Id.Value))
                { // object was not yet interpreted.
                    index.Add(osmGeo.Id.Value);

                    _interpreter.Translate(_scene, projection, dataSource, osmGeo);
                }
            }
        }
 /// <summary>
 /// Returns all data in this source for the given bounding box.
 /// </summary>
 /// <param name="box"></param>
 /// <returns></returns>
 public DataProcessorSource Get(GeoCoordinateBox box)
 {
     return(new OsmGeoListDataProcessorSource(
                _dataSourceReadOnly.Get(box, null)));
 }