Skip to content

Commit 3a5d693

Browse files
committed
Move from legacy Carto to Supabase retaining current functionality
1 parent 2eaf13b commit 3a5d693

File tree

8 files changed

+5297
-8154
lines changed

8 files changed

+5297
-8154
lines changed

package-lock.json

Lines changed: 5230 additions & 8139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint:fix": "eslint --fix './src/**/*.{js,ts,svelte}'"
1212
},
1313
"devDependencies": {
14-
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",
14+
"@sveltejs/vite-plugin-svelte": "^2.4.6",
1515
"@tsconfig/svelte": "^2.0.1",
1616
"autoprefixer": "^10.4.7",
1717
"eslint": "^8.20.0",
@@ -22,13 +22,13 @@
2222
"postcss": "^8.4.14",
2323
"postcss-load-config": "^4.0.1",
2424
"simple-svelte-autocomplete": "^2.4.0",
25-
"svelte": "^3.44.0",
26-
"svelte-check": "^2.2.7",
27-
"svelte-preprocess": "^4.10.7",
25+
"svelte": "^3.55.0",
26+
"svelte-check": "^3.4.6",
27+
"svelte-preprocess": "^5.0.3",
2828
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.17",
2929
"tslib": "^2.3.1",
3030
"typescript": "^4.5.4",
31-
"vite": "^2.9.9"
31+
"vite": "^4.4.9"
3232
},
3333
"dependencies": {
3434
"@mapbox/polylabel": "^1.0.2",
@@ -39,5 +39,11 @@
3939
"@types/polylabel": "^1.0.5",
4040
"mapbox-gl": "^2.8.2",
4141
"svelte-use-click-outside": "^1.0.0"
42+
},
43+
"exports": {
44+
".": {
45+
"svelte": "./src/index.js",
46+
"default": "./src/index.js"
47+
}
4248
}
4349
}

src/assets/boundaries/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export interface ILayer {
4040
/** SQL query to fetch data from Carto */
4141
sql: string;
4242

43+
/** SQL query to fetch data from Supabase */
44+
apiUrl: string;
45+
4346
/** Icon to display */
4447
icon: string;
4548

@@ -63,6 +66,7 @@ export const layers: ILayers = {
6366
description_url: 'https://communityprofiles.planning.nyc.gov/',
6467
// Remove parks
6568
sql: `SELECT * FROM all_bounds WHERE id = 'cd' AND NOT namecol IN ('164','226','227','228','355','356','480','481','482','483','484','595')`,
69+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.cd&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0&namecol=not.in.(164,226,227,228,355,356,480,481,482,483,484,595)',
6670
icon: '💬',
6771
formatUrl: name => get_cd_url(name[0], name.substring(1, 3)),
6872
formatContent: name => format_cd(name[0], name.substring(1, 3))
@@ -74,6 +78,7 @@ export const layers: ILayers = {
7478
'A police precinct is a geographical area patrolled by the NYPD. The term "precinct" may also refer to the main police station for such a geographical area.',
7579
description_url: 'https://www1.nyc.gov/site/nypd/index.page',
7680
sql: `SELECT * FROM all_bounds WHERE id = 'pp'`,
81+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.pp&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
7782
icon: '🚔',
7883
formatUrl: precinct => get_pp_url(parseInt(precinct)),
7984
formatContent: name => format_default(name)
@@ -85,6 +90,7 @@ export const layers: ILayers = {
8590
'For operations management, the Department of Sanitation (DSNY) divides the city into 59 Sanitation Districts. The boundary for each district is congruent with the Community District boundary.',
8691
description_url: 'https://www1.nyc.gov/assets/dsny/site/home',
8792
sql: `SELECT * FROM all_bounds WHERE id = 'dsny'`,
93+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.dsny&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
8894
icon: '🗑',
8995
formatContent: name => format_default(name)
9096
},
@@ -94,6 +100,7 @@ export const layers: ILayers = {
94100
description:
95101
'A Fire Battalion consists of several fire stations and multiple fire companies, and is led by a Battalion Chief.',
96102
sql: `SELECT * FROM all_bounds WHERE id = 'fb'`,
103+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.fb&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
97104
icon: '🔥',
98105
formatContent: name => format_default(name)
99106
},
@@ -104,6 +111,7 @@ export const layers: ILayers = {
104111
'A School District is a geographical area with multiple schools.',
105112
description_url: 'https://www.schools.nyc.gov/',
106113
sql: `SELECT * FROM all_bounds WHERE id = 'sd'`,
114+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.sd&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
107115
icon: '🎓',
108116
formatContent: name => format_default(name)
109117
},
@@ -113,6 +121,7 @@ export const layers: ILayers = {
113121
description:
114122
'Health Center Districts are aggregates of health areas and are used for reporting health statistics. They were created by the NYC Department of Health and Mental Hygiene (DOHMH).',
115123
sql: `SELECT * FROM all_bounds WHERE id = 'hc'`,
124+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.hc&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
116125
icon: '🩺',
117126
formatContent: name => format_default(name)
118127
},
@@ -123,6 +132,7 @@ export const layers: ILayers = {
123132
'The New York City Council is the lawmaking body of New York City. It has 51 members from 51 council districts throughout the five boroughs. The district lines have been updated in 2024.',
124133
description_url: 'https://council.nyc.gov/',
125134
sql: `SELECT * FROM all_bounds WHERE id = 'cc_upcoming'`,
135+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.cc_upcoming&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
126136
icon: '🍎',
127137
formatUrl: name => `https://council.nyc.gov/district-${name}`,
128138
formatContent: name => format_default(name)
@@ -134,6 +144,7 @@ export const layers: ILayers = {
134144
'Congressional Districts are the 435 regions from which voting representatives are elected to the U.S. House of Representatives.',
135145
description_url: 'https://www.house.gov/',
136146
sql: `SELECT * FROM all_bounds WHERE id = 'nycongress'`,
147+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.nycongress&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
137148
icon: '🇺🇸',
138149
formatUrl: name => `https://www.govtrack.us/congress/members/NY/${name}`,
139150
formatContent: name => format_default(name)
@@ -145,6 +156,7 @@ export const layers: ILayers = {
145156
'The New York State Assembly is the lower house of the New York State Legislature, with the New York State Senate being the upper house. There are 150 seats in the Assembly.',
146157
description_url: 'https://nyassembly.gov/',
147158
sql: `SELECT * FROM all_bounds WHERE id = 'sa'`,
159+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.sa&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
148160
icon: '🧑‍⚖️',
149161
formatUrl: name =>
150162
`https://ballotpedia.org/New_York_State_Assembly_District_${name}`,
@@ -157,6 +169,7 @@ export const layers: ILayers = {
157169
'The New York State Senate is the upper house of the New York State Legislature; the New York State Assembly is its lower house. Its members are elected to two-year terms; there are no term limits. There are 63 seats in the Senate.',
158170
description_url: 'https://www.nysenate.gov/',
159171
sql: `SELECT * FROM all_bounds WHERE id = 'ss'`,
172+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.ss&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
160173
icon: '⚖️',
161174
formatUrl: name => `https://www.nysenate.gov/district/${name}`,
162175
formatContent: name => format_default(name)
@@ -167,6 +180,7 @@ export const layers: ILayers = {
167180
description:
168181
'Neighborhood Tabulation Areas are aggregations of census tracts, adapted as a method of presenting the U.S. Census Bureau’s American Community Survey (ACS).',
169182
sql: `SELECT * FROM all_bounds WHERE namecol NOT IN ('park-cemetery-etc-Brooklyn','park-cemetery-etc-Queens', 'park-cemetery-etc-Bronx', 'park-cemetery-etc-Manhattan', 'park-cemetery-etc-Staten Island', 'Airport') and id = 'nta'`,
183+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.nta&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0&namecol=not.in.(park-cemetery-etc-Brooklyn,park-cemetery-etc-Queens, park-cemetery-etc-Bronx, park-cemetery-etc-Manhattan, park-cemetery-etc-Staten Island, Airport)',
170184
icon: '🏘',
171185
formatContent: name => format_default(name)
172186
},
@@ -175,6 +189,7 @@ export const layers: ILayers = {
175189
name: 'Historic District',
176190
name_plural: 'Historic Districts',
177191
sql: `SELECT * FROM all_bounds WHERE id = 'hd'`,
192+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.hd&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
178193
icon: '🗝',
179194
formatContent: name => format_default(name)
180195
},
@@ -185,6 +200,7 @@ export const layers: ILayers = {
185200
'A Business Improvement District (BID) is a geographical area where local stakeholders oversee and fund the maintenance, improvement, and promotion of their commercial district, going above and beyond those typically provided by the city.',
186201
description_url: 'https://www1.nyc.gov/site/sbs/neighborhoods/bids.page',
187202
sql: `SELECT * FROM all_bounds WHERE id = 'bid'`,
203+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.bid&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
188204
icon: '💸',
189205
formatContent: name => format_bid(name)
190206
},
@@ -195,6 +211,7 @@ export const layers: ILayers = {
195211
'A Industrial Business Zone (IBZ) is a geographic area that serve as safe havens for manufacturing and industrial firms.',
196212
description_url: 'https://edc.nyc/industry/industrial-and-manufacturing',
197213
sql: `SELECT * FROM all_bounds WHERE id = 'ibz'`,
214+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.ibz&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
198215
icon: '🏭',
199216
formatContent: name => format_default(name)
200217
},
@@ -204,6 +221,7 @@ export const layers: ILayers = {
204221
description:
205222
'A ZIP Code is a postal code used by the United States Postal Service (USPS).',
206223
sql: `SELECT * FROM all_bounds WHERE id = 'zipcode'`,
224+
apiUrl: 'https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/all_bounds?id=eq.zipcode&apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0',
207225
icon: '📫',
208226
formatContent: name => format_default(name)
209227
}

src/components/Map.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@
8888
8989
// Load source if not already loaded
9090
if ($mapStore && !$mapStore.getSource(boundaryId)) {
91-
const url = `https://betanyc.carto.com/api/v2/sql/?q=${layers[boundaryId].sql}&api_key=2J6__p_IWwUmOHYMKuMYjw&format=geojson`;
92-
const data = await fetch(url).then(res => res.json());
91+
const url = layers[boundaryId].apiUrl;
92+
const options = {
93+
headers: {
94+
'Accept': 'application/geo+json'
95+
}
96+
};
97+
const data = await fetch(url, options).then(res => res.json());
9398
9499
$mapStore
95100
.addSource(boundaryId, {

src/components/Sidebar/AddressDetails.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111
async function queryAllDistrictsForCoordinates(lng: number, lat: number) {
1212
districtsIntersectingAddress = [];
1313
isLoading = true;
14-
const intersectsUrl = `https://betanyc.carto.com/api/v2/sql/?q=SELECT * FROM all_bounds WHERE ST_Intersects(ST_SetSRID(ST_MakePoint(${lng}, ${lat}), 4326),the_geom)&api_key=2J6__p_IWwUmOHYMKuMYjw&format=geojson`;
15-
await fetch(intersectsUrl)
14+
//const intersectsUrl = `https://betanyc.carto.com/api/v2/sql/?q=SELECT * FROM all_bounds WHERE ST_Intersects(ST_SetSRID(ST_MakePoint(${lng}, ${lat}), 4326),the_geom)&api_key=2J6__p_IWwUmOHYMKuMYjw&format=geojson`;
15+
const intersectsUrl = `https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/rpc/address_details?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0&p_lng=${lng}&p_lat=${lat}`;
16+
const options = {
17+
headers: {
18+
'Accept': 'application/geo+json'
19+
}
20+
};
21+
await fetch(intersectsUrl, options)
1622
.then(res => res.json())
1723
.then(({ features }) => {
1824
isLoading = false;

src/components/Sidebar/BoundaryDetails.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@
5353
5454
async function queryAllDistrictsForMap(boundaryId: string) {
5555
isLoading = true;
56-
const url = `https://betanyc.carto.com/api/v2/sql/?q=${layers[boundaryId].sql}&api_key=2J6__p_IWwUmOHYMKuMYjw&format=geojson`;
57-
await fetch(url)
56+
const url = layers[boundaryId].apiUrl;
57+
const options = {
58+
headers: {
59+
'Accept': 'application/geo+json'
60+
}
61+
};
62+
await fetch(url, options)
5863
.then(res => res.json())
5964
.then(({ features }) => {
6065
isLoading = false;

src/components/Sidebar/CoordinateDetails.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@
1919
async function queryAllDistrictsForCoordinates(lngLat: LngLat) {
2020
districtsIntersectingAddress = [];
2121
isLoading = true;
22-
const intersectsUrl = `https://betanyc.carto.com/api/v2/sql/?q=SELECT * FROM all_bounds WHERE ST_Intersects(ST_SetSRID(ST_MakePoint(${lngLat.lng}, ${lngLat.lat}), 4326),the_geom)&api_key=2J6__p_IWwUmOHYMKuMYjw&format=geojson`;
23-
await fetch(intersectsUrl)
22+
//const intersectsUrl = `https://betanyc.carto.com/api/v2/sql/?q=SELECT * FROM all_bounds WHERE ST_Intersects(ST_SetSRID(ST_MakePoint(${lngLat.lng}, ${lngLat.lat}), 4326),the_geom)&api_key=2J6__p_IWwUmOHYMKuMYjw&format=geojson`;
23+
const intersectsUrl = `https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/rpc/address_details?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0&p_lng=${lngLat.lng}&p_lat=${lngLat.lat}`;
24+
const options = {
25+
headers: {
26+
'Accept': 'application/geo+json'
27+
}
28+
};
29+
await fetch(intersectsUrl, options)
2430
.then(res => res.json())
2531
.then(({ features }) => {
2632
isLoading = false;

src/components/Sidebar/DistrictDetails.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@
3232
boundId: string,
3333
featureId: string
3434
) {
35-
const intersectsUrl = `https://betanyc.carto.com/api/v2/sql/?q= WITH al as (SELECT ST_MakeValid(the_geom) as the_geom, id, namecol, namealt FROM all_bounds), se as (SELECT the_geom FROM al WHERE id = '${boundId}' AND namecol = '${featureId}'), inter as (SELECT DISTINCT al.id, al.namecol, al.namealt, ST_Area(se.the_geom) as area, ST_Area(ST_Intersection(al.the_geom, se.the_geom)) as searea, al.the_geom FROM al, se WHERE ST_Intersects(al.the_geom, se.the_geom)) SELECT * FROM inter WHERE searea / area > .005 &api_key=2J6__p_IWwUmOHYMKuMYjw&format=geojson`;
36-
return await fetch(intersectsUrl)
35+
//const intersectsUrl = `https://betanyc.carto.com/api/v2/sql/?q= WITH al as (SELECT ST_MakeValid(the_geom) as the_geom, id, namecol, namealt FROM all_bounds), se as (SELECT the_geom FROM al WHERE id = '${boundId}' AND namecol = '${featureId}'), inter as (SELECT DISTINCT al.id, al.namecol, al.namealt, ST_Area(se.the_geom) as area, ST_Area(ST_Intersection(al.the_geom, se.the_geom)) as searea, al.the_geom FROM al, se WHERE ST_Intersects(al.the_geom, se.the_geom)) SELECT * FROM inter WHERE searea / area > .005 &api_key=2J6__p_IWwUmOHYMKuMYjw&format=geojson`;
36+
const intersectsUrl = `https://yhatmsxmjxmpgnnzdrzy.supabase.co/rest/v1/rpc/district_details?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InloYXRtc3htanhtcGdubnpkcnp5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDM2OTA4OTQsImV4cCI6MjA1OTI2Njg5NH0.03AZcgwuHf2fAzIuCq8-O8UcSGVGfmvNdMYT6FH08b0&boundid=${boundId}&featureid=${featureId}`;
37+
const options = {
38+
headers: {
39+
'Accept': 'application/geo+json'
40+
}
41+
};
42+
return await fetch(intersectsUrl, options)
3743
.then(res => res.json())
3844
.then(({ features }) => {
3945
return sortedDistricts(features);

0 commit comments

Comments
 (0)