Esempio n. 1
0
        internal SubFileParameter(SubFileParameterBuilder subFileParameterBuilder)
        {
            this.StartAddress      = subFileParameterBuilder.StartAddress;
            this.IndexStartAddress = subFileParameterBuilder.IndexStartAddress;
            this.SubFileSize       = subFileParameterBuilder.SubFileSize;
            this.BaseZoomLevel     = subFileParameterBuilder.BaseZoomLevel;
            this.ZoomLevelMin      = subFileParameterBuilder.ZoomLevelMin;
            this.ZoomLevelMax      = subFileParameterBuilder.ZoomLevelMax;
            this.HashCodeValue     = CalculateHashCode();

            // calculate the XY numbers of the boundary tiles in this sub-file
            this.BoundaryTileBottom = MercatorProjection.LatitudeToTileY(subFileParameterBuilder.BoundingBox.MinLatitude, this.BaseZoomLevel);
            this.BoundaryTileLeft   = MercatorProjection.LongitudeToTileX(subFileParameterBuilder.BoundingBox.MinLongitude, this.BaseZoomLevel);
            this.BoundaryTileTop    = MercatorProjection.LatitudeToTileY(subFileParameterBuilder.BoundingBox.MaxLatitude, this.BaseZoomLevel);
            this.BoundaryTileRight  = MercatorProjection.LongitudeToTileX(subFileParameterBuilder.BoundingBox.MaxLongitude, this.BaseZoomLevel);

            // calculate the horizontal and vertical amount of blocks in this sub-file
            this.BlocksWidth  = this.BoundaryTileRight - this.BoundaryTileLeft + 1;
            this.BlocksHeight = this.BoundaryTileBottom - this.BoundaryTileTop + 1;

            // calculate the total amount of blocks in this sub-file
            this.NumberOfBlocks = this.BlocksWidth * this.BlocksHeight;

            this.IndexEndAddress = this.IndexStartAddress + this.NumberOfBlocks * BYTES_PER_INDEX_ENTRY;
        }
Esempio n. 2
0
        internal static void RunTest(MapFile mapFile)
        {
            // Calculate tile X and Y for lat=0 and lon=0
            int tileX = MercatorProjection.LongitudeToTileX(0, ZOOM_LEVEL);
            int tileY = MercatorProjection.LatitudeToTileY(0, ZOOM_LEVEL);

            Tile tile = new Tile(tileX, tileY, ZOOM_LEVEL);

            MapReadResult mapReadResult = mapFile.ReadMapData(tile);

            mapFile.Close();

            Assert.AreEqual(mapReadResult.PointOfInterests.Count, 0);
            Assert.AreEqual(1, mapReadResult.Ways.Count);

            Point point1 = new Point(0.0, 0.0);
            Point point2 = new Point(0.1, 0.0);
            Point point3 = new Point(0.1, -0.1);
            Point point4 = new Point(0.0, -0.1);

            Point[][] latLongsExpected = new Point[][]
            {
                new Point[] { point1, point2, point3, point4, point1 }
            };

            Way way = mapReadResult.Ways[0];

            // TODO: Was ArrayEquals()
            Assert.AreEqual(latLongsExpected, way.Points);
        }
        public virtual void FileEmptyTest()
        {
            MapFile mapFile = new MapFile(EmbeddedResourceLoader.Load("Resources.Empty.output.map", this.GetType()));

            for (sbyte zoomLevel = 0; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel)
            {
                int tileX = MercatorProjection.LongitudeToTileX(1, zoomLevel);
                int tileY = MercatorProjection.LatitudeToTileY(1, zoomLevel);

                Tile tile = new Tile(tileX, tileY, zoomLevel);

                MapReadResult mapReadResult = mapFile.ReadMapData(tile);

                Assert.AreEqual(0, mapReadResult.PointOfInterests.Count);
                Assert.AreEqual(0, mapReadResult.Ways.Count);
            }

            mapFile.Close();
        }
Esempio n. 4
0
        public virtual void WithDataTest()
        {
            MapFile mapFile = new MapFile(EmbeddedResourceLoader.Load("Resources.WithData.output.map", this.GetType()));

            MapFileInfo mapFileInfo = mapFile.MapFileInfo;

            Assert.True(mapFileInfo.DebugFile);

            for (sbyte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel)
            {
                Point poi = new Point(0.04, 0.04);

                int tileX = MercatorProjection.LongitudeToTileX(0.04, zoomLevel);
                int tileY = MercatorProjection.LatitudeToTileY(0.04, zoomLevel);

                Tile tile = new Tile(tileX, tileY, zoomLevel);

                double lonMin = MercatorProjection.TileXToLongitude(tileX, zoomLevel);
                double lonMax = MercatorProjection.TileXToLongitude(tileX + 1, zoomLevel);
                double latMin = MercatorProjection.TileYToLatitude(tileY + 1, zoomLevel);
                double latMax = MercatorProjection.TileYToLatitude(tileY, zoomLevel);

                //tile.Index = new TileIndex(tileX, tileY, zoomLevel.ToString());
                //tile.Extent = new Extent(lonMin, latMin, lonMax, latMax);

                MapReadResult mapReadResult = mapFile.ReadMapData(tile);

                Assert.AreEqual(1, mapReadResult.PointOfInterests.Count);
                Assert.AreEqual(1, mapReadResult.Ways.Count);

                CheckPointOfInterest(mapReadResult.PointOfInterests[0]);
                CheckWay(mapReadResult.Ways[0]);
            }

            mapFile.Close();
        }