{
  "cells": [
    {
      "cell_type": "markdown",
      "id": "geo-points-intro",
      "metadata": {},
      "source": "# Offline GeoPosition observations\n\nThe first chart requires no map pack. Later charts use optional `usa.co`, `usa.ca`, `mexico` and `canada` packs from the source side `plot` collection. Transfer and install the matching `.anermap` files locally with `aner maps install FILE.anermap`; set the same `ANER_MAPS_DIR` for terminal and notebook processes when using a custom store. Restart and Run All with the updated native development runtime and compatible editor. Rendering, proportional marker areas and label placement use no network, tiles, geocoder or font download.\n"
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "geo-points-imports",
      "metadata": {},
      "outputs": [],
      "source": [
        "// Requires the updated native development runtime.\n",
        "// Coordinates are illustrative city locations, not surveyed observations.\n",
        "// Values are synthetic indices; no spatial aggregation or geocoding is performed.\n",
        "// Point size and label placement are native and require no extra pack or service.\n",
        "import aner.plot\n",
        "import aner.geo\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "points-without-packs-context",
      "metadata": {},
      "source": "## Points without any map pack\n\nThis first chart uses only checked WGS84 positions and supplied values. The same synthetic index sets color and circle area: a doubled value gives twice the area. The default maximum radius is made explicit as 14 pixels. `point_labels(\"avoid\")` places labels near markers when space allows and hides crowded labels; full text remains in marker tooltips. Coordinates are illustrative city locations, not surveyed observations. No boundaries or network connection are needed.\n"
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "points-without-packs",
      "metadata": {},
      "outputs": [],
      "source": [
        "let cityPositions = List(\n",
        "    geo.position(longitude: -105.2705, latitude: 40.0150),\n",
        "    geo.position(longitude: -122.4194, latitude: 37.7749),\n",
        "    geo.position(longitude: -118.2437, latitude: 34.0522),\n",
        "    geo.position(longitude: -122.1430, latitude: 37.4419),\n",
        "    geo.position(longitude: -74.0060, latitude: 40.7128),\n",
        "    geo.position(longitude: -95.3698, latitude: 29.7604),\n",
        "    geo.position(longitude: -70.6693, latitude: -33.4489),\n",
        "    geo.position(longitude: -58.3816, latitude: -34.6037),\n",
        "    geo.position(longitude: -99.1332, latitude: 19.4326),\n",
        "    geo.position(longitude: -79.3832, latitude: 43.6532))\n",
        "let cityValues = List(8.0, 12.0, 18.0, 9.0, 15.0, 13.0, 11.0, 10.0, 14.0, 16.0)\n",
        "let cityLabels = List(\"Boulder\", \"San Francisco\", \"Los Angeles\", \"Palo Alto\", \"New York City\",\n",
        "    \"Houston\", \"Santiago\", \"Buenos Aires\", \"Mexico City\", \"Toronto\")\n",
        "plot.geo_scatter(positions: cityPositions, values: cityValues, labels: cityLabels)\n",
        "    .point_sizes(values: cityValues, max_radius: 14.0)\n",
        "    .point_labels(\"avoid\")\n",
        "    .extent(west: -132.0, south: -58.0, east: -45.0, north: 58.0)\n",
        "    .projection(\"equirectangular\")\n",
        "    .title(\"Illustrative city positions: no map pack required\")\n",
        "    .caption(\"Synthetic index sets color and circle area; crowded labels may be hidden; full text stays in tooltips. No boundary pack.\")\n",
        "    .show()\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "boulder-observations-context",
      "metadata": {},
      "source": "## Boulder: independent color and area variables\n\nInstall the optional usa.co pack for this chart. Point positions and the municipality polygon share a local display projection. Color uses synthetic indices 8 and 12; circle areas use separate synthetic totals 10 and 40, so Site B has four times Site A’s area and twice its radius. Complete all `add_points` calls before `point_sizes`: the size vector must cover every observation. Zoom retains both the color and size domains. All values and locations are illustrative.\n"
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "boulder-observations",
      "metadata": {},
      "outputs": [],
      "source": [
        "// Optional pack: usa.co. Boundary: generalized Census 2025 place geometry.\n",
        "let boulderPositions = List(\n",
        "    geo.position(longitude: -105.2705, latitude: 40.0150),\n",
        "    geo.position(longitude: -105.2500, latitude: 40.0300))\n",
        "let boulder = plot.map(\"usa.co.places\", keys: List(\"0807850\"), values: List(20.0))\n",
        "boulder.add_points(positions: boulderPositions, values: List(8.0, 12.0),\n",
        "        labels: List(\"Site A\", \"Site B\"))\n",
        "    .point_sizes(values: List(10.0, 40.0), max_radius: 16.0)\n",
        "    .focus(key: \"0807850\", padding: 0.20)\n",
        "    .projection(\"lambert_azimuthal_equal_area\")\n",
        "    .title(\"Boulder: labeled observation positions\")\n",
        "    .caption(\"Synthetic color indices; circle areas encode separate synthetic totals 10 and 40. Census 2025; labels avoid collisions.\")\n",
        "    .show()\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "bay-area-observations-context",
      "metadata": {},
      "source": "## San Francisco and Palo Alto: uniform sizes and a shared viewport\n\nInstall the optional usa.ca pack. The explicit Bay Area extent keeps both city locations visible and excludes San Francisco’s offshore Farallon parts. `point_size(radius: 6.0)` sets a uniform drawing size and clears any size mapping; it encodes no quantity. Point colors retain their own continuous value domain, independent of boundary colors. Labels use collision avoidance.\n"
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "bay-area-observations",
      "metadata": {},
      "outputs": [],
      "source": [
        "// Optional pack: usa.ca. The viewport shows San Francisco and Palo Alto together.\n",
        "let california = plot.map(\"usa.ca.places\",\n",
        "    keys: List(\"0667000\", \"0644000\", \"0655282\"), values: List(12.0, 18.0, 9.0))\n",
        "let bayPositions = List(\n",
        "    geo.position(longitude: -122.4194, latitude: 37.7749),\n",
        "    geo.position(longitude: -122.1430, latitude: 37.4419))\n",
        "let bayPoints = plot.add_points(chart: california, positions: bayPositions,\n",
        "    values: List(12.0, 9.0), labels: List(\"San Francisco\", \"Palo Alto\"))\n",
        "bayPoints.extent(west: -122.65, south: 37.20, east: -121.70, north: 38.15)\n",
        "    .point_size(radius: 6.0)\n",
        "    .point_labels(\"avoid\")\n",
        "    .projection(\"lambert_azimuthal_equal_area\")\n",
        "    .title(\"Bay Area: supplied positions and separate value colors\")\n",
        "    .caption(\"Synthetic indices set color; uniform 6-pixel radii encode no quantity. Census 2025; no automatic point-in-polygon join.\")\n",
        "    .show()\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "mexico-city-observations-context",
      "metadata": {},
      "source": "## Mexico City: an explicit label mode\n\nInstall the optional mexico pack. The source’s legacy MX DIF key identifies its Mexico City federal entity polygon. This chart uses `point_labels(\"all\")`, which permits overlapping labels when there are several; `\"avoid\"` is the default and `\"none\"` suppresses point text while retaining markers and tooltip metadata. A coordinate drawn here does not establish a spatial membership test.\n"
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "mexico-city-observations",
      "metadata": {},
      "outputs": [],
      "source": [
        "// Optional pack: mexico. MX-DIF is the pinned source's legacy Mexico City key.\n",
        "plot.map(\"mexico\", keys: List(\"MX-DIF\"), values: List(7.0))\n",
        "    .add_points(positions: List(geo.position(longitude: -99.1332, latitude: 19.4326)),\n",
        "        values: List(14.0), labels: List(\"Mexico City\"))\n",
        "    .point_labels(\"all\")\n",
        "    .focus(\"MX-DIF\")\n",
        "    .projection(\"lambert_azimuthal_equal_area\")\n",
        "    .title(\"Mexico City: illustrative location over a federal entity\")\n",
        "    .caption(\"Synthetic indices; Natural Earth 2022 snapshot; legacy MX-DIF boundary; no street or municipal layer.\")\n",
        "    .show()\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "toronto-observations-context",
      "metadata": {},
      "source": "## Toronto: provincial context and local extent\n\nInstall the optional canada pack. A local extent enlarges the illustrative Toronto point within the Ontario polygon, using the default uniform 4 pixel radius and collision aware labels. This generalizes provincial geometry for display; it does not supply Toronto’s municipal or street boundaries. An exported SVG retains its drawing and tooltip metadata offline.\n"
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "toronto-observations",
      "metadata": {},
      "outputs": [],
      "source": [
        "// Optional pack: canada. The background is Ontario, not a Toronto city boundary.\n",
        "plot.map(\"canada\", keys: List(\"CA-ON\"), values: List(6.0))\n",
        "    .add_points(positions: List(geo.position(longitude: -79.3832, latitude: 43.6532)),\n",
        "        values: List(16.0), labels: List(\"Toronto\"))\n",
        "    .extent(west: -79.9, south: 43.3, east: -78.9, north: 44.0)\n",
        "    .projection(\"lambert_azimuthal_equal_area\")\n",
        "    .title(\"Toronto: illustrative position in an Ontario viewport\")\n",
        "    .caption(\"Synthetic indices; Natural Earth 2022 province boundary; local extent adds no finer geometry.\")\n",
        "    .show()\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "name": "aner",
      "display_name": "Aner",
      "language": "aner"
    },
    "language_info": {
      "name": "aner",
      "file_extension": ".aner",
      "mimetype": "text/x-aner"
    },
    "aner": {
      "status": "example",
      "execution_mode": "persistent-session"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
