/// <summary> /// Reads and validates the header block from the map file. /// </summary> /// <param name="readBuffer"> /// the ReadBuffer for the file data. </param> /// <param name="fileSize"> /// the size of the map file in bytes. </param> /// <exception cref="IOException"> /// if an error occurs while reading the file. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void readHeader(MapsforgeSharp.Reader.ReadBuffer readBuffer, long fileSize) throws java.io.IOException public virtual void ReadHeader(ReadBuffer readBuffer, long fileSize) { RequiredFields.ReadMagicByte(readBuffer); RequiredFields.ReadRemainingHeader(readBuffer); MapFileInfoBuilder mapFileInfoBuilder = new MapFileInfoBuilder(); RequiredFields.readFileVersion(readBuffer, mapFileInfoBuilder); RequiredFields.ReadFileSize(readBuffer, fileSize, mapFileInfoBuilder); RequiredFields.ReadMapDate(readBuffer, mapFileInfoBuilder); RequiredFields.ReadBoundingBox(readBuffer, mapFileInfoBuilder); RequiredFields.ReadTilePixelSize(readBuffer, mapFileInfoBuilder); RequiredFields.ReadProjectionName(readBuffer, mapFileInfoBuilder); OptionalFields.ReadOptionalFields(readBuffer, mapFileInfoBuilder); RequiredFields.ReadPoiTags(readBuffer, mapFileInfoBuilder); RequiredFields.ReadWayTags(readBuffer, mapFileInfoBuilder); ReadSubFileParameters(readBuffer, fileSize, mapFileInfoBuilder); this.mapFileInfo = mapFileInfoBuilder.Build(); }
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); }
void LoadFromJsonFile() { string path = Application.dataPath + "/MapInfoData.json"; string jsonData = null; if ((jsonData = File.ReadAllText(path)) != null) { mapFileInfo = JsonUtility.FromJson <MapFileInfo>(jsonData); } }
/** * @return the start zoom level (may be null). */ public byte getStartZoomLevel() { if (this.mapDatabase != null && this.mapDatabase.HasOpenFile()) { MapFileInfo mapFileInfo = this.mapDatabase.getMapFileInfo(); if (mapFileInfo.StartZoomLevel != null) { return(mapFileInfo.StartZoomLevel); } } return(DEFAULT_START_ZOOM_LEVEL); }
/** * @return the start point (may be null). */ public GeoPoint getStartPoint() { if (this.mapDatabase != null && this.mapDatabase.HasOpenFile()) { MapFileInfo mapFileInfo = this.mapDatabase.getMapFileInfo(); if (mapFileInfo.StartPosition != null) { return(mapFileInfo.StartPosition); } return(mapFileInfo.BoundingBox.getCenterpoint()); } return(null); }
public virtual void RealMapTest() { CheckMapFile(); MapFileInfo mapFileInfo = mapFile.MapFileInfo; Assert.AreEqual(mapFileInfo.FileSize, 156836); Assert.AreEqual(mapFileInfo.FileVersion, 3); Assert.AreEqual(mapFileInfo.BoundingBox, new BoundingBox(7.309206, 43.623385, 7.548547, 43.851689)); Assert.AreEqual(mapFileInfo.StartPosition, new Point(7.4391, 43.7372)); Assert.AreEqual(mapFileInfo.LanguagesPreference, "en"); Assert.AreEqual(mapFileInfo.ProjectionName, "Mercator"); Assert.AreEqual(mapFileInfo.NumberOfSubFiles, 3); Assert.AreEqual(mapFileInfo.TilePixelSize, 256); Assert.AreEqual(mapFileInfo.ZoomLevelMin, 0); Assert.AreEqual(mapFileInfo.ZoomLevelMax, 21); Assert.AreEqual(mapFileInfo.StartZoomLevel, 14); Assert.AreEqual(mapFileInfo.PoiTags.Length, 54); Assert.AreEqual(mapFileInfo.WayTags.Length, 76); }
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(); }