internal static void ReadOptionalFields(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) { OptionalFields optionalFields = new OptionalFields(readBuffer.ReadByte()); mapFileInfoBuilder.optionalFields = optionalFields; optionalFields.ReadOptionalFields(readBuffer); }
internal static void ReadTilePixelSize(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) { // get and check the tile pixel size (2 bytes) int tilePixelSize = readBuffer.ReadShort(); // if (tilePixelSize != Tile.TILE_SIZE) { // return new FileOpenResult("unsupported tile pixel size: " + tilePixelSize); // } mapFileInfoBuilder.tilePixelSize = tilePixelSize; }
internal static void readFileVersion(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) { // get and check the file version (4 bytes) int fileVersion = readBuffer.ReadInt(); if (fileVersion < SUPPORTED_FILE_VERSION_MIN || fileVersion > SUPPORTED_FILE_VERSION_MAX) { throw new MapFileException("unsupported file version: " + fileVersion); } mapFileInfoBuilder.fileVersion = fileVersion; }
internal static void ReadFileSize(ReadBuffer readBuffer, long fileSize, MapFileInfoBuilder mapFileInfoBuilder) { // get and check the file size (8 bytes) long headerFileSize = readBuffer.ReadLong(); if (headerFileSize != fileSize) { throw new MapFileException("invalid file size: " + headerFileSize); } mapFileInfoBuilder.fileSize = fileSize; }
internal static void ReadProjectionName(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) { // get and check the projection name string projectionName = readBuffer.ReadUTF8EncodedString(); if (!MERCATOR.Equals(projectionName)) { throw new MapFileException("unsupported projection: " + projectionName); } mapFileInfoBuilder.projectionName = projectionName; }
internal static void ReadMapDate(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) { // get and check the the map date (8 bytes) long mapDate = readBuffer.ReadLong(); // is the map date before 2010-01-10 ? if (mapDate < 1200000000000L) { throw new MapFileException("invalid map date: " + mapDate); } mapFileInfoBuilder.mapDate = mapDate; }
internal static void ReadBoundingBox(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) { double minLatitude = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt()); double minLongitude = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt()); double maxLatitude = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt()); double maxLongitude = LatLongUtils.MicrodegreesToDegrees(readBuffer.ReadInt()); try { mapFileInfoBuilder.boundingBox = new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude); } catch (System.ArgumentException e) { throw new MapFileException(e.Message); } }
internal MapFileInfo(MapFileInfoBuilder mapFileInfoBuilder) { this.Comment = mapFileInfoBuilder.optionalFields.Comment; this.CreatedBy = mapFileInfoBuilder.optionalFields.CreatedBy; this.DebugFile = mapFileInfoBuilder.optionalFields.IsDebugFile; this.FileSize = mapFileInfoBuilder.fileSize; this.FileVersion = mapFileInfoBuilder.fileVersion; this.LanguagesPreference = mapFileInfoBuilder.optionalFields.LanguagesPreference; this.BoundingBox = mapFileInfoBuilder.boundingBox; this.MapDate = mapFileInfoBuilder.mapDate; this.NumberOfSubFiles = mapFileInfoBuilder.numberOfSubFiles; this.PoiTags = mapFileInfoBuilder.poiTags; this.ProjectionName = mapFileInfoBuilder.projectionName; this.StartPosition = mapFileInfoBuilder.optionalFields.StartPosition; this.StartZoomLevel = mapFileInfoBuilder.optionalFields.StartZoomLevel; this.TilePixelSize = mapFileInfoBuilder.tilePixelSize; this.WayTags = mapFileInfoBuilder.wayTags; this.ZoomLevelMax = mapFileInfoBuilder.zoomLevelMax; this.ZoomLevelMin = mapFileInfoBuilder.zoomLevelMin; }
internal static void ReadPoiTags(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) { // get and check the number of POI tags (2 bytes) int numberOfPoiTags = readBuffer.ReadShort(); if (numberOfPoiTags < 0) { throw new MapFileException("invalid number of POI tags: " + numberOfPoiTags); } Tag[] poiTags = new Tag[numberOfPoiTags]; for (int currentTagId = 0; currentTagId < numberOfPoiTags; ++currentTagId) { // get and check the POI tag string tag = readBuffer.ReadUTF8EncodedString(); if (string.ReferenceEquals(tag, null)) { throw new MapFileException("POI tag must not be null: " + currentTagId); } poiTags[currentTagId] = new Tag(tag); } mapFileInfoBuilder.poiTags = poiTags; }