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/Alert | |
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 '')
-rw-r--r-- | gtfs/GTFS/Realtime/Alert.hs | 204 | ||||
-rw-r--r-- | gtfs/GTFS/Realtime/Alert/Cause.hs | 118 | ||||
-rw-r--r-- | gtfs/GTFS/Realtime/Alert/Effect.hs | 114 | ||||
-rw-r--r-- | gtfs/GTFS/Realtime/Alert/SeverityLevel.hs | 76 |
4 files changed, 512 insertions, 0 deletions
diff --git a/gtfs/GTFS/Realtime/Alert.hs b/gtfs/GTFS/Realtime/Alert.hs new file mode 100644 index 0000000..bca6530 --- /dev/null +++ b/gtfs/GTFS/Realtime/Alert.hs @@ -0,0 +1,204 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.Alert (Alert(..)) 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.Alert.Cause as GTFS.Realtime.Alert +import qualified GTFS.Realtime.Alert.Effect as GTFS.Realtime.Alert +import qualified GTFS.Realtime.Alert.SeverityLevel as GTFS.Realtime.Alert +import qualified GTFS.Realtime.EntitySelector as GTFS.Realtime +import qualified GTFS.Realtime.TimeRange as GTFS.Realtime +import qualified GTFS.Realtime.TranslatedImage as GTFS.Realtime +import qualified GTFS.Realtime.TranslatedString as GTFS.Realtime + +data Alert = Alert{active_period :: !(P'.Seq GTFS.Realtime.TimeRange), informed_entity :: !(P'.Seq GTFS.Realtime.EntitySelector), + cause :: !(P'.Maybe GTFS.Realtime.Alert.Cause), effect :: !(P'.Maybe GTFS.Realtime.Alert.Effect), + url :: !(P'.Maybe GTFS.Realtime.TranslatedString), header_text :: !(P'.Maybe GTFS.Realtime.TranslatedString), + description_text :: !(P'.Maybe GTFS.Realtime.TranslatedString), + tts_header_text :: !(P'.Maybe GTFS.Realtime.TranslatedString), + tts_description_text :: !(P'.Maybe GTFS.Realtime.TranslatedString), + severity_level :: !(P'.Maybe GTFS.Realtime.Alert.SeverityLevel), + image :: !(P'.Maybe GTFS.Realtime.TranslatedImage), + image_alternative_text :: !(P'.Maybe GTFS.Realtime.TranslatedString), ext'field :: !(P'.ExtField)} + deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.ExtendMessage Alert where + getExtField = ext'field + putExtField e'f msg = msg{ext'field = e'f} + validExtRanges msg = P'.extRanges (P'.reflectDescriptorInfo msg) + +instance P'.Mergeable Alert where + mergeAppend (Alert x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11 x'12 x'13) + (Alert y'1 y'2 y'3 y'4 y'5 y'6 y'7 y'8 y'9 y'10 y'11 y'12 y'13) + = 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 + !z'9 = P'.mergeAppend x'9 y'9 + !z'10 = P'.mergeAppend x'10 y'10 + !z'11 = P'.mergeAppend x'11 y'11 + !z'12 = P'.mergeAppend x'12 y'12 + !z'13 = P'.mergeAppend x'13 y'13 + in Alert z'1 z'2 z'3 z'4 z'5 z'6 z'7 z'8 z'9 z'10 z'11 z'12 z'13 + +instance P'.Default Alert where + defaultValue + = Alert P'.defaultValue P'.defaultValue (Prelude'.Just (Prelude'.read "UNKNOWN_CAUSE")) + (Prelude'.Just (Prelude'.read "UNKNOWN_EFFECT")) + P'.defaultValue + P'.defaultValue + P'.defaultValue + P'.defaultValue + P'.defaultValue + (Prelude'.Just (Prelude'.read "UNKNOWN_SEVERITY")) + P'.defaultValue + P'.defaultValue + P'.defaultValue + +instance P'.Wire Alert where + wireSize ft' self'@(Alert x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11 x'12 x'13) + = case ft' of + 10 -> calc'Size + 11 -> P'.prependMessageSize calc'Size + _ -> P'.wireSizeErr ft' self' + where + calc'Size + = (P'.wireSizeRep 1 11 x'1 + P'.wireSizeRep 1 11 x'2 + P'.wireSizeOpt 1 14 x'3 + P'.wireSizeOpt 1 14 x'4 + + P'.wireSizeOpt 1 11 x'5 + + P'.wireSizeOpt 1 11 x'6 + + P'.wireSizeOpt 1 11 x'7 + + P'.wireSizeOpt 1 11 x'8 + + P'.wireSizeOpt 1 11 x'9 + + P'.wireSizeOpt 1 14 x'10 + + P'.wireSizeOpt 1 11 x'11 + + P'.wireSizeOpt 2 11 x'12 + + P'.wireSizeExtField x'13) + wirePutWithSize ft' self'@(Alert x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11 x'12 x'13) + = case ft' of + 10 -> put'Fields + 11 -> put'FieldsSized + _ -> P'.wirePutErr ft' self' + where + put'Fields + = P'.sequencePutWithSize + [P'.wirePutRepWithSize 10 11 x'1, P'.wirePutRepWithSize 42 11 x'2, P'.wirePutOptWithSize 48 14 x'3, + P'.wirePutOptWithSize 56 14 x'4, P'.wirePutOptWithSize 66 11 x'5, P'.wirePutOptWithSize 82 11 x'6, + P'.wirePutOptWithSize 90 11 x'7, P'.wirePutOptWithSize 98 11 x'8, P'.wirePutOptWithSize 106 11 x'9, + P'.wirePutOptWithSize 112 14 x'10, P'.wirePutOptWithSize 122 11 x'11, P'.wirePutOptWithSize 130 11 x'12, + P'.wirePutExtFieldWithSize x'13] + 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{active_period = P'.append (active_period old'Self) new'Field}) + (P'.wireGet 11) + 42 -> Prelude'.fmap (\ !new'Field -> old'Self{informed_entity = P'.append (informed_entity old'Self) new'Field}) + (P'.wireGet 11) + 48 -> Prelude'.fmap (\ !new'Field -> old'Self{cause = Prelude'.Just new'Field}) (P'.wireGet 14) + 56 -> Prelude'.fmap (\ !new'Field -> old'Self{effect = Prelude'.Just new'Field}) (P'.wireGet 14) + 66 -> Prelude'.fmap (\ !new'Field -> old'Self{url = P'.mergeAppend (url old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + 82 -> Prelude'.fmap + (\ !new'Field -> old'Self{header_text = P'.mergeAppend (header_text old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + 90 -> Prelude'.fmap + (\ !new'Field -> + old'Self{description_text = P'.mergeAppend (description_text old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + 98 -> Prelude'.fmap + (\ !new'Field -> + old'Self{tts_header_text = P'.mergeAppend (tts_header_text old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + 106 -> Prelude'.fmap + (\ !new'Field -> + old'Self{tts_description_text = P'.mergeAppend (tts_description_text old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + 112 -> Prelude'.fmap (\ !new'Field -> old'Self{severity_level = Prelude'.Just new'Field}) (P'.wireGet 14) + 122 -> Prelude'.fmap (\ !new'Field -> old'Self{image = P'.mergeAppend (image old'Self) (Prelude'.Just new'Field)}) + (P'.wireGet 11) + 130 -> Prelude'.fmap + (\ !new'Field -> + old'Self{image_alternative_text = + P'.mergeAppend (image_alternative_text 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' -> Alert) Alert where + getVal m' f' = f' m' + +instance P'.GPB Alert + +instance P'.ReflectDescriptor Alert where + getMessageInfo _ + = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [10, 42, 48, 56, 66, 82, 90, 98, 106, 112, 122, 130]) + reflectDescriptorInfo _ + = Prelude'.read + "DescriptorInfo {descName = ProtoName {protobufName = FIName \".transit_realtime.Alert\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"Alert\"}, descFilePath = [\"GTFS\",\"Realtime\",\"Alert.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.active_period\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"active_period\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TimeRange\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TimeRange\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.informed_entity\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"informed_entity\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 5}, wireTag = WireTag {getWireTag = 42}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.EntitySelector\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"EntitySelector\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.cause\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"cause\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 6}, wireTag = WireTag {getWireTag = 48}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 14}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.Alert.Cause\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName = MName \"Cause\"}), hsRawDefault = Just \"UNKNOWN_CAUSE\", hsDefault = Just (HsDef'Enum \"UNKNOWN_CAUSE\"), isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.effect\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"effect\", 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.Alert.Effect\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName = MName \"Effect\"}), hsRawDefault = Just \"UNKNOWN_EFFECT\", hsDefault = Just (HsDef'Enum \"UNKNOWN_EFFECT\"), isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.url\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"url\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 8}, wireTag = WireTag {getWireTag = 66}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TranslatedString\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TranslatedString\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.header_text\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"header_text\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 10}, wireTag = WireTag {getWireTag = 82}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TranslatedString\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TranslatedString\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.description_text\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"description_text\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 11}, wireTag = WireTag {getWireTag = 90}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TranslatedString\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TranslatedString\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.tts_header_text\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"tts_header_text\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 12}, wireTag = WireTag {getWireTag = 98}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TranslatedString\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TranslatedString\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.tts_description_text\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"tts_description_text\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 13}, wireTag = WireTag {getWireTag = 106}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TranslatedString\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TranslatedString\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.severity_level\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"severity_level\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 14}, wireTag = WireTag {getWireTag = 112}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 14}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.Alert.SeverityLevel\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName = MName \"SeverityLevel\"}), hsRawDefault = Just \"UNKNOWN_SEVERITY\", hsDefault = Just (HsDef'Enum \"UNKNOWN_SEVERITY\"), isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.image\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"image\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 15}, wireTag = WireTag {getWireTag = 122}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TranslatedImage\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TranslatedImage\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.Alert.image_alternative_text\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"Alert\"], baseName' = FName \"image_alternative_text\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 16}, wireTag = WireTag {getWireTag = 130}, packedTag = Nothing, wireTagLength = 2, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.TranslatedString\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"TranslatedString\"}), 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 Alert where + tellT = P'.tellSubMessage + getT = P'.getSubMessage + +instance P'.TextMsg Alert where + textPut msg + = do + P'.tellT "active_period" (active_period msg) + P'.tellT "informed_entity" (informed_entity msg) + P'.tellT "cause" (cause msg) + P'.tellT "effect" (effect msg) + P'.tellT "url" (url msg) + P'.tellT "header_text" (header_text msg) + P'.tellT "description_text" (description_text msg) + P'.tellT "tts_header_text" (tts_header_text msg) + P'.tellT "tts_description_text" (tts_description_text msg) + P'.tellT "severity_level" (severity_level msg) + P'.tellT "image" (image msg) + P'.tellT "image_alternative_text" (image_alternative_text msg) + textGet + = do + mods <- P'.sepEndBy + (P'.choice + [parse'active_period, parse'informed_entity, parse'cause, parse'effect, parse'url, parse'header_text, + parse'description_text, parse'tts_header_text, parse'tts_description_text, parse'severity_level, parse'image, + parse'image_alternative_text]) + P'.spaces + Prelude'.return (Prelude'.foldl' (\ v f -> f v) P'.defaultValue mods) + where + parse'active_period + = Prelude'.fmap (\ v o -> o{active_period = P'.append (active_period o) v}) (P'.try (P'.getT "active_period")) + parse'informed_entity + = Prelude'.fmap (\ v o -> o{informed_entity = P'.append (informed_entity o) v}) (P'.try (P'.getT "informed_entity")) + parse'cause = Prelude'.fmap (\ v o -> o{cause = v}) (P'.try (P'.getT "cause")) + parse'effect = Prelude'.fmap (\ v o -> o{effect = v}) (P'.try (P'.getT "effect")) + parse'url = Prelude'.fmap (\ v o -> o{url = v}) (P'.try (P'.getT "url")) + parse'header_text = Prelude'.fmap (\ v o -> o{header_text = v}) (P'.try (P'.getT "header_text")) + parse'description_text = Prelude'.fmap (\ v o -> o{description_text = v}) (P'.try (P'.getT "description_text")) + parse'tts_header_text = Prelude'.fmap (\ v o -> o{tts_header_text = v}) (P'.try (P'.getT "tts_header_text")) + parse'tts_description_text = Prelude'.fmap (\ v o -> o{tts_description_text = v}) (P'.try (P'.getT "tts_description_text")) + parse'severity_level = Prelude'.fmap (\ v o -> o{severity_level = v}) (P'.try (P'.getT "severity_level")) + parse'image = Prelude'.fmap (\ v o -> o{image = v}) (P'.try (P'.getT "image")) + parse'image_alternative_text + = Prelude'.fmap (\ v o -> o{image_alternative_text = v}) (P'.try (P'.getT "image_alternative_text"))
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/Alert/Cause.hs b/gtfs/GTFS/Realtime/Alert/Cause.hs new file mode 100644 index 0000000..9f71db7 --- /dev/null +++ b/gtfs/GTFS/Realtime/Alert/Cause.hs @@ -0,0 +1,118 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.Alert.Cause (Cause(..)) 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 Cause = UNKNOWN_CAUSE + | OTHER_CAUSE + | TECHNICAL_PROBLEM + | STRIKE + | DEMONSTRATION + | ACCIDENT + | HOLIDAY + | WEATHER + | MAINTENANCE + | CONSTRUCTION + | POLICE_ACTIVITY + | MEDICAL_EMERGENCY + deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.Mergeable Cause + +instance Prelude'.Bounded Cause where + minBound = UNKNOWN_CAUSE + maxBound = MEDICAL_EMERGENCY + +instance P'.Default Cause where + defaultValue = UNKNOWN_CAUSE + +toMaybe'Enum :: Prelude'.Int -> P'.Maybe Cause +toMaybe'Enum 1 = Prelude'.Just UNKNOWN_CAUSE +toMaybe'Enum 2 = Prelude'.Just OTHER_CAUSE +toMaybe'Enum 3 = Prelude'.Just TECHNICAL_PROBLEM +toMaybe'Enum 4 = Prelude'.Just STRIKE +toMaybe'Enum 5 = Prelude'.Just DEMONSTRATION +toMaybe'Enum 6 = Prelude'.Just ACCIDENT +toMaybe'Enum 7 = Prelude'.Just HOLIDAY +toMaybe'Enum 8 = Prelude'.Just WEATHER +toMaybe'Enum 9 = Prelude'.Just MAINTENANCE +toMaybe'Enum 10 = Prelude'.Just CONSTRUCTION +toMaybe'Enum 11 = Prelude'.Just POLICE_ACTIVITY +toMaybe'Enum 12 = Prelude'.Just MEDICAL_EMERGENCY +toMaybe'Enum _ = Prelude'.Nothing + +instance Prelude'.Enum Cause where + fromEnum UNKNOWN_CAUSE = 1 + fromEnum OTHER_CAUSE = 2 + fromEnum TECHNICAL_PROBLEM = 3 + fromEnum STRIKE = 4 + fromEnum DEMONSTRATION = 5 + fromEnum ACCIDENT = 6 + fromEnum HOLIDAY = 7 + fromEnum WEATHER = 8 + fromEnum MAINTENANCE = 9 + fromEnum CONSTRUCTION = 10 + fromEnum POLICE_ACTIVITY = 11 + fromEnum MEDICAL_EMERGENCY = 12 + toEnum = P'.fromMaybe (Prelude'.error "hprotoc generated code: toEnum failure for type GTFS.Realtime.Alert.Cause") . toMaybe'Enum + succ UNKNOWN_CAUSE = OTHER_CAUSE + succ OTHER_CAUSE = TECHNICAL_PROBLEM + succ TECHNICAL_PROBLEM = STRIKE + succ STRIKE = DEMONSTRATION + succ DEMONSTRATION = ACCIDENT + succ ACCIDENT = HOLIDAY + succ HOLIDAY = WEATHER + succ WEATHER = MAINTENANCE + succ MAINTENANCE = CONSTRUCTION + succ CONSTRUCTION = POLICE_ACTIVITY + succ POLICE_ACTIVITY = MEDICAL_EMERGENCY + succ _ = Prelude'.error "hprotoc generated code: succ failure for type GTFS.Realtime.Alert.Cause" + pred OTHER_CAUSE = UNKNOWN_CAUSE + pred TECHNICAL_PROBLEM = OTHER_CAUSE + pred STRIKE = TECHNICAL_PROBLEM + pred DEMONSTRATION = STRIKE + pred ACCIDENT = DEMONSTRATION + pred HOLIDAY = ACCIDENT + pred WEATHER = HOLIDAY + pred MAINTENANCE = WEATHER + pred CONSTRUCTION = MAINTENANCE + pred POLICE_ACTIVITY = CONSTRUCTION + pred MEDICAL_EMERGENCY = POLICE_ACTIVITY + pred _ = Prelude'.error "hprotoc generated code: pred failure for type GTFS.Realtime.Alert.Cause" + +instance P'.Wire Cause 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 Cause + +instance P'.MessageAPI msg' (msg' -> Cause) Cause where + getVal m' f' = f' m' + +instance P'.ReflectEnum Cause where + reflectEnum + = [(1, "UNKNOWN_CAUSE", UNKNOWN_CAUSE), (2, "OTHER_CAUSE", OTHER_CAUSE), (3, "TECHNICAL_PROBLEM", TECHNICAL_PROBLEM), + (4, "STRIKE", STRIKE), (5, "DEMONSTRATION", DEMONSTRATION), (6, "ACCIDENT", ACCIDENT), (7, "HOLIDAY", HOLIDAY), + (8, "WEATHER", WEATHER), (9, "MAINTENANCE", MAINTENANCE), (10, "CONSTRUCTION", CONSTRUCTION), + (11, "POLICE_ACTIVITY", POLICE_ACTIVITY), (12, "MEDICAL_EMERGENCY", MEDICAL_EMERGENCY)] + reflectEnumInfo _ + = P'.EnumInfo (P'.makePNF (P'.pack ".transit_realtime.Alert.Cause") [] ["GTFS", "Realtime", "Alert"] "Cause") + ["GTFS", "Realtime", "Alert", "Cause.hs"] + [(1, "UNKNOWN_CAUSE"), (2, "OTHER_CAUSE"), (3, "TECHNICAL_PROBLEM"), (4, "STRIKE"), (5, "DEMONSTRATION"), (6, "ACCIDENT"), + (7, "HOLIDAY"), (8, "WEATHER"), (9, "MAINTENANCE"), (10, "CONSTRUCTION"), (11, "POLICE_ACTIVITY"), (12, "MEDICAL_EMERGENCY")] + Prelude'.False + +instance P'.TextType Cause where + tellT = P'.tellShow + getT = P'.getRead
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/Alert/Effect.hs b/gtfs/GTFS/Realtime/Alert/Effect.hs new file mode 100644 index 0000000..dcaa77d --- /dev/null +++ b/gtfs/GTFS/Realtime/Alert/Effect.hs @@ -0,0 +1,114 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.Alert.Effect (Effect(..)) 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 Effect = NO_SERVICE + | REDUCED_SERVICE + | SIGNIFICANT_DELAYS + | DETOUR + | ADDITIONAL_SERVICE + | MODIFIED_SERVICE + | OTHER_EFFECT + | UNKNOWN_EFFECT + | STOP_MOVED + | NO_EFFECT + | ACCESSIBILITY_ISSUE + deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) + +instance P'.Mergeable Effect + +instance Prelude'.Bounded Effect where + minBound = NO_SERVICE + maxBound = ACCESSIBILITY_ISSUE + +instance P'.Default Effect where + defaultValue = NO_SERVICE + +toMaybe'Enum :: Prelude'.Int -> P'.Maybe Effect +toMaybe'Enum 1 = Prelude'.Just NO_SERVICE +toMaybe'Enum 2 = Prelude'.Just REDUCED_SERVICE +toMaybe'Enum 3 = Prelude'.Just SIGNIFICANT_DELAYS +toMaybe'Enum 4 = Prelude'.Just DETOUR +toMaybe'Enum 5 = Prelude'.Just ADDITIONAL_SERVICE +toMaybe'Enum 6 = Prelude'.Just MODIFIED_SERVICE +toMaybe'Enum 7 = Prelude'.Just OTHER_EFFECT +toMaybe'Enum 8 = Prelude'.Just UNKNOWN_EFFECT +toMaybe'Enum 9 = Prelude'.Just STOP_MOVED +toMaybe'Enum 10 = Prelude'.Just NO_EFFECT +toMaybe'Enum 11 = Prelude'.Just ACCESSIBILITY_ISSUE +toMaybe'Enum _ = Prelude'.Nothing + +instance Prelude'.Enum Effect where + fromEnum NO_SERVICE = 1 + fromEnum REDUCED_SERVICE = 2 + fromEnum SIGNIFICANT_DELAYS = 3 + fromEnum DETOUR = 4 + fromEnum ADDITIONAL_SERVICE = 5 + fromEnum MODIFIED_SERVICE = 6 + fromEnum OTHER_EFFECT = 7 + fromEnum UNKNOWN_EFFECT = 8 + fromEnum STOP_MOVED = 9 + fromEnum NO_EFFECT = 10 + fromEnum ACCESSIBILITY_ISSUE = 11 + toEnum = P'.fromMaybe (Prelude'.error "hprotoc generated code: toEnum failure for type GTFS.Realtime.Alert.Effect") . toMaybe'Enum + succ NO_SERVICE = REDUCED_SERVICE + succ REDUCED_SERVICE = SIGNIFICANT_DELAYS + succ SIGNIFICANT_DELAYS = DETOUR + succ DETOUR = ADDITIONAL_SERVICE + succ ADDITIONAL_SERVICE = MODIFIED_SERVICE + succ MODIFIED_SERVICE = OTHER_EFFECT + succ OTHER_EFFECT = UNKNOWN_EFFECT + succ UNKNOWN_EFFECT = STOP_MOVED + succ STOP_MOVED = NO_EFFECT + succ NO_EFFECT = ACCESSIBILITY_ISSUE + succ _ = Prelude'.error "hprotoc generated code: succ failure for type GTFS.Realtime.Alert.Effect" + pred REDUCED_SERVICE = NO_SERVICE + pred SIGNIFICANT_DELAYS = REDUCED_SERVICE + pred DETOUR = SIGNIFICANT_DELAYS + pred ADDITIONAL_SERVICE = DETOUR + pred MODIFIED_SERVICE = ADDITIONAL_SERVICE + pred OTHER_EFFECT = MODIFIED_SERVICE + pred UNKNOWN_EFFECT = OTHER_EFFECT + pred STOP_MOVED = UNKNOWN_EFFECT + pred NO_EFFECT = STOP_MOVED + pred ACCESSIBILITY_ISSUE = NO_EFFECT + pred _ = Prelude'.error "hprotoc generated code: pred failure for type GTFS.Realtime.Alert.Effect" + +instance P'.Wire Effect 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 Effect + +instance P'.MessageAPI msg' (msg' -> Effect) Effect where + getVal m' f' = f' m' + +instance P'.ReflectEnum Effect where + reflectEnum + = [(1, "NO_SERVICE", NO_SERVICE), (2, "REDUCED_SERVICE", REDUCED_SERVICE), (3, "SIGNIFICANT_DELAYS", SIGNIFICANT_DELAYS), + (4, "DETOUR", DETOUR), (5, "ADDITIONAL_SERVICE", ADDITIONAL_SERVICE), (6, "MODIFIED_SERVICE", MODIFIED_SERVICE), + (7, "OTHER_EFFECT", OTHER_EFFECT), (8, "UNKNOWN_EFFECT", UNKNOWN_EFFECT), (9, "STOP_MOVED", STOP_MOVED), + (10, "NO_EFFECT", NO_EFFECT), (11, "ACCESSIBILITY_ISSUE", ACCESSIBILITY_ISSUE)] + reflectEnumInfo _ + = P'.EnumInfo (P'.makePNF (P'.pack ".transit_realtime.Alert.Effect") [] ["GTFS", "Realtime", "Alert"] "Effect") + ["GTFS", "Realtime", "Alert", "Effect.hs"] + [(1, "NO_SERVICE"), (2, "REDUCED_SERVICE"), (3, "SIGNIFICANT_DELAYS"), (4, "DETOUR"), (5, "ADDITIONAL_SERVICE"), + (6, "MODIFIED_SERVICE"), (7, "OTHER_EFFECT"), (8, "UNKNOWN_EFFECT"), (9, "STOP_MOVED"), (10, "NO_EFFECT"), + (11, "ACCESSIBILITY_ISSUE")] + Prelude'.False + +instance P'.TextType Effect where + tellT = P'.tellShow + getT = P'.getRead
\ No newline at end of file diff --git a/gtfs/GTFS/Realtime/Alert/SeverityLevel.hs b/gtfs/GTFS/Realtime/Alert/SeverityLevel.hs new file mode 100644 index 0000000..bb50ff3 --- /dev/null +++ b/gtfs/GTFS/Realtime/Alert/SeverityLevel.hs @@ -0,0 +1,76 @@ +{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings + #-} +{-# OPTIONS_GHC -w #-} +module GTFS.Realtime.Alert.SeverityLevel (SeverityLevel(..)) 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 SeverityLevel = UNKNOWN_SEVERITY + | INFO + | WARNING + | SEVERE + deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, + Prelude'.Generic) + +instance P'.Mergeable SeverityLevel + +instance Prelude'.Bounded SeverityLevel where + minBound = UNKNOWN_SEVERITY + maxBound = SEVERE + +instance P'.Default SeverityLevel where + defaultValue = UNKNOWN_SEVERITY + +toMaybe'Enum :: Prelude'.Int -> P'.Maybe SeverityLevel +toMaybe'Enum 1 = Prelude'.Just UNKNOWN_SEVERITY +toMaybe'Enum 2 = Prelude'.Just INFO +toMaybe'Enum 3 = Prelude'.Just WARNING +toMaybe'Enum 4 = Prelude'.Just SEVERE +toMaybe'Enum _ = Prelude'.Nothing + +instance Prelude'.Enum SeverityLevel where + fromEnum UNKNOWN_SEVERITY = 1 + fromEnum INFO = 2 + fromEnum WARNING = 3 + fromEnum SEVERE = 4 + toEnum + = P'.fromMaybe (Prelude'.error "hprotoc generated code: toEnum failure for type GTFS.Realtime.Alert.SeverityLevel") . + toMaybe'Enum + succ UNKNOWN_SEVERITY = INFO + succ INFO = WARNING + succ WARNING = SEVERE + succ _ = Prelude'.error "hprotoc generated code: succ failure for type GTFS.Realtime.Alert.SeverityLevel" + pred INFO = UNKNOWN_SEVERITY + pred WARNING = INFO + pred SEVERE = WARNING + pred _ = Prelude'.error "hprotoc generated code: pred failure for type GTFS.Realtime.Alert.SeverityLevel" + +instance P'.Wire SeverityLevel 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 SeverityLevel + +instance P'.MessageAPI msg' (msg' -> SeverityLevel) SeverityLevel where + getVal m' f' = f' m' + +instance P'.ReflectEnum SeverityLevel where + reflectEnum = [(1, "UNKNOWN_SEVERITY", UNKNOWN_SEVERITY), (2, "INFO", INFO), (3, "WARNING", WARNING), (4, "SEVERE", SEVERE)] + reflectEnumInfo _ + = P'.EnumInfo (P'.makePNF (P'.pack ".transit_realtime.Alert.SeverityLevel") [] ["GTFS", "Realtime", "Alert"] "SeverityLevel") + ["GTFS", "Realtime", "Alert", "SeverityLevel.hs"] + [(1, "UNKNOWN_SEVERITY"), (2, "INFO"), (3, "WARNING"), (4, "SEVERE")] + Prelude'.False + +instance P'.TextType SeverityLevel where + tellT = P'.tellShow + getT = P'.getRead
\ No newline at end of file |