wsdp 0.1.0

Async high-level client for ČÚZK WSDP real-estate cadastre services
Documentation
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
use rust_decimal::Decimal;

use crate::model::{LegacyId, XmlDateTime};

/// Complete `CenoveUdajeDleNemovitosti` 1.05 report.
#[derive(Clone, Eq, PartialEq)]
pub struct PricesByPropertiesReport {
    /// Territorial groups from `KATASTRY/KATASTR`, in document order.
    pub cadastral_units: Vec<PriceCadastralUnit>,
    /// Uninterpreted `BEZPL_PRISTUP` text.
    pub free_access: String,
    /// Uninterpreted `PLATNOST` text; the legacy XSD declares it as `xs:string`.
    pub validity: String,
    /// Uninterpreted `VYHOTOVIL` text.
    pub prepared_by: String,
    /// Uninterpreted `INFO_VYSTUP` text.
    pub output_info: String,
    /// Uninterpreted `VYHOTOVENO` text; the legacy XSD declares it as `xs:string`.
    pub prepared_at: String,
}

/// One `KATASTR` territorial group in a prices-by-properties report.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceCadastralUnit {
    /// District information from `OKRES`.
    pub district: PriceDistrict,
    /// Municipality information from `OBEC`.
    pub municipality: PriceMunicipality,
    /// Cadastral-area information, absent when `KATUZE` is empty.
    pub cadastral_area: Option<PriceCadastralArea>,
    /// Properties from `NEMOVITOSTI/NEMOVITOST`.
    pub properties: Vec<PriceProperty>,
}

/// District details attached to a legacy price report.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceDistrict {
    /// Optional `nuts4` value, retained as text.
    pub nuts4: Option<String>,
    /// Optional district name.
    pub name: Option<String>,
}

/// Municipality details attached to a legacy price report.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceMunicipality {
    /// Numeric `OBEC/kod` (`xs:unsignedInt`).
    pub code: u32,
    /// Municipality name.
    pub name: String,
}

/// Cadastral-area details attached to a legacy price report.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceCadastralArea {
    /// Numeric `KATUZE/kod` (`xs:unsignedInt`).
    pub code: u32,
    /// Cadastral-area name.
    pub name: String,
}

/// One primary `NEMOVITOST` entry.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceProperty {
    /// Optional human-readable property type (`TYP_NEM_TEXT`).
    pub property_type: Option<String>,
    /// Ordered property choices from `NEM_IDENT`.
    pub identification: PricePropertyIdent,
    /// One or more component property identities from repeated `SOUCASTI_JE` elements.
    pub components: Vec<PricePropertyIdent>,
    /// Parent properties from `NADRAZENE_NEMOVITOSTI`.
    pub parents: Vec<PriceParentProperty>,
}

/// Legacy `NADRAZENA_NEMOVITOST`, whose entire inner sequence is optional.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct PriceParentProperty {
    /// Parent details, or `None` for a wholly empty `NADRAZENA_NEMOVITOST`.
    pub details: Option<PriceParentPropertyDetails>,
}

/// Fields in a non-empty legacy `NADRAZENA_NEMOVITOST` sequence.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceParentPropertyDetails {
    /// Optional human-readable property type.
    pub property_type: Option<String>,
    /// Ordered property choices from `NEM_IDENT`.
    pub identification: PricePropertyIdent,
    /// One or more component property identities from repeated `SOUCASTI_JE` elements.
    pub components: Vec<PricePropertyIdent>,
    /// `None` when the optional `LISTINY` wrapper is absent; otherwise all deeds,
    /// including an explicitly empty wrapper.
    pub deeds: Option<Vec<PriceDeed>>,
}

/// Price-specific representation of legacy `NemIdentType`.
///
/// The XSD choice is repeatable, so one identity can contain several different
/// property records. Their original order is retained.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct PricePropertyIdent {
    /// Ordered `parcela`, `stavba`, `jednotka`, and `pravo_stavby` choices.
    pub items: Vec<PricePropertyIdentItem>,
}

/// One property choice inside legacy `NemIdentType`.
#[derive(Clone, Eq, PartialEq)]
pub enum PricePropertyIdentItem {
    /// A `parcela` record.
    Parcel(PriceParcel),
    /// A `stavba` record.
    Building(PriceBuilding),
    /// A `jednotka` record.
    Unit(PriceUnit),
    /// A `pravo_stavby` record.
    BuildingRight(PriceBuildingRight),
}

/// Complete price-specific legacy `ParcelaType`.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct PriceParcel {
    /// Optional legacy internal ID (`id`), including the XSD-permitted empty value.
    pub id: Option<LegacyId>,
    /// Optional abbreviation (`zkratka`).
    pub abbreviation: Option<String>,
    /// Optional land-kind number (`druh_cis`), retained as text.
    pub land_kind_number: Option<String>,
    /// Optional parcel number (`par_cis`), retained verbatim including whitespace.
    pub parcel_number: Option<String>,
    /// Optional subdivision number (`podd_cis`), retained verbatim.
    pub subdivision_number: Option<String>,
    /// Optional parcel part (`dil_parcely`, `xs:byte`).
    pub parcel_part: Option<i8>,
    /// Optional legacy body ID (`tel_id`).
    pub body_id: Option<LegacyId>,
    /// Optional body number (`cislo_tel`), retained as text.
    pub body_number: Option<String>,
    /// Optional cadastral-area name (`ku_nazev`).
    pub cadastral_area_name: Option<String>,
    /// Optional original name (`nazev_puv`).
    pub original_name: Option<String>,
}

/// Complete price-specific legacy `StavbaType`.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct PriceBuilding {
    /// Optional legacy internal ID.
    pub id: Option<LegacyId>,
    /// Optional municipality-part text (`caobce`).
    pub municipality_part: Option<String>,
    /// Optional building-type abbreviation (`typbud_zkr`).
    pub building_type_abbreviation: Option<String>,
    /// Optional house numbers (`cisla_domovni`), retained as text.
    pub house_numbers: Option<String>,
    /// Optional use abbreviation (`vyuziti_zkr`).
    pub use_abbreviation: Option<String>,
    /// Optional legacy body ID.
    pub body_id: Option<LegacyId>,
    /// Optional `bez_lv` marker, retained without interpreting its text.
    pub without_ownership_sheet: Option<String>,
    /// Optional body number, retained as text.
    pub body_number: Option<String>,
    /// Optional cadastral-area name.
    pub cadastral_area_name: Option<String>,
    /// Optional temporary-building marker (`docasna`).
    pub temporary: Option<String>,
    /// Associated parcels from the optional `par_ident` wrapper. `None` and an
    /// explicitly empty wrapper remain distinguishable.
    pub parcels: Option<Vec<PriceParcel>>,
}

/// Complete price-specific legacy `JednotkaType`.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceUnit {
    /// Required legacy unit ID, which may be empty under legacy `ID_TYPE`.
    pub id: LegacyId,
    /// Optional municipality-part text (`caobce`).
    pub municipality_part: Option<String>,
    /// Optional house identification (`cp_ident`).
    pub house_identification: Option<String>,
    /// Optional unit identification (`jed_ident`).
    pub unit_identification: Option<String>,
    /// Optional legacy body ID.
    pub body_id: Option<LegacyId>,
    /// Optional body number, retained as text.
    pub body_number: Option<String>,
    /// Optional cadastral-area name.
    pub cadastral_area_name: Option<String>,
}

/// Complete price-specific legacy `PravoStavbyType`.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct PriceBuildingRight {
    /// Optional legacy building-right ID.
    pub id: Option<LegacyId>,
    /// Optional legacy body ID.
    pub body_id: Option<LegacyId>,
    /// All directly repeated associated `parcela` records.
    pub parcels: Vec<PriceParcel>,
    /// Optional body number, retained as text.
    pub body_number: Option<String>,
    /// Optional cadastral-area name.
    pub cadastral_area_name: Option<String>,
}

/// Legacy `IDENT_RIZENI`, whose entire inner sequence is optional.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct PriceProceedingReference {
    /// Proceeding number details, or `None` for an empty `IDENT_RIZENI`.
    pub identification: Option<PriceProceedingNumber>,
}

/// Complete legacy `RizeniType` value.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceProceedingNumber {
    /// Proceeding-type code (`typriz_kod`), retained as text.
    pub proceeding_type_code: String,
    /// Sequence number (`poradove_cislo`, `xs:unsignedInt`).
    pub sequence_number: u32,
    /// Year (`rok`, `xs:unsignedShort`).
    pub year: u16,
    /// Cadastral workplace number (`prares_kod`, `xs:unsignedShort`).
    pub workplace_code: u16,
}

/// A deed and price shared by both legacy price report families.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceDeed {
    /// `CENA_Z_LISTINY` exactly as text. It is not converted to `Decimal`, because
    /// the legacy XSD deliberately declares this field as `xs:string`.
    pub price: String,
    /// Proceeding identification associated with this deed.
    pub proceeding: PriceProceedingReference,
    /// Currency code (`MENA_KOD`), retained verbatim.
    pub currency: String,
    /// Complete `LISTINA_INFO` value.
    pub information: PriceDeedInfo,
    /// Historical relation groups from `SOUVISEJICI_TYPY`.
    pub related_types: Vec<PriceRelatedType>,
}

/// Legacy `NazevListType`, retaining the distinction between an empty value and
/// its complete optional sequence.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct PriceDeedInfo {
    /// All deed details, or `None` when `LISTINA_INFO` is empty.
    pub details: Option<PriceDeedDetails>,
}

/// Fields in the optional sequence of legacy `NazevListType`.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceDeedDetails {
    /// Deed type (`tlist`).
    pub deed_type: String,
    /// Additional data (`dalsi_udaje`).
    pub additional_data: String,
    /// Creation sequence number (`por_cis_zhot`), retained as text.
    pub creation_sequence_number: String,
    /// Description (`popis`).
    pub description: String,
    /// Issue text (`vystav_txt`).
    pub issued_text: String,
    /// Legal-force text (`prav_moc_txt`).
    pub legal_force_text: String,
    /// Submission text (`podani_txt`).
    pub submission_text: String,
    /// Enforceability text (`vykonatelnost_txt`).
    pub enforceability_text: String,
    /// Additional submission text (`podani_z_txt`).
    pub submission_z_text: String,
    /// Validation text (`zplatneni_txt`).
    pub validation_text: String,
    /// Optional proceeding-type name (`prares_nazev`).
    pub proceeding_type_name: Option<String>,
}

/// Legacy `SOUVISEJICI_TYP`, whose entire inner sequence is optional.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct PriceRelatedType {
    /// Relation details, or `None` for a wholly empty `SOUVISEJICI_TYP`.
    pub details: Option<PriceRelatedTypeDetails>,
}

/// Fields in a non-empty legacy `SOUVISEJICI_TYP` sequence.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceRelatedTypeDetails {
    /// Relation type text (`TYP_TEXT`), never mapped to a guessed legal enum.
    pub type_text: String,
    /// Related properties in document order; the required wrapper may be empty.
    pub properties: Vec<PriceRelatedProperty>,
}

/// Legacy `SOUVISEJICI_NEMOVISTOST` (the spelling is from the official XSD), whose
/// entire inner sequence is optional.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct PriceRelatedProperty {
    /// Related-property details, or `None` for a wholly empty value.
    pub details: Option<PriceRelatedPropertyDetails>,
}

/// Fields in a non-empty legacy `SOUVISEJICI_NEMOVISTOST` sequence.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceRelatedPropertyDetails {
    /// Ordered property choices from `NEM_IDENT`.
    pub identification: PricePropertyIdent,
    /// One or more component property identities from repeated `SOUCASTI_JE` elements.
    pub components: Vec<PricePropertyIdent>,
}

/// Complete `CenoveUdajeDleRizeni` 1.03 report.
#[derive(Clone, Eq, PartialEq)]
pub struct PricesByProceedingReport {
    /// Cadastral workplaces from `PRACOVISTE/KP`.
    pub workplaces: Vec<PriceWorkplace>,
    /// Uninterpreted `BEZPL_PRISTUP` text.
    pub free_access: String,
    /// Uninterpreted `VYHOTOVIL` text.
    pub prepared_by: String,
    /// Uninterpreted `INFO_VYSTUP` text.
    pub output_info: String,
    /// Uninterpreted `VYHOTOVENO` text; the legacy XSD declares it as `xs:string`.
    pub prepared_at: String,
}

/// One legacy cadastral workplace (`KP`) and its proceedings.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceWorkplace {
    /// Raw workplace code (`KOD`), which is an `xs:string` in this report.
    pub code: String,
    /// Workplace name (`NAZEV`).
    pub name: String,
    /// Proceedings from `RIZENI/RIZ`.
    pub proceedings: Vec<PriceProceeding>,
}

/// One proceeding (`RIZ`) in a prices-by-proceeding report.
#[derive(Clone, Eq, PartialEq)]
pub struct PriceProceeding {
    /// Proceeding-level identification.
    pub proceeding: PriceProceedingReference,
    /// Deeds from the required `LISTINY` wrapper; an empty wrapper yields an empty vector.
    pub deeds: Vec<PriceDeed>,
}

/// Monthly `CenoveUdaje` 1.0 document.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyPriceData {
    /// Values of the `bez_mj` XSD list, in lexical order.
    pub without_measurement: Vec<MonthlyYesNo>,
    /// Values of the `mesic` XSD list. Every value is in `1..=12`; an empty list
    /// remains empty rather than being treated as a missing attribute.
    pub months: Vec<u8>,
    /// Exact lexical `rok` value (`xs:gYear`), including any original timezone.
    pub year: String,
    /// Required `katuze_kod_cu` value (`xs:long`).
    pub cadastral_area_code: i64,
    /// Proceedings in document order.
    pub proceedings: Vec<MonthlyProceeding>,
}

/// The otherwise-unused `CenoveUdajePropertyType` from the monthly schema.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyPriceDataProperty {
    /// Inline `CenoveUdaje` value.
    pub value: MonthlyPriceData,
    /// All association attributes, retained with expanded names.
    pub attributes: MonthlyXmlAttributes,
}

/// One item of the monthly `bez_mj` list.
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
pub enum MonthlyYesNo {
    /// Czech `a` (yes).
    Yes,
    /// Czech `n` (no).
    No,
}

impl MonthlyYesNo {
    /// Returns the exact schema token.
    pub fn as_str(self) -> &'static str {
        match self {
            Self::Yes => "a",
            Self::No => "n",
        }
    }
}

/// One item of the monthly property `typ` list.
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
pub enum MonthlyPropertyKind {
    /// Parcel (`PAR`).
    Parcel,
    /// Unit (`JED`).
    Unit,
    /// Building (`BUD`).
    Building,
    /// Building right (`PS`).
    BuildingRight,
}

impl MonthlyPropertyKind {
    /// Returns the exact schema token.
    pub fn as_str(self) -> &'static str {
        match self {
            Self::Parcel => "PAR",
            Self::Unit => "JED",
            Self::Building => "BUD",
            Self::BuildingRight => "PS",
        }
    }
}

/// One monthly `Rizeni` proceeding.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyProceeding {
    /// Required `id` (`xs:long`).
    pub id: i64,
    /// Proceeding number (`cisloRizeni`), retained as text.
    pub number: String,
    /// Submission date-time (`datumPodani`), retaining offset semantics.
    pub submitted_at: XmlDateTime,
    /// Validation date-time (`datumZplatneni`), retaining offset semantics.
    pub validated_at: XmlDateTime,
    /// Workplace number (`praresKod`, `xs:int`).
    pub workplace_code: i32,
    /// Required deed collection.
    pub deeds: MonthlyDeedCollection,
    /// Required property collection.
    pub properties: MonthlyPropertyCollection,
}

/// Monthly `ListinyPropertyType` value.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyDeedCollection {
    /// One or more inline deeds in valid schema documents.
    pub deeds: Vec<MonthlyDeed>,
    /// Every GML association/ownership attribute, plus any other supplied
    /// attributes, retained with expanded names.
    pub attributes: MonthlyXmlAttributes,
}

/// Monthly `NemovitostiPropertyType` value.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyPropertyCollection {
    /// One or more inline properties in valid schema documents.
    pub properties: Vec<MonthlyProperty>,
    /// Every GML association/ownership attribute, plus any other supplied
    /// attributes, retained with expanded names.
    pub attributes: MonthlyXmlAttributes,
}

/// One monthly `Listina` deed with an exact decimal price.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyDeed {
    /// Required `id` (`xs:long`).
    pub id: i64,
    /// Exact `cena` (`xs:decimal`).
    pub price: Decimal,
    /// Currency (`mena`), retained verbatim.
    pub currency: String,
    /// Deed type (`listinaTyp`), retained verbatim.
    pub deed_type: String,
    /// Every GML association/ownership attribute, plus any other supplied
    /// attributes, retained with expanded names.
    pub attributes: MonthlyXmlAttributes,
}

/// One monthly `Nemovitost`, including inherited GML feature content.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyProperty {
    /// Required unqualified monthly `id` (`xs:long`).
    pub id: i64,
    /// Optional `gml:id`; the imported XSD does not mark the attribute as required.
    pub gml_id: Option<String>,
    /// Values of the required `typ` XSD list, in lexical order.
    pub kinds: Vec<MonthlyPropertyKind>,
    /// Inherited GML object/feature elements (`metaDataProperty`, `description`,
    /// `descriptionReference`, `identifier`, `name`, `boundedBy`, and `location`)
    /// in document order. Raw XML preserves arbitrary imported GML content.
    pub gml_elements: Vec<MonthlyRawXmlElement>,
    /// Cadastral-area code (`katuzeKod`, `xs:int`).
    pub cadastral_area_code: i32,
    /// Optional monthly `text`; this is distinct from `gml:description`.
    pub text: Option<String>,
    /// Optional monthly `popis` description.
    pub description: Option<String>,
    /// Optional monthly `bod` point property.
    pub point: Option<MonthlyPointProperty>,
    /// Required `teleso` value.
    pub body: MonthlyPropertyBody,
}

/// Monthly `TelesoPropertyType` value.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyPropertyBody {
    /// Optional unqualified `id` (`xs:long`).
    pub id: Option<i64>,
    /// Body number (`cislo`, `xs:int`).
    pub number: i32,
}

/// A monthly `bod` using GML 3.2 `PointPropertyType`.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyPointProperty {
    /// Inline `gml:Point`, or `None` for a by-reference property.
    pub point: Option<MonthlyPoint>,
    /// Every GML association/ownership attribute, plus any other supplied
    /// attributes, retained with expanded names.
    pub attributes: MonthlyXmlAttributes,
}

/// Inline GML 3.2 point.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyPoint {
    /// Optional `gml:id`; the imported XSD does not mark the attribute as required.
    pub gml_id: Option<String>,
    /// All point attributes, including `gml:id` and the SRS attribute group.
    pub attributes: MonthlyXmlAttributes,
    /// Inherited GML object properties in document order, preserved as raw XML.
    pub gml_elements: Vec<MonthlyRawXmlElement>,
    /// The point's `gml:pos` or deprecated `gml:coordinates` choice.
    pub position: MonthlyPointPosition,
}

/// Coordinates accepted by GML 3.2 `PointType`.
#[derive(Clone, Eq, PartialEq)]
pub enum MonthlyPointPosition {
    /// Modern `gml:pos` direct position.
    Position(MonthlyDirectPosition),
    /// Deprecated `gml:coordinates` encoding.
    Coordinates(MonthlyCoordinates),
}

/// GML `DirectPositionType`, preserving its `doubleList` lexical values.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyDirectPosition {
    /// Exact decoded `gml:pos` content, including its original whitespace.
    pub raw: String,
    /// Raw `xs:double` tokens in lexical order. Exponents, `INF`, `-INF`, and `NaN`
    /// remain available without conversion through a binary float.
    pub values: Vec<String>,
    /// Ordinates as exact decimals, or `None` unless every token uses exact XSD
    /// decimal syntax and is representable by `Decimal` without rounding.
    pub coordinates: Option<Vec<Decimal>>,
    /// All SRS attributes with expanded names.
    pub attributes: MonthlyXmlAttributes,
}

/// Deprecated GML `CoordinatesType` without discarding its lexical encoding.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyCoordinates {
    /// Exact decoded element text, including non-numeric text allowed by GML.
    pub raw: String,
    /// Numeric tuples parsed according to `decimal`, `cs`, and `ts`. This is
    /// `None` unless every normalized component is an exact, representable XSD
    /// decimal; `raw` retains every other value without loss.
    pub numeric_tuples: Option<Vec<Vec<Decimal>>>,
    /// Decimal separator from `decimal`, defaulting to `.`.
    pub decimal_separator: String,
    /// Component separator from `cs`, defaulting to `,`.
    pub coordinate_separator: String,
    /// Tuple separator from `ts`, defaulting to one space.
    pub tuple_separator: String,
    /// All supplied attributes with expanded names.
    pub attributes: MonthlyXmlAttributes,
}

/// An expanded XML name used by monthly GML preservation structures.
#[derive(Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct MonthlyExpandedName {
    /// Namespace URI, or `None` for an unqualified name.
    pub namespace: Option<String>,
    /// Local XML name.
    pub local_name: String,
}

/// One XML attribute with its expanded name and decoded value.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyXmlAttribute {
    /// Expanded attribute name, independent of its source prefix.
    pub name: MonthlyExpandedName,
    /// Attribute value as decoded by the XML parser.
    pub value: String,
}

/// Ordered, raw-value-preserving monthly XML attributes.
#[derive(Clone, Default, Eq, PartialEq)]
pub struct MonthlyXmlAttributes {
    /// Attributes in source order. Namespace declarations are represented by the
    /// enclosing raw XML rather than exposed as ordinary XML attributes.
    pub values: Vec<MonthlyXmlAttribute>,
}

impl MonthlyXmlAttributes {
    /// Finds an attribute by expanded name.
    pub fn get(&self, namespace: Option<&str>, local_name: &str) -> Option<&str> {
        self.values
            .iter()
            .find(|attribute| {
                attribute.name.namespace.as_deref() == namespace
                    && attribute.name.local_name == local_name
            })
            .map(|attribute| attribute.value.as_str())
    }
}

/// An imported GML element retained without flattening its extensible content.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyRawXmlElement {
    /// Expanded element name.
    pub name: MonthlyExpandedName,
    /// Attributes in source order with expanded names.
    pub attributes: MonthlyXmlAttributes,
    /// Exact UTF-8 XML slice for the complete element.
    pub xml: String,
}

/// Bounded expansion policy for [`MonthlyPriceArchive`] parsing.
#[derive(Clone, Copy, Eq, PartialEq)]
pub struct MonthlyPriceArchiveLimits {
    /// Maximum number of ZIP entries, including entries that later fail XML decoding.
    pub max_entries: usize,
    /// Maximum uncompressed bytes in any one entry.
    pub max_entry_uncompressed_bytes: u64,
    /// Maximum sum of uncompressed bytes across all entries.
    pub max_total_uncompressed_bytes: u64,
    /// Maximum permitted integer ratio `uncompressed_size / compressed_size`.
    /// A non-empty entry with zero compressed bytes is always rejected.
    pub max_compression_ratio: u64,
}

impl Default for MonthlyPriceArchiveLimits {
    fn default() -> Self {
        Self {
            max_entries: 4_096,
            max_entry_uncompressed_bytes: 64 * 1024 * 1024,
            max_total_uncompressed_bytes: 256 * 1024 * 1024,
            max_compression_ratio: 100,
        }
    }
}

/// A monthly price ZIP with untouched source bytes and all decoded entries.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyPriceArchive {
    /// Exact original ZIP archive bytes.
    pub original_bytes: Vec<u8>,
    /// Entries in central-directory order. Multiple entries and months are retained.
    pub entries: Vec<MonthlyPriceEntry>,
}

/// One safely named monthly ZIP entry.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyPriceEntry {
    /// Safe ZIP metadata; no filesystem path is created from it.
    pub metadata: MonthlyPriceEntryMetadata,
    /// Exact uncompressed XML bytes before decoding or normalization.
    pub original_bytes: Vec<u8>,
    /// Parsed monthly document.
    pub value: MonthlyPriceData,
}

/// Non-filesystem metadata for one validated monthly ZIP entry.
#[derive(Clone, Eq, PartialEq)]
pub struct MonthlyPriceEntryMetadata {
    /// Zero-based central-directory entry index.
    pub index: usize,
    /// Decoded entry name after rejection of absolute, parent-relative, Windows
    /// separator/drive, NUL, directory, and symbolic-link paths.
    pub name: String,
    /// Original entry-name bytes from the ZIP central directory.
    pub name_raw: Vec<u8>,
    /// Compressed size reported by the archive.
    pub compressed_size: u64,
    /// Verified uncompressed size.
    pub uncompressed_size: u64,
    /// CRC-32 from the archive metadata.
    pub crc32: u32,
}