Saturday, December 24, 2016

NYC parking app - An idea

I've had an idea bouncing around in my head for several months since I moved to NYC- a mobile app to give you a notification to move your car when it is no longer legal to leave your car parked where it is.



Street parking is underserved by technology


Background


No rants here about tight spots, inconsiderate drivers, or the difficulty of finding spots. Some of those can be influenced by technology, some cannot, but they are not the problem I am trying to address I want to address the legal implications of where you park.

Parking restrictions take these forms, which I am ranking by my own sense of priority based on how widespread they are
  • Alternate Side Parking, to my mind by far the biggest culprit, where an otherwise perfectly legal spot in any residential area becomes illegal for a short period of time for street cleaning twice a week.
  • School zones, which are fairly easy to identify and avoid, but sometimes they are the only place to park late at night and require you to move your car by 7am next morning.
  • Loading/unloading zones or commercial vehicle zones, also a problem for the same reasons as school zones.
  • No parking or no standing zones, in which it is usually extremely obvious that you cannot park there, are the lowest priority for this app to cover. This would take the form of an instantaneous notification to move your car.
I've been here for about 6 months, being accustomed to the lax parking mentality of Texas and Ohio where every business has its own lot and I've never even dreamed of getting a ticket for anything. After getting several tickets here, I've just about figured out how to remember to move my car (and also my fiancee's car sometimes) in time to avoid it happening again, but I still forget sometimes. Maybe the natives have licked this problem by making mental connections that are not obvious to me, but I reckon a lot of people do forget just like me.

The state of parking apps


Where's the app that will help with this? There do seem to be a plethora of parking apps for Android in general, However, in virtually all cases, all that they do is point you in the direction of paid parking garages and lots, which is I suppose is helpful in certain cities particularly for visitors who don't know where street parking is available or safe.

But New Yorkers tell me that they are parking on the street quite often. They don't have a ticket from a garage, and they need to remember every single day where their car is to move it or not depending on where they parked. It is harder to do it in this city than in any other I've lived in, but to put things in perspective, I have no complaints against the City of New York for their street cleaning program or for the tickets they've given me- I've watched the cycle of loose litter accumulating, with homeowners and property managers and corner store owners steadily sweeping the clutter from their portion into the street and awaiting its disposal. It's just how we do things. If we didn't clean the streets, this city would drown in trash, and if people didn't move their cars, we couldn't clean the streets. My intent is to render the regulations more effective, and hopefully save some people some money who need it.

If you drive to work on the weekdays, then you're probably OK most of the time, since street cleaning is always during ordinary business hours. But I work from home. And even if I didn't, I might come into work at different hours, and I would therefore need to know if my car had to move by 8:30 or 11:30. I can see using this app all the time even with changes to my job situation.


Where is the data?


Locals that I've discussed this idea with agree that it seems great, and cannot name any other app that would do the same thing. In my own searches on the Play Store, I cannot find anything that purports to do the same either.

So the data must be hidden, right? There are over a million traffic signs in New York City and it would be very easy for them to not have these data easily available in digital form. Well, they may not be terrifically easy to use, but they are more available than it may appear at first glance.

Interactive map


NYC Department of Transportation has a handy interactive map that shows, among other things, all of the street signs in the city, which is fantastic if you remember where you parked and have time to consult a web browser.



I applaud them for implementing this feature although its utility is limited for the forgetful. Moreover, although it works quite well on a desktop browser, it can be pretty tedious to manually pinch and zoom to find the exact location on the map on your phone.

Programmatically, I can see some difficulty in using this tool for the following reasons.

  • The selection of a region on the graphical map is obligatory; there is no web API to get JSON or XML of a particular sign's contents. Although I will attempt to peruse the webpage for clues, getting data from it might be a brittle approach if the implementation of this map is ever altered.
  • The street sign contents themselves are just stored as strings and put inside the dialog box. We can parse out the times and dates if the city is extremely systematic in their labeling (MON & THURS, TUE & FRI, 9-10:30AM, etc.). However, we need to be prepared for the possibility of inconsistency.
  • Going from your phone's geolocation data to the nearest sign is itself a tricky problem, requiring us to us the polygon drawing tool with increasing radius to find the nearest matching street sign, and thereafter ensure it is not on a different block or on a crossroads. We have the power to deduce the actual street address by geolocation and Google Maps, but the granularity of this map seems a little less precise.

Tabular data



NYC DOT also gives a full list of all the city's parking locations and parking signs in CSV form. These are pretty huge chunks of data. I suppose the user might consent to save a few megs on their device, but I feel the task of finding the adjacent signs based on the location is particularly poorly served by hunting through these CSVs, and so this is not tremendously helpful.

Block-by-Block Lookup


The most useful tool (although still somewhat hackier than an API which I wish they would implement or, if it exists, document) is this webpage listing parking regulations on a block. You look up a block by the combination of these criteria:

  • Borough
  • Street
  • Two cross-streets
To use this, you must convert the geolocation data into a format which allows you to determine the current street, side, and cross streets. Particularly tricky seems to be getting the side of the street, which is north/south, east/west depending on the direction of the road, and we must determine that through knowing the prevailing direction of the street and determining whether your position is further north or west (etc.) than the other side of that road. But I feel that this is a sufficiently soluble problem.

If you have already determined these (and I feel it is probably much easier to turn geolocation data into this street data than it is to determine distance from signs on the interactive map), then, through some hackiness on the web page, you can extract the parking restriction dates and times in a usable format for your app. I did demonstrate it to my own satisfaction and would happily share my JS with anyone who wants to collaborate on this project, but bear in mind we're at an early stage. I'm going to document my progress in future posts.


Enforcement updates


NYC DOT produces a standard list of holidays on which the ASP is suspended, and gives updates via Twitter or email.

Scheduled suspensions are trivial to program for; dynamically updating the rules for enforcement in the app based on unscheduled suspensions is probably not too difficult. I am certain there is some means of systematically parsing data out of tweets, especially when the DOT seems to be extremely consistent in the text of its messages on suspensions.