korp-map-client 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,34 @@
1
+ """korp-map-client: a Python data client for the korp-map server (map wire v1.2).
2
+
3
+ >>> import korp_map_client
4
+ >>> c = korp_map_client.Client("http://83.190.65.118:8765")
5
+ >>> res = c.map("lines", bbox=(17.9, 59.2, 18.2, 59.4), lod=14)
6
+ >>> res.table, res.truncated, res.data_version
7
+ """
8
+
9
+ from ._client import Client, KorpMapError, MapResult
10
+ from ._version import __version__
11
+
12
+
13
+ def geometry_to_shapely(col, encoding=None): # type: ignore[no-untyped-def]
14
+ """See :func:`korp_map_client._geo.geometry_to_shapely` (needs the ``[geo]`` extra)."""
15
+ from ._geo import geometry_to_shapely as f
16
+
17
+ return f(col, encoding)
18
+
19
+
20
+ def table_to_geodataframe(table, geometry="geometry"): # type: ignore[no-untyped-def]
21
+ """See :func:`korp_map_client._geo.table_to_geodataframe` (needs the ``[geo]`` extra)."""
22
+ from ._geo import table_to_geodataframe as f
23
+
24
+ return f(table, geometry)
25
+
26
+
27
+ __all__ = [
28
+ "Client",
29
+ "KorpMapError",
30
+ "MapResult",
31
+ "__version__",
32
+ "geometry_to_shapely",
33
+ "table_to_geodataframe",
34
+ ]
@@ -0,0 +1,287 @@
1
+ """The HTTP client for the korp-map wire (contract v1.2)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+ from typing import TYPE_CHECKING, Any, Literal, Sequence
7
+
8
+ import httpx
9
+ import pyarrow as pa
10
+
11
+ from ._version import __version__
12
+
13
+ if TYPE_CHECKING: # pragma: no cover
14
+ import geopandas
15
+
16
+ Kind = Literal["points", "lines", "areas"]
17
+ BBox = Sequence[float]
18
+
19
+ KINDS: tuple[str, ...] = ("points", "lines", "areas")
20
+ ARROW_STREAM = "application/vnd.apache.arrow.stream"
21
+ USER_AGENT = f"korp-map-client/{__version__}"
22
+
23
+
24
+ class KorpMapError(Exception):
25
+ """A refusal from the server (``code`` = ``korp-map-1xx``) or a failed request.
26
+
27
+ ``code`` is the wire error code when the server sent one, else ``None``
28
+ (transport failure, a body that is not the contract's JSON error).
29
+ ``status`` is the HTTP status, or ``None`` when no reply came.
30
+ """
31
+
32
+ def __init__(self, message: str, code: str | None = None, status: int | None = None) -> None:
33
+ super().__init__(message)
34
+ self.message = message
35
+ self.code = code
36
+ self.status = status
37
+
38
+ def __str__(self) -> str:
39
+ parts = [p for p in (self.code, f"HTTP {self.status}" if self.status else None) if p]
40
+ return f"{self.message} ({', '.join(parts)})" if parts else self.message
41
+
42
+
43
+ @dataclass(frozen=True)
44
+ class MapResult:
45
+ """One map reply: the Arrow table plus the reply facts from its schema metadata.
46
+
47
+ ``table`` keeps the schema metadata as sent (``geo``, ``data_version``, ...).
48
+ The object also speaks the Arrow PyCapsule stream protocol, so
49
+ ``polars.from_arrow(res)`` / ``duckdb.sql("from res")`` work directly.
50
+ """
51
+
52
+ table: pa.Table
53
+ kind: str
54
+ data_version: str | None
55
+ truncated: bool
56
+ row_groups_total: int | None
57
+ row_groups_scanned: int | None
58
+ status: str | None
59
+ geometry_source: str | None
60
+ metadata: dict[str, str] = field(repr=False)
61
+
62
+ @classmethod
63
+ def from_table(cls, table: pa.Table, kind: str) -> "MapResult":
64
+ raw = table.schema.metadata or {}
65
+ md = {k.decode("utf-8", "replace"): v.decode("utf-8", "replace") for k, v in raw.items()}
66
+ return cls(
67
+ table=table,
68
+ kind=kind,
69
+ data_version=md.get("data_version"),
70
+ truncated=md.get("truncated", "false").strip().lower() == "true",
71
+ row_groups_total=_int_or_none(md.get("row_groups_total")),
72
+ row_groups_scanned=_int_or_none(md.get("row_groups_scanned")),
73
+ status=md.get("status"),
74
+ geometry_source=md.get("geometry_source"),
75
+ metadata=md,
76
+ )
77
+
78
+ @property
79
+ def num_rows(self) -> int:
80
+ return self.table.num_rows
81
+
82
+ def __len__(self) -> int:
83
+ return self.table.num_rows
84
+
85
+ def __arrow_c_stream__(self, requested_schema: Any = None) -> Any:
86
+ return self.table.__arrow_c_stream__(requested_schema)
87
+
88
+ def to_pandas(self, **kwargs: Any) -> Any:
89
+ return self.table.to_pandas(**kwargs)
90
+
91
+ def to_geodataframe(self) -> "geopandas.GeoDataFrame":
92
+ """The rows as a GeoDataFrame in EPSG:4326 (needs the ``[geo]`` extra)."""
93
+ from ._geo import table_to_geodataframe
94
+
95
+ return table_to_geodataframe(self.table)
96
+
97
+
98
+ class Client:
99
+ """A korp-map server client.
100
+
101
+ ``base_url`` is the server root (``http://host:8765`` or ``https://...``).
102
+ ``region`` defaults to the first region the server lists, looked up on first use.
103
+ Extra keyword arguments go to :class:`httpx.Client` (``verify=``, ``proxy=``, ...).
104
+ Compressed replies (gzip, deflate, and br / zstd when ``brotli`` / ``zstandard``
105
+ are installed) are decoded transparently; ``Accept-Encoding`` names what is installed.
106
+ """
107
+
108
+ def __init__(
109
+ self,
110
+ base_url: str,
111
+ region: str | None = None,
112
+ *,
113
+ timeout: float | httpx.Timeout = 120.0,
114
+ headers: dict[str, str] | None = None,
115
+ transport: httpx.BaseTransport | None = None,
116
+ **httpx_kwargs: Any,
117
+ ) -> None:
118
+ hdrs = {"user-agent": USER_AGENT}
119
+ hdrs.update(headers or {})
120
+ self.base_url = base_url.rstrip("/")
121
+ self._region = region
122
+ self._http = httpx.Client(
123
+ base_url=self.base_url,
124
+ timeout=timeout,
125
+ headers=hdrs,
126
+ transport=transport,
127
+ follow_redirects=True,
128
+ **httpx_kwargs,
129
+ )
130
+
131
+ # -- lifecycle -------------------------------------------------------------
132
+ def close(self) -> None:
133
+ self._http.close()
134
+
135
+ def __enter__(self) -> "Client":
136
+ return self
137
+
138
+ def __exit__(self, *exc: object) -> None:
139
+ self.close()
140
+
141
+ def __repr__(self) -> str:
142
+ return f"korp_map_client.Client({self.base_url!r}, region={self._region!r})"
143
+
144
+ # -- plain endpoints -------------------------------------------------------
145
+ def health(self) -> bool:
146
+ """True when ``/v1/health`` answers 200."""
147
+ r = self._get("/v1/health")
148
+ return r.status_code == 200
149
+
150
+ def regions(self) -> list[dict[str, Any]]:
151
+ """The served regions: ``[{"name", "bbox": [minlon, minlat, maxlon, maxlat], "data_version"}]``."""
152
+ out = self._get("/v1/regions").json()
153
+ if not isinstance(out, list):
154
+ raise KorpMapError("/v1/regions did not answer a JSON list")
155
+ return out
156
+
157
+ @property
158
+ def region(self) -> str:
159
+ """The region used when a call names none (the first served region by default)."""
160
+ if self._region is None:
161
+ regs = self.regions()
162
+ if not regs:
163
+ raise KorpMapError("the server serves no regions")
164
+ self._region = str(regs[0]["name"])
165
+ return self._region
166
+
167
+ @region.setter
168
+ def region(self, name: str) -> None:
169
+ self._region = name
170
+
171
+ # -- the map ---------------------------------------------------------------
172
+ def map(
173
+ self,
174
+ kind: Kind,
175
+ bbox: BBox,
176
+ lod: int,
177
+ max: int | None = None,
178
+ *,
179
+ region: str | None = None,
180
+ compress: Literal["zstd"] | None = None,
181
+ ) -> MapResult:
182
+ """Rows of ``kind`` inside ``bbox = (minlon, minlat, maxlon, maxlat)`` at ``lod``.
183
+
184
+ ``max`` caps the row count (the reply says ``truncated``); ``compress="zstd"``
185
+ asks for zstd Arrow IPC buffers (pyarrow decodes them natively).
186
+ """
187
+ if kind not in KINDS:
188
+ raise ValueError(f"kind must be one of {KINDS}, not {kind!r}")
189
+ params: dict[str, str] = {
190
+ "region": region or self.region,
191
+ "bbox": _bbox_param(bbox),
192
+ "lod": str(int(lod)),
193
+ }
194
+ if max is not None:
195
+ params["max"] = str(int(max))
196
+ if compress is not None:
197
+ params["compress"] = compress
198
+ r = self._get(f"/v1/map/{kind}", params)
199
+ ctype = r.headers.get("content-type", "").split(";")[0].strip().lower()
200
+ if ctype and ctype != ARROW_STREAM:
201
+ raise KorpMapError(f"expected {ARROW_STREAM}, got {ctype!r}", status=r.status_code)
202
+ try:
203
+ table = pa.ipc.open_stream(pa.py_buffer(r.content)).read_all()
204
+ except pa.ArrowInvalid as e:
205
+ raise KorpMapError(f"the reply is not an Arrow IPC stream: {e}", status=r.status_code) from e
206
+ return MapResult.from_table(table, kind)
207
+
208
+ def map_table(self, kind: Kind, bbox: BBox, lod: int, max: int | None = None, **kw: Any) -> pa.Table:
209
+ """Like :meth:`map`, the bare :class:`pyarrow.Table` (schema metadata kept)."""
210
+ return self.map(kind, bbox, lod, max, **kw).table
211
+
212
+ def map_gdf(self, kind: Kind, bbox: BBox, lod: int, max: int | None = None, **kw: Any) -> "geopandas.GeoDataFrame":
213
+ """Like :meth:`map`, as a GeoDataFrame in EPSG:4326 (needs the ``[geo]`` extra).
214
+
215
+ The reply facts ride in ``gdf.attrs`` (``truncated``, ``data_version``, ...).
216
+ """
217
+ res = self.map(kind, bbox, lod, max, **kw)
218
+ gdf = res.to_geodataframe()
219
+ gdf.attrs.update(
220
+ kind=res.kind,
221
+ data_version=res.data_version,
222
+ truncated=res.truncated,
223
+ row_groups_total=res.row_groups_total,
224
+ row_groups_scanned=res.row_groups_scanned,
225
+ status=res.status,
226
+ geometry_source=res.geometry_source,
227
+ )
228
+ return gdf
229
+
230
+ # -- addresses (v1.2) ------------------------------------------------------
231
+ def geocode(self, q: str, max: int | None = None, *, region: str | None = None) -> list[dict[str, Any]]:
232
+ """Addresses matching ``q``, best first: ``[{"street", "housenumber", "city",
233
+ "postcode", "lon", "lat", "source", "score"}]``; no match is ``[]``."""
234
+ params = {"region": region or self.region, "q": q}
235
+ if max is not None:
236
+ params["max"] = str(int(max))
237
+ out = self._get("/v1/geocode", params).json()
238
+ return list(out.get("hits") or [])
239
+
240
+ def revgeocode(self, lon: float, lat: float, *, region: str | None = None) -> dict[str, Any] | None:
241
+ """The nearest address to ``(lon, lat)`` or ``None``; the hit carries ``distance_m``."""
242
+ params = {"region": region or self.region, "lon": repr(float(lon)), "lat": repr(float(lat))}
243
+ out = self._get("/v1/revgeocode", params).json()
244
+ hit = out.get("hit")
245
+ if hit is None:
246
+ return None
247
+ hit = dict(hit)
248
+ hit["distance_m"] = out.get("distance_m")
249
+ return hit
250
+
251
+ # -- plumbing --------------------------------------------------------------
252
+ def _get(self, path: str, params: dict[str, str] | None = None) -> httpx.Response:
253
+ try:
254
+ r = self._http.get(path, params=params)
255
+ except httpx.HTTPError as e:
256
+ raise KorpMapError(f"GET {path} failed: {e}") from e
257
+ if r.status_code >= 400:
258
+ raise _error_from(r)
259
+ return r
260
+
261
+
262
+ def _error_from(r: httpx.Response) -> KorpMapError:
263
+ code: str | None = None
264
+ message = r.text.strip() or r.reason_phrase or "request failed"
265
+ try:
266
+ body = r.json()
267
+ except ValueError:
268
+ body = None
269
+ if isinstance(body, dict):
270
+ code = body.get("code") if isinstance(body.get("code"), str) else None
271
+ if isinstance(body.get("error"), str):
272
+ message = body["error"]
273
+ return KorpMapError(message, code=code, status=r.status_code)
274
+
275
+
276
+ def _bbox_param(bbox: BBox) -> str:
277
+ vals = [float(v) for v in bbox]
278
+ if len(vals) != 4:
279
+ raise ValueError("bbox must be (minlon, minlat, maxlon, maxlat)")
280
+ return ",".join(repr(v) for v in vals)
281
+
282
+
283
+ def _int_or_none(s: str | None) -> int | None:
284
+ try:
285
+ return int(s) if s is not None else None
286
+ except ValueError:
287
+ return None
@@ -0,0 +1,120 @@
1
+ """GeoParquet 1.1 separated geometry (struct<x, y> in lists) to shapely, vectorised."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import TYPE_CHECKING, Any
7
+
8
+ import pyarrow as pa
9
+ import pyarrow.types as pat
10
+
11
+ if TYPE_CHECKING: # pragma: no cover
12
+ import geopandas
13
+
14
+ GEO_HINT = "korp_map_client geometry needs the [geo] extra: pip install 'korp-map-client[geo]'"
15
+ try:
16
+ import numpy as np
17
+ except ImportError as e: # numpy comes with shapely / geopandas
18
+ raise ImportError(GEO_HINT) from e
19
+
20
+ CRS = "EPSG:4326"
21
+
22
+
23
+ def _need_geo() -> tuple[Any, Any]:
24
+ try:
25
+ import geopandas
26
+ import shapely
27
+ except ImportError as e: # pragma: no cover - exercised only without the extra
28
+ raise ImportError(GEO_HINT) from e
29
+ return geopandas, shapely
30
+
31
+
32
+ def _is_list(t: pa.DataType) -> bool:
33
+ return pat.is_list(t) or pat.is_large_list(t)
34
+
35
+
36
+ def _list_levels(arr: pa.Array) -> tuple[pa.Array, list[np.ndarray]]:
37
+ """Peel list levels off ``arr``; return the innermost (struct) values and the
38
+ offsets of each level, outermost first, rebased to start at 0 and sliced to fit."""
39
+ offsets: list[np.ndarray] = []
40
+ while _is_list(arr.type):
41
+ offs = np.asarray(arr.offsets.to_numpy(zero_copy_only=False), dtype=np.int64)
42
+ start, stop = int(offs[0]), int(offs[-1])
43
+ offsets.append(offs - start)
44
+ arr = arr.values.slice(start, stop - start)
45
+ return arr, offsets
46
+
47
+
48
+ _ENCODINGS = {
49
+ "point": (0, "POINT"),
50
+ "linestring": (1, "LINESTRING"),
51
+ "multipoint": (1, "MULTIPOINT"),
52
+ "polygon": (2, "POLYGON"),
53
+ "multilinestring": (2, "MULTILINESTRING"),
54
+ "multipolygon": (3, "MULTIPOLYGON"),
55
+ }
56
+ _BY_DEPTH = {0: "POINT", 1: "LINESTRING", 2: "MULTILINESTRING", 3: "MULTIPOLYGON"}
57
+
58
+
59
+ def geo_encoding(table: pa.Table, column: str = "geometry") -> str | None:
60
+ """The column's GeoParquet ``encoding`` from the ``geo`` schema metadata, if any."""
61
+ raw = (table.schema.metadata or {}).get(b"geo")
62
+ if not raw:
63
+ return None
64
+ try:
65
+ enc = json.loads(raw)["columns"][column]["encoding"]
66
+ except (ValueError, KeyError, TypeError):
67
+ return None
68
+ return str(enc).lower()
69
+
70
+
71
+ def geometry_to_shapely(col: pa.Array | pa.ChunkedArray, encoding: str | None = None) -> np.ndarray:
72
+ """A separated-layout geometry column as a numpy array of shapely geometries.
73
+
74
+ point = ``struct<x, y>``; multilinestring = ``list<list<struct>>``;
75
+ multipolygon = ``list<list<list<struct>>>``. ``encoding`` (the GeoParquet ``geo``
76
+ metadata value) picks the type when the list depth is ambiguous (polygon vs
77
+ multilinestring); without it the depth decides. Null rows come back as ``None``.
78
+ No per-row Python loop.
79
+ """
80
+ _, shapely = _need_geo()
81
+ from shapely import GeometryType
82
+
83
+ if isinstance(col, pa.ChunkedArray):
84
+ col = col.combine_chunks() if col.num_chunks != 1 else col.chunk(0)
85
+ n = len(col)
86
+ nulls = col.is_null().to_numpy(zero_copy_only=False) if col.null_count else None
87
+
88
+ coords_arr, offsets = _list_levels(col)
89
+ if not pat.is_struct(coords_arr.type):
90
+ raise TypeError(f"geometry is not the separated layout: {col.type}")
91
+ x, y = (c.to_numpy(zero_copy_only=False) for c in coords_arr.flatten()[:2])
92
+ coords = np.column_stack([np.asarray(x, dtype=np.float64), np.asarray(y, dtype=np.float64)])
93
+
94
+ depth = len(offsets)
95
+ name = _BY_DEPTH.get(depth)
96
+ if encoding is not None and encoding in _ENCODINGS:
97
+ want_depth, want_name = _ENCODINGS[encoding]
98
+ if want_depth != depth:
99
+ raise TypeError(f"geometry encoding {encoding!r} does not fit {col.type}")
100
+ name = want_name
101
+ if name is None:
102
+ raise TypeError(f"unexpected list depth {depth} in geometry {col.type}")
103
+ if depth == 0:
104
+ geoms = shapely.points(coords)
105
+ else:
106
+ # from_ragged_array wants the innermost offsets first.
107
+ geoms = shapely.from_ragged_array(getattr(GeometryType, name), coords, tuple(reversed(offsets)))
108
+ geoms = np.asarray(geoms, dtype=object)
109
+ assert len(geoms) == n
110
+ if nulls is not None:
111
+ geoms[nulls] = None
112
+ return geoms
113
+
114
+
115
+ def table_to_geodataframe(table: pa.Table, geometry: str = "geometry") -> "geopandas.GeoDataFrame":
116
+ """``table`` as a GeoDataFrame (EPSG:4326); the geometry column becomes shapely."""
117
+ geopandas, _ = _need_geo()
118
+ geoms = geometry_to_shapely(table.column(geometry), geo_encoding(table, geometry))
119
+ df = table.drop_columns([geometry]).to_pandas()
120
+ return geopandas.GeoDataFrame(df, geometry=geopandas.GeoSeries(geoms, crs=CRS, index=df.index), crs=CRS)
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
File without changes
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.5
2
+ Name: korp-map-client
3
+ Version: 0.1.0
4
+ Summary: Python data client for the korp-map server: OpenStreetMap rows as Arrow tables, geocoding
5
+ Project-URL: Source, https://gunnar.rs/nordisk/korp-map
6
+ License-Expression: MIT OR Apache-2.0
7
+ License-File: LICENSE-APACHE
8
+ License-File: LICENSE-MIT
9
+ Keywords: arrow,geocoding,geoparquet,map,openstreetmap
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: GIS
12
+ Classifier: Typing :: Typed
13
+ Requires-Python: >=3.10
14
+ Requires-Dist: httpx>=0.27
15
+ Requires-Dist: pyarrow>=14
16
+ Provides-Extra: all
17
+ Requires-Dist: brotli>=1.0; extra == 'all'
18
+ Requires-Dist: geopandas>=0.14; extra == 'all'
19
+ Requires-Dist: shapely>=2.0; extra == 'all'
20
+ Requires-Dist: zstandard>=0.18; extra == 'all'
21
+ Provides-Extra: br
22
+ Requires-Dist: brotli>=1.0; extra == 'br'
23
+ Provides-Extra: geo
24
+ Requires-Dist: geopandas>=0.14; extra == 'geo'
25
+ Requires-Dist: shapely>=2.0; extra == 'geo'
26
+ Provides-Extra: test
27
+ Requires-Dist: pytest>=7; extra == 'test'
28
+ Provides-Extra: zstd
29
+ Requires-Dist: zstandard>=0.18; extra == 'zstd'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # korp-map-client (Python)
33
+
34
+ A Python data client for the **korp-map server**: OpenStreetMap rows for a bounding box
35
+ as Arrow tables (or GeoDataFrames), plus address geocoding. For notebooks and analysis;
36
+ it speaks the map wire, contract v1.2 (HTTP). Formerly published as `korp-map`
37
+ (`import korp_map`); that name is now a deprecated shim that installs this package.
38
+
39
+ ```sh
40
+ pip install korp-map-client # pyarrow + httpx
41
+ pip install 'korp-map-client[geo]' # + geopandas, shapely: map_gdf()
42
+ pip install 'korp-map-client[zstd,br]' # + zstd / brotli Content-Encoding
43
+ pip install 'korp-map-client[all]'
44
+ ```
45
+
46
+ ## Use
47
+
48
+ ```python
49
+ import korp_map_client
50
+
51
+ c = korp_map_client.Client("http://83.190.65.118:8765") # region = the first served region
52
+ c.regions() # [{"name": "sweden", "bbox": [...], "data_version": "files-..."}]
53
+
54
+ res = c.map("lines", bbox=(17.9, 59.2, 18.2, 59.4), lod=14)
55
+ res.table # pyarrow.Table; schema metadata kept (geo, data_version, ...)
56
+ res.truncated, res.data_version, res.geometry_source, res.row_groups_scanned
57
+ res.to_pandas()
58
+
59
+ gdf = c.map_gdf("areas", bbox=(17.9, 59.2, 18.2, 59.4), lod=12) # GeoDataFrame, EPSG:4326
60
+ gdf.attrs["truncated"]
61
+
62
+ c.geocode("Drottninggatan 53 Stockholm", max=5) # [{"street", "housenumber", "city", "postcode",
63
+ # "lon", "lat", "source", "score"}, ...]
64
+ c.revgeocode(18.07, 59.33) # {..., "distance_m": 11.9} or None
65
+ ```
66
+
67
+ * `kind` is `points` (tagged nodes), `lines` or `areas`.
68
+ * `bbox` is `(minlon, minlat, maxlon, maxlat)`; `lod` (0 to 20 or so) keeps rows with
69
+ `min_zoom <= lod` and picks the geometry detail (`geometry_source`: z6, z9, z12, full).
70
+ * `max=K` caps the rows; the reply then says `truncated=True`.
71
+ * `compress="zstd"` asks for zstd Arrow IPC buffers (pyarrow decodes them).
72
+ * `tags` is a JSON string per row: `res.to_pandas().tags.map(json.loads)`.
73
+ * `MapResult` speaks the Arrow stream protocol: `polars.from_arrow(res)`, `duckdb.sql("from res")`.
74
+ * `c.map_table(...)` gives the bare `pyarrow.Table`.
75
+ * `korp_map_client.geometry_to_shapely(col)` turns a separated-layout geometry column
76
+ (`struct<x, y>` in lists, GeoParquet 1.1) into shapely geometries, vectorised.
77
+
78
+ Errors raise `korp_map_client.KorpMapError`; `.code` is the wire code (`korp-map-108` for an
79
+ unknown region, ...) and `.status` the HTTP status. Replies compressed with gzip, br or
80
+ zstd are decoded transparently; `Accept-Encoding` names what is installed. `https://`
81
+ URLs work; extra keyword arguments go to `httpx.Client` (`verify=`, `proxy=`, ...).
82
+
83
+ ## Test
84
+
85
+ ```sh
86
+ pip install -e '.[all,test]'
87
+ pytest # the fake server
88
+ KORP_MAP_URL=http://127.0.0.1:8765 pytest -m live # a running server (Stockholm queries)
89
+ ```
90
+
91
+ License: MIT OR Apache-2.0.
@@ -0,0 +1,10 @@
1
+ korp_map_client/__init__.py,sha256=DK8aSGbu_Gs4-xsYrHyMh6oMg7dWJf3IgQZy-osuAEE,1025
2
+ korp_map_client/_client.py,sha256=Bify2zbmNWPATPo4vddMtU7vZlzl7A0nC5_VxpwuB9k,10732
3
+ korp_map_client/_geo.py,sha256=9KACrnVo3gODBiJv3g55d-Hd96JPXB-s6Jo_VxBwolc,4604
4
+ korp_map_client/_version.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
5
+ korp_map_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ korp_map_client-0.1.0.dist-info/METADATA,sha256=aDIfyz929jqutdVMab9DfplugyX_LB9WlZr21dUjyck,3944
7
+ korp_map_client-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
8
+ korp_map_client-0.1.0.dist-info/licenses/LICENSE-APACHE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
9
+ korp_map_client-0.1.0.dist-info/licenses/LICENSE-MIT,sha256=eeb0jAKwnEEyCgIXoPR86Kp35tx7rvVjBDDosppp3h8,1099
10
+ korp_map_client-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ignalina ApS (Rickard Ernst Björn Lundin)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.