Skip to content

Commit

Permalink
Added Mapy
Browse files Browse the repository at this point in the history
  • Loading branch information
barak committed Aug 13, 2024
1 parent d8438b2 commit ecdd309
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 136 deletions.
3 changes: 2 additions & 1 deletion src/common/maps/map.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { mapDataHaifa } from './haifa.data'
import { mapDataNetanya } from './netanya.data'
import { mapDataGalilTahton } from './galil-tahton.data'
import { mapDataHodHasharon } from './hod-hasharon.data'
import { mapDataMapy } from './mapy.data'

export type ZoomLayer = {
readonly scale: number
Expand Down Expand Up @@ -42,5 +43,5 @@ export const maps = [
mapDataHaifa,
mapDataHodHasharon,
mapDataNetanya,
// mapDataMapy
mapDataMapy
]
251 changes: 118 additions & 133 deletions src/common/maps/mapy.data.ts
Original file line number Diff line number Diff line change
@@ -1,133 +1,118 @@
// import * as pimage from "pureimage";
// import { Bitmap } from "pureimage/types/bitmap";
// import { Readable } from "stream";
// import { MapData, UrlResult, UrlUsageType } from "./map.data";
//
// export const mapDataMapy: MapData = {
// name: "Mapy",
//
// urlProvider: async (usageType: UrlUsageType, mapType: string, zoomLevel: number, row: number, col: number): Promise<UrlResult> => {
// const sourceType = mapType === "Street" ? "base-en" : "bing";
// return { url: `https://mapserver.mapy.cz/${sourceType}/${zoomLevel + 7}-${col}-${row}` };
// },
//
// getDownloaderHeaders: () => {
// return {
// headers: {
// referer: "https://en.mapy.cz/",
// },
// };
// },
//
// zoomLevelProvider: (zoomLevel: number): string => {
// return zoomLevel.toString();
// },
//
// zoomFactorProvider: (zoomLevel: number, zoomIn: boolean): number => {
// return 2;
// },
//
// decode: async (mapType: string, buffer: Buffer): Promise<Bitmap> => {
// return await (mapType === "Street" ? pimage.decodePNGFromStream(Readable.from(buffer)) : pimage.decodeJPEGFromStream(Readable.from(buffer)));
// },
//
// supportedMapTypes: ["Satellite", "Street"],
//
// showScale: false,
//
// referer: "https://en.mapy.cz/",
//
// zoomLayers: [
// {
// scale: 1,
// centerTileX: 76,
// centerTileY: 51,
// centerTileOffsetX: 94,
// centerTileOffsetY: 241,
// },
// {
// scale: 2,
// centerTileX: 152,
// centerTileY: 103,
// centerTileOffsetX: 201,
// centerTileOffsetY: 178,
// },
// {
// scale: 3,
// centerTileX: 305,
// centerTileY: 207,
// centerTileOffsetX: 121,
// centerTileOffsetY: 196,
// },
// {
// scale: 4,
// centerTileX: 610,
// centerTileY: 415,
// centerTileOffsetX: 241,
// centerTileOffsetY: 136,
// },
// {
// scale: 5,
// centerTileX: 1221,
// centerTileY: 831,
// centerTileOffsetX: 235,
// centerTileOffsetY: 19,
// },
// {
// scale: 6,
// centerTileX: 2443,
// centerTileY: 1662,
// centerTileOffsetX: 212,
// centerTileOffsetY: 49,
// },
// {
// scale: 7,
// centerTileX: 4887,
// centerTileY: 3324,
// centerTileOffsetX: 169,
// centerTileOffsetY: 98,
// },
// {
// scale: 8,
// centerTileX: 9775,
// centerTileY: 6648,
// centerTileOffsetX: 82,
// centerTileOffsetY: 197,
// },
// {
// scale: 9,
// centerTileX: 19550,
// centerTileY: 13297,
// centerTileOffsetX: 164,
// centerTileOffsetY: 140,
// },
// {
// scale: 10,
// centerTileX: 39101,
// centerTileY: 26595,
// centerTileOffsetX: 73,
// centerTileOffsetY: 24,
// },
// {
// scale: 11,
// centerTileX: 78202,
// centerTileY: 53190,
// centerTileOffsetX: 191,
// centerTileOffsetY: 12,
// },
// {
// scale: 12,
// centerTileX: 156405,
// centerTileY: 106380,
// centerTileOffsetX: 38,
// centerTileOffsetY: 99,
// },
// {
// scale: 13,
// centerTileX: 312810,
// centerTileY: 212760,
// centerTileOffsetX: 70,
// centerTileOffsetY: 212,
// },
// ],
// };
import { MapData, UrlResult, UrlUsageType } from './map.data'

export const mapDataMapy: MapData = {
name: 'Mapy',

urlProvider: async (_usageType: UrlUsageType, mapType: string, zoomLevel: number, row: number, col: number): Promise<UrlResult> => {
const sourceType = mapType === 'Street' ? 'base-en' : 'bing'
return { url: `https://mapserver.mapy.cz/${sourceType}/${zoomLevel + 7}-${col}-${row}` }
},

zoomLevelProvider: (zoomLevel: number): string => {
return zoomLevel.toString()
},

zoomFactorProvider: (_zoomLevel: number, _zoomIn: boolean): number => {
return 2
},

supportedMapTypes: ['Satellite', 'Street'],

showScale: false,

referer: 'https://en.mapy.cz/',

zoomLayers: [
{
scale: 1,
centerTileX: 76,
centerTileY: 51,
centerTileOffsetX: 94,
centerTileOffsetY: 241
},
{
scale: 2,
centerTileX: 152,
centerTileY: 103,
centerTileOffsetX: 201,
centerTileOffsetY: 178
},
{
scale: 3,
centerTileX: 305,
centerTileY: 207,
centerTileOffsetX: 121,
centerTileOffsetY: 196
},
{
scale: 4,
centerTileX: 610,
centerTileY: 415,
centerTileOffsetX: 241,
centerTileOffsetY: 136
},
{
scale: 5,
centerTileX: 1221,
centerTileY: 831,
centerTileOffsetX: 235,
centerTileOffsetY: 19
},
{
scale: 6,
centerTileX: 2443,
centerTileY: 1662,
centerTileOffsetX: 212,
centerTileOffsetY: 49
},
{
scale: 7,
centerTileX: 4887,
centerTileY: 3324,
centerTileOffsetX: 169,
centerTileOffsetY: 98
},
{
scale: 8,
centerTileX: 9775,
centerTileY: 6648,
centerTileOffsetX: 82,
centerTileOffsetY: 197
},
{
scale: 9,
centerTileX: 19550,
centerTileY: 13297,
centerTileOffsetX: 164,
centerTileOffsetY: 140
},
{
scale: 10,
centerTileX: 39101,
centerTileY: 26595,
centerTileOffsetX: 73,
centerTileOffsetY: 24
},
{
scale: 11,
centerTileX: 78202,
centerTileY: 53190,
centerTileOffsetX: 191,
centerTileOffsetY: 12
},
{
scale: 12,
centerTileX: 156405,
centerTileY: 106380,
centerTileOffsetX: 38,
centerTileOffsetY: 99
},
{
scale: 13,
centerTileX: 312810,
centerTileY: 212760,
centerTileOffsetX: 70,
centerTileOffsetY: 212
}
]
}
5 changes: 3 additions & 2 deletions src/main/maps/map-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { mapBackendDataHaifa } from './haifa.backend'
import { mapBackendDataNetanya } from './netanya.backend'
import { mapBackendHodHasharon } from './hod-hasharon.backend'
import { mapBackendGalilTahton } from './galil-tahton.backend'
import { mapBackendMapy } from './mapy.backend'

export type MapBackendData = {
name: string
Expand All @@ -17,8 +18,8 @@ const mapBackend = [
mapBackendTelAviv,
mapBackendDataHaifa,
mapBackendHodHasharon,
mapBackendDataNetanya
// mapDataMapy
mapBackendDataNetanya,
mapBackendMapy
]

export function getBackendData(mapName: string) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/maps/mapy.backend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as pimage from 'pureimage'
import { Bitmap } from 'pureimage'
import { Readable } from 'stream'
import { MapBackendData } from './map-backend'

export const mapBackendMapy: MapBackendData = {
name: 'Mapy',

decode: async (mapType: string, buffer: Buffer): Promise<Bitmap> => {
return await (mapType === 'Street' ? pimage.decodePNGFromStream(Readable.from(buffer)) : pimage.decodeJPEGFromStream(Readable.from(buffer)))
}
}

0 comments on commit ecdd309

Please sign in to comment.