dogpolicies-mcp 0.2.9 → 0.3.0
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.
- package/CHANGELOG.md +37 -0
- package/README.md +8 -4
- package/data/snapshot.json.gz +0 -0
- package/docs/tools.md +85 -15
- package/package.json +1 -1
- package/server.json +4 -4
- package/src/core/server.mjs +16 -4
- package/src/dogpolicies/i5.mjs +191 -0
- package/src/dogpolicies/prompts.mjs +23 -0
- package/src/dogpolicies/resources.mjs +49 -1
- package/src/dogpolicies/server.mjs +27 -2
- package/src/dogpolicies/tools/changes-near.mjs +1 -1
- package/src/dogpolicies/tools/compare-places.mjs +1 -1
- package/src/dogpolicies/tools/find-hotels.mjs +3 -1
- package/src/dogpolicies/tools/get-place.mjs +39 -2
- package/src/dogpolicies/tools/i5-conditions.mjs +219 -0
- package/src/dogpolicies/tools/i5-corridor.mjs +315 -0
- package/src/dogpolicies/tools/index.mjs +4 -0
- package/src/dogpolicies/tools/near.mjs +2 -2
- package/src/dogpolicies/tools/plan-trip.mjs +94 -3
- package/src/dogpolicies/tools/report-correction.mjs +1 -1
- package/src/dogpolicies/tools/route-stops.mjs +106 -7
- package/src/dogpolicies/tools/search-places.mjs +1 -1
- package/src/snapshot/build.mjs +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,43 @@ The data inside the package has its own date (`as_of` in every result). A
|
|
|
10
10
|
new package version ships a new snapshot; the server also refreshes from the
|
|
11
11
|
site on its own when the network allows.
|
|
12
12
|
|
|
13
|
+
## 0.3.0 - 2026-11-04
|
|
14
|
+
|
|
15
|
+
The I-5 axis: every I-5 stop in California carries its position on the I-5
|
|
16
|
+
centerline (s meters from San Ysidro, the same number the corridor JSON and
|
|
17
|
+
the simulator use) beside its Caltrans mile.
|
|
18
|
+
|
|
19
|
+
Added
|
|
20
|
+
|
|
21
|
+
- `dogpolicies_route_stops`: `ahead_miles` (a window from the start in the
|
|
22
|
+
direction of travel), `family` (only stops whose official source states
|
|
23
|
+
restrooms and a pet area or dog park) and `paired` (exits with people-stops
|
|
24
|
+
nearby, counted from OpenStreetMap and never named, matched to the nearest
|
|
25
|
+
dog-legal place). On I-5 every stop returns `s_m`, `miles_ahead`, `side`,
|
|
26
|
+
`off_miles`, `elevation_m`, `strip`, `restrooms`, `water`, `pet_area`,
|
|
27
|
+
`dog_park`, `hours` (with its source) and `family_stop`.
|
|
28
|
+
- `dogpolicies_i5_corridor`: the eleven stretches of I-5 in California with
|
|
29
|
+
their s and mile ranges, and the stops in a stretch, a mile range or a
|
|
30
|
+
window ahead of a point.
|
|
31
|
+
- `dogpolicies_i5_conditions`: Caltrans lane closures, road-weather readings,
|
|
32
|
+
message-sign text and chain-control status on I-5, fetched within the last
|
|
33
|
+
15 minutes and placed on the axis; conditions, not rules. Needs the network.
|
|
34
|
+
- `dogpolicies_get_place` returns `axis` and, for the dog side of a pairing,
|
|
35
|
+
`paired_stop`. `dogpolicies_plan_trip` returns `i5` (the drive leg's family
|
|
36
|
+
stops and paired stops) when the town is within 10 miles of I-5.
|
|
37
|
+
- Resource `dogpolicies://corridor/i-5`; prompt `drive_i5_with_dog`.
|
|
38
|
+
- The `hours` fact, in the source's own words.
|
|
39
|
+
- The snapshot carries the I-5 calibration table, strips and paired stops.
|
|
40
|
+
|
|
41
|
+
## 0.2.10 - 2026-11-04
|
|
42
|
+
|
|
43
|
+
- Listed in Claude's connector directory: the README and the install guide
|
|
44
|
+
link the listing, with adding it by URL kept as the alternative.
|
|
45
|
+
- Tool servers take an `onToolResult` hook (tool name, arguments, result and
|
|
46
|
+
time) after each call, beside `onToolCall`; the hosted server uses it to
|
|
47
|
+
count failures by code and names asked for that are not in the data.
|
|
48
|
+
- Fresh data snapshot.
|
|
49
|
+
|
|
13
50
|
## 0.2.9 - 2026-11-01
|
|
14
51
|
|
|
15
52
|
Data release: the snapshot now carries data round 5.
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
**[dogpolicies.com](https://dogpolicies.com/)** · Verified dog rules for California and Nevada travel, for AI assistants. [Install guide and example](https://dogpolicies.com/mcp/about/).
|
|
4
4
|
|
|
5
|
+
**Listed in Claude's connector directory** since November 4, 2026: [add DogPolicies in Claude](https://claude.ai/directory/dogpolicies) with nothing to install. DogPolicies is independent and not affiliated with Anthropic.
|
|
6
|
+
|
|
5
7
|
Ask Claude, Cursor or any MCP client "can my 70 lb dog stay at a Monterey hotel for under $50?", "what can my dog do in Carmel?" or "plan three nights in Tahoe with two dogs" and get an answer with the official source, the date it was checked and a link to the record. No API key, no account, no configuration: the data ships inside the package.
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -21,7 +23,7 @@ npx dogpolicies-mcp demo
|
|
|
21
23
|
- Whether dogs are allowed at 2,400+ parks, beaches, trails, hotels, campgrounds, cabin resorts and restaurant patios, with leash rules, restrictions, weight limits and pet fees.
|
|
22
24
|
- Which hotel will take _your_ dog: weight, number of dogs, nights and a fee budget, with the fee arithmetic spelled out ("2 dogs x 3 nights x $25 per pet per night = $150, capped at $100 per stay").
|
|
23
25
|
- A whole trip in one call: where to stay with this dog, what to do, where to eat, near any town or county.
|
|
24
|
-
- Dog-friendly stops along I-5, US-101, Highway 1, I-15, I-80, US-50, US-95 and US-93, in driving order.
|
|
26
|
+
- Dog-friendly stops along I-5, US-101, Highway 1, I-15, I-80, US-50, US-95 and US-93, in driving order. On I-5 in California, every stop sits on the I-5 centerline (s meters from San Ysidro) with its side, elevation and stretch; the next family stop (restrooms and a pet area stated by the source) in N miles; paired exits; and Caltrans conditions right now.
|
|
25
27
|
- Hotel chain pet policies (Motel 6, Red Roof, Kimpton and more) and which properties are exceptions.
|
|
26
28
|
- Side-by-side comparisons, and what changed since a date, everywhere or near a town.
|
|
27
29
|
- Areas the way travelers name them: East Bay, Lake Tahoe, Big Sur, Yosemite, Death Valley, the Mendocino Coast and the Bay Area's metros, as a filter, a place name in `near` and `plan_trip`, and a resource.
|
|
@@ -34,7 +36,7 @@ Pick the first one that fits; they all give the same server.
|
|
|
34
36
|
|
|
35
37
|
### 1. Claude (claude.ai or Claude Desktop): add the hosted connector, nothing to install
|
|
36
38
|
|
|
37
|
-
Settings → Connectors → **Add custom connector** → name **DogPolicies**, URL `https://dogpolicies.com/mcp/` → Add.
|
|
39
|
+
Open [DogPolicies in Claude's connector directory](https://claude.ai/directory/dogpolicies) and add it, then turn it on in the chat's tools menu. Or by hand: Settings → Connectors → **Add custom connector** → name **DogPolicies**, URL `https://dogpolicies.com/mcp/` → Add. No Node.js, no file editing; works on every plan that has connectors.
|
|
38
40
|
|
|
39
41
|
### 2. Claude Desktop: one-click extension
|
|
40
42
|
|
|
@@ -152,7 +154,9 @@ The `demo` output is the exact text an assistant receives:
|
|
|
152
154
|
| `dogpolicies_find_hotels` | Hotels that take a specific dog: weight, number of dogs, nights, fee budget. Verdicts (match, possible, excluded), cheapest first, fee arithmetic shown. |
|
|
153
155
|
| `dogpolicies_get_brand_policy` | A chain's published pet policy, its listed exceptions and property counts. |
|
|
154
156
|
| `dogpolicies_browse_answers` | Ready-made answers to common questions ("Which California state parks allow dogs?"). |
|
|
155
|
-
| `dogpolicies_route_stops` | Dog stops along a highway by mile and direction: rest areas with pet areas, hotels, campgrounds, parks, beaches.
|
|
157
|
+
| `dogpolicies_route_stops` | Dog stops along a highway by mile and direction: rest areas with pet areas, hotels, campgrounds, parks, beaches. On I-5 in California: s meters from San Ysidro, side, elevation, family stops (restrooms and a pet area stated) and paired exits. |
|
|
158
|
+
| `dogpolicies_i5_corridor` | I-5 in California as eleven stretches on the I-5 centerline, and the stops in a stretch, a mile range or a window ahead of a point. |
|
|
159
|
+
| `dogpolicies_i5_conditions` | Caltrans closures, road weather, sign text and chain controls on I-5 right now, placed on the same axis; conditions, not rules. Needs the network. |
|
|
156
160
|
| `dogpolicies_get_rule` | One rule by its stable id, with source, quote, confidence, verified date and freshness. |
|
|
157
161
|
| `dogpolicies_changes_since` | Verification events and rule changes since a date, newest first. |
|
|
158
162
|
| `dogpolicies_changes_near` | The same, limited to a radius around a town or point. |
|
|
@@ -162,7 +166,7 @@ Every tool returns readable markdown by default and structured JSON (`response_f
|
|
|
162
166
|
|
|
163
167
|
### Resources and prompts
|
|
164
168
|
|
|
165
|
-
Resources let a client attach a record without a tool call: `dogpolicies://place/{id}`, `dogpolicies://brand/{id}`, `dogpolicies://answer/{slug}`, `dogpolicies://route/{id}`, `dogpolicies://area/{id}` (all with completion), plus `dogpolicies://about`, `dogpolicies://answers` and `dogpolicies://
|
|
169
|
+
Resources let a client attach a record without a tool call: `dogpolicies://place/{id}`, `dogpolicies://brand/{id}`, `dogpolicies://answer/{slug}`, `dogpolicies://route/{id}`, `dogpolicies://area/{id}` (all with completion), plus `dogpolicies://about`, `dogpolicies://answers`, `dogpolicies://status` and `dogpolicies://corridor/i-5` (the I-5 stretches and every stop by s). Prompts give a client's slash menu the common trips: `plan_dog_trip`, `check_hotel_for_dog`, `road_trip_with_dog`, `drive_i5_with_dog`, `what_can_my_dog_do_here`, `cite_a_rule`, with town-name completion.
|
|
166
170
|
|
|
167
171
|
## How the data stays current
|
|
168
172
|
|
package/data/snapshot.json.gz
CHANGED
|
Binary file
|
package/docs/tools.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Tool reference
|
|
2
2
|
|
|
3
|
-
dogpolicies-mcp 0.
|
|
3
|
+
dogpolicies-mcp 0.3.0, generated by `node scripts/docs.mjs` from the live definitions. Every tool returns readable markdown by default and structured JSON with `response_format: "json"`; every result starts with a citation and ends with the attribution line.
|
|
4
4
|
|
|
5
5
|
## `dogpolicies_search_places`
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ dogpolicies-mcp 0.2.7, generated by `node scripts/docs.mjs` from the live defini
|
|
|
8
8
|
|
|
9
9
|
Search parks, beaches, trails, hotels, campgrounds and cabin resorts in California and Nevada by name, location and dog rules.
|
|
10
10
|
|
|
11
|
-
Returns one page of places with a one-line answer ("Yes, on a leash no longer than 6 feet."), status (yes, yes_restricted, no, varies), verification date and page URL.
|
|
11
|
+
Returns one page of places with a one-line answer ("Yes, on a leash no longer than 6 feet."), status (yes, yes_restricted, no, varies), verification date and page URL. Each result includes the place id.
|
|
12
12
|
|
|
13
13
|
Examples:
|
|
14
14
|
- "Off-leash beaches near San Diego" -> type="beach", off_leash=true, near={lat:32.72, lon:-117.16}
|
|
@@ -43,9 +43,9 @@ Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `total
|
|
|
43
43
|
|
|
44
44
|
**What is near a town** · since 0.2.0
|
|
45
45
|
|
|
46
|
-
Anything for dogs around a town, county or point: everything dog-related nearby, grouped by kind: beaches, parks, trails, hotels, campgrounds, cabins, places to eat and rest areas, each sorted by distance, with the dog rule and citation for each.
|
|
46
|
+
Anything for dogs around a town, county or point: everything dog-related nearby, grouped by kind: beaches, parks, trails, hotels, campgrounds, cabins, places to eat and rest areas, each sorted by distance, with the dog rule and citation for each. Answers "what can I do with my dog there?" for a named place.
|
|
47
47
|
|
|
48
|
-
Takes a town or county name (no coordinates needed) or a point.
|
|
48
|
+
Takes a town or county name (no coordinates needed) or a point.
|
|
49
49
|
|
|
50
50
|
Examples:
|
|
51
51
|
- "What can my dog do in Carmel?" -> place="Carmel"
|
|
@@ -70,9 +70,9 @@ Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `cente
|
|
|
70
70
|
|
|
71
71
|
**Get place details** · since 0.1.0
|
|
72
72
|
|
|
73
|
-
The full record for one place you already know by id: every dog rule with its display text, the rules list, and each source with its URL, publisher, capture date and quote.
|
|
73
|
+
The full record for one place you already know by id: every dog rule with its display text, the rules list, and each source with its URL, publisher, capture date and quote. A place on I-5 in California also carries its axis position (s meters from San Ysidro on the I-5 centerline, Caltrans mile, meters off the road, side of northbound travel, road elevation, strip) and, when it is the dog side of a paired stop, that pair: the exit and the people-stops near it (counted from OpenStreetMap, never named, not verified for restrooms).
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
Takes a place id, as returned in every search result. Example: id="carmel-beach".
|
|
76
76
|
|
|
77
77
|
Annotations: read-only true, destructive false, idempotent true, open-world false.
|
|
78
78
|
|
|
@@ -81,7 +81,7 @@ Annotations: read-only true, destructive false, idempotent true, open-world fals
|
|
|
81
81
|
| `id` (required) | string (min length 2, max length 120) | Place id, e.g. "fort-funston" |
|
|
82
82
|
| `response_format` | `markdown`, `json` (default `"markdown"`) | 'markdown' for readable text, 'json' for structured data |
|
|
83
83
|
|
|
84
|
-
Output fields: `id`, `uid`, `name`, `type`, `status`, `answer`, `citation`, `confidence`, `confirmed_by`, `freshness`, `verified_at`, `url`, `source_urls`, `record_license`, `as_of`, `license`, `attribution_text`, `attribution_url`, `facts`, `rule_records`, `not_stated`, `rules`, `sources`, `review_due` (more may be added; none removed).
|
|
84
|
+
Output fields: `id`, `uid`, `name`, `type`, `status`, `answer`, `citation`, `confidence`, `confirmed_by`, `freshness`, `verified_at`, `url`, `source_urls`, `record_license`, `as_of`, `license`, `attribution_text`, `attribution_url`, `facts`, `rule_records`, `not_stated`, `rules`, `sources`, `review_due`, `axis`, `paired_stop` (more may be added; none removed).
|
|
85
85
|
|
|
86
86
|
## `dogpolicies_compare_places`
|
|
87
87
|
|
|
@@ -89,7 +89,7 @@ Output fields: `id`, `uid`, `name`, `type`, `status`, `answer`, `citation`, `con
|
|
|
89
89
|
|
|
90
90
|
Which one is better for a dog? Compare two to six places on the facts that decide a dog trip: dogs allowed, leash rule, where dogs may go, pet fee, weight limit, pets per room, restrictions, plus confidence, freshness and who confirmed each record. One row per fact, one column per place, every place with its citation.
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
Answers "which one?" between candidates; ids come from any search result. Example: ids=["carmel-beach","asilomar-state-beach"].
|
|
93
93
|
|
|
94
94
|
Annotations: read-only true, destructive false, idempotent true, open-world false.
|
|
95
95
|
|
|
@@ -104,9 +104,9 @@ Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `place
|
|
|
104
104
|
|
|
105
105
|
**Plan a trip with a dog** · since 0.2.0
|
|
106
106
|
|
|
107
|
-
Plan a stay in a California or Nevada town with a dog, in one call: where to stay (hotels, campgrounds and cabins that will take this dog, with the pet fee for the whole stay worked out), what to do (beaches, parks and trails that allow dogs, nearest first) and where to eat (patios that take dogs), every item with its citation.
|
|
107
|
+
Plan a stay in a California or Nevada town with a dog, in one call: where to stay (hotels, campgrounds and cabins that will take this dog, with the pet fee for the whole stay worked out), what to do (beaches, parks and trails that allow dogs, nearest first) and where to eat (patios that take dogs), every item with its citation. When the town is within 10 miles of I-5 in California, the result also carries the drive leg on the I-5 axis: the town's position (Caltrans mile and s meters from San Ysidro), the next family stops (restrooms and a pet area or dog park stated by their official source) in each direction within 60 miles, and the paired stops (an exit with people-stops nearby, counted from OpenStreetMap and never named, matched to the nearest dog-legal place) within 10 miles.
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
Inputs: the town or county and the dog: weight, how many dogs, nights, and the most the user will pay in pet fees.
|
|
110
110
|
|
|
111
111
|
Examples:
|
|
112
112
|
- "Three nights in Monterey with our 70 lb Lab, pet fees under $100" -> place="Monterey", dog_weight_lb=70, nights=3, max_total_fee=100
|
|
@@ -129,7 +129,7 @@ Annotations: read-only true, destructive false, idempotent true, open-world fals
|
|
|
129
129
|
| `per_section` | integer (min 1, max 15, default `5`) | Results per section |
|
|
130
130
|
| `response_format` | `markdown`, `json` (default `"markdown"`) | 'markdown' for readable text, 'json' for structured data |
|
|
131
131
|
|
|
132
|
-
Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `label`, `radius_miles`, `asked`, `stays`, `stay_counts`, `outings` (more may be added; none removed).
|
|
132
|
+
Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `label`, `radius_miles`, `asked`, `stays`, `stay_counts`, `outings`, `i5` (more may be added; none removed).
|
|
133
133
|
|
|
134
134
|
## `dogpolicies_find_hotels`
|
|
135
135
|
|
|
@@ -137,6 +137,8 @@ Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `label
|
|
|
137
137
|
|
|
138
138
|
Find hotels and motels in California and Nevada that will take a specific dog, with the estimated pet fee for the stay.
|
|
139
139
|
|
|
140
|
+
Every amount is the hotel's pet fee, never the room rate: DogPolicies has no room prices.
|
|
141
|
+
|
|
140
142
|
Each hotel is sorted into "match" (the policy says yes on everything asked), "possible" (nothing rules it out, but something needs a call: a hotel that decides case by case, an unstated weight limit, a limit the hotel lifts with its approval, an "up to" fee) or excluded (left out). Matches come first, cheapest pet fee first. The fee arithmetic is spelled out for every result.
|
|
141
143
|
|
|
142
144
|
Examples:
|
|
@@ -209,13 +211,17 @@ Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `total
|
|
|
209
211
|
|
|
210
212
|
Dog-friendly stops along a California or Nevada highway, in driving order: rest areas (Caltrans rest areas with pet areas; Nevada rest areas, where leashed dogs are allowed), travel stops with dog parks, hotels, cabin resorts and campgrounds or RV parks near the road (all checked against the dog's weight and the pet-fee budget) and parks or beaches that allow dogs.
|
|
211
213
|
|
|
212
|
-
Each stop has its mile on the route and its distance off the road. Each route covers one state and stops at the state line. California miles follow the Caltrans odometer: north on I-5 (from the Mexican border), US-101 (from Los Angeles), Highway 1 (from Dana Point) and I-15 (i-15, San Diego to Primm); east on I-80 (i-80, San Francisco to the Nevada line) and US-50 (us-50, West Sacramento to Stateline). Nevada routes count Nevada mileposts from the California line, matching the exit numbers: north on I-15 (i-15-nevada), east on I-80 (i-80-nevada) and US-50 (us-50-nevada, Stateline to Utah); north on US-95 (us-95-nevada, California line to Oregon) and US-93 (us-93-nevada, Hoover Dam to Idaho), whose miles include the stretches they share with other highways. Where Highway 1 runs on US-101, stops on that stretch say so in on_road.
|
|
214
|
+
Each stop has its mile on the route and its distance off the road. Each route covers one state and stops at the state line. California miles follow the Caltrans odometer: north on I-5 (from the Mexican border), US-101 (from Los Angeles), Highway 1 (from Dana Point) and I-15 (i-15, San Diego to Primm); east on I-80 (i-80, San Francisco to the Nevada line) and US-50 (us-50, West Sacramento to Stateline). Nevada routes count Nevada mileposts from the California line, matching the exit numbers: north on I-15 (i-15-nevada), east on I-80 (i-80-nevada) and US-50 (us-50-nevada, Stateline to Utah); north on US-95 (us-95-nevada, California line to Oregon) and US-93 (us-93-nevada, Hoover Dam to Idaho), whose miles include the stretches they share with other highways. Where Highway 1 runs on US-101, stops on that stretch say so in on_road. A starting point is set with from_mile or near, plus a direction; ahead_miles limits the window to that many miles from the start in the direction of travel.
|
|
215
|
+
|
|
216
|
+
On I-5 in California each stop also carries its position on the I-5 centerline in meters from San Ysidro (s_m), miles_ahead of the start along the direction of travel, the side of the road it serves (right or left of northbound travel, or both), its distance off the freeway, the road's elevation in meters and the stretch (strip) it is in, plus restrooms, water, pet_area, dog_park and hours as its official source states them. With family=true only stops whose official source states restrooms and a pet area or dog park are returned. With paired=true the result also lists paired stops: a freeway exit in the window with places to stop for people nearby (located through OpenStreetMap, counted by kind, never named and not verified for restrooms) matched to the nearest DogPolicies place that allows dogs within about a mile, with its rule and source.
|
|
213
217
|
|
|
214
218
|
Routes covered: I-5 (i-5, 796 miles), US-101 (us-101, 809 miles), Highway 1 (highway-1, 736 miles), I-15 (i-15, 294 miles), I-80 (i-80, 204 miles), US-50 (us-50, 109 miles), I-15 (i-15-nevada, 124 miles), I-80 (i-80-nevada, 410 miles), US-50 (us-50-nevada, 409 miles), US-95 (us-95-nevada, 664 miles), US-93 (us-93-nevada, 526 miles).
|
|
215
219
|
|
|
216
220
|
Examples:
|
|
217
221
|
- "Driving north on I-5 from Los Angeles with a 70 lb dog, where can we stop?" -> near={lat:34.05, lon:-118.24}, direction="north", dog_weight_lb=70
|
|
218
222
|
- "Pet areas on the Grapevine" -> from_mile=170, to_mile=222, kinds=["rest_area","park"]
|
|
223
|
+
- "Next place in 40 miles where the whole family can use a restroom, dog included, northbound at Harris Ranch" -> near={lat:36.25, lon:-120.25}, direction="north", ahead_miles=40, family=true
|
|
224
|
+
- "Exits with a coffee shop and a park for the dog between Sacramento and Redding" -> from_mile=520, to_mile=680, paired=true
|
|
219
225
|
- "Heading south on 101 from San Francisco to Santa Barbara, where can the dog run?" -> route="us-101", near={lat:37.77, lon:-122.42}, to_mile=100, direction="south"
|
|
220
226
|
- "Dog-friendly hotel near Redding under $40 a night" -> near={lat:40.59, lon:-122.39}, kinds=["lodging"], max_total_fee=40
|
|
221
227
|
- "Driving I-80 east from Reno with a dog, where can we stop?" -> route="i-80-nevada", near={lat:39.53, lon:-119.81}, direction="east"
|
|
@@ -228,8 +234,11 @@ Annotations: read-only true, destructive false, idempotent true, open-world fals
|
|
|
228
234
|
| `near` | object | Start from the route mile nearest this point |
|
|
229
235
|
| `from_mile` | number (min 0, max 1000) | Start at this route mile |
|
|
230
236
|
| `to_mile` | number (min 0, max 1000) | Stop at this route mile |
|
|
237
|
+
| `ahead_miles` | number (min 1, max 1000) | Window in miles from the start (near or from_mile) in the direction of travel; an alternative to to_mile |
|
|
231
238
|
| `direction` | `north`, `south`, `east`, `west` (default `"north"`) | Direction of travel. Route miles increase going north, or east on I-80 and US-50; north and east both mean increasing miles |
|
|
232
239
|
| `kinds` | array of `rest_area`, `stop`, `lodging`, `campground`, `cabins`, `park`, `beach`, `trail`, `restaurant` | Kinds of stops to include; all by default |
|
|
240
|
+
| `family` | boolean (default `false`) | Only stops whose official source states restrooms and a pet area or dog park (I-5 in California) |
|
|
241
|
+
| `paired` | boolean (default `false`) | Also list the paired stops in the window: an exit with people-stops nearby and the nearest dog-legal place (I-5 in California) |
|
|
233
242
|
| `dog_friendly_only` | boolean (default `true`) | Leave out stops where dogs are not allowed |
|
|
234
243
|
| `dog_weight_lb` | number (min 1, max 250) | The dog's weight in pounds |
|
|
235
244
|
| `dogs` | integer (min 1, max 4, default `1`) | Number of dogs |
|
|
@@ -239,7 +248,66 @@ Annotations: read-only true, destructive false, idempotent true, open-world fals
|
|
|
239
248
|
| `offset` | integer (min 0, max 9007199254740991, default `0`) | Results to skip, for pagination |
|
|
240
249
|
| `response_format` | `markdown`, `json` (default `"markdown"`) | 'markdown' for readable text, 'json' for structured data |
|
|
241
250
|
|
|
242
|
-
Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `total`, `count`, `offset`, `has_more`, `stops`, `route`, `guide` (more may be added; none removed).
|
|
251
|
+
Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `total`, `count`, `offset`, `has_more`, `stops`, `route`, `guide`, `start`, `paired_stops` (more may be added; none removed).
|
|
252
|
+
|
|
253
|
+
## `dogpolicies_i5_corridor`
|
|
254
|
+
|
|
255
|
+
**I-5 corridor by stretch** · since 0.3.0
|
|
256
|
+
|
|
257
|
+
The I-5 corridor in California as eleven named stretches (strips) on the I-5 centerline, from San Ysidro (s = 0 m) to the Oregon line (s ≈ 1,281,400 m), and the dog stops in any stretch, mile range or window ahead of a point. Every stop carries its s in meters from San Ysidro, its Caltrans odometer mile, the side of the road it serves (right or left of northbound travel, or both), its distance off the freeway, the road's elevation, and restrooms, water, pet area, dog park and hours as its official source states them. A family stop is one whose official source states restrooms and a pet area or dog park. A paired stop is a freeway exit with places to stop for people nearby (located through OpenStreetMap, counted by kind, never named and not verified for restrooms) matched to the nearest DogPolicies place that allows dogs within about a mile, with its rule and source.
|
|
258
|
+
|
|
259
|
+
With no stretch, miles or point, the result is the list of stretches with their s and mile ranges and stop counts. Strips: sandiego (San Ysidro → Camp Pendleton), orange-la (Camp Pendleton → East LA), grapevine (East LA → Wheeler Ridge), kern-westside (Wheeler Ridge → Kettleman), westside (Kettleman → Santa Nella), delta (Santa Nella → Stockton), sacramento (Stockton → Woodland), valley (Woodland → Williams), tehama (Williams → Red Bluff), shasta (Red Bluff → Mt Shasta), siskiyou (Mt Shasta → Siskiyou Summit).
|
|
260
|
+
|
|
261
|
+
Examples:
|
|
262
|
+
- "What is between the Grapevine and Kettleman?" -> strip="grapevine" (East LA to Wheeler Ridge) and strip="kern-westside" (Wheeler Ridge to Kettleman)
|
|
263
|
+
- "The next 5 family stops northbound from Stockton" -> near={lat:37.95, lon:-121.29}, direction="north", family=true, limit=5
|
|
264
|
+
- "Every stop between mile 300 and 340" -> from_mile=300, to_mile=340
|
|
265
|
+
- "Exits with somewhere for people and a park for the dog in the Sacramento stretch" -> strip="sacramento", paired=true
|
|
266
|
+
|
|
267
|
+
Annotations: read-only true, destructive false, idempotent true, open-world false.
|
|
268
|
+
|
|
269
|
+
| Input | Type | Meaning |
|
|
270
|
+
|---|---|---|
|
|
271
|
+
| `strip` | `sandiego`, `orange-la`, `grapevine`, `kern-westside`, `westside`, `delta`, `sacramento`, `valley`, `tehama`, `shasta`, `siskiyou` | A stretch by id (sandiego, orange-la, grapevine, kern-westside, westside, delta, sacramento, valley, tehama, shasta, siskiyou) |
|
|
272
|
+
| `from_mile` | number (min 0, max 800) | Start of a mile range (Caltrans odometer) |
|
|
273
|
+
| `to_mile` | number (min 0, max 800) | End of a mile range |
|
|
274
|
+
| `near` | object | A point on or near I-5; the window starts at the nearest point of the road |
|
|
275
|
+
| `direction` | `north`, `south` (default `"north"`) | Direction of travel from near; north means increasing s |
|
|
276
|
+
| `ahead_miles` | number (min 1, max 800, default `50`) | Window in miles from near in the direction of travel |
|
|
277
|
+
| `kinds` | array of `rest_area`, `stop`, `lodging`, `campground`, `cabins`, `park`, `beach`, `trail`, `restaurant` | Kinds of stops to include; all by default |
|
|
278
|
+
| `family` | boolean (default `false`) | Only family stops |
|
|
279
|
+
| `paired` | boolean (default `false`) | Also list the paired stops in the window |
|
|
280
|
+
| `dog_friendly_only` | boolean (default `true`) | Leave out stops where dogs are not allowed |
|
|
281
|
+
| `limit` | integer (min 1, max 50, default `15`) | Maximum stops to return |
|
|
282
|
+
| `offset` | integer (min 0, max 9007199254740991, default `0`) | Stops to skip |
|
|
283
|
+
| `response_format` | `markdown`, `json` (default `"markdown"`) | 'markdown' for readable text, 'json' for structured data |
|
|
284
|
+
|
|
285
|
+
Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `axis_version`, `strips`, `window`, `total`, `stops`, `paired_stops` (more may be added; none removed).
|
|
286
|
+
|
|
287
|
+
## `dogpolicies_i5_conditions`
|
|
288
|
+
|
|
289
|
+
**I-5 conditions now** · since 0.3.0
|
|
290
|
+
|
|
291
|
+
Current Caltrans lane closures, road-weather station readings, changeable-message-sign text and chain-control status on I-5 in California, each placed on the I-5 centerline (s meters from San Ysidro and the Caltrans mile) and matched to the nearest DogPolicies dog stop. Conditions come from Caltrans' CWWP2 feeds fetched within the last 15 minutes (fetched_at in the result) and are not verified rules.
|
|
292
|
+
|
|
293
|
+
The window is a mile range (from_mile, to_mile) or a point with a direction and ahead_miles; with none, the whole of I-5 in California. Needs the network (the document is read from dogpolicies.com); offline the result is an error with code offline.
|
|
294
|
+
|
|
295
|
+
Examples:
|
|
296
|
+
- "Is there a closure or chains on the Grapevine right now?" -> from_mile=170, to_mile=222
|
|
297
|
+
- "Weather and closures in the next 60 miles northbound from Redding" -> near={lat:40.59, lon:-122.39}, direction="north", ahead_miles=60
|
|
298
|
+
|
|
299
|
+
Annotations: read-only true, destructive false, idempotent true, open-world false.
|
|
300
|
+
|
|
301
|
+
| Input | Type | Meaning |
|
|
302
|
+
|---|---|---|
|
|
303
|
+
| `from_mile` | number (min 0, max 800) | Start of a mile range |
|
|
304
|
+
| `to_mile` | number (min 0, max 800) | End of a mile range |
|
|
305
|
+
| `near` | object | A point on or near I-5 |
|
|
306
|
+
| `direction` | `north`, `south` (default `"north"`) | Direction of travel from near |
|
|
307
|
+
| `ahead_miles` | number (min 1, max 800, default `50`) | Window in miles from near |
|
|
308
|
+
| `response_format` | `markdown`, `json` (default `"markdown"`) | 'markdown' for readable text, 'json' for structured data |
|
|
309
|
+
|
|
310
|
+
Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `fetched_at`, `notice`, `window`, `chains_in_effect`, `closures`, `weather`, `signs`, `chain_controls`, `source` (more may be added; none removed).
|
|
243
311
|
|
|
244
312
|
## `dogpolicies_get_rule`
|
|
245
313
|
|
|
@@ -278,7 +346,7 @@ Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `total
|
|
|
278
346
|
|
|
279
347
|
**What changed near a town** · since 0.2.0
|
|
280
348
|
|
|
281
|
-
Verification events (confirmed, changed, source gone, blocked, disputed) since a date for places within a radius of a town, county or point, newest first. The way to answer "has anything changed around Tahoe since my last trip?" or to re-check a saved itinerary.
|
|
349
|
+
Verification events (confirmed, changed, source gone, blocked, disputed) since a date for places within a radius of a town, county or point, newest first. The way to answer "has anything changed around Tahoe since my last trip?" or to re-check a saved itinerary.
|
|
282
350
|
|
|
283
351
|
Example: "What changed near Monterey since September?" -> place="Monterey", since="2026-09-01"
|
|
284
352
|
|
|
@@ -301,7 +369,7 @@ Output fields: `as_of`, `license`, `attribution_text`, `attribution_url`, `label
|
|
|
301
369
|
|
|
302
370
|
**Report a correction** · since 0.1.0
|
|
303
371
|
|
|
304
|
-
File a correction when a user says a rule on a record is wrong or has changed (a fee went up, a beach closed to dogs, a hotel now takes two pets). The report goes to a person who re-reads the official source; nothing is published automatically and the record does not change until it is verified.
|
|
372
|
+
File a correction when a user says a rule on a record is wrong or has changed (a fee went up, a beach closed to dogs, a hotel now takes two pets). The report goes to a person who re-reads the official source; nothing is published automatically and the record does not change until it is verified. Takes the place id, a sentence or two on what is wrong, and optionally the official page the user saw. The only personal detail it accepts is an optional contact the user offers.
|
|
305
373
|
|
|
306
374
|
Annotations: read-only false, destructive false, idempotent false, open-world true.
|
|
307
375
|
|
|
@@ -325,6 +393,7 @@ Output fields: `report_id`, `place_id`, `status`, `url` (more may be added; none
|
|
|
325
393
|
| `dogpolicies://brand/{id}` | A chain's published pet policy, exceptions and property counts | text/markdown |
|
|
326
394
|
| `dogpolicies://answer/{slug}` | The places that answer one ready-made question | text/markdown |
|
|
327
395
|
| `dogpolicies://route/{id}` | Dog-friendly stops along one highway in driving order | text/markdown |
|
|
396
|
+
| `dogpolicies://corridor/i-5` | I-5 in California as eleven stretches on the I-5 centerline (s meters from San Ysidro), with every dog stop at its s, the family stops and the paired stops | application/json |
|
|
328
397
|
| `dogpolicies://area/{id}` | Every dog-related place in one area (East Bay, Lake Tahoe, Big Sur), grouped by kind | text/markdown |
|
|
329
398
|
|
|
330
399
|
Templates support completion (`completion/complete`) for their variable.
|
|
@@ -336,5 +405,6 @@ Templates support completion (`completion/complete`) for their variable.
|
|
|
336
405
|
| `plan_dog_trip` | A stay in a California or Nevada town: where to stay with this dog, what to do, where to eat, with sources | `destination`, `dog`, `nights`, `budget` |
|
|
337
406
|
| `check_hotel_for_dog` | Check one hotel or a town's hotels against a specific dog: weight, count, nights, fee | `hotel_or_town`, `dog_weight_lb`, `dogs`, `nights` |
|
|
338
407
|
| `road_trip_with_dog` | Dog-friendly stops along a highway in driving order: rest areas, parks, hotels within budget | `route`, `from`, `direction`, `dog_weight_lb` |
|
|
408
|
+
| `drive_i5_with_dog` | The drive on I-5 in California: the next family stops (restrooms and a pet area) and paired exits ahead, with conditions now | `from`, `direction`, `ahead_miles` |
|
|
339
409
|
| `what_can_my_dog_do_here` | Beaches, parks, trails, patios and stays near a town, with the rule for each | `place` |
|
|
340
410
|
| `cite_a_rule` | The official rule for one place with the quoted source text, ready to cite | `place_id` |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dogpolicies-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MCP server for verified dog rules at California and Nevada parks, beaches, trails, hotels, campgrounds and restaurant patios: leash rules, pet fees, weight limits, trip planning, every fact with its official source and the date it was checked.",
|
|
5
5
|
"mcpName": "io.github.xultrax-web/dogpolicies-mcp",
|
|
6
6
|
"type": "module",
|
package/server.json
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
"name": "io.github.xultrax-web/dogpolicies-mcp",
|
|
4
4
|
"title": "DogPolicies",
|
|
5
5
|
"description": "Verified dog rules for California and Nevada travel: parks, beaches, hotels, fees, sourced and dated",
|
|
6
|
-
"websiteUrl": "https://
|
|
6
|
+
"websiteUrl": "https://dogpolicies.com/mcp/about/",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "https://github.com/xultrax-web/dogpolicies-mcp",
|
|
9
9
|
"source": "github"
|
|
10
10
|
},
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.3.0",
|
|
12
12
|
"packages": [
|
|
13
13
|
{
|
|
14
14
|
"registryType": "npm",
|
|
15
15
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
16
16
|
"identifier": "dogpolicies-mcp",
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.3.0",
|
|
18
18
|
"runtimeHint": "npx",
|
|
19
19
|
"transport": {
|
|
20
20
|
"type": "stdio"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"tool": "dogpolicies-release",
|
|
49
49
|
"license": "code MIT; data CC BY 4.0 (chain-hotel names and locations ODbL)",
|
|
50
50
|
"coverage": "California and Nevada",
|
|
51
|
-
"tools":
|
|
51
|
+
"tools": 15
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
package/src/core/server.mjs
CHANGED
|
@@ -48,7 +48,7 @@ import { stableStringify } from "./result.mjs";
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* @param {object} options
|
|
51
|
-
* @param {{ name: string, title?: string, version: string }} options.identity
|
|
51
|
+
* @param {{ name: string, title?: string, version: string, websiteUrl?: string, icons?: { src: string, mimeType?: string, sizes?: string[] }[] }} options.identity
|
|
52
52
|
* @param {string} options.instructions
|
|
53
53
|
* @param {ToolDefinition[]} options.tools
|
|
54
54
|
* @param {ResourceDefinition[]} [options.resources]
|
|
@@ -56,6 +56,7 @@ import { stableStringify } from "./result.mjs";
|
|
|
56
56
|
* @param {() => string} options.dataVersion current data version, for the cache key
|
|
57
57
|
* @param {object} [options.log]
|
|
58
58
|
* @param {(name: string, ctx: object) => any} [options.onToolCall]
|
|
59
|
+
* @param {(name: string, ctx: object, done: { args: object, output: object, ms: number }) => any} [options.onToolResult] after the call, with its result and time
|
|
59
60
|
* @param {number} [options.cacheSize]
|
|
60
61
|
* @param {object} [options.stats] a counter object shared across servers
|
|
61
62
|
* @param {string} [options.aliasPrefix] also register every tool under this prefix (older clients)
|
|
@@ -69,12 +70,19 @@ export function createToolServer({
|
|
|
69
70
|
dataVersion = () => "",
|
|
70
71
|
log,
|
|
71
72
|
onToolCall,
|
|
73
|
+
onToolResult,
|
|
72
74
|
cacheSize = 200,
|
|
73
75
|
stats = { calls: 0, errors: 0, cacheHits: 0 },
|
|
74
76
|
aliasPrefix = null,
|
|
75
77
|
}) {
|
|
76
78
|
const server = new McpServer(
|
|
77
|
-
{
|
|
79
|
+
{
|
|
80
|
+
name: identity.name,
|
|
81
|
+
title: identity.title,
|
|
82
|
+
version: identity.version,
|
|
83
|
+
...(identity.icons ? { icons: identity.icons } : {}),
|
|
84
|
+
...(identity.websiteUrl ? { websiteUrl: identity.websiteUrl } : {}),
|
|
85
|
+
},
|
|
78
86
|
{
|
|
79
87
|
instructions,
|
|
80
88
|
// Empty lists, not "method not found": directory scanners and some
|
|
@@ -116,13 +124,15 @@ export function createToolServer({
|
|
|
116
124
|
output = toErrorResult(error, { log });
|
|
117
125
|
}
|
|
118
126
|
if (output.isError) stats.errors++;
|
|
127
|
+
const ms = performance.now() - started;
|
|
119
128
|
try {
|
|
120
129
|
await counted;
|
|
130
|
+
await onToolResult?.(tool.name, ctx, { args, output, ms });
|
|
121
131
|
} catch {
|
|
122
132
|
// counting never fails a call
|
|
123
133
|
}
|
|
124
134
|
log?.debug(
|
|
125
|
-
`${tool.name} ${output.isError ? "error" : "ok"} in ${
|
|
135
|
+
`${tool.name} ${output.isError ? "error" : "ok"} in ${ms.toFixed(1)} ms`,
|
|
126
136
|
);
|
|
127
137
|
return output;
|
|
128
138
|
};
|
|
@@ -131,7 +141,9 @@ export function createToolServer({
|
|
|
131
141
|
description,
|
|
132
142
|
inputSchema: tool.inputSchema,
|
|
133
143
|
outputSchema: tool.outputSchema,
|
|
134
|
-
annotations:
|
|
144
|
+
// The title also goes in the annotations: directories (Claude's among
|
|
145
|
+
// them) read annotations.title for the listing.
|
|
146
|
+
annotations: { title: tool.title, ...tool.annotations },
|
|
135
147
|
};
|
|
136
148
|
server.registerTool(tool.name, config, handler);
|
|
137
149
|
// The old names, for clients configured before a rename.
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// The I-5 axis as the package sees it: the snapshot's routes["i-5"].axis
|
|
2
|
+
// carries the calibration table (Caltrans odometer mile <-> s meters from
|
|
3
|
+
// San Ysidro), the 11 California strips and the paired stops; every I-5 stop
|
|
4
|
+
// carries s_m, axis_side, elevation_m and strip. This module turns those into
|
|
5
|
+
// the windows and rows the tools return. Pure: no I/O.
|
|
6
|
+
|
|
7
|
+
import { nearestOnLine } from "../core/geo.mjs";
|
|
8
|
+
|
|
9
|
+
export const MILE_M = 1609.344;
|
|
10
|
+
export const I5 = "i-5";
|
|
11
|
+
|
|
12
|
+
/** The axis block of a route, or null when the route has none. */
|
|
13
|
+
export const axisOf = (route) => route?.axis ?? null;
|
|
14
|
+
|
|
15
|
+
/** Piecewise-linear interpolation over the calibration table, both ways. */
|
|
16
|
+
export function calibrationOf(axis) {
|
|
17
|
+
const miles = axis.calibration.map((r) => r[0]);
|
|
18
|
+
const ss = axis.calibration.map((r) => r[1]);
|
|
19
|
+
const n = miles.length;
|
|
20
|
+
const interp = (xs, ys, x) => {
|
|
21
|
+
if (x <= xs[0]) return ys[0] + ((x - xs[0]) * (ys[1] - ys[0])) / (xs[1] - xs[0]);
|
|
22
|
+
if (x >= xs[n - 1])
|
|
23
|
+
return ys[n - 1] + ((x - xs[n - 1]) * (ys[n - 1] - ys[n - 2])) / (xs[n - 1] - xs[n - 2]);
|
|
24
|
+
let lo = 0;
|
|
25
|
+
let hi = n - 1;
|
|
26
|
+
while (hi - lo > 1) {
|
|
27
|
+
const mid = (lo + hi) >> 1;
|
|
28
|
+
if (xs[mid] <= x) lo = mid;
|
|
29
|
+
else hi = mid;
|
|
30
|
+
}
|
|
31
|
+
const span = xs[hi] - xs[lo];
|
|
32
|
+
return span ? ys[lo] + ((x - xs[lo]) * (ys[hi] - ys[lo])) / span : ys[lo];
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
sToMile: (s) => interp(ss, miles, s),
|
|
36
|
+
mileToS: (mile) => interp(miles, ss, mile),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The strip whose [startS, endS) holds s (strips overlap; the first wins). */
|
|
41
|
+
export function stripAt(axis, s) {
|
|
42
|
+
for (const st of axis.strips) if (s >= st.startS && s < st.endS) return st;
|
|
43
|
+
return s >= axis.strips.at(-1).endS ? axis.strips.at(-1) : axis.strips[0];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A strip by id or by a word of its name ("grapevine", "Kettleman"). */
|
|
47
|
+
export function findStrip(axis, text) {
|
|
48
|
+
const q = (text ?? "").toLowerCase().trim();
|
|
49
|
+
if (!q) return null;
|
|
50
|
+
return (
|
|
51
|
+
axis.strips.find((st) => st.id === q) ??
|
|
52
|
+
axis.strips.find((st) => st.name.toLowerCase().includes(q)) ??
|
|
53
|
+
null
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Where a point is on I-5: snap to the route's Caltrans line for the mile,
|
|
59
|
+
* then the calibration table for s. { mile, s, off_miles } or null when the
|
|
60
|
+
* point is more than `maxOffMiles` from the road.
|
|
61
|
+
*/
|
|
62
|
+
export function positionOf(route, near, { maxOffMiles = 25 } = {}) {
|
|
63
|
+
const axis = axisOf(route);
|
|
64
|
+
if (!axis || !near) return null;
|
|
65
|
+
const at = nearestOnLine(route.points, near);
|
|
66
|
+
if (at.mile == null || at.offMiles > maxOffMiles) return null;
|
|
67
|
+
const cal = calibrationOf(axis);
|
|
68
|
+
return {
|
|
69
|
+
mile: Math.round(at.mile * 10) / 10,
|
|
70
|
+
s: Math.round(cal.mileToS(at.mile)),
|
|
71
|
+
off_miles: Math.round(at.offMiles * 10) / 10,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const hasRestrooms = (p) =>
|
|
76
|
+
(p.facts?.amenities?.value ?? []).some((a) => /restroom/i.test(a));
|
|
77
|
+
const hasWater = (p) =>
|
|
78
|
+
(p.facts?.amenities?.value ?? []).some((a) => /water/i.test(a));
|
|
79
|
+
|
|
80
|
+
/** Restrooms stated, a pet area or dog park stated, dogs allowed, open. */
|
|
81
|
+
export const isFamilyStop = (p) =>
|
|
82
|
+
hasRestrooms(p) &&
|
|
83
|
+
Boolean(p.facts?.petArea?.value || p.facts?.dogPark?.value) &&
|
|
84
|
+
["yes", "yes_restricted"].includes(p.status) &&
|
|
85
|
+
(p.operating_status ?? "open") === "open";
|
|
86
|
+
|
|
87
|
+
/** The hours fact with its source, or null. */
|
|
88
|
+
export function hoursOf(p) {
|
|
89
|
+
const row = (p.rows ?? []).find((r) => r.key === "hours");
|
|
90
|
+
if (!row) return null;
|
|
91
|
+
const src = (p.sources ?? [])[row.source - 1];
|
|
92
|
+
return { text: row.value, source_url: src?.url ?? null, checked: src?.checked ?? null };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The axis fields for a stop row: s, miles ahead of a start (signed along
|
|
97
|
+
* the direction of travel), side, distance off, elevation, and the family
|
|
98
|
+
* facts with their sources.
|
|
99
|
+
*/
|
|
100
|
+
export function axisFields(stop, { startS = null, ahead = true } = {}) {
|
|
101
|
+
const p = stop.place;
|
|
102
|
+
const out = {
|
|
103
|
+
s_m: stop.s_m ?? null,
|
|
104
|
+
miles_ahead:
|
|
105
|
+
stop.s_m != null && startS != null
|
|
106
|
+
? Math.round((((ahead ? 1 : -1) * (stop.s_m - startS)) / MILE_M) * 10) / 10
|
|
107
|
+
: null,
|
|
108
|
+
side: stop.axis_side ?? null,
|
|
109
|
+
off_miles: stop.off_miles ?? null,
|
|
110
|
+
elevation_m: stop.elevation_m ?? null,
|
|
111
|
+
strip: stop.strip ?? null,
|
|
112
|
+
restrooms: hasRestrooms(p),
|
|
113
|
+
water: hasWater(p),
|
|
114
|
+
pet_area: Boolean(p.facts?.petArea?.value),
|
|
115
|
+
dog_park: Boolean(p.facts?.dogPark?.value),
|
|
116
|
+
hours: hoursOf(p),
|
|
117
|
+
family_stop: isFamilyStop(p),
|
|
118
|
+
};
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** True when the stop serves travel in this direction (ahead = northbound). */
|
|
123
|
+
export const servesDirection = (stop, ahead) =>
|
|
124
|
+
!stop.axis_side ||
|
|
125
|
+
stop.axis_side === "both" ||
|
|
126
|
+
stop.axis_side === (ahead ? "right" : "left");
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The window of stops from a start s in a direction: ahead means increasing
|
|
130
|
+
* s. `aheadMiles` null means to the end of the route.
|
|
131
|
+
*/
|
|
132
|
+
export function windowStops(route, { startS, ahead, aheadMiles = null }) {
|
|
133
|
+
const axis = axisOf(route);
|
|
134
|
+
const end = ahead
|
|
135
|
+
? aheadMiles == null
|
|
136
|
+
? Infinity
|
|
137
|
+
: startS + aheadMiles * MILE_M
|
|
138
|
+
: aheadMiles == null
|
|
139
|
+
? -Infinity
|
|
140
|
+
: startS - aheadMiles * MILE_M;
|
|
141
|
+
const inWindow = (s) =>
|
|
142
|
+
ahead ? s > startS && s <= end : s < startS && s >= end;
|
|
143
|
+
const rows = route.stops.filter(
|
|
144
|
+
(x) => x.s_m != null && inWindow(x.s_m) && servesDirection(x, ahead),
|
|
145
|
+
);
|
|
146
|
+
rows.sort((a, b) => (ahead ? a.s_m - b.s_m : b.s_m - a.s_m));
|
|
147
|
+
void axis;
|
|
148
|
+
return rows;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The paired stops whose exit lies in [lo, hi] s, in s order. */
|
|
152
|
+
export function pairedIn(axis, lo, hi) {
|
|
153
|
+
return (axis.paired ?? []).filter((p) => p.exit.s >= lo && p.exit.s <= hi);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The sentence for a pair's people side: counts and kinds, never a name. */
|
|
157
|
+
export function peopleStopsText(c) {
|
|
158
|
+
const parts = [];
|
|
159
|
+
if (c.cafe) parts.push(c.cafe === 1 ? "a coffee shop" : `${c.cafe} coffee shops`);
|
|
160
|
+
if (c.fast_food)
|
|
161
|
+
parts.push(c.fast_food === 1 ? "a fast-food place" : `${c.fast_food} fast-food places`);
|
|
162
|
+
if (c.fuel) parts.push(c.fuel === 1 ? "a gas station" : `${c.fuel} gas stations`);
|
|
163
|
+
const list =
|
|
164
|
+
parts.length > 1 ? `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}` : (parts[0] ?? "nothing");
|
|
165
|
+
return `${list} within half a mile of the exit (locations from OpenStreetMap; restrooms not verified)`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** A pair as a tool returns it, with the dog-stop's current freshness-free summary fields. */
|
|
169
|
+
export function pairRow(pair, graph) {
|
|
170
|
+
const p = graph.placeById.get(pair.dogStop.placeId);
|
|
171
|
+
return {
|
|
172
|
+
exit: pair.exit,
|
|
173
|
+
people_stops: { ...pair.peopleStops, restrooms: "unverified", source: "OpenStreetMap" },
|
|
174
|
+
dog_stop: {
|
|
175
|
+
...pair.dogStop,
|
|
176
|
+
url: p?.url ?? null,
|
|
177
|
+
markdown_url: p?.markdown_url ?? null,
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** The markdown line for a pair. */
|
|
183
|
+
export function pairLine(row) {
|
|
184
|
+
const d = row.dog_stop;
|
|
185
|
+
const leash =
|
|
186
|
+
d.leash === "required" ? ", on leash" : d.leash?.startsWith("off_leash") ? ", off leash" : "";
|
|
187
|
+
return [
|
|
188
|
+
`- Exit ${row.exit.ref}${row.exit.name ? ` (${row.exit.name})` : ""}, mile ${row.exit.mile.toFixed(1)} (s ${row.exit.s.toLocaleString("en-US")} m): ${peopleStopsText(row.people_stops)}.`,
|
|
189
|
+
` Dogs: ${d.name}, about ${d.walkMin} minute${d.walkMin === 1 ? "" : "s"} on foot (${(d.distM / MILE_M).toFixed(1)} mi), ${d.answer === "yes" ? "dogs allowed" : "allowed with restrictions"}${leash}. ${d.citation}`,
|
|
190
|
+
].join("\n");
|
|
191
|
+
}
|