xref: /webtrees/app/Gedcom.php (revision b6017f990d38d8c56e04c0096ce9a7e8745ad4ba)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2021 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees;
21
22/**
23 * GEDCOM 5.5.1 specification
24 */
25class Gedcom
26{
27    // Use MSDOS style line endings, for maximum compatibility.
28    public const EOL = "\r\n";
29
30    // 255 less the EOL character.
31    public const LINE_LENGTH = 253;
32
33    // Gedcom tags which indicate the start of life.
34    public const BIRTH_EVENTS = ['BIRT', 'CHR', 'BAPM', 'ADOP'];
35
36    // Gedcom tags which indicate the end of life.
37    public const DEATH_EVENTS = ['DEAT', 'BURI', 'CREM'];
38
39    // Gedcom tags which indicate the start of a relationship.
40    public const MARRIAGE_EVENTS = ['MARR', '_NMR'];
41
42    // Gedcom tags which indicate the end of a relationship.
43    public const DIVORCE_EVENTS = ['DIV', 'ANUL', '_SEPR'];
44
45    // Regular expression to match a GEDCOM tag.
46    public const REGEX_TAG = '[_A-Z][_A-Z0-9]*';
47
48    // Regular expression to match a GEDCOM XREF.
49    public const REGEX_XREF = '[A-Za-z0-9:_.-]{1,20}';
50
51    // UTF-8 encoded files may begin with an optional byte-order-mark (U+FEFF).
52    public const UTF8_BOM = "\xEF\xBB\xBF";
53
54    // Separates parts of a place name.
55    public const PLACE_SEPARATOR = ', ';
56
57    // Regex to match a (badly formed) GEDCOM place separator.
58    public const PLACE_SEPARATOR_REGEX = '/ *,[, ]*/';
59
60    // LATI and LONG tags
61    public const LATITUDE_NORTH = 'N';
62    public const LATITUDE_SOUTH = 'S';
63    public const LONGITUDE_EAST = 'E';
64    public const LONGITUDE_WEST = 'W';
65
66    // Not all record types allow a CHAN event.
67    public const RECORDS_WITH_CHAN = [
68        Family::RECORD_TYPE,
69        Individual::RECORD_TYPE,
70        Media::RECORD_TYPE,
71        Note::RECORD_TYPE,
72        Repository::RECORD_TYPE,
73        Source::RECORD_TYPE,
74        Submitter::RECORD_TYPE,
75    ];
76}
77