+
+ progressBar.removeAttribute("value");
+ statusSpan.innerText = "analyzing walkability"
+ const amenitiesResponse = await fetch(AMENITIES_PATH);
+ if (amenitiesResponse.ok) {
+ const amenities = await amenitiesResponse.json();
+ const featuresAndScores = [];
+ for (const [i, feature] of matches.entries()) {
+ progressBar.value = i / matches.length;
+ const arcLengths = Object.values(amenities).map(
+ locations => Math.min(...locations.map(
+ point => arcBetween(feature.centerPoint, point)))
+ );
+ arcLengths.sort();
+ // score: median across amenity types of arc length to nearest
+ const mid = arcLengths.length / 2;
+ const score = arcLengths.length % 2 == 0 ?
+ (arcLengths[mid] + arcLengths[mid - 1]) / 2
+ : arcLengths[Math.floor(mid)];
+ featuresAndScores.push([feature, score]);
+ }
+ featuresAndScores.sort(([a, aScore], [b, bScore]) => aScore - bScore);
+ const listElement = document.getElementById("walkable");
+ for (const [feature, _] of featuresAndScores.values().take(10)) {
+ const entryElement = document.createElement("li");
+ const linkElement = document.createElement("a");
+ entryElement.append(linkElement);
+ linkElement.setAttribute(
+ "href",
+ `https://www.cityofmadison.com/assessor/property/propertydata.cfm?ParcelN=${feature.properties.Parcel}`
+ );
+ linkElement.append(feature.properties.Address);
+ listElement.append(entryElement);
+ }
+ } else {
+ console.error(amenitiesResponse);
+ throw new Error("Amenities request failed");
+ }