aboutsummaryrefslogtreecommitdiff
path: root/gtfs/GTFS/Realtime/VehiclePosition.hs
diff options
context:
space:
mode:
authorstuebinm2024-04-17 01:21:33 +0200
committerstuebinm2024-04-17 01:48:35 +0200
commit385e15fc22f48a1f8d40b8263a54155fdab499ea (patch)
tree19f3a8b3fcb017eebdba3f094ceb5ff80c6c0134 /gtfs/GTFS/Realtime/VehiclePosition.hs
parenta995dabf07574a32c1ae62ad23b96ba7d8e076ee (diff)
replace protocol-buffers with proto-lens
I do not really like either option, but at least the second one seems more likely to be maintained (and a little less clunky to use, too, for what it's worth).
Diffstat (limited to '')
-rw-r--r--gtfs/GTFS/Realtime/VehiclePosition.hs183
1 files changed, 0 insertions, 183 deletions
diff --git a/gtfs/GTFS/Realtime/VehiclePosition.hs b/gtfs/GTFS/Realtime/VehiclePosition.hs
deleted file mode 100644
index da2cb12..0000000
--- a/gtfs/GTFS/Realtime/VehiclePosition.hs
+++ /dev/null
@@ -1,183 +0,0 @@
-{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings
- #-}
-{-# OPTIONS_GHC -w #-}
-module GTFS.Realtime.VehiclePosition (VehiclePosition(..)) 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.Position as GTFS.Realtime
-import qualified GTFS.Realtime.TripDescriptor as GTFS.Realtime
-import qualified GTFS.Realtime.VehicleDescriptor as GTFS.Realtime
-import qualified GTFS.Realtime.VehiclePosition.CarriageDetails as GTFS.Realtime.VehiclePosition
-import qualified GTFS.Realtime.VehiclePosition.CongestionLevel as GTFS.Realtime.VehiclePosition
-import qualified GTFS.Realtime.VehiclePosition.OccupancyStatus as GTFS.Realtime.VehiclePosition
-import qualified GTFS.Realtime.VehiclePosition.VehicleStopStatus as GTFS.Realtime.VehiclePosition
-
-data VehiclePosition = VehiclePosition{trip :: !(P'.Maybe GTFS.Realtime.TripDescriptor),
- vehicle :: !(P'.Maybe GTFS.Realtime.VehicleDescriptor),
- position :: !(P'.Maybe GTFS.Realtime.Position),
- current_stop_sequence :: !(P'.Maybe P'.Word32), stop_id :: !(P'.Maybe P'.Utf8),
- current_status :: !(P'.Maybe GTFS.Realtime.VehiclePosition.VehicleStopStatus),
- timestamp :: !(P'.Maybe P'.Word64),
- congestion_level :: !(P'.Maybe GTFS.Realtime.VehiclePosition.CongestionLevel),
- occupancy_status :: !(P'.Maybe GTFS.Realtime.VehiclePosition.OccupancyStatus),
- occupancy_percentage :: !(P'.Maybe P'.Word32),
- multi_carriage_details :: !(P'.Seq GTFS.Realtime.VehiclePosition.CarriageDetails),
- ext'field :: !(P'.ExtField)}
- deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic)
-
-instance P'.ExtendMessage VehiclePosition where
- getExtField = ext'field
- putExtField e'f msg = msg{ext'field = e'f}
- validExtRanges msg = P'.extRanges (P'.reflectDescriptorInfo msg)
-
-instance P'.Mergeable VehiclePosition where
- mergeAppend (VehiclePosition x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11 x'12)
- (VehiclePosition y'1 y'2 y'3 y'4 y'5 y'6 y'7 y'8 y'9 y'10 y'11 y'12)
- = 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
- in VehiclePosition z'1 z'2 z'3 z'4 z'5 z'6 z'7 z'8 z'9 z'10 z'11 z'12
-
-instance P'.Default VehiclePosition where
- defaultValue
- = VehiclePosition P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue
- (Prelude'.Just (Prelude'.read "IN_TRANSIT_TO"))
- P'.defaultValue
- P'.defaultValue
- P'.defaultValue
- P'.defaultValue
- P'.defaultValue
- P'.defaultValue
-
-instance P'.Wire VehiclePosition where
- wireSize ft' self'@(VehiclePosition x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11 x'12)
- = case ft' of
- 10 -> calc'Size
- 11 -> P'.prependMessageSize calc'Size
- _ -> P'.wireSizeErr ft' self'
- where
- calc'Size
- = (P'.wireSizeOpt 1 11 x'1 + P'.wireSizeOpt 1 11 x'2 + P'.wireSizeOpt 1 11 x'3 + P'.wireSizeOpt 1 13 x'4 +
- P'.wireSizeOpt 1 9 x'5
- + P'.wireSizeOpt 1 14 x'6
- + P'.wireSizeOpt 1 4 x'7
- + P'.wireSizeOpt 1 14 x'8
- + P'.wireSizeOpt 1 14 x'9
- + P'.wireSizeOpt 1 13 x'10
- + P'.wireSizeRep 1 11 x'11
- + P'.wireSizeExtField x'12)
- wirePutWithSize ft' self'@(VehiclePosition x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9 x'10 x'11 x'12)
- = case ft' of
- 10 -> put'Fields
- 11 -> put'FieldsSized
- _ -> P'.wirePutErr ft' self'
- where
- put'Fields
- = P'.sequencePutWithSize
- [P'.wirePutOptWithSize 10 11 x'1, P'.wirePutOptWithSize 18 11 x'3, P'.wirePutOptWithSize 24 13 x'4,
- P'.wirePutOptWithSize 32 14 x'6, P'.wirePutOptWithSize 40 4 x'7, P'.wirePutOptWithSize 48 14 x'8,
- P'.wirePutOptWithSize 58 9 x'5, P'.wirePutOptWithSize 66 11 x'2, P'.wirePutOptWithSize 72 14 x'9,
- P'.wirePutOptWithSize 80 13 x'10, P'.wirePutRepWithSize 90 11 x'11, P'.wirePutExtFieldWithSize x'12]
- 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) (Prelude'.Just new'Field)})
- (P'.wireGet 11)
- 66 -> 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{position = P'.mergeAppend (position old'Self) (Prelude'.Just new'Field)})
- (P'.wireGet 11)
- 24 -> Prelude'.fmap (\ !new'Field -> old'Self{current_stop_sequence = Prelude'.Just new'Field}) (P'.wireGet 13)
- 58 -> Prelude'.fmap (\ !new'Field -> old'Self{stop_id = Prelude'.Just new'Field}) (P'.wireGet 9)
- 32 -> Prelude'.fmap (\ !new'Field -> old'Self{current_status = Prelude'.Just new'Field}) (P'.wireGet 14)
- 40 -> Prelude'.fmap (\ !new'Field -> old'Self{timestamp = Prelude'.Just new'Field}) (P'.wireGet 4)
- 48 -> Prelude'.fmap (\ !new'Field -> old'Self{congestion_level = Prelude'.Just new'Field}) (P'.wireGet 14)
- 72 -> Prelude'.fmap (\ !new'Field -> old'Self{occupancy_status = Prelude'.Just new'Field}) (P'.wireGet 14)
- 80 -> Prelude'.fmap (\ !new'Field -> old'Self{occupancy_percentage = Prelude'.Just new'Field}) (P'.wireGet 13)
- 90 -> Prelude'.fmap
- (\ !new'Field -> old'Self{multi_carriage_details = P'.append (multi_carriage_details old'Self) 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' -> VehiclePosition) VehiclePosition where
- getVal m' f' = f' m'
-
-instance P'.GPB VehiclePosition
-
-instance P'.ReflectDescriptor VehiclePosition where
- getMessageInfo _
- = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [10, 18, 24, 32, 40, 48, 58, 66, 72, 80, 90])
- reflectDescriptorInfo _
- = Prelude'.read
- "DescriptorInfo {descName = ProtoName {protobufName = FIName \".transit_realtime.VehiclePosition\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"VehiclePosition\"}, descFilePath = [\"GTFS\",\"Realtime\",\"VehiclePosition.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.trip\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"trip\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, 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.VehiclePosition.vehicle\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"vehicle\", 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.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.VehiclePosition.position\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"position\", 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.Position\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\"], baseName = MName \"Position\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.current_stop_sequence\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"current_stop_sequence\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 24}, 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.VehiclePosition.stop_id\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"stop_id\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 7}, wireTag = WireTag {getWireTag = 58}, 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.current_status\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"current_status\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 4}, wireTag = WireTag {getWireTag = 32}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 14}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.VehiclePosition.VehicleStopStatus\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName = MName \"VehicleStopStatus\"}), hsRawDefault = Just \"IN_TRANSIT_TO\", hsDefault = Just (HsDef'Enum \"IN_TRANSIT_TO\"), isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.timestamp\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"timestamp\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 5}, wireTag = WireTag {getWireTag = 40}, 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.VehiclePosition.congestion_level\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"congestion_level\", 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.VehiclePosition.CongestionLevel\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName = MName \"CongestionLevel\"}), hsRawDefault = Nothing, hsDefault = Nothing, isMapField = False, mapKeyVal = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".transit_realtime.VehiclePosition.occupancy_status\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"occupancy_status\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 9}, wireTag = WireTag {getWireTag = 72}, 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.VehiclePosition.occupancy_percentage\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"occupancy_percentage\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 10}, wireTag = WireTag {getWireTag = 80}, 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.VehiclePosition.multi_carriage_details\", haskellPrefix' = [], parentModule' = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName' = FName \"multi_carriage_details\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 11}, wireTag = WireTag {getWireTag = 90}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".transit_realtime.VehiclePosition.CarriageDetails\", haskellPrefix = [], parentModule = [MName \"GTFS\",MName \"Realtime\",MName \"VehiclePosition\"], baseName = MName \"CarriageDetails\"}), 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 VehiclePosition where
- tellT = P'.tellSubMessage
- getT = P'.getSubMessage
-
-instance P'.TextMsg VehiclePosition where
- textPut msg
- = do
- P'.tellT "trip" (trip msg)
- P'.tellT "vehicle" (vehicle msg)
- P'.tellT "position" (position msg)
- P'.tellT "current_stop_sequence" (current_stop_sequence msg)
- P'.tellT "stop_id" (stop_id msg)
- P'.tellT "current_status" (current_status msg)
- P'.tellT "timestamp" (timestamp msg)
- P'.tellT "congestion_level" (congestion_level msg)
- P'.tellT "occupancy_status" (occupancy_status msg)
- P'.tellT "occupancy_percentage" (occupancy_percentage msg)
- P'.tellT "multi_carriage_details" (multi_carriage_details msg)
- textGet
- = do
- mods <- P'.sepEndBy
- (P'.choice
- [parse'trip, parse'vehicle, parse'position, parse'current_stop_sequence, parse'stop_id, parse'current_status,
- parse'timestamp, parse'congestion_level, parse'occupancy_status, parse'occupancy_percentage,
- parse'multi_carriage_details])
- 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'position = Prelude'.fmap (\ v o -> o{position = v}) (P'.try (P'.getT "position"))
- parse'current_stop_sequence
- = Prelude'.fmap (\ v o -> o{current_stop_sequence = v}) (P'.try (P'.getT "current_stop_sequence"))
- parse'stop_id = Prelude'.fmap (\ v o -> o{stop_id = v}) (P'.try (P'.getT "stop_id"))
- parse'current_status = Prelude'.fmap (\ v o -> o{current_status = v}) (P'.try (P'.getT "current_status"))
- parse'timestamp = Prelude'.fmap (\ v o -> o{timestamp = v}) (P'.try (P'.getT "timestamp"))
- parse'congestion_level = Prelude'.fmap (\ v o -> o{congestion_level = v}) (P'.try (P'.getT "congestion_level"))
- 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'multi_carriage_details
- = Prelude'.fmap (\ v o -> o{multi_carriage_details = P'.append (multi_carriage_details o) v})
- (P'.try (P'.getT "multi_carriage_details")) \ No newline at end of file