minotor
Version:
A lightweight client-side transit routing library.
476 lines (428 loc) • 13.5 kB
text/typescript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.6.1
// protoc v4.23.4
// source: src/stops/proto/stops.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
export const protobufPackage = "minotor.stops";
export enum LocationType {
SIMPLE_STOP_OR_PLATFORM = 0,
STATION = 1,
ENTRANCE_EXIT = 2,
GENERIC_NODE = 3,
BOARDING_AREA = 4,
UNRECOGNIZED = -1,
}
export function locationTypeFromJSON(object: any): LocationType {
switch (object) {
case 0:
case "SIMPLE_STOP_OR_PLATFORM":
return LocationType.SIMPLE_STOP_OR_PLATFORM;
case 1:
case "STATION":
return LocationType.STATION;
case 2:
case "ENTRANCE_EXIT":
return LocationType.ENTRANCE_EXIT;
case 3:
case "GENERIC_NODE":
return LocationType.GENERIC_NODE;
case 4:
case "BOARDING_AREA":
return LocationType.BOARDING_AREA;
case -1:
case "UNRECOGNIZED":
default:
return LocationType.UNRECOGNIZED;
}
}
export function locationTypeToJSON(object: LocationType): string {
switch (object) {
case LocationType.SIMPLE_STOP_OR_PLATFORM:
return "SIMPLE_STOP_OR_PLATFORM";
case LocationType.STATION:
return "STATION";
case LocationType.ENTRANCE_EXIT:
return "ENTRANCE_EXIT";
case LocationType.GENERIC_NODE:
return "GENERIC_NODE";
case LocationType.BOARDING_AREA:
return "BOARDING_AREA";
case LocationType.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export interface Stop {
name: string;
sourceStopId: string;
lat?: number | undefined;
lon?: number | undefined;
children: number[];
parent?: number | undefined;
locationType: LocationType;
platform?: string | undefined;
}
export interface StopsMap {
version: string;
stops: { [key: number]: Stop };
}
export interface StopsMap_StopsEntry {
key: number;
value: Stop | undefined;
}
function createBaseStop(): Stop {
return {
name: "",
sourceStopId: "",
lat: undefined,
lon: undefined,
children: [],
parent: undefined,
locationType: 0,
platform: undefined,
};
}
export const Stop: MessageFns<Stop> = {
encode(message: Stop, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.name !== "") {
writer.uint32(10).string(message.name);
}
if (message.sourceStopId !== "") {
writer.uint32(18).string(message.sourceStopId);
}
if (message.lat !== undefined) {
writer.uint32(25).double(message.lat);
}
if (message.lon !== undefined) {
writer.uint32(33).double(message.lon);
}
writer.uint32(42).fork();
for (const v of message.children) {
writer.uint32(v);
}
writer.join();
if (message.parent !== undefined) {
writer.uint32(48).uint32(message.parent);
}
if (message.locationType !== 0) {
writer.uint32(56).int32(message.locationType);
}
if (message.platform !== undefined) {
writer.uint32(66).string(message.platform);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): Stop {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStop();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.name = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.sourceStopId = reader.string();
continue;
}
case 3: {
if (tag !== 25) {
break;
}
message.lat = reader.double();
continue;
}
case 4: {
if (tag !== 33) {
break;
}
message.lon = reader.double();
continue;
}
case 5: {
if (tag === 40) {
message.children.push(reader.uint32());
continue;
}
if (tag === 42) {
const end2 = reader.uint32() + reader.pos;
while (reader.pos < end2) {
message.children.push(reader.uint32());
}
continue;
}
break;
}
case 6: {
if (tag !== 48) {
break;
}
message.parent = reader.uint32();
continue;
}
case 7: {
if (tag !== 56) {
break;
}
message.locationType = reader.int32() as any;
continue;
}
case 8: {
if (tag !== 66) {
break;
}
message.platform = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): Stop {
return {
name: isSet(object.name) ? globalThis.String(object.name) : "",
sourceStopId: isSet(object.sourceStopId) ? globalThis.String(object.sourceStopId) : "",
lat: isSet(object.lat) ? globalThis.Number(object.lat) : undefined,
lon: isSet(object.lon) ? globalThis.Number(object.lon) : undefined,
children: globalThis.Array.isArray(object?.children) ? object.children.map((e: any) => globalThis.Number(e)) : [],
parent: isSet(object.parent) ? globalThis.Number(object.parent) : undefined,
locationType: isSet(object.locationType) ? locationTypeFromJSON(object.locationType) : 0,
platform: isSet(object.platform) ? globalThis.String(object.platform) : undefined,
};
},
toJSON(message: Stop): unknown {
const obj: any = {};
if (message.name !== "") {
obj.name = message.name;
}
if (message.sourceStopId !== "") {
obj.sourceStopId = message.sourceStopId;
}
if (message.lat !== undefined) {
obj.lat = message.lat;
}
if (message.lon !== undefined) {
obj.lon = message.lon;
}
if (message.children?.length) {
obj.children = message.children.map((e) => Math.round(e));
}
if (message.parent !== undefined) {
obj.parent = Math.round(message.parent);
}
if (message.locationType !== 0) {
obj.locationType = locationTypeToJSON(message.locationType);
}
if (message.platform !== undefined) {
obj.platform = message.platform;
}
return obj;
},
create<I extends Exact<DeepPartial<Stop>, I>>(base?: I): Stop {
return Stop.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Stop>, I>>(object: I): Stop {
const message = createBaseStop();
message.name = object.name ?? "";
message.sourceStopId = object.sourceStopId ?? "";
message.lat = object.lat ?? undefined;
message.lon = object.lon ?? undefined;
message.children = object.children?.map((e) => e) || [];
message.parent = object.parent ?? undefined;
message.locationType = object.locationType ?? 0;
message.platform = object.platform ?? undefined;
return message;
},
};
function createBaseStopsMap(): StopsMap {
return { version: "", stops: {} };
}
export const StopsMap: MessageFns<StopsMap> = {
encode(message: StopsMap, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.version !== "") {
writer.uint32(10).string(message.version);
}
Object.entries(message.stops).forEach(([key, value]) => {
StopsMap_StopsEntry.encode({ key: key as any, value }, writer.uint32(18).fork()).join();
});
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): StopsMap {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStopsMap();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.version = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
const entry2 = StopsMap_StopsEntry.decode(reader, reader.uint32());
if (entry2.value !== undefined) {
message.stops[entry2.key] = entry2.value;
}
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): StopsMap {
return {
version: isSet(object.version) ? globalThis.String(object.version) : "",
stops: isObject(object.stops)
? Object.entries(object.stops).reduce<{ [key: number]: Stop }>((acc, [key, value]) => {
acc[globalThis.Number(key)] = Stop.fromJSON(value);
return acc;
}, {})
: {},
};
},
toJSON(message: StopsMap): unknown {
const obj: any = {};
if (message.version !== "") {
obj.version = message.version;
}
if (message.stops) {
const entries = Object.entries(message.stops);
if (entries.length > 0) {
obj.stops = {};
entries.forEach(([k, v]) => {
obj.stops[k] = Stop.toJSON(v);
});
}
}
return obj;
},
create<I extends Exact<DeepPartial<StopsMap>, I>>(base?: I): StopsMap {
return StopsMap.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<StopsMap>, I>>(object: I): StopsMap {
const message = createBaseStopsMap();
message.version = object.version ?? "";
message.stops = Object.entries(object.stops ?? {}).reduce<{ [key: number]: Stop }>((acc, [key, value]) => {
if (value !== undefined) {
acc[globalThis.Number(key)] = Stop.fromPartial(value);
}
return acc;
}, {});
return message;
},
};
function createBaseStopsMap_StopsEntry(): StopsMap_StopsEntry {
return { key: 0, value: undefined };
}
export const StopsMap_StopsEntry: MessageFns<StopsMap_StopsEntry> = {
encode(message: StopsMap_StopsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.key !== 0) {
writer.uint32(8).uint32(message.key);
}
if (message.value !== undefined) {
Stop.encode(message.value, writer.uint32(18).fork()).join();
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): StopsMap_StopsEntry {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStopsMap_StopsEntry();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.key = reader.uint32();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.value = Stop.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): StopsMap_StopsEntry {
return {
key: isSet(object.key) ? globalThis.Number(object.key) : 0,
value: isSet(object.value) ? Stop.fromJSON(object.value) : undefined,
};
},
toJSON(message: StopsMap_StopsEntry): unknown {
const obj: any = {};
if (message.key !== 0) {
obj.key = Math.round(message.key);
}
if (message.value !== undefined) {
obj.value = Stop.toJSON(message.value);
}
return obj;
},
create<I extends Exact<DeepPartial<StopsMap_StopsEntry>, I>>(base?: I): StopsMap_StopsEntry {
return StopsMap_StopsEntry.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<StopsMap_StopsEntry>, I>>(object: I): StopsMap_StopsEntry {
const message = createBaseStopsMap_StopsEntry();
message.key = object.key ?? 0;
message.value = (object.value !== undefined && object.value !== null) ? Stop.fromPartial(object.value) : undefined;
return message;
},
};
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
export type DeepPartial<T> = T extends Builtin ? T
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function isObject(value: any): boolean {
return typeof value === "object" && value !== null;
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
export interface MessageFns<T> {
encode(message: T, writer?: BinaryWriter): BinaryWriter;
decode(input: BinaryReader | Uint8Array, length?: number): T;
fromJSON(object: any): T;
toJSON(message: T): unknown;
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
}