coregis / cbf-programs-map-2023

Rebranding and other updates to the Raise Your Hand Texas Programs Map
GNU General Public License v3.0
0 stars 0 forks source link

If there are multiple coordinate fields, use the first #40

Closed eldang closed 6 months ago

eldang commented 6 months ago

This should fix the bug reported by @cbfdn-kwang today, and does when I test it locally. Background:

@cbfdn-kwang reported that the Charles Butt Scholars layer wasn't showing up. Looking at requests in the JS console I see that the data are being received from Google Drive, and there are no error messages.

The issue seems to be that my normaliseHeaders() function, which identifies which fields to use for x and y coordinates, didn't do anything sensible when a data source contained multiple potential fields. The relevant sheet had longitude,latitude as its first two columns, but in demoing the geocoding function a couple of weeks ago we had added lat,long as the last two, but left them blank. That in turn was leading my code to use the blank columns and have no coordinates to place the Charles Butt Scholars points at. They're probably all at Null Island, but because we set limits on scrolling the map I couldn't check that.

As a quick fix, I have deleted the lat and long columns from the Charles Butt Scholars sheet, which has restored the layer visually. But adding those columns is a routine part of the geocoding process, and leaving the headers in there shouldn't break anything! Meanwhile we do have a pretty strong convention of putting the real coordinates first in these files. So to prevent a recurrence of this problem, this PR simply makes normaliseHeaders() use the first potential X and Y columns it finds and ignore others.