Transitime / core

Transitime 0.1 (beta) is an open source project created and managed by Swiftly, Inc. to help transit agencies generate more accurate and reliable real-time arrival information for passengers. This version of the code is an early beta release and should not be used for production implementations. Please reach out to Swiftly at contact@goswift.ly for the most up-to-date software.
https://goswift.ly/transitime
GNU General Public License v3.0
62 stars 77 forks source link

GtfsRtVehiclePositionsReaderBase.java seems to expect gtfs vehicle position timestamps to be in milliseconds rather than seconds. #12

Closed scrudden closed 9 years ago

scrudden commented 9 years ago

The GTFS-rt spec states the time stamps for vehicle positions are to be in seconds from epoch not milliseconds.

            if (vehicle.hasTimestamp())
                gpsTime = vehicle.getTimestamp();
            else
                gpsTime = System.currentTimeMillis();

I expect this should be

        if (vehicle.hasTimestamp())
                gpsTime = vehicle.getTimestamp()*1000;
            else
                gpsTime = System.currentTimeMillis();
skibu commented 9 years ago

You are correct. Glad you found it. gpsTime should be in msec yet vehicle.getTimestamp() returns time in seconds.

By the way, I prefer using Time.MS_PER_SEC or Time.SEC_IN_MSECS instead of 1000 because it makes it more clear why doing the conversion.

Let me know if you will create a pull request or if I should make the change myself.

barbeau commented 9 years ago

I'd suggest using Java TimeUnit. IMHO, it makes it very clear what conversion is happening and is native Java. For usage examples see: http://www.javaworld.com/article/2074114/core-java/the-highly-useful-java-timeunit-enum.html On Aug 18, 2015 9:09 PM, "skibu" notifications@github.com wrote:

You are correct. Glad you found it. gpsTime should be in msec yet vehicle.getTimestamp() returns time in seconds.

By the way, I prefer using Time.MS_PER_SEC or Time.SEC_IN_MSECS instead of 1000 because it makes it more clear why doing the conversion.

Let me know if you will create a pull request or if I should make the change myself.

— Reply to this email directly or view it on GitHub https://github.com/Transitime/core/issues/12#issuecomment-132408117.

skibu commented 9 years ago

Sean, thanks for the tip on TimeUnit. I've been using constants for so long I didn't realize TimeUnit was a viable alternative.

skibu commented 9 years ago

Closed due to pull request #16.