1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm.pbf;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.data.osm.BBox;
|
---|
5 |
|
---|
6 | import jakarta.annotation.Nonnull;
|
---|
7 | import jakarta.annotation.Nullable;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * The header block contains data on required features, optional features, the bbox of the data, the source, the osmosis replication timestamp,
|
---|
11 | * the osmosis replication sequence number, and the osmosis replication base url
|
---|
12 | * @since 18695
|
---|
13 | */
|
---|
14 | public final class HeaderBlock {
|
---|
15 | private final BBox bbox;
|
---|
16 | private final String[] requiredFeatures;
|
---|
17 | private final String[] optionalFeatures;
|
---|
18 | private final String writingProgram;
|
---|
19 | private final String source;
|
---|
20 | private final Long osmosisReplicationTimestamp;
|
---|
21 | private final Long osmosisReplicationSequenceNumber;
|
---|
22 | private final String osmosisReplicationBaseUrl;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Create a new {@link HeaderBlock} for an OSM PBF file
|
---|
26 | * @param bbox The bbox
|
---|
27 | * @param requiredFeatures The required features
|
---|
28 | * @param optionalFeatures The optional features
|
---|
29 | * @param writingProgram The program used to write the file
|
---|
30 | * @param source The source
|
---|
31 | * @param osmosisReplicationTimestamp The last time that osmosis updated the source (in seconds since epoch)
|
---|
32 | * @param osmosisReplicationSequenceNumber The replication sequence number
|
---|
33 | * @param osmosisReplicationBaseUrl The replication base url
|
---|
34 | */
|
---|
35 | public HeaderBlock(@Nullable BBox bbox, @Nonnull String[] requiredFeatures, @Nonnull String[] optionalFeatures,
|
---|
36 | @Nullable String writingProgram, @Nullable String source, @Nullable Long osmosisReplicationTimestamp,
|
---|
37 | @Nullable Long osmosisReplicationSequenceNumber, @Nullable String osmosisReplicationBaseUrl) {
|
---|
38 | this.bbox = bbox;
|
---|
39 | this.requiredFeatures = requiredFeatures;
|
---|
40 | this.optionalFeatures = optionalFeatures;
|
---|
41 | this.writingProgram = writingProgram;
|
---|
42 | this.source = source;
|
---|
43 | this.osmosisReplicationTimestamp = osmosisReplicationTimestamp;
|
---|
44 | this.osmosisReplicationSequenceNumber = osmosisReplicationSequenceNumber;
|
---|
45 | this.osmosisReplicationBaseUrl = osmosisReplicationBaseUrl;
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * The required features to parse the PBF
|
---|
50 | * @return The required features
|
---|
51 | */
|
---|
52 | @Nonnull
|
---|
53 | public String[] requiredFeatures() {
|
---|
54 | return this.requiredFeatures.clone();
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * The optional features to parse the PBF
|
---|
59 | * @return The optional features
|
---|
60 | */
|
---|
61 | @Nonnull
|
---|
62 | public String[] optionalFeatures() {
|
---|
63 | return this.optionalFeatures.clone();
|
---|
64 | }
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Get the program used to write the PBF
|
---|
68 | * @return The program that wrote the PBF
|
---|
69 | */
|
---|
70 | @Nullable
|
---|
71 | public String writingProgram() {
|
---|
72 | return this.writingProgram;
|
---|
73 | }
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * The source
|
---|
77 | * @return The source (same as bbox field from OSM)
|
---|
78 | */
|
---|
79 | @Nullable
|
---|
80 | public String source() {
|
---|
81 | return this.source;
|
---|
82 | }
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * The replication timestamp
|
---|
86 | * @return The time that the file was last updated
|
---|
87 | */
|
---|
88 | @Nullable
|
---|
89 | public Long osmosisReplicationTimestamp() {
|
---|
90 | return this.osmosisReplicationTimestamp;
|
---|
91 | }
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * The replication sequence number
|
---|
95 | * @return The sequence number
|
---|
96 | */
|
---|
97 | @Nullable
|
---|
98 | public Long osmosisReplicationSequenceNumber() {
|
---|
99 | return this.osmosisReplicationSequenceNumber;
|
---|
100 | }
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * The replication base URL
|
---|
104 | * @return the base url for replication, if we ever want/need to continue the replication
|
---|
105 | */
|
---|
106 | @Nullable
|
---|
107 | public String osmosisReplicationBaseUrl() {
|
---|
108 | return this.osmosisReplicationBaseUrl;
|
---|
109 | }
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * The bbox
|
---|
113 | * @return The bbox
|
---|
114 | */
|
---|
115 | @Nullable
|
---|
116 | public BBox bbox() {
|
---|
117 | return this.bbox;
|
---|
118 | }
|
---|
119 | }
|
---|