diff options
Diffstat (limited to '')
-rw-r--r-- | gtfs/GTFS/Realtime/TripUpdate.hs | 133 | ||||
-rw-r--r-- | gtfs/GTFS/Realtime/TripUpdate/StopTimeEvent.hs | 101 | ||||
-rw-r--r-- | gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate.hs | 149 | ||||
-rw-r--r-- | gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate/ScheduleRelationship.hs | 83 | ||||
-rw-r--r-- | gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties.hs | 89 | ||||
-rw-r--r-- | gtfs/GTFS/Realtime/TripUpdate/TripProperties.hs | 108 |
6 files changed, 663 insertions, 0 deletions
diff --git a/gtfs/GTFS/Realtime/TripUpdate.hs b/gtfs/GTFS/Realtime/TripUpdate.hs new file mode 100644 index 0000000..24ef425 --- /dev/null +++ b/gtfs/GTFS/Realtime/TripUpdate.hs @@ -0,0 +1,133 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.TripUpdate (TripUpdate(..)) where +import Prelude ((+), (/), (++), (.), (==), (<=), (&&)) +import qualified Prelude as Prelude' +import qualified Data.List as Prelude' +import qualified Data.Typeable as Prelude' +import qualified GHC.Generics as Prelude' +import qualified Data.Data as Prelude' +import qualified Text.ProtocolBuffers.Header as P' +import qualified GTFS.Realtime.TripDescriptor as GTFS.Realtime +import qualified GTFS.Realtime.TripUpdate.StopTimeUpdate as GTFS.Realtime.TripUpdate +import qualified GTFS.Realtime.TripUpdate.TripProperties as GTFS.Realtime.TripUpdate +import qualified GTFS.Realtime.VehicleDescriptor as GTFS.Realtime + +data TripUpdate = TripUpdate{trip :: !(GTFS.Realtime.TripDescriptor), vehicle :: !(P'.Maybe GTFS.Realtime.VehicleDescriptor), + stop_time_update :: !(P'.Seq GTFS.Realtime.TripUpdate.StopTimeUpdate), + timestamp :: !(P'.Maybe P'.Word64), delay :: !(P'.Maybe P'.Int32), + trip_properties :: !(P'.Maybe GTFS.Realtime.TripUpdate.TripProperties), ext'field :: !(P'.ExtField)} + deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.ExtendMessage TripUpdate where + getExtField = ext'field + putExtField e'f msg = msg{ext'field = e'f} + validExtRanges msg = P'.extRanges (P'.reflectDescriptorInfo msg) + +instance P'.Mergeable TripUpdate where + mergeAppend (TripUpdate x'1 x'2 x'3 x'4 x'5 x'6 x'7) (TripUpdate y'1 y'2 y'3 y'4 y'5 y'6 y'7) + = let !z'1 = P'.mergeAppend x'1 y'1 + !z'2 = P'.mergeAppend x'2 y'2 + !z'3 = P'.mergeAppend x'3 y'3 + !z'4 = P'.mergeAppend x'4 y'4 + !z'5 = P'.mergeAppend x'5 y'5 + !z'6 = P'.mergeAppend x'6 y'6 + !z'7 = P'.mergeAppend x'7 y'7 + in TripUpdate z'1 z'2 z'3 z'4 z'5 z'6 z'7 + +instance P'.Default TripUpdate where + defaultValue + = TripUpdate P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue + +instance P'.Wire TripUpdate where + wireSize ft' self'@(TripUpdate x'1 x'2 x'3 x'4 x'5 x'6 x'7) + = case ft' of + 10 -> calc'Size + 11 -> P'.prependMessageSize calc'Size + _ -> P'.wireSizeErr ft' self' + where + calc'Size + = (P'.wireSizeReq 1 11 x'1 + P'.wireSizeOpt 1 11 x'2 + P'.wireSizeRep 1 11 x'3 + P'.wireSizeOpt 1 4 x'4 + + P'.wireSizeOpt 1 5 x'5 + + P'.wireSizeOpt 1 11 x'6 + + P'.wireSizeExtField x'7) + wirePutWithSize ft' self'@(TripUpdate x'1 x'2 x'3 x'4 x'5 x'6 x'7) + = case ft' of + 10 -> put'Fields + 11 -> put'FieldsSized + _ -> P'.wirePutErr ft' self' + where + put'Fields + = P'.sequencePutWithSize + [P'.wirePutReqWithSize 10 11 x'1, P'.wirePutRepWithSize 18 11 x'3, P'.wirePutOptWithSize 26 11 x'2, + P'.wirePutOptWithSize 32 4 x'4, P'.wirePutOptWithSize 40 5 x'5, P'.wirePutOptWithSize 50 11 x'6, + P'.wirePutExtFieldWithSize x'7] + put'FieldsSized + = let size' = Prelude'.fst (P'.runPutM put'Fields) + put'Size + = do + P'.putSize size' + Prelude'.return (P'.size'WireSize size') + in P'.sequencePutWithSize [put'Size, put'Fields] + wireGet ft' + = case ft' of + 10 -> P'.getBareMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + 11 -> P'.getMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + _ -> P'.wireGetErr ft' + where + update'Self wire'Tag old'Self + = case wire'Tag of + 10 -> Prelude'.fmap (\ !new'Field -> old'Self{trip = P'.mergeAppend (trip old'Self) (new'Field)}) (P'.wireGet 11) + 26 -> Prelude'.fmap (\ !new'Field -> old'Self{vehicle = P'.mergeAppend (vehicle old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + 18 -> Prelude'.fmap (\ !new'Field -> old'Self{stop_time_update = P'.append (stop_time_update old'Self) new'Field}) + (P'.wireGet 11) + 32 -> Prelude'.fmap (\ !new'Field -> old'Self{timestamp = Prelude'.Just new'Field}) (P'.wireGet 4) + 40 -> Prelude'.fmap (\ !new'Field -> old'Self{delay = Prelude'.Just new'Field}) (P'.wireGet 5) + 50 -> Prelude'.fmap + (\ !new'Field -> + old'Self{trip_properties = P'.mergeAppend (trip_properties old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in + if Prelude'.or [1000 <= field'Number && field'Number <= 1999, 9000 <= field'Number && field'Number <= 9999] then + P'.loadExtension field'Number wire'Type old'Self else P'.unknown field'Number wire'Type old'Self + +instance P'.MessageAPI msg' (msg' -> TripUpdate) TripUpdate where + getVal m' f' = f' m' + +instance P'.GPB TripUpdate + +instance P'.ReflectDescriptor TripUpdate where + getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList [10]) (P'.fromDistinctAscList [10, 18, 26, 32, 40, 50]) + reflectDescriptorInfo _ + = Prelude'.read + "DescriptorInfo {descName = ProtoName {protobufName = FIName \".transit_realtime.TripUpdate\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TripUpdate\"}, descFilePath = [\"GTFS\",\"Realtime\",\"TripUpdate.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.trip\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName' = FName \"trip\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TripDescriptor\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TripDescriptor\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.vehicle\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName' = FName \"vehicle\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 26}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.VehicleDescriptor\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"VehicleDescriptor\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.stop_time_update\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName' = FName \"stop_time_update\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 18}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.StopTimeUpdate\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName = MName \"StopTimeUpdate\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.timestamp\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName' = FName \"timestamp\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 4}, wireTag = WireTag {getWireTag = 32}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 4}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.delay\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName' = FName \"delay\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 5}, wireTag = WireTag {getWireTag = 40}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 5}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.trip_properties\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName' = FName \"trip_properties\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 6}, wireTag = WireTag {getWireTag = 50}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.TripProperties\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName = MName \"TripProperties\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing}], descOneofs = fromList [], keys = fromList [], extRanges = [(FieldId {getFieldId = 1000},FieldId {getFieldId = 1999}),(FieldId {getFieldId = 9000},FieldId {getFieldId = 9999})], knownKeys = fromList [], storeUnknown = False, lazyFields = False, makeLenses = False, jsonInstances = False, mapEntry = False}" + +instance P'.TextType TripUpdate where + tellT = P'.tellSubMessage + getT = P'.getSubMessage + +instance P'.TextMsg TripUpdate where + textPut msg + = do + P'.tellT "trip" (trip msg) + P'.tellT "vehicle" (vehicle msg) + P'.tellT "stop_time_update" (stop_time_update msg) + P'.tellT "timestamp" (timestamp msg) + P'.tellT "delay" (delay msg) + P'.tellT "trip_properties" (trip_properties msg) + textGet + = do + mods <- P'.sepEndBy + (P'.choice [parse'trip, parse'vehicle, parse'stop_time_update, parse'timestamp, parse'delay, parse'trip_properties]) + P'.spaces + Prelude'.return (Prelude'.foldl' (\ v f -> f v) P'.defaultValue mods) + where + parse'trip = Prelude'.fmap (\ v o -> o{trip = v}) (P'.try (P'.getT "trip")) + parse'vehicle = Prelude'.fmap (\ v o -> o{vehicle = v}) (P'.try (P'.getT "vehicle")) + parse'stop_time_update + = Prelude'.fmap (\ v o -> o{stop_time_update = P'.append (stop_time_update o) v}) (P'.try (P'.getT "stop_time_update")) + parse'timestamp = Prelude'.fmap (\ v o -> o{timestamp = v}) (P'.try (P'.getT "timestamp")) + parse'delay = Prelude'.fmap (\ v o -> o{delay = v}) (P'.try (P'.getT "delay")) + parse'trip_properties = Prelude'.fmap (\ v o -> o{trip_properties = v}) (P'.try (P'.getT "trip_properties"))
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/TripUpdate/StopTimeEvent.hs b/gtfs/GTFS/Realtime/TripUpdate/StopTimeEvent.hs new file mode 100644 index 0000000..0005e4c --- /dev/null +++ b/gtfs/GTFS/Realtime/TripUpdate/StopTimeEvent.hs @@ -0,0 +1,101 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.TripUpdate.StopTimeEvent (StopTimeEvent(..)) where +import Prelude ((+), (/), (++), (.), (==), (<=), (&&)) +import qualified Prelude as Prelude' +import qualified Data.List as Prelude' +import qualified Data.Typeable as Prelude' +import qualified GHC.Generics as Prelude' +import qualified Data.Data as Prelude' +import qualified Text.ProtocolBuffers.Header as P' + +data StopTimeEvent = StopTimeEvent{delay :: !(P'.Maybe P'.Int32), time :: !(P'.Maybe P'.Int64), uncertainty :: !(P'.Maybe P'.Int32), + ext'field :: !(P'.ExtField)} + deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.ExtendMessage StopTimeEvent where + getExtField = ext'field + putExtField e'f msg = msg{ext'field = e'f} + validExtRanges msg = P'.extRanges (P'.reflectDescriptorInfo msg) + +instance P'.Mergeable StopTimeEvent where + mergeAppend (StopTimeEvent x'1 x'2 x'3 x'4) (StopTimeEvent y'1 y'2 y'3 y'4) + = let !z'1 = P'.mergeAppend x'1 y'1 + !z'2 = P'.mergeAppend x'2 y'2 + !z'3 = P'.mergeAppend x'3 y'3 + !z'4 = P'.mergeAppend x'4 y'4 + in StopTimeEvent z'1 z'2 z'3 z'4 + +instance P'.Default StopTimeEvent where + defaultValue = StopTimeEvent P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue + +instance P'.Wire StopTimeEvent where + wireSize ft' self'@(StopTimeEvent x'1 x'2 x'3 x'4) + = case ft' of + 10 -> calc'Size + 11 -> P'.prependMessageSize calc'Size + _ -> P'.wireSizeErr ft' self' + where + calc'Size = (P'.wireSizeOpt 1 5 x'1 + P'.wireSizeOpt 1 3 x'2 + P'.wireSizeOpt 1 5 x'3 + P'.wireSizeExtField x'4) + wirePutWithSize ft' self'@(StopTimeEvent x'1 x'2 x'3 x'4) + = case ft' of + 10 -> put'Fields + 11 -> put'FieldsSized + _ -> P'.wirePutErr ft' self' + where + put'Fields + = P'.sequencePutWithSize + [P'.wirePutOptWithSize 8 5 x'1, P'.wirePutOptWithSize 16 3 x'2, P'.wirePutOptWithSize 24 5 x'3, + P'.wirePutExtFieldWithSize x'4] + put'FieldsSized + = let size' = Prelude'.fst (P'.runPutM put'Fields) + put'Size + = do + P'.putSize size' + Prelude'.return (P'.size'WireSize size') + in P'.sequencePutWithSize [put'Size, put'Fields] + wireGet ft' + = case ft' of + 10 -> P'.getBareMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + 11 -> P'.getMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + _ -> P'.wireGetErr ft' + where + update'Self wire'Tag old'Self + = case wire'Tag of + 8 -> Prelude'.fmap (\ !new'Field -> old'Self{delay = Prelude'.Just new'Field}) (P'.wireGet 5) + 16 -> Prelude'.fmap (\ !new'Field -> old'Self{time = Prelude'.Just new'Field}) (P'.wireGet 3) + 24 -> Prelude'.fmap (\ !new'Field -> old'Self{uncertainty = Prelude'.Just new'Field}) (P'.wireGet 5) + _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in + if Prelude'.or [1000 <= field'Number && field'Number <= 1999, 9000 <= field'Number && field'Number <= 9999] then + P'.loadExtension field'Number wire'Type old'Self else P'.unknown field'Number wire'Type old'Self + +instance P'.MessageAPI msg' (msg' -> StopTimeEvent) StopTimeEvent where + getVal m' f' = f' m' + +instance P'.GPB StopTimeEvent + +instance P'.ReflectDescriptor StopTimeEvent where + getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [8, 16, 24]) + reflectDescriptorInfo _ + = Prelude'.read + "DescriptorInfo {descName = ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.StopTimeEvent\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName = MName \"StopTimeEvent\"}, descFilePath = [\"GTFS\",\"Realtime\",\"TripUpdate\",\"StopTimeEvent.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeEvent.delay\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeEvent\"], baseName' = FName \"delay\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 8}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 5}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeEvent.time\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeEvent\"], baseName' = FName \"time\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 16}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 3}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeEvent.uncertainty\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeEvent\"], baseName' = FName \"uncertainty\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 24}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 5}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing}], descOneofs = fromList [], keys = fromList [], extRanges = [(FieldId {getFieldId = 1000},FieldId {getFieldId = 1999}),(FieldId {getFieldId = 9000},FieldId {getFieldId = 9999})], knownKeys = fromList [], storeUnknown = False, lazyFields = False, makeLenses = False, jsonInstances = False, mapEntry = False}" + +instance P'.TextType StopTimeEvent where + tellT = P'.tellSubMessage + getT = P'.getSubMessage + +instance P'.TextMsg StopTimeEvent where + textPut msg + = do + P'.tellT "delay" (delay msg) + P'.tellT "time" (time msg) + P'.tellT "uncertainty" (uncertainty msg) + textGet + = do + mods <- P'.sepEndBy (P'.choice [parse'delay, parse'time, parse'uncertainty]) P'.spaces + Prelude'.return (Prelude'.foldl' (\ v f -> f v) P'.defaultValue mods) + where + parse'delay = Prelude'.fmap (\ v o -> o{delay = v}) (P'.try (P'.getT "delay")) + parse'time = Prelude'.fmap (\ v o -> o{time = v}) (P'.try (P'.getT "time")) + parse'uncertainty = Prelude'.fmap (\ v o -> o{uncertainty = v}) (P'.try (P'.getT "uncertainty"))
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate.hs b/gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate.hs new file mode 100644 index 0000000..e2553e3 --- /dev/null +++ b/gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate.hs @@ -0,0 +1,149 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.TripUpdate.StopTimeUpdate (StopTimeUpdate(..)) where +import Prelude ((+), (/), (++), (.), (==), (<=), (&&)) +import qualified Prelude as Prelude' +import qualified Data.List as Prelude' +import qualified Data.Typeable as Prelude' +import qualified GHC.Generics as Prelude' +import qualified Data.Data as Prelude' +import qualified Text.ProtocolBuffers.Header as P' +import qualified GTFS.Realtime.TripUpdate.StopTimeEvent as GTFS.Realtime.TripUpdate +import qualified GTFS.Realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship as GTFS.Realtime.TripUpdate.StopTimeUpdate +import qualified GTFS.Realtime.TripUpdate.StopTimeUpdate.StopTimeProperties as GTFS.Realtime.TripUpdate.StopTimeUpdate +import qualified GTFS.Realtime.VehiclePosition.OccupancyStatus as GTFS.Realtime.VehiclePosition + +data StopTimeUpdate = StopTimeUpdate{stop_sequence :: !(P'.Maybe P'.Word32), stop_id :: !(P'.Maybe P'.Utf8), + arrival :: !(P'.Maybe GTFS.Realtime.TripUpdate.StopTimeEvent), + departure :: !(P'.Maybe GTFS.Realtime.TripUpdate.StopTimeEvent), + departure_occupancy_status :: !(P'.Maybe GTFS.Realtime.VehiclePosition.OccupancyStatus), + schedule_relationship :: + !(P'.Maybe GTFS.Realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship), + stop_time_properties :: !(P'.Maybe GTFS.Realtime.TripUpdate.StopTimeUpdate.StopTimeProperties), + ext'field :: !(P'.ExtField)} + deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.ExtendMessage StopTimeUpdate where + getExtField = ext'field + putExtField e'f msg = msg{ext'field = e'f} + validExtRanges msg = P'.extRanges (P'.reflectDescriptorInfo msg) + +instance P'.Mergeable StopTimeUpdate where + mergeAppend (StopTimeUpdate x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8) (StopTimeUpdate y'1 y'2 y'3 y'4 y'5 y'6 y'7 y'8) + = let !z'1 = P'.mergeAppend x'1 y'1 + !z'2 = P'.mergeAppend x'2 y'2 + !z'3 = P'.mergeAppend x'3 y'3 + !z'4 = P'.mergeAppend x'4 y'4 + !z'5 = P'.mergeAppend x'5 y'5 + !z'6 = P'.mergeAppend x'6 y'6 + !z'7 = P'.mergeAppend x'7 y'7 + !z'8 = P'.mergeAppend x'8 y'8 + in StopTimeUpdate z'1 z'2 z'3 z'4 z'5 z'6 z'7 z'8 + +instance P'.Default StopTimeUpdate where + defaultValue + = StopTimeUpdate P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue + (Prelude'.Just (Prelude'.read "SCHEDULED")) + P'.defaultValue + P'.defaultValue + +instance P'.Wire StopTimeUpdate where + wireSize ft' self'@(StopTimeUpdate x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8) + = case ft' of + 10 -> calc'Size + 11 -> P'.prependMessageSize calc'Size + _ -> P'.wireSizeErr ft' self' + where + calc'Size + = (P'.wireSizeOpt 1 13 x'1 + P'.wireSizeOpt 1 9 x'2 + P'.wireSizeOpt 1 11 x'3 + P'.wireSizeOpt 1 11 x'4 + + P'.wireSizeOpt 1 14 x'5 + + P'.wireSizeOpt 1 14 x'6 + + P'.wireSizeOpt 1 11 x'7 + + P'.wireSizeExtField x'8) + wirePutWithSize ft' self'@(StopTimeUpdate x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8) + = case ft' of + 10 -> put'Fields + 11 -> put'FieldsSized + _ -> P'.wirePutErr ft' self' + where + put'Fields + = P'.sequencePutWithSize + [P'.wirePutOptWithSize 8 13 x'1, P'.wirePutOptWithSize 18 11 x'3, P'.wirePutOptWithSize 26 11 x'4, + P'.wirePutOptWithSize 34 9 x'2, P'.wirePutOptWithSize 40 14 x'6, P'.wirePutOptWithSize 50 11 x'7, + P'.wirePutOptWithSize 56 14 x'5, P'.wirePutExtFieldWithSize x'8] + put'FieldsSized + = let size' = Prelude'.fst (P'.runPutM put'Fields) + put'Size + = do + P'.putSize size' + Prelude'.return (P'.size'WireSize size') + in P'.sequencePutWithSize [put'Size, put'Fields] + wireGet ft' + = case ft' of + 10 -> P'.getBareMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + 11 -> P'.getMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + _ -> P'.wireGetErr ft' + where + update'Self wire'Tag old'Self + = case wire'Tag of + 8 -> Prelude'.fmap (\ !new'Field -> old'Self{stop_sequence = Prelude'.Just new'Field}) (P'.wireGet 13) + 34 -> Prelude'.fmap (\ !new'Field -> old'Self{stop_id = Prelude'.Just new'Field}) (P'.wireGet 9) + 18 -> Prelude'.fmap (\ !new'Field -> old'Self{arrival = P'.mergeAppend (arrival old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + 26 -> Prelude'.fmap + (\ !new'Field -> old'Self{departure = P'.mergeAppend (departure old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + 56 -> Prelude'.fmap (\ !new'Field -> old'Self{departure_occupancy_status = Prelude'.Just new'Field}) (P'.wireGet 14) + 40 -> Prelude'.fmap (\ !new'Field -> old'Self{schedule_relationship = Prelude'.Just new'Field}) (P'.wireGet 14) + 50 -> Prelude'.fmap + (\ !new'Field -> + old'Self{stop_time_properties = P'.mergeAppend (stop_time_properties old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in + if Prelude'.or [1000 <= field'Number && field'Number <= 1999, 9000 <= field'Number && field'Number <= 9999] then + P'.loadExtension field'Number wire'Type old'Self else P'.unknown field'Number wire'Type old'Self + +instance P'.MessageAPI msg' (msg' -> StopTimeUpdate) StopTimeUpdate where + getVal m' f' = f' m' + +instance P'.GPB StopTimeUpdate + +instance P'.ReflectDescriptor StopTimeUpdate where + getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [8, 18, 26, 34, 40, 50, 56]) + reflectDescriptorInfo _ + = Prelude'.read + "DescriptorInfo {descName = ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.StopTimeUpdate\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName = MName \"StopTimeUpdate\"}, descFilePath = [\"GTFS\",\"Realtime\",\"TripUpdate\",\"StopTimeUpdate.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.stop_sequence\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName' = FName \"stop_sequence\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 8}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 13}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.stop_id\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName' = FName \"stop_id\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 4}, wireTag = WireTag {getWireTag = 34}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.arrival\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName' = FName \"arrival\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 18}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.StopTimeEvent\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName = MName \"StopTimeEvent\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.departure\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName' = FName \"departure\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 26}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.StopTimeEvent\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName = MName \"StopTimeEvent\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.departure_occupancy_status\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName' = FName \"departure_occupancy_status\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 7}, wireTag = WireTag {getWireTag = 56}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 14}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.VehiclePosition.OccupancyStatus\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName = MName \"OccupancyStatus\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.schedule_relationship\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName' = FName \"schedule_relationship\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 5}, wireTag = WireTag {getWireTag = 40}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 14}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName = MName \"ScheduleRelationship\"}), hsRawDefault = Just \"SCHEDULED\", hsDefault = Just (HsDef'Enum \"SCHEDULED\"), isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.stop_time_properties\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName' = FName \"stop_time_properties\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 6}, wireTag = WireTag {getWireTag = 50}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName = MName \"StopTimeProperties\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing}], descOneofs = fromList [], keys = fromList [], extRanges = [(FieldId {getFieldId = 1000},FieldId {getFieldId = 1999}),(FieldId {getFieldId = 9000},FieldId {getFieldId = 9999})], knownKeys = fromList [], storeUnknown = False, lazyFields = False, makeLenses = False, jsonInstances = False, mapEntry = False}" + +instance P'.TextType StopTimeUpdate where + tellT = P'.tellSubMessage + getT = P'.getSubMessage + +instance P'.TextMsg StopTimeUpdate where + textPut msg + = do + P'.tellT "stop_sequence" (stop_sequence msg) + P'.tellT "stop_id" (stop_id msg) + P'.tellT "arrival" (arrival msg) + P'.tellT "departure" (departure msg) + P'.tellT "departure_occupancy_status" (departure_occupancy_status msg) + P'.tellT "schedule_relationship" (schedule_relationship msg) + P'.tellT "stop_time_properties" (stop_time_properties msg) + textGet + = do + mods <- P'.sepEndBy + (P'.choice + [parse'stop_sequence, parse'stop_id, parse'arrival, parse'departure, parse'departure_occupancy_status, + parse'schedule_relationship, parse'stop_time_properties]) + P'.spaces + Prelude'.return (Prelude'.foldl' (\ v f -> f v) P'.defaultValue mods) + where + parse'stop_sequence = Prelude'.fmap (\ v o -> o{stop_sequence = v}) (P'.try (P'.getT "stop_sequence")) + parse'stop_id = Prelude'.fmap (\ v o -> o{stop_id = v}) (P'.try (P'.getT "stop_id")) + parse'arrival = Prelude'.fmap (\ v o -> o{arrival = v}) (P'.try (P'.getT "arrival")) + parse'departure = Prelude'.fmap (\ v o -> o{departure = v}) (P'.try (P'.getT "departure")) + parse'departure_occupancy_status + = Prelude'.fmap (\ v o -> o{departure_occupancy_status = v}) (P'.try (P'.getT "departure_occupancy_status")) + parse'schedule_relationship + = Prelude'.fmap (\ v o -> o{schedule_relationship = v}) (P'.try (P'.getT "schedule_relationship")) + parse'stop_time_properties = Prelude'.fmap (\ v o -> o{stop_time_properties = v}) (P'.try (P'.getT "stop_time_properties"))
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate/ScheduleRelationship.hs b/gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate/ScheduleRelationship.hs new file mode 100644 index 0000000..050ac88 --- /dev/null +++ b/gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate/ScheduleRelationship.hs @@ -0,0 +1,83 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship (ScheduleRelationship(..)) where +import Prelude ((+), (/), (.)) +import qualified Prelude as Prelude' +import qualified Data.List as Prelude' +import qualified Data.Typeable as Prelude' +import qualified GHC.Generics as Prelude' +import qualified Data.Data as Prelude' +import qualified Text.ProtocolBuffers.Header as P' + +data ScheduleRelationship = SCHEDULED + | SKIPPED + | NO_DATA + | UNSCHEDULED + deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, + Prelude'.Generic) + +instance P'.Mergeable ScheduleRelationship + +instance Prelude'.Bounded ScheduleRelationship where + minBound = SCHEDULED + maxBound = UNSCHEDULED + +instance P'.Default ScheduleRelationship where + defaultValue = SCHEDULED + +toMaybe'Enum :: Prelude'.Int -> P'.Maybe ScheduleRelationship +toMaybe'Enum 0 = Prelude'.Just SCHEDULED +toMaybe'Enum 1 = Prelude'.Just SKIPPED +toMaybe'Enum 2 = Prelude'.Just NO_DATA +toMaybe'Enum 3 = Prelude'.Just UNSCHEDULED +toMaybe'Enum _ = Prelude'.Nothing + +instance Prelude'.Enum ScheduleRelationship where + fromEnum SCHEDULED = 0 + fromEnum SKIPPED = 1 + fromEnum NO_DATA = 2 + fromEnum UNSCHEDULED = 3 + toEnum + = P'.fromMaybe + (Prelude'.error + "hprotoc generated code: toEnum failure for type GTFS.Realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship") + . toMaybe'Enum + succ SCHEDULED = SKIPPED + succ SKIPPED = NO_DATA + succ NO_DATA = UNSCHEDULED + succ _ + = Prelude'.error "hprotoc generated code: succ failure for type GTFS.Realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship" + pred SKIPPED = SCHEDULED + pred NO_DATA = SKIPPED + pred UNSCHEDULED = NO_DATA + pred _ + = Prelude'.error "hprotoc generated code: pred failure for type GTFS.Realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship" + +instance P'.Wire ScheduleRelationship where + wireSize ft' enum = P'.wireSize ft' (Prelude'.fromEnum enum) + wirePut ft' enum = P'.wirePut ft' (Prelude'.fromEnum enum) + wireGet 14 = P'.wireGetEnum toMaybe'Enum + wireGet ft' = P'.wireGetErr ft' + wireGetPacked 14 = P'.wireGetPackedEnum toMaybe'Enum + wireGetPacked ft' = P'.wireGetErr ft' + +instance P'.GPB ScheduleRelationship + +instance P'.MessageAPI msg' (msg' -> ScheduleRelationship) ScheduleRelationship where + getVal m' f' = f' m' + +instance P'.ReflectEnum ScheduleRelationship where + reflectEnum = [(0, "SCHEDULED", SCHEDULED), (1, "SKIPPED", SKIPPED), (2, "NO_DATA", NO_DATA), (3, "UNSCHEDULED", UNSCHEDULED)] + reflectEnumInfo _ + = P'.EnumInfo + (P'.makePNF (P'.pack ".transit_realtime.TripUpdate.StopTimeUpdate.ScheduleRelationship") [] + ["GTFS", "Realtime", "TripUpdate", "StopTimeUpdate"] + "ScheduleRelationship") + ["GTFS", "Realtime", "TripUpdate", "StopTimeUpdate", "ScheduleRelationship.hs"] + [(0, "SCHEDULED"), (1, "SKIPPED"), (2, "NO_DATA"), (3, "UNSCHEDULED")] + Prelude'.False + +instance P'.TextType ScheduleRelationship where + tellT = P'.tellShow + getT = P'.getRead
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties.hs b/gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties.hs new file mode 100644 index 0000000..8784522 --- /dev/null +++ b/gtfs/GTFS/Realtime/TripUpdate/StopTimeUpdate/StopTimeProperties.hs @@ -0,0 +1,89 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.TripUpdate.StopTimeUpdate.StopTimeProperties (StopTimeProperties(..)) where +import Prelude ((+), (/), (++), (.), (==), (<=), (&&)) +import qualified Prelude as Prelude' +import qualified Data.List as Prelude' +import qualified Data.Typeable as Prelude' +import qualified GHC.Generics as Prelude' +import qualified Data.Data as Prelude' +import qualified Text.ProtocolBuffers.Header as P' + +data StopTimeProperties = StopTimeProperties{assigned_stop_id :: !(P'.Maybe P'.Utf8), ext'field :: !(P'.ExtField)} + deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.ExtendMessage StopTimeProperties where + getExtField = ext'field + putExtField e'f msg = msg{ext'field = e'f} + validExtRanges msg = P'.extRanges (P'.reflectDescriptorInfo msg) + +instance P'.Mergeable StopTimeProperties where + mergeAppend (StopTimeProperties x'1 x'2) (StopTimeProperties y'1 y'2) + = let !z'1 = P'.mergeAppend x'1 y'1 + !z'2 = P'.mergeAppend x'2 y'2 + in StopTimeProperties z'1 z'2 + +instance P'.Default StopTimeProperties where + defaultValue = StopTimeProperties P'.defaultValue P'.defaultValue + +instance P'.Wire StopTimeProperties where + wireSize ft' self'@(StopTimeProperties x'1 x'2) + = case ft' of + 10 -> calc'Size + 11 -> P'.prependMessageSize calc'Size + _ -> P'.wireSizeErr ft' self' + where + calc'Size = (P'.wireSizeOpt 1 9 x'1 + P'.wireSizeExtField x'2) + wirePutWithSize ft' self'@(StopTimeProperties x'1 x'2) + = case ft' of + 10 -> put'Fields + 11 -> put'FieldsSized + _ -> P'.wirePutErr ft' self' + where + put'Fields = P'.sequencePutWithSize [P'.wirePutOptWithSize 10 9 x'1, P'.wirePutExtFieldWithSize x'2] + put'FieldsSized + = let size' = Prelude'.fst (P'.runPutM put'Fields) + put'Size + = do + P'.putSize size' + Prelude'.return (P'.size'WireSize size') + in P'.sequencePutWithSize [put'Size, put'Fields] + wireGet ft' + = case ft' of + 10 -> P'.getBareMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + 11 -> P'.getMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + _ -> P'.wireGetErr ft' + where + update'Self wire'Tag old'Self + = case wire'Tag of + 10 -> Prelude'.fmap (\ !new'Field -> old'Self{assigned_stop_id = Prelude'.Just new'Field}) (P'.wireGet 9) + _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in + if Prelude'.or [1000 <= field'Number && field'Number <= 1999, 9000 <= field'Number && field'Number <= 9999] then + P'.loadExtension field'Number wire'Type old'Self else P'.unknown field'Number wire'Type old'Self + +instance P'.MessageAPI msg' (msg' -> StopTimeProperties) StopTimeProperties where + getVal m' f' = f' m' + +instance P'.GPB StopTimeProperties + +instance P'.ReflectDescriptor StopTimeProperties where + getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [10]) + reflectDescriptorInfo _ + = Prelude'.read + "DescriptorInfo {descName = ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\"], baseName = MName \"StopTimeProperties\"}, descFilePath = [\"GTFS\",\"Realtime\",\"TripUpdate\",\"StopTimeUpdate\",\"StopTimeProperties.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.StopTimeUpdate.StopTimeProperties.assigned_stop_id\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"StopTimeUpdate\",MName \"StopTimeProperties\"], baseName' = FName \"assigned_stop_id\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing}], descOneofs = fromList [], keys = fromList [], extRanges = [(FieldId {getFieldId = 1000},FieldId {getFieldId = 1999}),(FieldId {getFieldId = 9000},FieldId {getFieldId = 9999})], knownKeys = fromList [], storeUnknown = False, lazyFields = False, makeLenses = False, jsonInstances = False, mapEntry = False}" + +instance P'.TextType StopTimeProperties where + tellT = P'.tellSubMessage + getT = P'.getSubMessage + +instance P'.TextMsg StopTimeProperties where + textPut msg + = do + P'.tellT "assigned_stop_id" (assigned_stop_id msg) + textGet + = do + mods <- P'.sepEndBy (P'.choice [parse'assigned_stop_id]) P'.spaces + Prelude'.return (Prelude'.foldl' (\ v f -> f v) P'.defaultValue mods) + where + parse'assigned_stop_id = Prelude'.fmap (\ v o -> o{assigned_stop_id = v}) (P'.try (P'.getT "assigned_stop_id"))
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/TripUpdate/TripProperties.hs b/gtfs/GTFS/Realtime/TripUpdate/TripProperties.hs new file mode 100644 index 0000000..ad66022 --- /dev/null +++ b/gtfs/GTFS/Realtime/TripUpdate/TripProperties.hs @@ -0,0 +1,108 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.TripUpdate.TripProperties (TripProperties(..)) where +import Prelude ((+), (/), (++), (.), (==), (<=), (&&)) +import qualified Prelude as Prelude' +import qualified Data.List as Prelude' +import qualified Data.Typeable as Prelude' +import qualified GHC.Generics as Prelude' +import qualified Data.Data as Prelude' +import qualified Text.ProtocolBuffers.Header as P' + +data TripProperties = TripProperties{trip_id :: !(P'.Maybe P'.Utf8), start_date :: !(P'.Maybe P'.Utf8), + start_time :: !(P'.Maybe P'.Utf8), shape_id :: !(P'.Maybe P'.Utf8), + ext'field :: !(P'.ExtField)} + deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.ExtendMessage TripProperties where + getExtField = ext'field + putExtField e'f msg = msg{ext'field = e'f} + validExtRanges msg = P'.extRanges (P'.reflectDescriptorInfo msg) + +instance P'.Mergeable TripProperties where + mergeAppend (TripProperties x'1 x'2 x'3 x'4 x'5) (TripProperties y'1 y'2 y'3 y'4 y'5) + = let !z'1 = P'.mergeAppend x'1 y'1 + !z'2 = P'.mergeAppend x'2 y'2 + !z'3 = P'.mergeAppend x'3 y'3 + !z'4 = P'.mergeAppend x'4 y'4 + !z'5 = P'.mergeAppend x'5 y'5 + in TripProperties z'1 z'2 z'3 z'4 z'5 + +instance P'.Default TripProperties where + defaultValue = TripProperties P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue + +instance P'.Wire TripProperties where + wireSize ft' self'@(TripProperties x'1 x'2 x'3 x'4 x'5) + = case ft' of + 10 -> calc'Size + 11 -> P'.prependMessageSize calc'Size + _ -> P'.wireSizeErr ft' self' + where + calc'Size + = (P'.wireSizeOpt 1 9 x'1 + P'.wireSizeOpt 1 9 x'2 + P'.wireSizeOpt 1 9 x'3 + P'.wireSizeOpt 1 9 x'4 + + P'.wireSizeExtField x'5) + wirePutWithSize ft' self'@(TripProperties x'1 x'2 x'3 x'4 x'5) + = case ft' of + 10 -> put'Fields + 11 -> put'FieldsSized + _ -> P'.wirePutErr ft' self' + where + put'Fields + = P'.sequencePutWithSize + [P'.wirePutOptWithSize 10 9 x'1, P'.wirePutOptWithSize 18 9 x'2, P'.wirePutOptWithSize 26 9 x'3, + P'.wirePutOptWithSize 34 9 x'4, P'.wirePutExtFieldWithSize x'5] + put'FieldsSized + = let size' = Prelude'.fst (P'.runPutM put'Fields) + put'Size + = do + P'.putSize size' + Prelude'.return (P'.size'WireSize size') + in P'.sequencePutWithSize [put'Size, put'Fields] + wireGet ft' + = case ft' of + 10 -> P'.getBareMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + 11 -> P'.getMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) + _ -> P'.wireGetErr ft' + where + update'Self wire'Tag old'Self + = case wire'Tag of + 10 -> Prelude'.fmap (\ !new'Field -> old'Self{trip_id = Prelude'.Just new'Field}) (P'.wireGet 9) + 18 -> Prelude'.fmap (\ !new'Field -> old'Self{start_date = Prelude'.Just new'Field}) (P'.wireGet 9) + 26 -> Prelude'.fmap (\ !new'Field -> old'Self{start_time = Prelude'.Just new'Field}) (P'.wireGet 9) + 34 -> Prelude'.fmap (\ !new'Field -> old'Self{shape_id = Prelude'.Just new'Field}) (P'.wireGet 9) + _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in + if Prelude'.or [1000 <= field'Number && field'Number <= 1999, 9000 <= field'Number && field'Number <= 9999] then + P'.loadExtension field'Number wire'Type old'Self else P'.unknown field'Number wire'Type old'Self + +instance P'.MessageAPI msg' (msg' -> TripProperties) TripProperties where + getVal m' f' = f' m' + +instance P'.GPB TripProperties + +instance P'.ReflectDescriptor TripProperties where + getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [10, 18, 26, 34]) + reflectDescriptorInfo _ + = Prelude'.read + "DescriptorInfo {descName = ProtoName {protobufName = FIName \".transit_realtime.TripUpdate.TripProperties\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\"], baseName = MName \"TripProperties\"}, descFilePath = [\"GTFS\",\"Realtime\",\"TripUpdate\",\"TripProperties.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.TripProperties.trip_id\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"TripProperties\"], baseName' = FName \"trip_id\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.TripProperties.start_date\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"TripProperties\"], baseName' = FName \"start_date\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 18}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.TripProperties.start_time\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"TripProperties\"], baseName' = FName \"start_time\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 26}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.TripUpdate.TripProperties.shape_id\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"TripUpdate\",MName \"TripProperties\"], baseName' = FName \"shape_id\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 4}, wireTag = WireTag {getWireTag = 34}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing}], descOneofs = fromList [], keys = fromList [], extRanges = [(FieldId {getFieldId = 1000},FieldId {getFieldId = 1999}),(FieldId {getFieldId = 9000},FieldId {getFieldId = 9999})], knownKeys = fromList [], storeUnknown = False, lazyFields = False, makeLenses = False, jsonInstances = False, mapEntry = False}" + +instance P'.TextType TripProperties where + tellT = P'.tellSubMessage + getT = P'.getSubMessage + +instance P'.TextMsg TripProperties where + textPut msg + = do + P'.tellT "trip_id" (trip_id msg) + P'.tellT "start_date" (start_date msg) + P'.tellT "start_time" (start_time msg) + P'.tellT "shape_id" (shape_id msg) + textGet + = do + mods <- P'.sepEndBy (P'.choice [parse'trip_id, parse'start_date, parse'start_time, parse'shape_id]) P'.spaces + Prelude'.return (Prelude'.foldl' (\ v f -> f v) P'.defaultValue mods) + where + parse'trip_id = Prelude'.fmap (\ v o -> o{trip_id = v}) (P'.try (P'.getT "trip_id")) + parse'start_date = Prelude'.fmap (\ v o -> o{start_date = v}) (P'.try (P'.getT "start_date")) + parse'start_time = Prelude'.fmap (\ v o -> o{start_time = v}) (P'.try (P'.getT "start_time")) + parse'shape_id = Prelude'.fmap (\ v o -> o{shape_id = v}) (P'.try (P'.getT "shape_id"))
\ No newline at end of file |