minotor
Version:
A lightweight client-side transit routing library.
359 lines (322 loc) • 10.5 kB
text/typescript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.10.1
// protoc v4.23.4
// source: src/stops/proto/v1/stops.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
export const protobufPackage = "minotor.stops.v1";
export enum LocationType {
LOCATION_TYPE_UNSPECIFIED = 0,
LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM = 1,
LOCATION_TYPE_STATION = 2,
LOCATION_TYPE_ENTRANCE_EXIT = 3,
LOCATION_TYPE_GENERIC_NODE = 4,
LOCATION_TYPE_BOARDING_AREA = 5,
UNRECOGNIZED = -1,
}
export function locationTypeFromJSON(object: any): LocationType {
switch (object) {
case 0:
case "LOCATION_TYPE_UNSPECIFIED":
return LocationType.LOCATION_TYPE_UNSPECIFIED;
case 1:
case "LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM":
return LocationType.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM;
case 2:
case "LOCATION_TYPE_STATION":
return LocationType.LOCATION_TYPE_STATION;
case 3:
case "LOCATION_TYPE_ENTRANCE_EXIT":
return LocationType.LOCATION_TYPE_ENTRANCE_EXIT;
case 4:
case "LOCATION_TYPE_GENERIC_NODE":
return LocationType.LOCATION_TYPE_GENERIC_NODE;
case 5:
case "LOCATION_TYPE_BOARDING_AREA":
return LocationType.LOCATION_TYPE_BOARDING_AREA;
case -1:
case "UNRECOGNIZED":
default:
return LocationType.UNRECOGNIZED;
}
}
export function locationTypeToJSON(object: LocationType): string {
switch (object) {
case LocationType.LOCATION_TYPE_UNSPECIFIED:
return "LOCATION_TYPE_UNSPECIFIED";
case LocationType.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM:
return "LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM";
case LocationType.LOCATION_TYPE_STATION:
return "LOCATION_TYPE_STATION";
case LocationType.LOCATION_TYPE_ENTRANCE_EXIT:
return "LOCATION_TYPE_ENTRANCE_EXIT";
case LocationType.LOCATION_TYPE_GENERIC_NODE:
return "LOCATION_TYPE_GENERIC_NODE";
case LocationType.LOCATION_TYPE_BOARDING_AREA:
return "LOCATION_TYPE_BOARDING_AREA";
case LocationType.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export interface Stop {
name: string;
sourceStopId?: string | undefined;
lat?: number | undefined;
lon?: number | undefined;
children: number[];
parent?: number | undefined;
locationType: LocationType;
platform?: string | undefined;
}
export interface StopsMap {
stops: Stop[];
}
function createBaseStop(): Stop {
return {
name: "",
sourceStopId: undefined,
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 !== undefined) {
writer.uint32(18).string(message.sourceStopId);
}
if (message.lat !== undefined) {
writer.uint32(29).float(message.lat);
}
if (message.lon !== undefined) {
writer.uint32(37).float(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);
const 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 !== 29) {
break;
}
message.lat = reader.float();
continue;
}
case 4: {
if (tag !== 37) {
break;
}
message.lon = reader.float();
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) : undefined,
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 !== undefined) {
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 ?? undefined;
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 { stops: [] };
}
export const StopsMap: MessageFns<StopsMap> = {
encode(message: StopsMap, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
for (const v of message.stops) {
Stop.encode(v!, writer.uint32(18).fork()).join();
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): StopsMap {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStopsMap();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 2: {
if (tag !== 18) {
break;
}
message.stops.push(Stop.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): StopsMap {
return { stops: globalThis.Array.isArray(object?.stops) ? object.stops.map((e: any) => Stop.fromJSON(e)) : [] };
},
toJSON(message: StopsMap): unknown {
const obj: any = {};
if (message.stops?.length) {
obj.stops = message.stops.map((e) => Stop.toJSON(e));
}
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.stops = object.stops?.map((e) => Stop.fromPartial(e)) || [];
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 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;
}