# MpzpValue

covered_no_data oznacza, że źródło obejmuje gminę, ale żaden MPZP nie obejmuje działki: {status: none, symbol: null, plans: [], effective_from: null}. Plan w przygotowaniu ma status draft. Plan lub strefa bez opublikowanego statusu prawnego ma coverage=covered, status=null, effective_from=null i uwagę wyjaśniającą; symbol, przeznaczenie, identyfikator i nazwa planu są zachowywane, jeżeli je opublikowano.

Layer keys: `mpzp`.

## Cost and inputs

`x-request-cost`: 1 request per call via [GET /v1/layer/{layer}](../operations/layer.md).

Dokładnie jeden z parametrów q, id, point (lat i lng razem liczą się jako point). Wszystkie punkty odczytu API i wszystkie narzędzia obsługują te trzy warianty.

## Value schema

| Field | Required | Schema / constraints | Description |
| --- | --- | --- | --- |
| `effective_from` | yes | `{"format": "date", "type": ["string", "null"]}` | not specified in the source contract |
| `plans` | yes | `{"items": {"properties": {"adopted_on": {"format": "date", "type": ["string", "null"]}, "effective_from": {"format": "date", "type": ["string", "null"]}, "name": {"type": ["string", "null"]}, "plan_id": {"type": "string"}, "resolution_url": {"type": ["string", "null"]}, "status": {"$ref": "./envelope.json#/$defs/MpzpStatus"}}, "type": "object"}, "type": "array"}` | not specified in the source contract |
| `share_pct` | no | `{"type": ["number", "null"]}` | not specified in the source contract |
| `status` | yes | `{"anyOf": [{"$ref": "#/$defs/PlanStatus"}, {"type": "null"}]}` | Status prawny MPZP; null, gdy integracja wymienia plan lub strefę, ale nie publikuje statusu prawnego. Taki rekord ma coverage=covered i effective_from=null, a note wyjaśnia brak statusu. Statusy draft, adopted i in_force wymagają potwierdzenia w źródle; brak danych nigdy nie oznacza none. |
| `symbol` | yes | `{"type": ["string", "null"]}` | Symbol KIMPZP, jeżeli go opublikowano; w przeciwnym razie null z wyjaśnieniem w note. |

```json
{
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "type": "null"
          }
        }
      },
      "then": {
        "properties": {
          "effective_from": {
            "type": "null"
          }
        }
      }
    }
  ],
  "description": "covered_no_data oznacza, że źródło obejmuje gminę, ale żaden MPZP nie obejmuje działki: {status: none, symbol: null, plans: [], effective_from: null}. Plan w przygotowaniu ma status draft. Plan lub strefa bez opublikowanego statusu prawnego ma coverage=covered, status=null, effective_from=null i uwagę wyjaśniającą; symbol, przeznaczenie, identyfikator i nazwa planu są zachowywane, jeżeli je opublikowano.",
  "properties": {
    "effective_from": {
      "format": "date",
      "type": [
        "string",
        "null"
      ]
    },
    "plans": {
      "items": {
        "properties": {
          "adopted_on": {
            "format": "date",
            "type": [
              "string",
              "null"
            ]
          },
          "effective_from": {
            "format": "date",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "plan_id": {
            "type": "string"
          },
          "resolution_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "$ref": "./envelope.json#/$defs/MpzpStatus"
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "share_pct": {
      "type": [
        "number",
        "null"
      ]
    },
    "status": {
      "$ref": "./envelope.json#/$defs/MpzpStatus"
    },
    "symbol": {
      "description": "Symbol KIMPZP, jeżeli go opublikowano; w przeciwnym razie null z wyjaśnieniem w note.",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "status",
    "symbol",
    "plans",
    "effective_from"
  ],
  "type": "object"
}
```

## Empty answer: covered_no_data

The contract states this empty `value`:

```json
{
  "effective_from": null,
  "plans": [],
  "status": "none",
  "symbol": null
}
```

## Coverage states

Cztery stany zakresu danych dla jednej kategorii w danym miejscu. covered: źródło obejmuje to miejsce i zawiera rekord; value zawiera ten rekord. covered_no_data: źródło obejmuje to miejsce, lecz nie zawiera rekordu; value ma określoną dla danej kategorii pustą wartość (false, 0, [], none), nigdy null; jest to potwierdzony brak rekordu, za który naliczana jest opłata. not_covered: źródło nie obejmuje miejsca albo państwo nie publikuje tych danych w postaci do odczytu maszynowego; value=null, agent nie może wyciągać wniosków, a opłata jest zwracana, gdy zapytanie dotyczy tych danych. not_computed: posiadamy źródło, lecz nie obliczyliśmy jeszcze wyniku dla tego miejsca, np. trwa ładowanie zbioru; value=null, opłata jest zwracana. Każdy stan zawiera uwagę napisaną prostym językiem.

States: `covered` | `covered_no_data` | `not_covered` | `not_computed`.

`LayerAnswer` required fields: `layer`, `coverage`, `value`, `note`, `source`, `as_of`, `layer_version`.

## Billing rule

Koszt żądania. charged: liczba naliczonych wywołań po zwrotach. refunded: liczba wywołań naliczonych, a następnie zwróconych. rule: zastosowana reguła. Płatne są odpowiedzi, potwierdzone braki rekordów (covered_no_data) i niejednoznaczne listy kandydatów. Bezpłatne są błędne dane wejściowe (400), brak uwierzytelnienia (401), odpowiedzi bez zmiany danych (304) i operacje bezpłatne. Zwrot obejmuje pozostałe 4xx, każde 5xx, status not_covered oraz odpowiedź dotyczącą jednej kategorii ze stanem not_covered lub not_computed. W operacjach zbiorczych liczby dotyczą poszczególnych elementów.

Rule values: `charged` | `free_operation` | `free_invalid_input` | `free_unauthorized` | `free_not_modified` | `refunded_client_error` | `refunded_server_error` | `refunded_not_covered` | `refunded_not_computed` | `batch_mixed`.

## curl example

```sh
curl --silent --show-error --request GET "https://mcp.agentdzialek.pl/v1/layer/flood" --get \
  -H "X-Api-Key: ${LANDFEED_API_KEY}" \
  --data-urlencode 'id=141803_2.0001.12/3'
```
