Exemplo n.º 1
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 GetMapFileInfoTest()
        {
            MapFile mapFile = new MapFile(EmbeddedResourceLoader.Load("Resources.FileHeader.output.map", this.GetType()));

            MapFileInfo mapFileInfo = mapFile.MapFileInfo;

            mapFile.Close();

            Assert.AreEqual(BOUNDING_BOX, mapFileInfo.BoundingBox);
            Assert.AreEqual(FILE_SIZE, mapFileInfo.FileSize);
            Assert.AreEqual(FILE_VERSION, mapFileInfo.FileVersion);
            Assert.AreEqual(MAP_DATE, mapFileInfo.MapDate);
            Assert.AreEqual(NUMBER_OF_SUBFILES, mapFileInfo.NumberOfSubFiles);
            Assert.AreEqual(PROJECTION_NAME, mapFileInfo.ProjectionName);
            Assert.AreEqual(TILE_PIXEL_SIZE, mapFileInfo.TilePixelSize);

            Assert.AreEqual(0, mapFileInfo.PoiTags.Length);
            Assert.AreEqual(0, mapFileInfo.WayTags.Length);

            Assert.False(mapFileInfo.DebugFile);
            Assert.AreEqual(START_POSITION, mapFileInfo.StartPosition);
            Assert.AreEqual(START_ZOOM_LEVEL, mapFileInfo.StartZoomLevel);
            Assert.AreEqual(LANGUAGES_PREFERENCE, mapFileInfo.LanguagesPreference);
            Assert.AreEqual(COMMENT, mapFileInfo.Comment);
            Assert.AreEqual(CREATED_BY, mapFileInfo.CreatedBy);
        }
        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();
        }
Exemplo 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();
        }