File size: 1,702 Bytes
008947a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import geopandas as gpd
import pytest
from shapely.geometry import LineString, Polygon

from maptoposter.models import (
    BBox,
    Coordinate,
    Location,
    MapConfig,
    MapData,
    MapViewport,
    PosterConfig,
    TypographyConfig,
)
from maptoposter.themes import load_style


@pytest.fixture
def poster_config() -> PosterConfig:
    location = Location("Test Place", Coordinate(40.0, 116.3), "China", "Beijing")
    bbox = BBox(116.25, 39.95, 116.35, 40.05)
    return PosterConfig(
        location=location,
        map=MapConfig(MapViewport(location.coordinate, bbox, 11, 10_000)),
        style=load_style("japanese_ink"),
        typography=TypographyConfig(title="TEST PLACE", subtitle="BEIJING", caption="2024"),
    )


@pytest.fixture
def map_data() -> MapData:
    roads = gpd.GeoDataFrame(
        {
            "road_class": ["motorway", "primary", "secondary", "residential"],
            "geometry": [
                LineString([(116.25, 39.96), (116.35, 40.04)]),
                LineString([(116.26, 40.04), (116.34, 39.96)]),
                LineString([(116.25, 40.0), (116.35, 40.0)]),
                LineString([(116.3, 39.95), (116.3, 40.05)]),
            ],
        },
        crs="EPSG:4326",
    )
    water = gpd.GeoDataFrame(
        {"geometry": [Polygon([(116.26, 39.97), (116.28, 39.97), (116.28, 39.99), (116.26, 39.99)])]},
        crs="EPSG:4326",
    )
    parks = gpd.GeoDataFrame(
        {"geometry": [Polygon([(116.31, 40.01), (116.33, 40.01), (116.33, 40.03), (116.31, 40.03)])]},
        crs="EPSG:4326",
    )
    return MapData(BBox(116.25, 39.95, 116.35, 40.05), roads, water_polygons=water, parks=parks)