1st trim version

This commit is contained in:
zino
2021-04-29 13:13:22 +02:00
parent eb640a6fb5
commit a22728a802
5 changed files with 558 additions and 69 deletions

View File

@@ -1,4 +1,5 @@
import * as I from "../types/types";
import { state } from "../seatmap";
export function getSeats(inXML: any): I.JSCSeats {
const pricescaleArr: I.SeatmapPricescale[] = inXML.seatmap[0].pricescale_config[0].pricescale;
@@ -29,13 +30,84 @@ export function activateSeatsBySectionID(inXML: any, seatmap: any, inValue: stri
});
}
export function getRows(inXML: any): number[] {
export function getRowsNaming(inXML: any): string[] {
const layout: I.SeatmapLayout = inXML.seatmap[0].layouts[0].layout[0];
const height: number = parseInt(layout.height[0]);
// return Array.from({ length: height }, (_, i: number) => i + 1);
const namingArr = Array.from({ length: height }, (_) => "");
const rowsArr = layout.rows[0].row;
return Array.from({ length: height }, (_, i: number) => i + 1);
rowsArr.forEach(element => {
const index: number = parseInt(element.y_cell_coord[0]);
const seatsArr: string[] = element.seats[0].split("|");
const seatArr: string[] = splitSeatStr(seatsArr[0]);
const row = seatArr[4];
namingArr[index] = row;
});
return namingArr;
}
// export function getColumnNaming(inXML: any): string[] {
// const layout: I.SeatmapLayout = inXML.seatmap[0].layouts[0].layout[0];
// const width: number = parseInt(layout.width[0]);
// const namingArr = Array.from({ length: width }, (_) => "");
// const rowsArr = layout.rows[0].row;
// // let seats: number[] = [];
// // let x: number[] = [];
// rowsArr.forEach(element => {
// // const index: number = parseInt(element.y_cell_coord[0]);
// const seatsArr: string[] = element.seats[0].split("|");
// seatsArr.forEach(seatStr => {
// const seatArr: string[] = splitSeatStr(seatStr);
// // seats.push(parseInt(seatArr[5]));
// // x.push(parseInt(seatArr[2]));
// const x = parseInt(seatArr[2]);
// // Form:
// // 0: "568528" -> ID
// // 1: "568528" -> ID
// // 2: "21" -> X-Coord benutzen
// // 3: "7024" -> section ID
// // 4: "13" -> Reihenbezeichnung
// // 5: "4" -> Platznummer
// namingArr[x] = seatArr[5];
// });
// // const row = seatArr[4];
// // namingArr[index] = row;
// });
// // console.log(seats);
// // console.log(x);
// // console.log(Math.min.apply(Math, seats));
// // console.log(Math.max.apply(Math, seats));
// // console.log(Math.min.apply(Math, x));
// // console.log(Math.max.apply(Math, x));
// // const minimum = Math.min.apply(Math, seats);
// // let i = 0;
// // for (let index = Math.min.apply(Math, x); index < Math.max.apply(Math, x); index++) {
// // // const element = array[index];
// // namingArr[index] = (minimum + i).toString();
// // i++;
// // }
// console.log(namingArr);
// return namingArr;
// }
export function generateMap(inXML: any): string[] {
const layout: I.SeatmapLayout = inXML.seatmap[0].layouts[0].layout[0];
const rows: I.LayoutRow2[] = layout.rows[0].row;
@@ -58,11 +130,12 @@ export function generateLegend(inVenueXML: I.VenueXML, inSeatmapXML: any, inNode
items: []
}
// todo: dynamic function to get a pricescale property by id
for (let key in pricescaleArr) {
const id: string = pricescaleArr[key].id[0];
const seatsKey: string = String.fromCharCode(97 + parseInt(key)).toLocaleUpperCase();
// get pricescale desc from venueXML
// get pricescale desc from venueXML
const desc = venuePricescaleArr.find(obj => {
const pricecaleID = obj.id[0];
return pricecaleID === id;
@@ -118,7 +191,7 @@ function enterSeatsInMatrix(inRows: I.LayoutRow2[], inArrMatrix: string[][], inP
// 2: "21" -> X-Coord benutzen
// 3: "7024" -> section ID
// 4: "13" -> Reihenbezeichnung
// 5: "4" -> ?
// 5: "4" -> Platznummer
// skip blacked out seats
if (!availableArr.includes(seatArr[0]) && !unavailableArr.includes(seatArr[0]))
@@ -130,6 +203,9 @@ function enterSeatsInMatrix(inRows: I.LayoutRow2[], inArrMatrix: string[][], inP
if (seatsKey)
inArrMatrix[Y][X] = generateSeatStr(seatsKey, seatArr);
// save seatArr in state with seatID as key
state.layoutRows[seatArr[0]] = seatArr;
});
});