diff options
author | stuebinm | 2022-07-02 00:16:02 +0200 |
---|---|---|
committer | stuebinm | 2022-07-02 00:35:34 +0200 |
commit | 6c25964c0165530e7db6650eea79cbac99031353 (patch) | |
tree | 2b821e5e07320c211a8af0e70974cbbe6defef9e /gtfs/GTFS/Realtime/VehiclePosition | |
parent | 6b4e8ba88f35538d62bb78b9872bc298178cf96d (diff) |
gtfs realtime proof of concept
this adds a package for protobuf stuff, generated via hprotoc. Seems to
work kinda fine?
(the generated API is horrible though, will have to write some wrappers
for that)
Diffstat (limited to 'gtfs/GTFS/Realtime/VehiclePosition')
4 files changed, 387 insertions, 0 deletions
diff --git a/gtfs/GTFS/Realtime/VehiclePosition/CarriageDetails.hs b/gtfs/GTFS/Realtime/VehiclePosition/CarriageDetails.hs new file mode 100644 index 0000000..1afba89 --- /dev/null +++ b/gtfs/GTFS/Realtime/VehiclePosition/CarriageDetails.hs @@ -0,0 +1,120 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.VehiclePosition.CarriageDetails (CarriageDetails(..)) 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.VehiclePosition.OccupancyStatus as GTFS.Realtime.VehiclePosition + +data CarriageDetails = CarriageDetails{id :: !(P'.Maybe P'.Utf8), label :: !(P'.Maybe P'.Utf8), + occupancy_status :: !(P'.Maybe GTFS.Realtime.VehiclePosition.OccupancyStatus), + occupancy_percentage :: !(P'.Maybe P'.Int32), carriage_sequence :: !(P'.Maybe P'.Word32), + ext'field :: !(P'.ExtField)} + deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.ExtendMessage CarriageDetails where + getExtField = ext'field + putExtField e'f msg = msg{ext'field = e'f} + validExtRanges msg = P'.extRanges (P'.reflectDescriptorInfo msg) + +instance P'.Mergeable CarriageDetails where + mergeAppend (CarriageDetails x'1 x'2 x'3 x'4 x'5 x'6) (CarriageDetails y'1 y'2 y'3 y'4 y'5 y'6) + = 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 + in CarriageDetails z'1 z'2 z'3 z'4 z'5 z'6 + +instance P'.Default CarriageDetails where + defaultValue + = CarriageDetails P'.defaultValue P'.defaultValue (Prelude'.Just (Prelude'.read "NO_DATA_AVAILABLE")) (Prelude'.Just (-1)) + P'.defaultValue + P'.defaultValue + +instance P'.Wire CarriageDetails where + wireSize ft' self'@(CarriageDetails x'1 x'2 x'3 x'4 x'5 x'6) + = 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 14 x'3 + P'.wireSizeOpt 1 5 x'4 + + P'.wireSizeOpt 1 13 x'5 + + P'.wireSizeExtField x'6) + wirePutWithSize ft' self'@(CarriageDetails x'1 x'2 x'3 x'4 x'5 x'6) + = 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 24 14 x'3, + P'.wirePutOptWithSize 32 5 x'4, P'.wirePutOptWithSize 40 13 x'5, P'.wirePutExtFieldWithSize x'6] + 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{id = Prelude'.Just new'Field}) (P'.wireGet 9) + 18 -> Prelude'.fmap (\ !new'Field -> old'Self{label = Prelude'.Just new'Field}) (P'.wireGet 9) + 24 -> Prelude'.fmap (\ !new'Field -> old'Self{occupancy_status = Prelude'.Just new'Field}) (P'.wireGet 14) + 32 -> Prelude'.fmap (\ !new'Field -> old'Self{occupancy_percentage = Prelude'.Just new'Field}) (P'.wireGet 5) + 40 -> Prelude'.fmap (\ !new'Field -> old'Self{carriage_sequence = Prelude'.Just new'Field}) (P'.wireGet 13) + _ -> 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' -> CarriageDetails) CarriageDetails where + getVal m' f' = f' m' + +instance P'.GPB CarriageDetails + +instance P'.ReflectDescriptor CarriageDetails where + getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [10, 18, 24, 32, 40]) + reflectDescriptorInfo _ + = Prelude'.read + "DescriptorInfo {descName = ProtoName {protobufName = FIName \".transit_realtime.VehiclePosition.CarriageDetails\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName = MName \"CarriageDetails\"}, descFilePath = [\"GTFS\",\"Realtime\",\"VehiclePosition\",\"CarriageDetails.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.CarriageDetails.id\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"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.VehiclePosition.CarriageDetails.label\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"label\", 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.VehiclePosition.CarriageDetails.occupancy_status\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"occupancy_status\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 24}, 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 = Just \"NO_DATA_AVAILABLE\", hsDefault = Just (HsDef'Enum \"NO_DATA_AVAILABLE\"), isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.CarriageDetails.occupancy_percentage\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"occupancy_percentage\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 4}, wireTag = WireTag {getWireTag = 32}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 5}, typeName = Nothing, hsRawDefault = Just \"-1\", hsDefault = Just (HsDef'Integer (-1)), isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.CarriageDetails.carriage_sequence\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\",MName \"CarriageDetails\"], baseName' = FName \"carriage_sequence\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 5}, wireTag = WireTag {getWireTag = 40}, 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}], 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 CarriageDetails where + tellT = P'.tellSubMessage + getT = P'.getSubMessage + +instance P'.TextMsg CarriageDetails where + textPut msg + = do + P'.tellT "id" (id msg) + P'.tellT "label" (label msg) + P'.tellT "occupancy_status" (occupancy_status msg) + P'.tellT "occupancy_percentage" (occupancy_percentage msg) + P'.tellT "carriage_sequence" (carriage_sequence msg) + textGet + = do + mods <- P'.sepEndBy + (P'.choice [parse'id, parse'label, parse'occupancy_status, parse'occupancy_percentage, parse'carriage_sequence]) + P'.spaces + Prelude'.return (Prelude'.foldl' (\ v f -> f v) P'.defaultValue mods) + where + parse'id = Prelude'.fmap (\ v o -> o{id = v}) (P'.try (P'.getT "id")) + parse'label = Prelude'.fmap (\ v o -> o{label = v}) (P'.try (P'.getT "label")) + parse'occupancy_status = Prelude'.fmap (\ v o -> o{occupancy_status = v}) (P'.try (P'.getT "occupancy_status")) + parse'occupancy_percentage = Prelude'.fmap (\ v o -> o{occupancy_percentage = v}) (P'.try (P'.getT "occupancy_percentage")) + parse'carriage_sequence = Prelude'.fmap (\ v o -> o{carriage_sequence = v}) (P'.try (P'.getT "carriage_sequence"))
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/VehiclePosition/CongestionLevel.hs b/gtfs/GTFS/Realtime/VehiclePosition/CongestionLevel.hs new file mode 100644 index 0000000..4f84eac --- /dev/null +++ b/gtfs/GTFS/Realtime/VehiclePosition/CongestionLevel.hs @@ -0,0 +1,85 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.VehiclePosition.CongestionLevel (CongestionLevel(..)) 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 CongestionLevel = UNKNOWN_CONGESTION_LEVEL + | RUNNING_SMOOTHLY + | STOP_AND_GO + | CONGESTION + | SEVERE_CONGESTION + deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, + Prelude'.Generic) + +instance P'.Mergeable CongestionLevel + +instance Prelude'.Bounded CongestionLevel where + minBound = UNKNOWN_CONGESTION_LEVEL + maxBound = SEVERE_CONGESTION + +instance P'.Default CongestionLevel where + defaultValue = UNKNOWN_CONGESTION_LEVEL + +toMaybe'Enum :: Prelude'.Int -> P'.Maybe CongestionLevel +toMaybe'Enum 0 = Prelude'.Just UNKNOWN_CONGESTION_LEVEL +toMaybe'Enum 1 = Prelude'.Just RUNNING_SMOOTHLY +toMaybe'Enum 2 = Prelude'.Just STOP_AND_GO +toMaybe'Enum 3 = Prelude'.Just CONGESTION +toMaybe'Enum 4 = Prelude'.Just SEVERE_CONGESTION +toMaybe'Enum _ = Prelude'.Nothing + +instance Prelude'.Enum CongestionLevel where + fromEnum UNKNOWN_CONGESTION_LEVEL = 0 + fromEnum RUNNING_SMOOTHLY = 1 + fromEnum STOP_AND_GO = 2 + fromEnum CONGESTION = 3 + fromEnum SEVERE_CONGESTION = 4 + toEnum + = P'.fromMaybe (Prelude'.error "hprotoc generated code: toEnum failure for type GTFS.Realtime.VehiclePosition.CongestionLevel") . + toMaybe'Enum + succ UNKNOWN_CONGESTION_LEVEL = RUNNING_SMOOTHLY + succ RUNNING_SMOOTHLY = STOP_AND_GO + succ STOP_AND_GO = CONGESTION + succ CONGESTION = SEVERE_CONGESTION + succ _ = Prelude'.error "hprotoc generated code: succ failure for type GTFS.Realtime.VehiclePosition.CongestionLevel" + pred RUNNING_SMOOTHLY = UNKNOWN_CONGESTION_LEVEL + pred STOP_AND_GO = RUNNING_SMOOTHLY + pred CONGESTION = STOP_AND_GO + pred SEVERE_CONGESTION = CONGESTION + pred _ = Prelude'.error "hprotoc generated code: pred failure for type GTFS.Realtime.VehiclePosition.CongestionLevel" + +instance P'.Wire CongestionLevel 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 CongestionLevel + +instance P'.MessageAPI msg' (msg' -> CongestionLevel) CongestionLevel where + getVal m' f' = f' m' + +instance P'.ReflectEnum CongestionLevel where + reflectEnum + = [(0, "UNKNOWN_CONGESTION_LEVEL", UNKNOWN_CONGESTION_LEVEL), (1, "RUNNING_SMOOTHLY", RUNNING_SMOOTHLY), + (2, "STOP_AND_GO", STOP_AND_GO), (3, "CONGESTION", CONGESTION), (4, "SEVERE_CONGESTION", SEVERE_CONGESTION)] + reflectEnumInfo _ + = P'.EnumInfo + (P'.makePNF (P'.pack ".transit_realtime.VehiclePosition.CongestionLevel") [] ["GTFS", "Realtime", "VehiclePosition"] + "CongestionLevel") + ["GTFS", "Realtime", "VehiclePosition", "CongestionLevel.hs"] + [(0, "UNKNOWN_CONGESTION_LEVEL"), (1, "RUNNING_SMOOTHLY"), (2, "STOP_AND_GO"), (3, "CONGESTION"), (4, "SEVERE_CONGESTION")] + Prelude'.False + +instance P'.TextType CongestionLevel where + tellT = P'.tellShow + getT = P'.getRead
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/VehiclePosition/OccupancyStatus.hs b/gtfs/GTFS/Realtime/VehiclePosition/OccupancyStatus.hs new file mode 100644 index 0000000..92d4064 --- /dev/null +++ b/gtfs/GTFS/Realtime/VehiclePosition/OccupancyStatus.hs @@ -0,0 +1,109 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.VehiclePosition.OccupancyStatus (OccupancyStatus(..)) 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 OccupancyStatus = EMPTY + | MANY_SEATS_AVAILABLE + | FEW_SEATS_AVAILABLE + | STANDING_ROOM_ONLY + | CRUSHED_STANDING_ROOM_ONLY + | FULL + | NOT_ACCEPTING_PASSENGERS + | NO_DATA_AVAILABLE + | NOT_BOARDABLE + deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, + Prelude'.Generic) + +instance P'.Mergeable OccupancyStatus + +instance Prelude'.Bounded OccupancyStatus where + minBound = EMPTY + maxBound = NOT_BOARDABLE + +instance P'.Default OccupancyStatus where + defaultValue = EMPTY + +toMaybe'Enum :: Prelude'.Int -> P'.Maybe OccupancyStatus +toMaybe'Enum 0 = Prelude'.Just EMPTY +toMaybe'Enum 1 = Prelude'.Just MANY_SEATS_AVAILABLE +toMaybe'Enum 2 = Prelude'.Just FEW_SEATS_AVAILABLE +toMaybe'Enum 3 = Prelude'.Just STANDING_ROOM_ONLY +toMaybe'Enum 4 = Prelude'.Just CRUSHED_STANDING_ROOM_ONLY +toMaybe'Enum 5 = Prelude'.Just FULL +toMaybe'Enum 6 = Prelude'.Just NOT_ACCEPTING_PASSENGERS +toMaybe'Enum 7 = Prelude'.Just NO_DATA_AVAILABLE +toMaybe'Enum 8 = Prelude'.Just NOT_BOARDABLE +toMaybe'Enum _ = Prelude'.Nothing + +instance Prelude'.Enum OccupancyStatus where + fromEnum EMPTY = 0 + fromEnum MANY_SEATS_AVAILABLE = 1 + fromEnum FEW_SEATS_AVAILABLE = 2 + fromEnum STANDING_ROOM_ONLY = 3 + fromEnum CRUSHED_STANDING_ROOM_ONLY = 4 + fromEnum FULL = 5 + fromEnum NOT_ACCEPTING_PASSENGERS = 6 + fromEnum NO_DATA_AVAILABLE = 7 + fromEnum NOT_BOARDABLE = 8 + toEnum + = P'.fromMaybe (Prelude'.error "hprotoc generated code: toEnum failure for type GTFS.Realtime.VehiclePosition.OccupancyStatus") . + toMaybe'Enum + succ EMPTY = MANY_SEATS_AVAILABLE + succ MANY_SEATS_AVAILABLE = FEW_SEATS_AVAILABLE + succ FEW_SEATS_AVAILABLE = STANDING_ROOM_ONLY + succ STANDING_ROOM_ONLY = CRUSHED_STANDING_ROOM_ONLY + succ CRUSHED_STANDING_ROOM_ONLY = FULL + succ FULL = NOT_ACCEPTING_PASSENGERS + succ NOT_ACCEPTING_PASSENGERS = NO_DATA_AVAILABLE + succ NO_DATA_AVAILABLE = NOT_BOARDABLE + succ _ = Prelude'.error "hprotoc generated code: succ failure for type GTFS.Realtime.VehiclePosition.OccupancyStatus" + pred MANY_SEATS_AVAILABLE = EMPTY + pred FEW_SEATS_AVAILABLE = MANY_SEATS_AVAILABLE + pred STANDING_ROOM_ONLY = FEW_SEATS_AVAILABLE + pred CRUSHED_STANDING_ROOM_ONLY = STANDING_ROOM_ONLY + pred FULL = CRUSHED_STANDING_ROOM_ONLY + pred NOT_ACCEPTING_PASSENGERS = FULL + pred NO_DATA_AVAILABLE = NOT_ACCEPTING_PASSENGERS + pred NOT_BOARDABLE = NO_DATA_AVAILABLE + pred _ = Prelude'.error "hprotoc generated code: pred failure for type GTFS.Realtime.VehiclePosition.OccupancyStatus" + +instance P'.Wire OccupancyStatus 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 OccupancyStatus + +instance P'.MessageAPI msg' (msg' -> OccupancyStatus) OccupancyStatus where + getVal m' f' = f' m' + +instance P'.ReflectEnum OccupancyStatus where + reflectEnum + = [(0, "EMPTY", EMPTY), (1, "MANY_SEATS_AVAILABLE", MANY_SEATS_AVAILABLE), (2, "FEW_SEATS_AVAILABLE", FEW_SEATS_AVAILABLE), + (3, "STANDING_ROOM_ONLY", STANDING_ROOM_ONLY), (4, "CRUSHED_STANDING_ROOM_ONLY", CRUSHED_STANDING_ROOM_ONLY), + (5, "FULL", FULL), (6, "NOT_ACCEPTING_PASSENGERS", NOT_ACCEPTING_PASSENGERS), (7, "NO_DATA_AVAILABLE", NO_DATA_AVAILABLE), + (8, "NOT_BOARDABLE", NOT_BOARDABLE)] + reflectEnumInfo _ + = P'.EnumInfo + (P'.makePNF (P'.pack ".transit_realtime.VehiclePosition.OccupancyStatus") [] ["GTFS", "Realtime", "VehiclePosition"] + "OccupancyStatus") + ["GTFS", "Realtime", "VehiclePosition", "OccupancyStatus.hs"] + [(0, "EMPTY"), (1, "MANY_SEATS_AVAILABLE"), (2, "FEW_SEATS_AVAILABLE"), (3, "STANDING_ROOM_ONLY"), + (4, "CRUSHED_STANDING_ROOM_ONLY"), (5, "FULL"), (6, "NOT_ACCEPTING_PASSENGERS"), (7, "NO_DATA_AVAILABLE"), + (8, "NOT_BOARDABLE")] + Prelude'.False + +instance P'.TextType OccupancyStatus where + tellT = P'.tellShow + getT = P'.getRead
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/VehiclePosition/VehicleStopStatus.hs b/gtfs/GTFS/Realtime/VehiclePosition/VehicleStopStatus.hs new file mode 100644 index 0000000..3bc70e5 --- /dev/null +++ b/gtfs/GTFS/Realtime/VehiclePosition/VehicleStopStatus.hs @@ -0,0 +1,73 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.VehiclePosition.VehicleStopStatus (VehicleStopStatus(..)) 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 VehicleStopStatus = INCOMING_AT + | STOPPED_AT + | IN_TRANSIT_TO + deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, + Prelude'.Generic) + +instance P'.Mergeable VehicleStopStatus + +instance Prelude'.Bounded VehicleStopStatus where + minBound = INCOMING_AT + maxBound = IN_TRANSIT_TO + +instance P'.Default VehicleStopStatus where + defaultValue = INCOMING_AT + +toMaybe'Enum :: Prelude'.Int -> P'.Maybe VehicleStopStatus +toMaybe'Enum 0 = Prelude'.Just INCOMING_AT +toMaybe'Enum 1 = Prelude'.Just STOPPED_AT +toMaybe'Enum 2 = Prelude'.Just IN_TRANSIT_TO +toMaybe'Enum _ = Prelude'.Nothing + +instance Prelude'.Enum VehicleStopStatus where + fromEnum INCOMING_AT = 0 + fromEnum STOPPED_AT = 1 + fromEnum IN_TRANSIT_TO = 2 + toEnum + = P'.fromMaybe (Prelude'.error "hprotoc generated code: toEnum failure for type GTFS.Realtime.VehiclePosition.VehicleStopStatus") + . toMaybe'Enum + succ INCOMING_AT = STOPPED_AT + succ STOPPED_AT = IN_TRANSIT_TO + succ _ = Prelude'.error "hprotoc generated code: succ failure for type GTFS.Realtime.VehiclePosition.VehicleStopStatus" + pred STOPPED_AT = INCOMING_AT + pred IN_TRANSIT_TO = STOPPED_AT + pred _ = Prelude'.error "hprotoc generated code: pred failure for type GTFS.Realtime.VehiclePosition.VehicleStopStatus" + +instance P'.Wire VehicleStopStatus 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 VehicleStopStatus + +instance P'.MessageAPI msg' (msg' -> VehicleStopStatus) VehicleStopStatus where + getVal m' f' = f' m' + +instance P'.ReflectEnum VehicleStopStatus where + reflectEnum = [(0, "INCOMING_AT", INCOMING_AT), (1, "STOPPED_AT", STOPPED_AT), (2, "IN_TRANSIT_TO", IN_TRANSIT_TO)] + reflectEnumInfo _ + = P'.EnumInfo + (P'.makePNF (P'.pack ".transit_realtime.VehiclePosition.VehicleStopStatus") [] ["GTFS", "Realtime", "VehiclePosition"] + "VehicleStopStatus") + ["GTFS", "Realtime", "VehiclePosition", "VehicleStopStatus.hs"] + [(0, "INCOMING_AT"), (1, "STOPPED_AT"), (2, "IN_TRANSIT_TO")] + Prelude'.False + +instance P'.TextType VehicleStopStatus where + tellT = P'.tellShow + getT = P'.getRead
\ No newline at end of file |