-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
1435 lines (1291 loc) · 72.6 KB
/
app.js
File metadata and controls
1435 lines (1291 loc) · 72.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* TODO -
- Add noscript message
- Populate addressRangeList (not sure if this is worth doing without the full address range data from Geosupport.)
- Expand "Blvd" (maybe also "Blvd."?) before search ("213-03 NORTHERN blvd" gives wrong result)
- If no housenumber match is found in geosearch, look for address matches in DOB NOW data
- Zoom to BBL (or just BB?) if no latlon found
- Links to NY state offering plan search
- 855 Clarkson Brooklyn
"1745 Forest Avenue, Staten Island, New York 10302" vs "1745 Forest Avenue"??????
BIN 3428826, 3337899, 3425581 -- examples where DOB has correct building height, height listed with footprint is much higher
https://a836-acris.nyc.gov/DS/DocumentSearch/DocumentDetail?doc_id=2014082101390003 ownership search
*/
document.getElementById('searchInputId').addEventListener('keyup', checkSearchKey);
window.addEventListener('popstate', (event) => { doParamSearch(event.state.search ?? ''); });
const searchInput = document.getElementById('searchInputId');
const addressDiv = document.getElementById('addressDivId');
const binDiv = document.getElementById('binDivId');
const bblDiv = document.getElementById('bblDivId');
const hpdDiv = document.getElementById('hpdDivId');
const buildingClassDiv = document.getElementById('buildingClassDivId');
const addressRangeList = document.getElementById('addressRangeListId');
const infoTable = document.getElementById('infoTableId');
const bblRegex = /^([1-5])([0-9]{5})([0-9]{4})$/;
const latlonRegex = /^\s*([0-9\.]+)[\s,;]+(\-[0-9\.]+)\s*$/;
const urlDobNow = 'https://a810-dobnow.nyc.gov/publish/#!/';
const boros = ['Manhattan', 'Bronx', 'Brooklyn', 'Queens', 'Staten Island'];
var slippyMap = null;
var markerLatLon = null;
var footprintJson = [];
var footprintDrawn = false;
var bin = '';
const params = (new URL(document.location)).searchParams;
const paramSearch = params.get('search');
if (paramSearch === null) {
clearSearchLog();
slippyMapDefault();
} else {
doParamSearch(paramSearch.trim());
}
/* SEARCH FUNCTIONS */
function checkSearchKey(e) {
if (e.keyCode === 13) {
doSearch();
}
}
function doParamSearch(p) {
searchInput.value = p;
doSearch(false);
}
async function doSearch(addToHistory = true) {
const searchText = searchInput.value.trim();
searchInput.value = searchText;
clearIoElements();
clearSearchLog();
markerLatLon = null;
footprintJson = [];
footprintDrawn = false;
bin = '';
if (addToHistory) {
history.pushState({search: searchText}, '', window.location.href.split(/[?#]/)[0] + '?search=' + encodeURIComponent(searchText));
}
//document.getElementById('searchLogTextareaId').style.color = 'black';
const reMatch = searchText.match(latlonRegex);
if (reMatch !== null) {
writeSearchLog('Search text "' + searchText + '" ' + "looks like a latlon pair\r\nAttempting latlon search...\r\n");
await doFootprintLatlonSearch(reMatch[1], reMatch[2]);
} else if (validBin(searchText)) {
writeSearchLog('Search text "' + searchText + '" looks like a BIN\r\nAttempting BIN search...\r\n');
writeBin(searchText);
await doBinSearch(searchText);
} else {
writeSearchLog('Search text "' + searchText + '" ' + "doesn't look like a BIN or latlon\r\nAttempting address search...\r\n");
await doAddressSearch(searchText);
}
if (addressDiv.innerHTML === '') {
writeFailedAddress();
}
if (!footprintDrawn) {
/* No footprint was drawn... If we got latlon from one of the API calls, add a marker and zoom
there, otherwise reset map to default state. */
if (markerLatLon === null) {
slippyMapDefault();
} else {
slippyMapAddMarker(markerLatLon);
}
}
}
async function doFootprintLatlonSearch(lat, lon) {
markerLatLon = [lat, lon];
const latLonApiQuery = 'https://data.cityofnewyork.us/api/geospatial/5zhs-2jue?lat=' + lat + '&lng=' + lon + '&zoom=17';
let fpJson = await httpGetJson(latLonApiQuery, '"Building Footprints" latlon');
if (fpJson.length > 0) {
const latlonBin = fpJson[0].bin;
if (validBin(latlonBin)) {
writeSearchLog(' - found BIN ' + latlonBin + ', attemping BIN search...\r\n');
writeBin(latlonBin);
await doBinSearch(latlonBin);
}
}
}
async function doBinSearch(searchBin) {
bin = searchBin;
doHpdSearch();
await doFootprintBinSearch();
await doDobJobSearch();
await doDobNowSearch();
}
async function doFootprintBinSearch() {
function footprintFeatureText(featureCode) {
//Codes taken from https://github.com/CityOfNewYork/nyc-geo-metadata/blob/master/Metadata/Metadata_BuildingFootprints.md and https://github.com/CityOfNewYork/nyc-planimetrics/blob/master/Capture_Rules.md#building-footprint
const featureCodes = {
2100: 'Building',
5100: 'Construction',
2110: 'Garage',
1001: 'Fuel Canopy',
1002: 'Tank',
1003: 'Placeholder',
1004: 'Auxiliary',
1005: 'Temporary',
5110: 'Garage'
};
return featureCodes[featureCode] ?? featureCode;
}
let row = infoTable.insertRow(-1);
row.className = 'rowHead';
row.innerHTML = '<td>Footprint</td><td>Yr Built</td><td>Status</td><td>Date</td><td>Height</td>';
const buildingFootprintApiQuery = 'https://data.cityofnewyork.us/resource/5zhs-2jue.json?bin=' + bin;
footprintJson = await httpGetJson(buildingFootprintApiQuery, '"Building Footprint" BIN');
if ((footprintJson[0]?.the_geom?.type ?? '') !== 'MultiPolygon') {
/* NYC's building footprints API endpoint (https://data.cityofnewyork.us/resource/5zhs-2jue.json)
has been known to temporarily switch places with the building center points API endpoint
(https://data.cityofnewyork.us/resource/u9wf-3gbt.json). If this happens, a footprint search by
BIN will only return point geometry instead of a multipolygon. (All footprints are recorded as
"MultiPolygon" in the city data, even if they're just simple polygons.)
If the returned geometry contains no multipolygons, we'll try the search again using the building
center points API instead.
*/
const buildingPointApiQuery = 'https://data.cityofnewyork.us/resource/u9wf-3gbt.json?bin=' + bin;
footprintJson = await httpGetJson(buildingPointApiQuery, 'Did not get a footprint, trying "Building Point" BIN');
}
if (footprintJson.length > 0) {
let needBbl = (bblDiv.innerHTML === '');
let heightInMeters = '';
let formattedHeight = '';
let footprintLinks = '';
if (footprintJson.length === 1) {
writeSearchLog(' - only one footprint result for this BIN\r\n');
} else {
writeSearchLog(' - ' + footprintJson.length + ' footprint results for this BIN\r\n');
}
/* Loop through footprint results, adding footprints to slippy map and crafting download
links. Theoretically we might want to reverse sort by status date, but I've never
actually seen more than one footprint result for a valid BIN. As of now, if the API did
return multiple footprints, they would all be listed in the table but only the first
result would be added to the map.
*/
for (let i = 0; i < footprintJson.length; i++) {
//Take the BBL from this footprint record, if it's valid and needed
if (needBbl) {
const bbl = footprintJson[i].base_bbl.trim();
const reMatch = bbl.match(bblRegex);
if (reMatch === null) {
writeSearchLog(' - not using invalid BBL ' + bbl + '\r\n');
} else {
writeBbl(reMatch[1], reMatch[2], reMatch[3]);
writeSearchLog(' - showing BBL ' + bbl + '\r\n');
needBbl = false;
}
}
if (!footprintDrawn) {
slippyMapAddFootprint(footprintJson[i].the_geom);
footprintDrawn = true;
}
row = infoTable.insertRow(-1);
row.className = 'rowBg' + (i % 2);
if (typeof footprintJson[i].height_roof === 'undefined') {
heightInMeters = '';
formattedHeight = '?';
} else {
heightInMeters = feetToMeters(footprintJson[i].height_roof);
formattedHeight = formatHeight(footprintJson[i].height_roof, heightInMeters);
}
footprintLinks = '';
if (footprintJson[i].the_geom.type === 'MultiPolygon') {
processFootprint(i, bin, heightInMeters);
if (typeof(footprintJson[i]?.nycaabs_osm_xml) !== 'undefined') {
footprintLinks = '<a href="data:text/xml;charset=utf-8,' + encodeURIComponent(footprintJson[i].nycaabs_osm_xml) + '" download="bin' + bin + '_footprint.osm">Download as .osm</a> <a class="josmLink" href="javascript:void(0);" onclick="javascript:sendFootprintToJosm(' + i + ')">Send to JOSM</a>';
}
//Possibly consider a geojson download link as well -- iD users would be able to
//load this, though it only works as an imagery layer, not importable data.
}
row.innerHTML = '<td>' + footprintFeatureText(footprintJson[i].feature_code) + '</td><td>' + (footprintJson[i].construction_year ?? '?') + '</td><td>' + footprintJson[i].last_status_type + '</td><td>' + footprintJson[i].last_edited_date.slice(0,10) + '</td><td>' + formattedHeight + '</td><td class="tdLink">' + footprintLinks + '</td>';
}
} else {
writeSearchLog(' - no footprint results for this BIN\r\n');
row = infoTable.insertRow(-1);
row.innerHTML = '<td>none found</td>';
}
}
async function doHpdSearch() {
const dobHpdApiQuery = 'https://data.cityofnewyork.us/resource/kj4p-ruqc.json?bin=' + bin;
let json = await httpGetJson(dobHpdApiQuery, '"Buildings Subject to HPD Jurisdiction"');
let j = json?.length ?? 0;
if (j > 0) {
if (j === 1) {
writeSearchLog(' - only one HPD result for this BIN\r\n');
} else {
writeSearchLog(' - ' + j + ' HPD results for this BIN, using result 0\r\n');
}
let needAddress = (addressDiv.innerHTML === '');
let houseNumber = '';
let street = '';
let boroCode = bin.slice(0,1);
let needBbl = (bblDiv.innerHTML === '');
let lot = '';
let block = '';
if (needAddress) {
houseNumber = json[0].housenumber ?? '';
street = json[0].streetname ?? '';
if (houseNumber !== '' && street !== '') {
writeSearchLog(' - showing address ' + houseNumber + ' ' + street + ', boro ' + boroCode + '\r\n');
writeAddress(houseNumber, street, boroCode);
needAddress = false;
}
}
if (needBbl) {
block = json[0].block ?? '';
lot = json[0].lot ?? '';
if (block !== '' && lot !== '') {
block = block.padStart(5, '0');
lot = lot.padStart(5, '0');
writeBbl(boroCode, block, lot);
writeSearchLog(' - showing BBL ' + boroCode + block + lot + '\r\n');
needBbl = false;
}
}
writeHpd(json[0].buildingid);
} else {
writeSearchLog(' - no HPD results for this BIN\r\n');
writeHpd('');
}
}
async function doDobJobSearch() {
function dobJobSortRank(type, jobStatus, date, height) {
/* Ideally I want the top sort entry to be the same job you'd get if you searched this BIN
in BIS -- because that's the job that usually links to the current zoning documents. Users
can then simply use the top-ranked "Zoning Docs @ BIS" link to look for the zoning docs,
using only one request to the BIS server. (Note that there's no guarantee that BIS will have
any zoning docs on offer, even if we pick the "right" job number.)
My working theory is that BIS will return the newest non-rejected (status !== 'J') type NB
(new building) job, and if no NB job is on record, then the newest A1, then A2, then A3
(various levels of building alterations) and after that who knows. So that's approximately
what this sort rank does.
I have my doubts that this approach will work every time, but I don't know of any
counterexamples at the moment. (Please report if found!)
The full list of DOB job types (taken from BIS's JobsQueryByLocationServlet page) is:
A1 - ALTERATION TYPE 1
A2 - ALTERATION TYPE 2
A3 - ALTERATION TYPE 3
DM - FULL DEMOLITION
NB - NEW BUILDING
PA - PLACE OF ASSEMBLY
PR - LAA (ARA)
SC - SUBDIVISION - CONDO
SG - SIGN
SI - SUBDIVISION - IMPROVED
SU - SUBDIVISION - UNIMPROVED
*/
const jobTypes = ['A3', 'A2', 'A1', 'NB'];
return parseInt((String(jobTypes.indexOf(type) + ((jobStatus == 'J') ? 1 : 6)) + date.slice(0,4) + date.slice(5,7) + date.slice(8,10)) * 1000000000) + Math.round(height * 1000);
}
function expandJobType(code) {
const jobTypes = { A1: 'Alteration Type 1 (Major alteration, changes to building use or occupancy)',
A2: 'Alteration Type 2 (Major alteration, no changes to building use or occupancy)',
A3: 'Alteration Type 3 (Minor alteration)',
DM: 'Full Demolition',
NB: 'New Building',
PA: 'Place of Assembly',
PR: 'Limited Alteration Application (Alteration Repair Application)',
SC: 'Subdivision - Condo',
SG: 'Sign',
SI: 'Subdivision - Improved',
SU: 'Subdivision - Unimproved'
};
return jobTypes[code] ?? 'Unknown job type code ' + code;
}
function expandJobStatus(code) {
const jobStatuses = { A: 'Pre-Filed',
B: 'Application Processed - Part-No Payment',
C: 'Application Processed - Payment Only',
D: 'Application Processed - Completed',
E: 'Application Processed - No Plan Exam',
F: 'Application Assigned To Plan Examiner',
G: 'PAA Fee Due',
H: 'Plan Exam - In Process',
I: 'Sign-Off (ARA)',
J: 'Plan Exam - Disapproved',
K: 'Plan Exam - Partial Approval',
L: 'Plan Exam PAA - Pending Fee Estimation',
M: 'Plan Exam PAA - Fee Resolved',
P: 'Plan Exam - Approved',
Q: 'Permit Issued - Partial Job',
R: 'Permit Issued - Entire Job/Work',
U: 'Completed',
X: 'Signed-Off',
3: 'Suspended'
};
return jobStatuses[code] ?? 'Unknown job status code ' + code;
}
function formatDate(input) {
/* Dates in the city's DOB job dataset are almost all mm/dd/yyyy but there are a few yyyy-mm-dd thrown in
there just to make things fun, BIN 4097171 eg */
input = input.trim();
let matches = input.match(/^(\d\d)\D(\d\d)\D(\d\d\d\d)/);
if (matches !== null) {
return matches[3] + '-' + matches[1] + '-' + matches[2];
}
return input;
}
const buildingClassMap = new Map();
const maxResults = 15;
let row = infoTable.insertRow(-1);
row.className = 'rowHead';
row.innerHTML = '<td>DOB BIS Job</td><td>Type</td><td>Status</td><td>Date</td><td>Height</td><td class="tdLink"><a href="' + constructUrlBisJobs(bin) + '">Job List @ BIS</a> <a href="' + constructUrlBisJobs(bin, 'A') + '">Active Zoning Job @ BIS</a></td>';
let dobJobApiQuery = 'https://data.cityofnewyork.us/resource/ic3t-wcy2.json?$select=distinct%20job__,house__,street_name,borough,block,lot,building_class,job_type,job_status,latest_action_date,proposed_height,gis_latitude,gis_longitude&$where=bin__=%27' + bin + '%27';
//Note: previously I was also requesting the "job_s1_no" field, and using it to populate the "allisn" url parameter of the BIS Zoning Documents page urls, imitating the urls generated by the BIS web portal. I've concluded that this field isn't neccessary (the Zoning Documents page seems to load just as well without it) so I'm no longer requesting or using it.
let json = await httpGetJson(dobJobApiQuery, '"DOB Job Application Filings"');
let j = json?.length ?? 0;
if (j > 0) {
let needAddress = (addressDiv.innerHTML === '');
let houseNumber = '';
let street = '';
let boroCode = bin.slice(0,1);
let needBbl = (bblDiv.innerHTML === '');
let jobLot = '';
let jobBlock = '';
let actionDate = '';
let buildingClass = '';
if (j === 1) {
writeSearchLog(' - only one DOB Job Application result for this BIN\r\n');
} else if (j > maxResults) {
writeSearchLog(' - ' + j + ' DOB Job Application results for this BIN, only showing the top ' + maxResults + '\r\n');
j = maxResults;
} else {
writeSearchLog(' - ' + j + ' DOB Job Application results for this BIN\r\n');
}
json.sort(function(a, b) { return dobJobSortRank(b.job_type, b.job_status, formatDate(b.latest_action_date), b.proposed_height) - dobJobSortRank(a.job_type, a.job_status, formatDate(a.latest_action_date), a.proposed_height); });
const listedJobsWithHeight = [];
let addedRowCount = 0;
for (let i = 0; i < j; i++) {
if (needAddress) {
houseNumber = json[i].house__ ?? '';
street = json[i].street_name ?? '';
if (houseNumber !== '' && street !== '') {
writeSearchLog(' - showing address ' + houseNumber + ' ' + street + ', boro ' + boroCode + '\r\n');
writeAddress(houseNumber, street, boroCode);
needAddress = false;
}
}
if (needBbl) {
jobBlock = json[i].block.trim();
jobLot = json[i].lot.trim();
if (jobBlock !== '' && jobLot !== '') {
writeBbl(boroCode, json[i].block, json[i].lot);
writeSearchLog(' - showing BBL ' + boroCode + json[i].block + json[i].lot + ' from result ' + i + '\r\n');
needBbl = false;
}
}
if (markerLatLon === null) {
if ((json[i].gis_latitude > 40) && (json[i].gis_longitude < -73)) {
markerLatLon = [json[i].gis_latitude, json[i].gis_longitude];
writeSearchLog(' - got latlon ' + json[i].gis_latitude + ', ' + json[i].gis_longitude + ' from result ' + i + '\r\n');
}
}
actionDate = formatDate(json[i].latest_action_date);
buildingClass = json[i].building_class.trim();
if (!buildingClassMap.has(buildingClass) || (actionDate > buildingClassMap.get(buildingClass))) {
buildingClassMap.set(buildingClass, actionDate);
}
if (!listedJobsWithHeight.includes(json[i].job__)) {
row = infoTable.insertRow(-1);
row.className = 'rowBg' + (addedRowCount % 2);
row.innerHTML = '<td>' + json[i].job__ + '</td><td><abbr title="' + expandJobType(json[i].job_type) + '">' + json[i].job_type + '</abbr></td><td><abbr title="' + expandJobStatus(json[i].job_status) + '">' + json[i].job_status + '</abbr></td><td>' + formatDate(json[i].latest_action_date) + '</td><td>' + formatHeight(json[i].proposed_height) + '</td><td class="tdLink"><a href="https://a810-bisweb.nyc.gov/bisweb/JobsQueryByNumberServlet?passjobnumber=' + json[i].job__ + '&passdocnumber=01">Job Details @ BIS</a> <a href="https://a810-bisweb.nyc.gov/bisweb/JobsZoningDocumentsServlet?passjobnumber=' + json[i].job__ + '&passdocnumber=01&allbin=' + bin + '">Zoning Docs @ BIS</a></td>';
addedRowCount++;
if (json[i].proposed_height > 0) {
listedJobsWithHeight.push(json[i].job__);
}
}
}
} else {
writeSearchLog(' - no DOB Job Application results for this BIN\r\n');
row = infoTable.insertRow(-1);
row.innerHTML = '<td>none found</td>';
}
writeBuildingClass(buildingClassMap);
}
async function doDobNowSearch() {
function shortenDobNowStatus(dobNowStatus) {
let j = dobNowStatus.indexOf(' -');
if (j > 2) {
return dobNowStatus.slice(0,j);
}
return dobNowStatus.replace('Certificate of Operation', 'Cert of Op');
//check ?search=40.64242407021607 -73.98076415061952 for another lengthy status
}
let row = infoTable.insertRow(-1);
row.className = 'rowHead';
row.innerHTML = '<td>DOB NOW Job</td><td>Type</td><td>Status</td><td>Date</td><td>Height</td><td id="dobNowLink" class="tdLink" id="dobNowLink"><a href="' + urlDobNow + '">open DOB NOW w/ BIN in clipboard</a></td>';
const dobNowLink = document.getElementById('dobNowLink');
dobNowLink.addEventListener('mouseup', handleDobNowLinkEvents, {capture: true});
dobNowLink.addEventListener('click', handleDobNowLinkEvents, {capture: true});
const dobNowJobApiQuery = 'https://data.cityofnewyork.us/resource/w9ak-ipjd.json?$select=distinct%20job_filing_number,house_no,street_name,borough,block,lot,job_type,filing_status,current_status_date,proposed_height,latitude,longitude&$where=bin=%27' + bin + '%27&$order=current_status_date';
let json = await httpGetJson(dobNowJobApiQuery, '"DOB NOW: Build – Job Application Filings"');
if (json.length > 0) {
if (json.length === 1) {
writeSearchLog(' - only one DOB NOW Job result for this BIN\r\n');
} else {
writeSearchLog(' - ' + json.length + ' DOB NOW Job results for this BIN\r\n');
}
let j = json.length - 1;
let needAddress = (addressDiv.innerHTML === '');
let houseNumber = '';
let street = '';
let boroCode = bin.slice(0,1);
let needBbl = (bblDiv.innerHTML === '');
let jobLot = '';
let jobBlock = '';
let currentStatusDate = '';
/* I don't have a particular goal with the sort order in the DOB NOW portion of the table, so I'll just show the newest jobs on top. The date is in a sortable format but the API can't do a descending sort, so this loop processes the rows in reverse order. */
for (let i=0; i <= j; i++) {
if (needAddress) {
houseNumber = json[j-i].house_no ?? '';
street = json[j-i].street_name ?? '';
if (houseNumber !== '' && street !== '') {
writeSearchLog(' - showing address ' + houseNumber + ' ' + street + ', boro ' + boroCode + '\r\n');
writeAddress(houseNumber, street, boroCode);
needAddress = false;
}
}
if (needBbl) {
jobBlock = json[j-i].block ?? '';
jobLot = json[j-i].lot ?? '';
if (jobBlock !== '' && jobLot !== '') {
jobBlock = jobBlock.padStart(5, '0');
jobLot = jobLot.padStart(5, '0');
writeBbl(boroCode, jobBlock, jobLot);
writeSearchLog(' - showing BBL ' + boroCode + jobBlock + jobLot + ' from result ' + (j-i) + '\r\n');
needBbl = false;
}
}
if (markerLatLon === null) {
if ((json[j-i].latitude > 40) && (json[j-i].longitude < -73)) {
markerLatLon = [json[j-i].latitude, json[j-i].longitude];
writeSearchLog(' - got latlon ' + json[j-i].latitude + ', ' + json[j-i].longitude + ' from result ' + i + '\r\n');
}
}
if (typeof(json[j-i].job_filing_number) !== 'undefined') {
row = infoTable.insertRow(-1);
row.className = 'rowBg' + (i % 2);
if (typeof(json[j-i].current_status_date) === 'undefined') {
currentStatusDate = '?';
} else {
currentStatusDate = json[j-i].current_status_date.slice(0,10);
}
row.innerHTML = '<td>' + json[j-i].job_filing_number + '</td><td>' + json[j-i].job_type + '</td><td>' + shortenDobNowStatus(json[j-i].filing_status) + '</td><td>' + currentStatusDate + '</td><td>' + formatHeight(json[j-i].proposed_height) + '</td>';
}
}
} else {
writeSearchLog(' - no DOB NOW Job results for this BIN\r\n');
row = infoTable.insertRow(-1);
row.innerHTML = '<td>none found</td>';
}
}
async function doAddressSearch(searchText) {
/* For the address search, we'll use the NYC GeoSearch API (https://geosearch.planninglabs.nyc)
which parses freeform address search text and returns a list of the most likely matching
addresses with their associated BINs and other info.
It works well even with minimal input, eg "32 middagh" will return BIN 3001569 (32 MIDDAGH
STREET BROOKLYN) as the top ranked result without the need to specify "street" or "brooklyn" in
the search. This is unambiguous since there's only one road named Middagh in NYC, and only one
building on that road with housenumber 32.
A more ambiguous query, "32 cranberry", ranks 32 Cranberry Court in Staten Island first, and
then 32 Cranberry Street in Brooklyn. Nycaabs simply uses the top result, so if the Brooklyn
address is preferred, the search text can be made more explicit by adding "street" or "st".
Querying the API for "32 cranberry brooklyn" without the street suffix will still return the
Staten Island address first, however. This is new behavior in v2 of GeoSearch, which appears
to be much more reliant on the query containing a valid street suffix than v1 did. There are
definitely some upsides to the v2 API though. The old v1 would sometimes return unquestionably
incorrect results and, for certain addresses, would *never* rank the right result first no
matter how explicit the query text.
For NYC GeoSearch v1, Nycaabs had a multi-tier custom sort to deal with these edge cases. We
now use a much simpler sort that only compares the boro guessed from the parsed search text
to the boro of the returned properties. This enables us to search using eg "87 3rd av mn"
instead of need to spell out "87 3rd av manhattan"
1515 Park Place
Franklin Av BK
The API v2 is still very new and may have its own mysterious edge cases that need massaging.
Please raise a Github issue at https://github.com/jmapb/nycaabs/issues with examples of any
address searches that return the wrong property, thanks!
*/
function boroMatchRank(resultBin, searchBoro) {
if (searchBoro === 0) {
return 2000000;
}
if (resultBin.slice(0,1) === searchBoro.toString()) {
return 1000000;
}
return 9000000;
}
function streetMatchRank(resultStreet, searchStreet) {
if (searchStreet === '') {
return 40000;
}
if (searchStreet === resultStreet) {
return 10000;
}
if (resultStreet.includes(searchStreet)) {
return 20000;
}
if (searchStreet.includes(resultStreet)) {
return 30000;
}
return 90000;
}
function houseNumberMatchRank(resultHouseNumber, searchHouseNumber) {
if (searchHouseNumber === '') {
return 4000;
}
if (searchHouseNumber === resultHouseNumber) {
return 1000;
}
if (resultHouseNumber.includes(searchHouseNumber)) {
return 200000;
}
if (searchHouseNumber.includes(resultHouseNumber)) {
return 300000;
}
return 900000;
}
let parsedAddress = parseNycAddress(searchText);
writeSearchLog(' - parser "parse-nyc-address" found ' + JSON.stringify(parsedAddress));
let searchBoroNum = parsedAddress.borough ?? 0;
let searchStreet = parsedAddress.street ?? '';
let searchHouseNumber = parsedAddress.housenumber ?? '';
//To-do if parseNycAddress() gives us street and boro, attempt a Geoservice search.
//If Geoservice fails us, fall back to NYC GeoSearch
const nycGeosearchApiQuery = 'https://geosearch.planninglabs.nyc/v2/search?text=' + encodeURIComponent(searchText);
let json = await httpGetJson(nycGeosearchApiQuery, '"NYC GeoSearch"');
if (typeof json?.geocoding !== 'undefined') {
(json.geocoding?.errors ?? []).forEach (error => {
writeSearchLog(' - GeoSearch error "' + error + '"\r\n');
});
let parserDesc = 'an unspecified parser';
if (typeof json.geocoding?.query?.parser !== 'undefined') {
parserDesc = 'parser "' + json.geocoding.query.parser + '"';
}
if (typeof json.geocoding?.query?.parsed_text !== 'undefined') {
writeSearchLog(' - GeoSearch used ' + parserDesc + ', parsed address=' + JSON.stringify(json.geocoding.query.parsed_text) + ' \r\n');
} else {
writeSearchLog(' - GeoSearch used ' + parserDesc + ', no parsed address was returned\r\n');
}
}
let geosearchResults = json?.features ?? [];
if (geosearchResults.length === 0) {
writeSearchLog(' - no NYC GeoSearch results');
} else {
if (geosearchResults.length === 1) {
writeSearchLog(' - only one NYC GeoSearch result');
//document.getElementById('searchLogTextareaId').style.color = 'blue';
} else {
for (let i = 0; i < geosearchResults.length; i++) {
geosearchResults[i].geosearch_rank = i;
geosearchResults[i].nycaabs_rank = i + boroMatchRank(geosearchResults[i].properties.addendum.pad.bin, searchBoroNum)
+ streetMatchRank(geosearchResults[i].properties.street, searchStreet)
+ houseNumberMatchRank(geosearchResults[i].properties.housenumber ?? '', searchHouseNumber);
}
json.features.sort(function(a, b) { return a.nycaabs_rank - b.nycaabs_rank; });
if (geosearchResults[0].geosearch_rank === 0) {
writeSearchLog(' - ' + geosearchResults.length + ' NYC GeoSearch results, using result 0');
} else {
writeSearchLog(' - ' + geosearchResults.length + ' NYC GeoSearch results, using result ' + geosearchResults[0].geosearch_rank + ' after custom sort');
//document.getElementById('searchLogTextareaId').style.color = 'red';
}
}
let gsBin = geosearchResults[0]?.properties?.addendum?.pad?.bin ?? '';
let boroCode = gsBin.slice(0,1);
if (boroCode === searchBoroNum.toString()) {
writeSearchLog(', matches search boro\r\n');
} else {
writeSearchLog(', no boro match\r\n');
}
let houseNumber = geosearchResults[0]?.properties?.housenumber ?? '';
let street = geosearchResults[0]?.properties?.street ?? '';
let bbl = geosearchResults[0]?.properties?.addendum?.pad?.bbl ?? '';
/* We also have geosearchResult.properties.borough but we don't need it since we're
setting the boro based on the first digit of the bin. If someday we want to show zip
codes, we can use geosearchResult.properties.postalcode but the quality of this field
is unknown.
*/
/* BIG TODO -- At this point it would be great to take the address components (maybe as
returned in the parsed_text structure above, or failing that from the top search result,
or failing that parse the text ourselves) and feed them into a "Function1A" query on the
NYC Planning Geoservice API https://geoservice.planning.nyc.gov/, which has important
advantages over the NYC GeoSearch API:
- First, it returns address ranges for all streets of multi-street buildings. (NYC
GeoSearch only returns the address range on the queried street.)
- Second, it gives additional address classification info (See "Address Types" at
http://a030-goat.nyc.gov/goat/Glossary for documentation.)
- Third, it can find recently updated addresses and BINs by accessing the Transitional
PAD file (TPAD). NYC GeoSearch uses the standard PAD file, which is only updated
quarterly.
If we could get decent results from the NYC Planning Geoservice API, we probably
wouldn't even need to sort or further examine the NYC GeoSearch results. (Curse these
very similar names!) However, access to NYC Planning Geoservice requires registration
and department approval, and will only work with a city-issued private API key. Since
this app currently uses client-side fetches for all API calls, keeping the API key
private wouldn't be possible.
There's a web app wrapper around the NYC Planning Geoservice API called "GOAT",
https://a030-goat.nyc.gov/goat. The GOAT app supports URL query parameters and is free
to use without credentials, but its cross-site scripting policy prevents us from screen-
scraping the results from our own web app. In theory we could attempt to work around
this with a CORS proxy but that's messy. (GOAT is also available as a downloadable
offline desktop app, but that version only uses the standard PAD file, not the TPAD
file.)
For now, we'll simply rely on the results from NYC GeoSearch with the following known
limitations:
- Slightly out-of-date data (PAD only, not TPAD) that will not reflect newer
developments and may return obsolete or temporary BINs instead of current ones.
- Incomplete housenumber range info, especially for multi-street buildings.
- Need custom sort to favor results that match the requested borough and street name, as
described in the comment at this top of this function.
*/
writeSearchLog(' - showing address ' + houseNumber + ' ' + street + ', boro ' + boroCode + '\r\n');
writeAddress(houseNumber, street, boroCode);
const reMatch = bbl.match(bblRegex);
if (reMatch === null) {
writeSearchLog(' - not using invalid BBL ' + bbl + '\r\n');
} else {
writeSearchLog(' - showing BBL ' + bbl + '\r\n');
writeBbl(reMatch[1], reMatch[2], reMatch[3]);
}
if (validBin(gsBin)) {
writeSearchLog(' - showing BIN ' + gsBin + '\r\n');
writeBin(gsBin);
await doBinSearch(gsBin);
} else {
writeSearchLog(' - showing invalid BIN ' + gsBin + ', deeper search impossible without a valid BIN\r\n');
writeInvalidBin(gsBin);
}
if (((geosearchResults[0]?.geometry?.coordinates[0] ?? 0) < -73) && ((geosearchResults[0]?.geometry?.coordinates[1] ?? 0) > 40)) {
markerLatLon = [geosearchResults[0].geometry.coordinates[1], geosearchResults[0].geometry.coordinates[0]];
writeSearchLog(' - got latlon ' + markerLatLon[0] + ', ' + markerLatLon[0] + ' from Geosearch\r\n');
}
}
}
/* HTML OUTPUT FUNCTIONS */
function writeSearchLog(logText) {
document.getElementById('searchLogTextareaId').value += logText;
}
function clearSearchLog() {
document.getElementById('searchLogTextareaId').value = '';
}
function writeAddress(housenumber, street, boroCode) {
let boroName = boros[parseInt(boroCode)-1];
addressDiv.innerHTML = '<strong>Address</strong> ' + housenumber + ' ' + street + ' ' + boroName + ' <a href="' + constructUrlBisProfileAddress(housenumber, street, boroCode) + '">Search Address @ BIS</a> <a href="' + constructUrlGoat1A(housenumber, street, boroCode) + '">Search Address @ GOAT</a>';
}
function writeFailedAddress() {
addressDiv.innerHTML = '<strong>Address</strong> Not found';
}
function writeBin(wBin) {
binDiv.innerHTML = '<strong>BIN</strong> ' + wBin + ' <a href="' + constructUrlBisProfileBin(wBin) + '">Property Profile @ BIS</a> <a href="' + constructUrlGoatBN(wBin) + '">Search BIN @ GOAT</a> <a href="' + constructUrlOverpassTurbo(wBin) + '">Search BIN @ Overpass Turbo</a>';
}
function writeInvalidBin(wBin) {
binDiv.innerHTML = '<strong>BIN</strong> ' + wBin + ' (invalid, search halted)';
}
function writeBbl(boro, block, lot) {
bblDiv.innerHTML = '<strong>BBL</strong> ' + boro + block + lot + ' <a href="' + constructUrlBisBrowse(boro, block) + '">Browse Block @ BIS</a> <a href="' + constructUrlBisBrowse(boro, block, lot) + '">Browse BBL @ BIS</a> <a href="' + constructUrlZolaLot(boro, block, lot) + '">View BBL @ ZoLa</a>';
}
function writeHpd(hpdId) {
let hpdHtml = 'Not found';
if (hpdId !== '') {
hpdHtml = hpdId + ' <a href="' + constructUrlHpdId(hpdId) + '">Overview @ HPD</a>';
}
hpdDiv.innerHTML = '<strong>HPD ID</strong> ' + hpdHtml;
}
function writeBuildingClass(buildingClassMap) {
function expandBuildingClass(code) {
const buildingClasses = { A0: 'CAPE COD',
A1: 'TWO STORIES - DETACHED SM OR MID',
A2: 'ONE STORY - PERMANENT LIVING QUARTER',
A3: 'LARGE SUBURBAN RESIDENCE',
A4: 'CITY RESIDENCE ONE FAMILY',
A5: 'ONE FAMILY ATTACHED OR SEMI-DETACHED',
A6: 'SUMMER COTTAGE',
A7: 'MANSION TYPE OR TOWN HOUSE',
A8: 'BUNGALOW COLONY - COOPERATIVELY OWNED LAND',
A9: 'MISCELLANEOUS ONE FAMILY',
B1: 'TWO FAMILY BRICK',
B2: 'TWO FAMILY FRAME',
B3: 'TWO FAMILY CONVERTED FROM ONE FAMILY',
B9: 'MISCELLANEOUS TWO FAMILY',
C0: 'THREE FAMILIES',
C1: 'OVER SIX FAMILIES WITHOUT STORES',
C2: 'FIVE TO SIX FAMILIES',
C3: 'FOUR FAMILIES',
C4: 'OLD LAW TENEMENT',
C5: 'CONVERTED DWELLINGS OR ROOMING HOUSE',
C6: 'WALK-UP COOPERATIVE',
C7: 'WALK-UP APT. OVER SIX FAMILIES WITH STORES',
C8: 'WALK-UP CO-OP; CONVERSION FROM LOFT/WAREHOUSE',
C9: 'GARDEN APARTMENTS',
CB: 'WALKUP APT LESS THAN 11 UNITS RESIDENTIAL',
CC: 'WALKUP CO-OP APT LESS THAN 11 UNITS RESIDENTIAL',
CM: 'MOBILE HOMES/TRAILER PARKS',
D0: 'ELEVATOR CO-OP; CONVERSION FROM LOFT/WAREHOUSE',
D1: 'ELEVATOR APT; SEMI-FIREPROOF WITHOUT STORES',
D2: 'ELEVATOR APT; ARTISTS IN RESIDENCE',
D3: 'ELEVATOR APT; FIREPROOF WITHOUT STORES',
D4: 'ELEVATOR COOPERATIVE',
D5: 'ELEVATOR APT; CONVERTED',
D6: 'ELEVATOR APT; FIREPROOF WITH STORES',
D7: 'ELEVATOR APT; SEMI-FIREPROOF WITH STORES',
D8: 'ELEVATOR APT; LUXURY TYPE',
D9: 'ELEVATOR APT; MISCELLANEOUS',
DB: 'ELEVATOR APT LESS THAN 11 UNITS RESIDENTIAL',
DC: 'ELEVATOR CO-OP APT LESS THAN 11 UNITS RESIDENTIAL',
E1: 'GENERAL WAREHOUSE',
E2: 'CONTRACTORS WAREHOUSE',
E7: 'SELF-STORAGE WAREHOUSES',
E9: 'MISCELLANEOUS WAREHOUSE',
F1: 'FACTORY; HEAVY MANUFACTURING - FIREPROOF',
F2: 'FACTORY; SPECIAL CONSTRUCTION - FIREPROOF',
F4: 'FACTORY; INDUSTRIAL SEMI-FIREPROOF',
F5: 'FACTORY; LIGHT MANUFACTURING',
F8: 'FACTORY; TANK FARM',
F9: 'FACTORY; INDUSTRIAL-MISCELLANEOUS',
G0: 'GARAGE; RESIDENTIAL TAX CLASS 1',
G1: 'ALL PARKING GARAGES',
G2: 'AUTO BODY/COLLISION OR AUTO REPAIR',
G3: 'GAS STATION WITH RETAIL STORE',
G4: 'GAS STATION WITH SERVICE/AUTO REPAIR',
G5: 'GAS STATION ONLY WITH/WITHOUT SMALL KIOSK',
G6: 'LICENSED PARKING LOT',
G7: 'UNLICENSED PARKING LOT',
G8: 'CAR SALES/RENTAL WITH SHOWROOM',
G9: 'MISCELLANEOUS GARAGE',
GU: 'CAR SALES OR RENTAL LOTS WITHOUT SHOWROOM',
GW: 'CAR WASH OR LUBRITORIUM FACILITY',
HB: 'BOUTIQUE HOTEL: 10-100 ROOMS, W/LUXURY FACILITIES, THEMED, STYLISH, W/FULL SVC ACCOMMODATIONS',
HH: 'HOSTELS- BED RENTALS IN DORMITORY-LIKE SETTINGS W/SHARED ROOMS & BATHROOMS',
HR: 'SRO- 1 OR 2 PEOPLE HOUSED IN INDIVIDUAL ROOMS IN MULTIPLE DWELLING AFFORDABLE HOUSING',
HS: 'EXTENDED STAY/SUITE: AMENITIES SIMILAR TO APT; TYPICALLY CHARGE WEEKLY RATES & LESS EXPENSIVE THAN FULL-SERVICE HOTEL',
H1: 'LUXURY HOTEL',
H2: 'FULL SERVICE HOTEL',
H3: 'LIMITED SERVICE HOTEL; MANY AFFILIATED WITH NATIONAL CHAIN',
H4: 'MOTEL',
H5: 'HOTEL; PRIVATE CLUB, LUXURY TYPE',
H6: 'APARTMENT HOTEL',
H7: 'APARTMENT HOTEL - COOPERATIVELY OWNED',
H8: 'DORMITORY',
H9: 'MISCELLANEOUS HOTEL',
I1: 'HOSPITAL, SANITARIUM, MENTAL INSTITUTION',
I2: 'INFIRMARY',
I3: 'DISPENSARY',
I4: 'HOSPITAL; STAFF FACILITY',
I5: 'HEALTH CENTER, CHILD CENTER, CLINIC',
I6: 'NURSING HOME',
I7: 'ADULT CARE FACILITY',
I9: 'MISCELLANEOUS HOSPITAL, HEALTH CARE FACILITY',
J1: 'THEATRE; ART TYPE LESS THAN 400 SEATS',
J2: 'THEATRE; ART TYPE MORE THAN 400 SEATS',
J3: 'MOTION PICTURE THEATRE WITH BALCONY',
J4: 'LEGITIMATE THEATRE, SOLE USE',
J5: 'THEATRE IN MIXED-USE BUILDING',
J6: 'TELEVISION STUDIO',
J7: 'OFF BROADWAY TYPE THEATRE',
J8: 'MULTIPLEX PICTURE THEATRE',
J9: 'MISCELLANEOUS THEATRE',
K1: 'ONE STORY RETAIL BUILDING',
K2: 'MULTI-STORY RETAIL BUILDING (2 OR MORE)',
K3: 'MULTI-STORY DEPARTMENT STORE',
K4: 'PREDOMINANT RETAIL WITH OTHER USES',
K5: 'STAND-ALONE FOOD ESTABLISHMENT',
K6: 'SHOPPING CENTER WITH OR WITHOUT PARKING',
K7: 'BANKING FACILITIES WITH OR WITHOUT PARKING',
K8: 'BIG BOX RETAIL: NOT AFFIXED & STANDING ON OWN LOT W/PARKING, E.G. COSTCO & BJS',
K9: 'MISCELLANEOUS STORE BUILDING',
L1: 'LOFT; OVER 8 STORIES (MID MANH. TYPE)',
L2: 'LOFT; FIREPROOF AND STORAGE TYPE WITHOUT STORES',
L3: 'LOFT; SEMI-FIREPROOF',
L8: 'LOFT; WITH RETAIL STORES OTHER THAN TYPE ONE',
L9: 'MISCELLANEOUS LOFT',
M1: 'CHURCH, SYNAGOGUE, CHAPEL',
M2: 'MISSION HOUSE (NON-RESIDENTIAL)',
M3: 'PARSONAGE, RECTORY',
M4: 'CONVENT',
M9: 'MISCELLANEOUS RELIGIOUS FACILITY',
N1: 'ASYLUM',
N2: 'HOME FOR INDIGENT CHILDREN, AGED, HOMELESS',
N3: 'ORPHANAGE',
N4: 'DETENTION HOUSE FOR WAYWARD GIRLS',
N9: 'MISCELLANEOUS ASYLUM, HOME',
O1: 'OFFICE ONLY - 1 STORY',
O2: 'OFFICE ONLY 2 - 6 STORIES',
O3: 'OFFICE ONLY 7 - 19 STORIES',
O4: 'OFFICE ONLY WITH OR WITHOUT COMM - 20 STORIES OR MORE',
O5: 'OFFICE WITH COMM - 1 TO 6 STORIES',
O6: 'OFFICE WITH COMM 7 - 19 STORIES',
O7: 'PROFESSIONAL BUILDINGS/STAND ALONE FUNERAL HOMES',
O8: 'OFFICE WITH APARTMENTS ONLY (NO COMM)',
O9: 'MISCELLANEOUS AND OLD STYLE BANK BLDGS.',
P1: 'CONCERT HALL',
P2: 'LODGE ROOM',
P3: 'YWCA, YMCA, YWHA, YMHA, PAL',
P4: 'BEACH CLUB',
P5: 'COMMUNITY CENTER',
P6: 'AMUSEMENT PLACE, BATH HOUSE, BOAT HOUSE',
P7: 'MUSEUM',
P8: 'LIBRARY',
P9: 'MISCELLANEOUS INDOOR PUBLIC ASSEMBLY',
Q1: 'PARKS/RECREATION FACILTY',
Q2: 'PLAYGROUND',
Q3: 'OUTDOOR POOL',
Q4: 'BEACH',
Q5: 'GOLF COURSE',
Q6: 'STADIUM, RACE TRACK, BASEBALL FIELD',
Q7: 'TENNIS COURT',
Q8: 'MARINA, YACHT CLUB',
Q9: 'MISCELLANEOUS OUTDOOR RECREATIONAL FACILITY',
RA: 'CONDO; CULTURAL, MEDICAL, EDUCATIONAL, ETC.',
RB: 'CONDO; OFFICE SPACE',
RG: 'CONDO; INDOOR PARKING',
RH: 'CONDO; HOTEL/BOATEL',
RK: 'CONDO; RETAIL SPACE',
RP: 'CONDO; OUTDOOR PARKING',
RR: 'CONDOMINIUM RENTALS',
RS: 'CONDO; NON-BUSINESS STORAGE SPACE',
RT: 'CONDO; TERRACES/GARDENS/CABANAS',
RW: 'CONDO; WAREHOUSE/FACTORY/INDUSTRIAL',
R0: 'SPECIAL CONDOMINIUM BILLING LOT',
R1: 'CONDO; RESIDENTIAL UNIT IN 2-10 UNIT BLDG.',
R2: 'CONDO; RESIDENTIAL UNIT IN WALK-UP BLDG.',
R3: 'CONDO; RESIDENTIAL UNIT IN 1-3 STORY BLDG.',
R4: 'CONDO; RESIDENTIAL UNIT IN ELEVATOR BLDG.',
R5: 'CONDO; MISCELLANEOUS COMMERCIAL',
R6: 'CONDO; RESID.UNIT OF 1-3 UNIT BLDG-ORIG CLASS 1',
R7: 'CONDO; COMML.UNIT OF 1-3 UNIT BLDG-ORIG CLASS 1',
R8: 'CONDO; COMML.UNIT OF 2-10 UNIT BLDG.',
R9: 'CO-OP WITHIN A CONDOMINIUM',
S0: 'PRIMARILY 1 FAMILY WITH 2 STORES OR OFFICES',
S1: 'PRIMARILY 1 FAMILY WITH 1 STORE OR OFFICE',
S2: 'PRIMARILY 2 FAMILY WITH 1 STORE OR OFFICE',
S3: 'PRIMARILY 3 FAMILY WITH 1 STORE OR OFFICE',
S4: 'PRIMARILY 4 FAMILY WITH 1 STORE OR OFFICE',
S5: 'PRIMARILY 5-6 FAMILY WITH 1 STORE OR OFFICE',
S9: 'SINGLE OR MULTIPLE DWELLING WITH STORES OR OFFICES',
T1: 'AIRPORT, AIRFIELD, TERMINAL',
T2: 'PIER, DOCK, BULKHEAD',
T9: 'MISCELLANEOUS TRANSPORTATION FACILITY',
U0: 'UTILITY COMPANY LAND AND BUILDING',
U1: 'BRIDGE, TUNNEL, HIGHWAY',
U2: 'GAS OR ELECTRIC UTILITY',
U3: 'CEILING RAILROAD',
U4: 'TELEPHONE UTILITY',
U5: 'COMMUNICATION FACILITY OTHER THAN TELEPHONE',
U6: 'RAILROAD - PRIVATE OWNERSHIP',
U7: 'TRANSPORTATION - PUBLIC OWNERSHIP',
U8: 'REVOCABLE CONSENT',
U9: 'MISCELLANEOUS UTILITY PROPERTY',
V0: 'ZONED RESIDENTIAL; NOT MANHATTAN',
V1: 'ZONED COMMERCIAL OR MANHATTAN RESIDENTIAL',
V2: 'ZONED COMMERCIAL ADJACENT TO CLASS 1 DWELLING: NOT MANHATTAN',
V3: 'ZONED PRIMARILY RESIDENTIAL; NOT MANHATTAN',
V4: 'POLICE OR FIRE DEPARTMENT',
V5: 'SCHOOL SITE OR YARD',
V6: 'LIBRARY, HOSPITAL OR MUSEUM',
V7: 'PORT AUTHORITY OF NEW YORK AND NEW JERSEY',
V8: 'NEW YORK STATE OR US GOVERNMENT',
V9: 'MISCELLANEOUS VACANT LAND',
W1: 'PUBLIC ELEMENTARY, JUNIOR OR SENIOR HIGH',
W2: 'PAROCHIAL SCHOOL, YESHIVA',
W3: 'SCHOOL OR ACADEMY',
W4: 'TRAINING SCHOOL',
W5: 'CITY UNIVERSITY',
W6: 'OTHER COLLEGE AND UNIVERSITY',
W7: 'THEOLOGICAL SEMINARY',
W8: 'OTHER PRIVATE SCHOOL',
W9: 'MISCELLANEOUS EDUCATIONAL FACILITY',
Y1: 'FIRE DEPARTMENT',
Y2: 'POLICE DEPARTMENT',
Y3: 'PRISON, JAIL, HOUSE OF DETENTION',
Y4: 'MILITARY AND NAVAL INSTALLATION',
Y5: 'DEPARTMENT OF REAL ESTATE',
Y6: 'DEPARTMENT OF SANITATION',
Y7: 'DEPARTMENT OF PORTS AND TERMINALS',
Y8: 'DEPARTMENT OF PUBLIC WORKS',
Y9: 'DEPARTMENT OF ENVIRONMENTAL PROTECTION',
Z0: 'TENNIS COURT, POOL, SHED, ETC.',
Z1: 'COURT HOUSE',
Z2: 'PUBLIC PARKING AREA',
Z3: 'POST OFFICE',
Z4: 'FOREIGN GOVERNMENT',
Z5: 'UNITED NATIONS',
Z7: 'EASEMENT',
Z8: 'CEMETERY',
Z9: 'OTHER MISCELLANEOUS'
};
return buildingClasses[code] ?? 'Unknown building class ' + code;
}
let bcHtml = 'Not found';
if (buildingClassMap.size === 1) {
let bc = buildingClassMap.keys().next().value;