// Requires the updated native development runtime.
// Coordinates are illustrative city locations, not surveyed observations.
// Values are synthetic indices; no spatial aggregation or geocoding is performed.
// Point size and label placement are native and require no extra pack or service.
import aner.plot
import aner.geo

let cityPositions = List(
    geo.position(longitude: -105.2705, latitude: 40.0150),
    geo.position(longitude: -122.4194, latitude: 37.7749),
    geo.position(longitude: -118.2437, latitude: 34.0522),
    geo.position(longitude: -122.1430, latitude: 37.4419),
    geo.position(longitude: -74.0060, latitude: 40.7128),
    geo.position(longitude: -95.3698, latitude: 29.7604),
    geo.position(longitude: -70.6693, latitude: -33.4489),
    geo.position(longitude: -58.3816, latitude: -34.6037),
    geo.position(longitude: -99.1332, latitude: 19.4326),
    geo.position(longitude: -79.3832, latitude: 43.6532))
let cityValues = List(8.0, 12.0, 18.0, 9.0, 15.0, 13.0, 11.0, 10.0, 14.0, 16.0)
let cityLabels = List("Boulder", "San Francisco", "Los Angeles", "Palo Alto", "New York City",
    "Houston", "Santiago", "Buenos Aires", "Mexico City", "Toronto")
plot.geo_scatter(positions: cityPositions, values: cityValues, labels: cityLabels)
    .point_sizes(values: cityValues, max_radius: 14.0)
    .point_labels("avoid")
    .extent(west: -132.0, south: -58.0, east: -45.0, north: 58.0)
    .projection("equirectangular")
    .title("Illustrative city positions: no map pack required")
    .caption("Synthetic index sets color and circle area; crowded labels may be hidden; full text stays in tooltips. No boundary pack.")
    .show()

// Optional pack: usa.co. Boundary: generalized Census 2025 place geometry.
let boulderPositions = List(
    geo.position(longitude: -105.2705, latitude: 40.0150),
    geo.position(longitude: -105.2500, latitude: 40.0300))
let boulder = plot.map("usa.co.places", keys: List("0807850"), values: List(20.0))
boulder.add_points(positions: boulderPositions, values: List(8.0, 12.0),
        labels: List("Site A", "Site B"))
    .point_sizes(values: List(10.0, 40.0), max_radius: 16.0)
    .focus(key: "0807850", padding: 0.20)
    .projection("lambert_azimuthal_equal_area")
    .title("Boulder: labeled observation positions")
    .caption("Synthetic color indices; circle areas encode separate synthetic totals 10 and 40. Census 2025; labels avoid collisions.")
    .show()

// Optional pack: usa.ca. The viewport shows San Francisco and Palo Alto together.
let california = plot.map("usa.ca.places",
    keys: List("0667000", "0644000", "0655282"), values: List(12.0, 18.0, 9.0))
let bayPositions = List(
    geo.position(longitude: -122.4194, latitude: 37.7749),
    geo.position(longitude: -122.1430, latitude: 37.4419))
let bayPoints = plot.add_points(chart: california, positions: bayPositions,
    values: List(12.0, 9.0), labels: List("San Francisco", "Palo Alto"))
bayPoints.extent(west: -122.65, south: 37.20, east: -121.70, north: 38.15)
    .point_size(radius: 6.0)
    .point_labels("avoid")
    .projection("lambert_azimuthal_equal_area")
    .title("Bay Area: supplied positions and separate value colors")
    .caption("Synthetic indices set color; uniform 6-pixel radii encode no quantity. Census 2025; no automatic point-in-polygon join.")
    .show()

// Optional pack: mexico. MX-DIF is the pinned source's legacy Mexico City key.
plot.map("mexico", keys: List("MX-DIF"), values: List(7.0))
    .add_points(positions: List(geo.position(longitude: -99.1332, latitude: 19.4326)),
        values: List(14.0), labels: List("Mexico City"))
    .point_labels("all")
    .focus("MX-DIF")
    .projection("lambert_azimuthal_equal_area")
    .title("Mexico City: illustrative location over a federal entity")
    .caption("Synthetic indices; Natural Earth 2022 snapshot; legacy MX-DIF boundary; no street or municipal layer.")
    .show()

// Optional pack: canada. The background is Ontario, not a Toronto city boundary.
plot.map("canada", keys: List("CA-ON"), values: List(6.0))
    .add_points(positions: List(geo.position(longitude: -79.3832, latitude: 43.6532)),
        values: List(16.0), labels: List("Toronto"))
    .extent(west: -79.9, south: 43.3, east: -78.9, north: 44.0)
    .projection("lambert_azimuthal_equal_area")
    .title("Toronto: illustrative position in an Ontario viewport")
    .caption("Synthetic indices; Natural Earth 2022 province boundary; local extent adds no finer geometry.")
    .show()
