-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.ts
More file actions
44 lines (40 loc) · 1.84 KB
/
Copy pathdata.ts
File metadata and controls
44 lines (40 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (C) 2026, Stichting Mapcode Foundation (http://www.mapcode.com)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { DataModel } from "./data-model.js";
const DATA_MODEL = DataModel.getInstance();
export class Data {
static readonly ENCODE_CHARS = [
"0","1","2","3","4","5","6","7","8","9",
"B","C","D","F","G","H","J","K","L","M",
"N","P","Q","R","S","T","V","W","X","Y","Z",
"A","E","U",
];
static readonly TERRITORY_RECORD_TYPE_NONE = 0;
static readonly TERRITORY_RECORD_TYPE_PIPE = 1;
static readonly TERRITORY_RECORD_TYPE_PLUS = 2;
static readonly TERRITORY_RECORD_TYPE_STAR = 3;
static isNameless(r: number): boolean { return (DATA_MODEL.getDataFlags(r) & 64) !== 0; }
static isSpecialShape(r: number): boolean { return (DATA_MODEL.getDataFlags(r) & 1024) !== 0; }
static getTerritoryRecordType(r: number): number { return (DATA_MODEL.getDataFlags(r) >> 7) & 3; }
static isRestricted(r: number): boolean { return (DATA_MODEL.getDataFlags(r) & 512) !== 0; }
static getCodex(r: number): number {
const codexflags = DATA_MODEL.getDataFlags(r) & 31;
return 10 * Math.trunc(codexflags / 5) + (codexflags % 5) + 1;
}
static headerLetter(i: number): string {
const flags = DATA_MODEL.getDataFlags(i);
if (((flags >> 7) & 3) === 1) return Data.ENCODE_CHARS[(flags >> 11) & 31];
return "";
}
}