text-to-map 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +20 -0
- package/dist/bin/address-points-import-only.d.ts +1 -0
- package/dist/bin/address-points-import-only.js +14 -0
- package/dist/bin/address-points.d.ts +1 -0
- package/dist/bin/address-points.js +14 -0
- package/dist/bin/clear-all.d.ts +1 -0
- package/dist/bin/clear-all.js +5 -0
- package/dist/bin/generate-syntax-diagrams.d.ts +1 -0
- package/dist/bin/generate-syntax-diagrams.js +19 -0
- package/dist/bin/parse-ordinance.d.ts +1 -0
- package/dist/bin/parse-ordinance.js +20 -0
- package/dist/bin/schools.d.ts +1 -0
- package/dist/bin/schools.js +8 -0
- package/dist/bin/streets.d.ts +1 -0
- package/dist/bin/streets.js +14 -0
- package/dist/db/address-points.d.ts +38 -0
- package/dist/db/address-points.js +312 -0
- package/dist/db/db.d.ts +23 -0
- package/dist/db/db.js +90 -0
- package/dist/db/founders.d.ts +9 -0
- package/dist/db/founders.js +191 -0
- package/dist/db/meta.d.ts +3 -0
- package/dist/db/meta.js +17 -0
- package/dist/db/schools.d.ts +6 -0
- package/dist/db/schools.js +61 -0
- package/dist/db/street-sync.d.ts +5 -0
- package/dist/db/street-sync.js +18 -0
- package/dist/db/types.d.ts +34 -0
- package/dist/db/types.js +12 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/open-data-sync/address-points.d.ts +4 -0
- package/dist/open-data-sync/address-points.js +73 -0
- package/dist/open-data-sync/schools.d.ts +3 -0
- package/dist/open-data-sync/schools.js +308 -0
- package/dist/open-data-sync/streets.d.ts +2 -0
- package/dist/open-data-sync/streets.js +77 -0
- package/dist/smd-to-csv/json-to-csv.d.ts +1 -0
- package/dist/smd-to-csv/json-to-csv.js +153 -0
- package/dist/smd-to-csv/ordinance-to-csv-rules.d.ts +1 -0
- package/dist/smd-to-csv/ordinance-to-csv-rules.js +31 -0
- package/dist/smd-to-csv/txt-to-json.d.ts +1 -0
- package/dist/smd-to-csv/txt-to-json.js +102 -0
- package/dist/street-markdown/municipality.d.ts +5 -0
- package/dist/street-markdown/municipality.js +44 -0
- package/dist/street-markdown/roman-numerals.d.ts +1 -0
- package/dist/street-markdown/roman-numerals.js +67 -0
- package/dist/street-markdown/smd-line-parser.d.ts +4 -0
- package/dist/street-markdown/smd-line-parser.js +29 -0
- package/dist/street-markdown/smd-parser.d.ts +21 -0
- package/dist/street-markdown/smd-parser.js +343 -0
- package/dist/street-markdown/smd.d.ts +9 -0
- package/dist/street-markdown/smd.js +182 -0
- package/dist/street-markdown/token-definition.d.ts +23 -0
- package/dist/street-markdown/token-definition.js +154 -0
- package/dist/street-markdown/types.d.ts +83 -0
- package/dist/street-markdown/types.js +18 -0
- package/dist/utils/addressBuilder.d.ts +8 -0
- package/dist/utils/addressBuilder.js +101 -0
- package/dist/utils/atom.d.ts +2 -0
- package/dist/utils/atom.js +65 -0
- package/dist/utils/helpers.d.ts +34 -0
- package/dist/utils/helpers.js +157 -0
- package/package.json +82 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DbMunicipalityResult } from "./types";
|
|
2
|
+
export declare const isMunicipalitySwitch: (line: string) => boolean;
|
|
3
|
+
export declare const getSwitchMunicipality: (line: string) => DbMunicipalityResult;
|
|
4
|
+
export declare const isWholeMunicipality: (line: string) => boolean;
|
|
5
|
+
export declare const getWholeMunicipality: (line: string) => DbMunicipalityResult;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { findMunicipalityByNameAndType } from "../db/founders";
|
|
2
|
+
import { MunicipalityType } from "../db/types";
|
|
3
|
+
const municipalitySwitchPattern = /^navíc ulice (z )?(?<type>městské části|městského obvodu|obce|města) (?<name>.+):$/;
|
|
4
|
+
const wholeMunicipalityPattern = /^území (?<type>městské části|městského obvodu|obce|města) (?<name>.+)$/;
|
|
5
|
+
export const isMunicipalitySwitch = (line) => {
|
|
6
|
+
return municipalitySwitchPattern.test(line);
|
|
7
|
+
};
|
|
8
|
+
export const getSwitchMunicipality = (line) => {
|
|
9
|
+
const match = municipalitySwitchPattern.exec(line);
|
|
10
|
+
if (match === null) {
|
|
11
|
+
throw new Error("Invalid municipality switch line");
|
|
12
|
+
}
|
|
13
|
+
const { type, name } = match.groups;
|
|
14
|
+
return getMunicipalityResult(type, name);
|
|
15
|
+
};
|
|
16
|
+
export const isWholeMunicipality = (line) => {
|
|
17
|
+
return wholeMunicipalityPattern.test(line);
|
|
18
|
+
};
|
|
19
|
+
export const getWholeMunicipality = (line) => {
|
|
20
|
+
const match = wholeMunicipalityPattern.exec(line);
|
|
21
|
+
if (match === null) {
|
|
22
|
+
return { errors: ["Invalid whole municipality line"], municipality: null };
|
|
23
|
+
}
|
|
24
|
+
const { type, name } = match.groups;
|
|
25
|
+
return getMunicipalityResult(type, name);
|
|
26
|
+
};
|
|
27
|
+
const getMunicipalityResult = (type, name) => {
|
|
28
|
+
const typeValue = getMunicipalityType(type);
|
|
29
|
+
const { municipality, errors } = findMunicipalityByNameAndType(name, typeValue);
|
|
30
|
+
return {
|
|
31
|
+
municipality,
|
|
32
|
+
errors,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const getMunicipalityType = (type) => {
|
|
36
|
+
switch (type) {
|
|
37
|
+
case "městské části":
|
|
38
|
+
case "městského obvodu":
|
|
39
|
+
return MunicipalityType.District;
|
|
40
|
+
case "obce":
|
|
41
|
+
case "města":
|
|
42
|
+
return MunicipalityType.City;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const splitStreetViaRomanNumerals: (input: string) => string[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
let romanNumerals;
|
|
2
|
+
const singleRomanNumeralPattern = /X{1,3}(IX|IV|V?I{0,3})|(IX|IV|VI{0,3})|(I{1,3})/g;
|
|
3
|
+
const romanNumeralsListPattern = /(X{1,3}(IX|IV|V?I{0,3})|(IX|IV|VI{0,3})|(I{1,3}))(, ?(X{1,3}(IX|IV|V?I{0,3})|(IX|IV|VI{0,3})|(I{1,3})))+$/;
|
|
4
|
+
const romanNumeralsRangePattern = /([IVXLCDM]+) ?- ?([IVXLCDM]+)$/;
|
|
5
|
+
export const splitStreetViaRomanNumerals = (input) => {
|
|
6
|
+
const list = romanNumeralsListPattern.exec(input);
|
|
7
|
+
if (list) {
|
|
8
|
+
const streetName = input.substring(0, input.indexOf(list[0])).trim();
|
|
9
|
+
return extractRomanNumerals(list[0]).map((numeral) => `${streetName} ${numeral}`);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
const range = romanNumeralsRangePattern.exec(input);
|
|
13
|
+
if (range) {
|
|
14
|
+
const streetName = input.substring(0, input.indexOf(range[0])).trim();
|
|
15
|
+
const bounds = extractRomanNumerals(range[0]);
|
|
16
|
+
if (!romanNumerals) {
|
|
17
|
+
romanNumerals = generateRomanNumerals(100);
|
|
18
|
+
}
|
|
19
|
+
return romanNumerals
|
|
20
|
+
.slice(romanNumerals.indexOf(bounds[0]), romanNumerals.indexOf(bounds[1]) + 1)
|
|
21
|
+
.map((numeral) => `${streetName} ${numeral}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return [input];
|
|
25
|
+
};
|
|
26
|
+
const extractRomanNumerals = (input) => {
|
|
27
|
+
let n;
|
|
28
|
+
const numerals = [];
|
|
29
|
+
do {
|
|
30
|
+
n = singleRomanNumeralPattern.exec(input);
|
|
31
|
+
if (n) {
|
|
32
|
+
numerals.push(n[0]);
|
|
33
|
+
}
|
|
34
|
+
} while (n);
|
|
35
|
+
return numerals;
|
|
36
|
+
};
|
|
37
|
+
// source: ChatGPT
|
|
38
|
+
const generateRomanNumerals = (n) => {
|
|
39
|
+
const romanNumerals = [];
|
|
40
|
+
const romanNumeralsMap = new Map([
|
|
41
|
+
[1000, "M"],
|
|
42
|
+
[900, "CM"],
|
|
43
|
+
[500, "D"],
|
|
44
|
+
[400, "CD"],
|
|
45
|
+
[100, "C"],
|
|
46
|
+
[90, "XC"],
|
|
47
|
+
[50, "L"],
|
|
48
|
+
[40, "XL"],
|
|
49
|
+
[10, "X"],
|
|
50
|
+
[9, "IX"],
|
|
51
|
+
[5, "V"],
|
|
52
|
+
[4, "IV"],
|
|
53
|
+
[1, "I"],
|
|
54
|
+
]);
|
|
55
|
+
for (let i = 1; i <= n; i++) {
|
|
56
|
+
let number = i;
|
|
57
|
+
let romanNumeral = "";
|
|
58
|
+
for (const [value, symbol] of romanNumeralsMap) {
|
|
59
|
+
while (number >= value) {
|
|
60
|
+
number -= value;
|
|
61
|
+
romanNumeral += symbol;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
romanNumerals.push(romanNumeral);
|
|
65
|
+
}
|
|
66
|
+
return romanNumerals;
|
|
67
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Lexer } from "chevrotain";
|
|
2
|
+
import { SmdParser } from "./smd-parser";
|
|
3
|
+
// const token_definition = require("token_definition");
|
|
4
|
+
import { tokenVocabulary, smdTokens, resetTokenState, prepareLine, } from "./token-definition";
|
|
5
|
+
const printLexingResultInfo = (lexingResult) => {
|
|
6
|
+
// console.error(JSON.stringify(lexingResult, null, "\t"));
|
|
7
|
+
const tokens = lexingResult.tokens.map((token) => "'" + token.image + "' (" + token.tokenType.name + ")");
|
|
8
|
+
console.error(tokens);
|
|
9
|
+
};
|
|
10
|
+
const smdLexer = new Lexer(smdTokens, { positionTracking: "onlyOffset" });
|
|
11
|
+
export const smdParser = new SmdParser(tokenVocabulary);
|
|
12
|
+
export const parseLine = (text) => {
|
|
13
|
+
resetTokenState(); // this is needed to reset the token state between lines
|
|
14
|
+
const errors = [];
|
|
15
|
+
const lexingResult = smdLexer.tokenize(prepareLine(text));
|
|
16
|
+
if (lexingResult.errors.length > 0) {
|
|
17
|
+
errors.push(...lexingResult.errors.map((error) => error.message));
|
|
18
|
+
printLexingResultInfo(lexingResult);
|
|
19
|
+
return { smdLines: [], errors };
|
|
20
|
+
}
|
|
21
|
+
// printLexingResultInfo(lexingResult);
|
|
22
|
+
smdParser.input = lexingResult.tokens;
|
|
23
|
+
const smdLines = smdParser.street();
|
|
24
|
+
if (smdParser.errors.length > 0) {
|
|
25
|
+
errors.push(...smdParser.errors.map((error) => error.message));
|
|
26
|
+
printLexingResultInfo(lexingResult);
|
|
27
|
+
}
|
|
28
|
+
return { smdLines, errors };
|
|
29
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EmbeddedActionsParser, TokenVocabulary } from "chevrotain";
|
|
2
|
+
import { RichNumber, SmdLine } from "./types";
|
|
3
|
+
export declare class SmdParser extends EmbeddedActionsParser {
|
|
4
|
+
constructor(tokenVocabulary: TokenVocabulary);
|
|
5
|
+
street: import("chevrotain").ParserMethod<[], SmdLine[]>;
|
|
6
|
+
private streetNameAndNumbersSpecs;
|
|
7
|
+
private numberSpecs;
|
|
8
|
+
private seriesSpecs;
|
|
9
|
+
private _gatePostfixTypeSeriesSpec;
|
|
10
|
+
private postfixTypeSeriesSpec;
|
|
11
|
+
private rangeList;
|
|
12
|
+
private seriesType;
|
|
13
|
+
private rangeOrNumber;
|
|
14
|
+
private range;
|
|
15
|
+
private fromAndAbove;
|
|
16
|
+
private fromAndAboveWithType;
|
|
17
|
+
private toOrBelow;
|
|
18
|
+
private toOrBelowWithType;
|
|
19
|
+
private fullStreetNumber;
|
|
20
|
+
}
|
|
21
|
+
export declare const parseRichNumber: (number: string) => RichNumber;
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { EmbeddedActionsParser, EOF } from "chevrotain";
|
|
2
|
+
import { splitStreetViaRomanNumerals } from "./roman-numerals";
|
|
3
|
+
import { MainSeparator, Separator, OddType, EvenType, DescriptiveType, AllType, Number, Hyphen, StreetName, From, To, AndAbove, AndBelow, Slash, Without, } from "./token-definition";
|
|
4
|
+
import { SeriesType } from "./types";
|
|
5
|
+
export class SmdParser extends EmbeddedActionsParser {
|
|
6
|
+
constructor(tokenVocabulary) {
|
|
7
|
+
super(tokenVocabulary);
|
|
8
|
+
this.street = this.RULE("street", () => {
|
|
9
|
+
let result;
|
|
10
|
+
this.OR([
|
|
11
|
+
{
|
|
12
|
+
ALT: () => {
|
|
13
|
+
result = this.SUBRULE(this.streetNameAndNumbersSpecs);
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
ALT: () => {
|
|
18
|
+
result = { street: this.CONSUME(StreetName).image, numberSpec: [] };
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
return splitStreetViaRomanNumerals(result.street).map((street) => ({
|
|
23
|
+
street,
|
|
24
|
+
numberSpec: result.numberSpec,
|
|
25
|
+
}));
|
|
26
|
+
});
|
|
27
|
+
this.streetNameAndNumbersSpecs = this.RULE("streetNameAndNumbersSpecs", () => {
|
|
28
|
+
const street = this.CONSUME(StreetName).image;
|
|
29
|
+
this.OPTION(() => {
|
|
30
|
+
this.CONSUME(MainSeparator);
|
|
31
|
+
});
|
|
32
|
+
const numberSpec = this.SUBRULE(this.numberSpecs);
|
|
33
|
+
return { street, numberSpec };
|
|
34
|
+
});
|
|
35
|
+
this.numberSpecs = this.RULE("numberSpecs", () => {
|
|
36
|
+
const result = [];
|
|
37
|
+
this.OR([
|
|
38
|
+
{
|
|
39
|
+
GATE: () => this.LA(2).tokenType === Without,
|
|
40
|
+
ALT: () => {
|
|
41
|
+
const type = this.SUBRULE(this.seriesType);
|
|
42
|
+
this.CONSUME(Without);
|
|
43
|
+
this.OPTION(() => {
|
|
44
|
+
this.CONSUME(AllType);
|
|
45
|
+
});
|
|
46
|
+
const ranges = this.SUBRULE(this.rangeList);
|
|
47
|
+
return { negative: true, type, ranges };
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
ALT: () => {
|
|
52
|
+
this.CONSUME2(Without);
|
|
53
|
+
this.OR1([
|
|
54
|
+
{
|
|
55
|
+
GATE: this._gatePostfixTypeSeriesSpec,
|
|
56
|
+
ALT: () => {
|
|
57
|
+
const { type, ranges } = this.SUBRULE(this.postfixTypeSeriesSpec);
|
|
58
|
+
return { negative: true, type, ranges };
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
ALT: () => {
|
|
63
|
+
const type = this.SUBRULE2(this.seriesType);
|
|
64
|
+
const ranges = this.SUBRULE2(this.rangeList);
|
|
65
|
+
return { negative: true, type, ranges };
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
ALT: () => {
|
|
73
|
+
this.AT_LEAST_ONE_SEP({
|
|
74
|
+
SEP: Separator,
|
|
75
|
+
DEF: () => {
|
|
76
|
+
result.push(this.SUBRULE(this.seriesSpecs));
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
]);
|
|
82
|
+
return result;
|
|
83
|
+
});
|
|
84
|
+
this.seriesSpecs = this.RULE("seriesSpecs", () => {
|
|
85
|
+
let ranges = [];
|
|
86
|
+
let type;
|
|
87
|
+
this.OR([
|
|
88
|
+
{
|
|
89
|
+
GATE: this._gatePostfixTypeSeriesSpec,
|
|
90
|
+
ALT: () => {
|
|
91
|
+
({ type, ranges } = this.SUBRULE(this.postfixTypeSeriesSpec));
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
ALT: () => {
|
|
96
|
+
type = this.SUBRULE(this.seriesType);
|
|
97
|
+
this.OPTION(() => {
|
|
98
|
+
ranges = this.SUBRULE(this.rangeList);
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
ALT: () => {
|
|
104
|
+
({ type, ranges } = this.SUBRULE2(this.fromAndAboveWithType));
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
ALT: () => {
|
|
109
|
+
({ type, ranges } = this.SUBRULE(this.toOrBelowWithType));
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
]);
|
|
113
|
+
return { type, ranges };
|
|
114
|
+
});
|
|
115
|
+
this._gatePostfixTypeSeriesSpec = () => {
|
|
116
|
+
let index = 2;
|
|
117
|
+
while (![Separator, EOF].includes(this.LA(index).tokenType)) {
|
|
118
|
+
if ([OddType, EvenType].includes(this.LA(index).tokenType)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
index++;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
};
|
|
125
|
+
this.postfixTypeSeriesSpec = this.RULE("postfixTypeSeriesSpec", () => {
|
|
126
|
+
this.CONSUME(AllType);
|
|
127
|
+
const ranges = [this.SUBRULE(this.rangeOrNumber)];
|
|
128
|
+
let type;
|
|
129
|
+
this.OR1([
|
|
130
|
+
{
|
|
131
|
+
ALT: () => {
|
|
132
|
+
this.CONSUME(OddType);
|
|
133
|
+
type = SeriesType.Odd;
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
ALT: () => {
|
|
138
|
+
this.CONSUME1(EvenType);
|
|
139
|
+
type = SeriesType.Even;
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
]);
|
|
143
|
+
return { type, ranges };
|
|
144
|
+
});
|
|
145
|
+
this.rangeList = this.RULE("rangeList", () => {
|
|
146
|
+
let ranges = [];
|
|
147
|
+
ranges.push(this.SUBRULE(this.rangeOrNumber));
|
|
148
|
+
this.MANY({
|
|
149
|
+
GATE: () => [Number, To, From].includes(this.LA(2).tokenType),
|
|
150
|
+
DEF: () => {
|
|
151
|
+
this.CONSUME(Separator);
|
|
152
|
+
ranges.push(this.SUBRULE2(this.rangeOrNumber));
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
return ranges;
|
|
156
|
+
});
|
|
157
|
+
this.seriesType = this.RULE("seriesType", () => {
|
|
158
|
+
let type;
|
|
159
|
+
this.OR([
|
|
160
|
+
{
|
|
161
|
+
ALT: () => {
|
|
162
|
+
this.CONSUME(OddType);
|
|
163
|
+
type = SeriesType.Odd;
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
ALT: () => {
|
|
168
|
+
this.CONSUME1(EvenType);
|
|
169
|
+
type = SeriesType.Even;
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
ALT: () => {
|
|
174
|
+
this.CONSUME2(AllType);
|
|
175
|
+
type = SeriesType.All;
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
ALT: () => {
|
|
180
|
+
this.CONSUME3(DescriptiveType);
|
|
181
|
+
type = SeriesType.Descriptive;
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
]);
|
|
185
|
+
return type;
|
|
186
|
+
});
|
|
187
|
+
this.rangeOrNumber = this.RULE("rangeOrNumber", () => {
|
|
188
|
+
let result;
|
|
189
|
+
this.OR([
|
|
190
|
+
{
|
|
191
|
+
ALT: () => {
|
|
192
|
+
result = this.SUBRULE(this.range);
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
ALT: () => {
|
|
197
|
+
result = this.SUBRULE(this.fromAndAbove);
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
ALT: () => {
|
|
202
|
+
result = this.SUBRULE(this.toOrBelow);
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
ALT: () => {
|
|
207
|
+
result = this.SUBRULE(this.fullStreetNumber);
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
ALT: () => {
|
|
212
|
+
const n = parseRichNumber(this.CONSUME(Number).image);
|
|
213
|
+
result = { from: n, to: n };
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
]);
|
|
217
|
+
return result;
|
|
218
|
+
});
|
|
219
|
+
this.range = this.RULE("range", () => {
|
|
220
|
+
const from = parseRichNumber(this.CONSUME(Number).image);
|
|
221
|
+
this.OR([
|
|
222
|
+
{ ALT: () => this.CONSUME1(Hyphen) },
|
|
223
|
+
{ ALT: () => this.CONSUME2(MainSeparator) },
|
|
224
|
+
]);
|
|
225
|
+
this.OPTION(() => {
|
|
226
|
+
this.CONSUME(AllType);
|
|
227
|
+
});
|
|
228
|
+
const to = parseRichNumber(this.CONSUME3(Number).image);
|
|
229
|
+
return { from, to };
|
|
230
|
+
});
|
|
231
|
+
this.fromAndAbove = this.RULE("fromAndAbove", () => {
|
|
232
|
+
let from;
|
|
233
|
+
this.OR([
|
|
234
|
+
{
|
|
235
|
+
ALT: () => {
|
|
236
|
+
from = parseRichNumber(this.CONSUME(Number).image);
|
|
237
|
+
this.CONSUME(AndAbove);
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
ALT: () => {
|
|
242
|
+
this.CONSUME(From);
|
|
243
|
+
this.OPTION(() => {
|
|
244
|
+
this.CONSUME(AllType);
|
|
245
|
+
});
|
|
246
|
+
from = parseRichNumber(this.CONSUME2(Number).image);
|
|
247
|
+
this.OPTION2(() => {
|
|
248
|
+
this.CONSUME2(AndAbove);
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
]);
|
|
253
|
+
return { from };
|
|
254
|
+
});
|
|
255
|
+
this.fromAndAboveWithType = this.RULE("fromAndAboveWithType", () => {
|
|
256
|
+
let type = SeriesType.All;
|
|
257
|
+
this.CONSUME(From);
|
|
258
|
+
this.OPTION(() => {
|
|
259
|
+
this.OR([
|
|
260
|
+
{
|
|
261
|
+
ALT: () => {
|
|
262
|
+
type = SeriesType.All;
|
|
263
|
+
this.CONSUME(AllType);
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
ALT: () => {
|
|
268
|
+
type = SeriesType.Descriptive;
|
|
269
|
+
this.CONSUME(DescriptiveType);
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
]);
|
|
273
|
+
});
|
|
274
|
+
const from = parseRichNumber(this.CONSUME(Number).image);
|
|
275
|
+
this.OPTION2(() => {
|
|
276
|
+
this.CONSUME(AndAbove);
|
|
277
|
+
});
|
|
278
|
+
return { type, ranges: [{ from }] };
|
|
279
|
+
});
|
|
280
|
+
this.toOrBelow = this.RULE("toOrBelow", () => {
|
|
281
|
+
let to;
|
|
282
|
+
this.OR([
|
|
283
|
+
{
|
|
284
|
+
ALT: () => {
|
|
285
|
+
to = parseRichNumber(this.CONSUME(Number).image);
|
|
286
|
+
this.CONSUME(AndBelow);
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
ALT: () => {
|
|
291
|
+
this.CONSUME2(To);
|
|
292
|
+
to = parseRichNumber(this.CONSUME2(Number).image);
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
]);
|
|
296
|
+
return { to };
|
|
297
|
+
});
|
|
298
|
+
this.toOrBelowWithType = this.RULE("toOrBelowWithType", () => {
|
|
299
|
+
let type = SeriesType.All;
|
|
300
|
+
this.CONSUME(To);
|
|
301
|
+
this.OPTION(() => {
|
|
302
|
+
this.OR([
|
|
303
|
+
{
|
|
304
|
+
ALT: () => {
|
|
305
|
+
type = SeriesType.All;
|
|
306
|
+
this.CONSUME(AllType);
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
ALT: () => {
|
|
311
|
+
type = SeriesType.Descriptive;
|
|
312
|
+
this.CONSUME(DescriptiveType);
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
]);
|
|
316
|
+
});
|
|
317
|
+
const to = parseRichNumber(this.CONSUME(Number).image);
|
|
318
|
+
return { type, ranges: [{ to }] };
|
|
319
|
+
});
|
|
320
|
+
this.fullStreetNumber = this.RULE("fullStreetNumber", () => {
|
|
321
|
+
const descriptiveNumber = parseRichNumber(this.CONSUME(Number).image);
|
|
322
|
+
this.CONSUME(Slash);
|
|
323
|
+
const orientationNumber = parseRichNumber(this.CONSUME2(Number).image);
|
|
324
|
+
return { descriptiveNumber, orientationalNumber: orientationNumber };
|
|
325
|
+
});
|
|
326
|
+
this.performSelfAnalysis();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const numberWithCharacterPattern = /^(\d+)([a-z])$/;
|
|
330
|
+
export const parseRichNumber = (number) => {
|
|
331
|
+
if (numberWithCharacterPattern.test(number)) {
|
|
332
|
+
const match = numberWithCharacterPattern.exec(number);
|
|
333
|
+
return {
|
|
334
|
+
number: parseInt(match[1]),
|
|
335
|
+
letter: match[2],
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
return {
|
|
340
|
+
number: parseInt(number),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Founder } from "../db/types";
|
|
2
|
+
import { OpenDataSyncOptions } from "../utils/helpers";
|
|
3
|
+
import { Municipality } from "./types";
|
|
4
|
+
interface MunicipalityWithFounder extends Municipality {
|
|
5
|
+
founder: Founder | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const parseOrdinanceToAddressPoints: (lines: string[], options?: OpenDataSyncOptions) => Municipality[];
|
|
8
|
+
export declare const convertMunicipality: (municipality: MunicipalityWithFounder) => Municipality;
|
|
9
|
+
export {};
|