Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentripplanner/core-utils

Package Overview
Dependencies
Maintainers
3
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentripplanner/core-utils - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

36

lib/map.js

@@ -16,2 +16,3 @@ "use strict";

exports.isBikeshareStation = isBikeshareStation;
exports.isEScooterStation = isEScooterStation;
exports.isValidLat = isValidLat;

@@ -93,4 +94,3 @@ exports.isValidLng = isValidLng;

function itineraryToTransitive(itin) {
// console.log('itineraryToTransitive', itin);
function itineraryToTransitive(itin, companies) {
const tdata = {

@@ -126,4 +126,22 @@ journeys: [],

if (leg.mode === "WALK" || leg.mode === "BICYCLE" || leg.mode === "CAR" || leg.mode === "MICROMOBILITY") {
const fromPlaceId = leg.from.bikeShareId ? `bicycle_rent_station_${leg.from.bikeShareId}` : `itin_street_${streetEdgeId}_from`;
const toPlaceId = leg.to.bikeShareId ? `bicycle_rent_station_${leg.to.bikeShareId}` : `itin_street_${streetEdgeId}_to`;
let fromPlaceId;
if (leg.from.bikeShareId) {
fromPlaceId = `bicycle_rent_station_${leg.from.bikeShareId}`;
} else if (leg.from.vertexType === "VEHICLERENTAL") {
fromPlaceId = `escooter_rent_station_${leg.from.name}`;
} else {
fromPlaceId = `itin_street_${streetEdgeId}_from`;
}
let toPlaceId;
if (leg.to.bikeShareId) {
toPlaceId = `bicycle_rent_station_${leg.to.bikeShareId}`;
} else if (leg.to.vertexType === "VEHICLERENTAL") {
toPlaceId = `escooter_rent_station_${leg.to.name}`;
} else {
toPlaceId = `itin_street_${streetEdgeId}_to`;
}
const segment = {

@@ -160,3 +178,3 @@ type: leg.mode,

place_id: toPlaceId,
place_name: leg.to.name,
place_name: (0, _itinerary.getPlaceName)(leg.to, companies),
place_lat: leg.to.lat,

@@ -237,4 +255,4 @@ place_lon: leg.to.lon

tdata.routes.push(...routes);
tdata.stops.push(...stops); // add the journey to the tdata journeys array
tdata.routes.push(...Object.values(routes));
tdata.stops.push(...Object.values(stops)); // add the journey to the tdata journeys array

@@ -250,2 +268,6 @@ tdata.journeys.push(journey); // console.log('derived tdata', tdata);

function isEScooterStation(place) {
return place.place_id.lastIndexOf("escooter_rent_station") !== -1;
}
function isValidLat(lat) {

@@ -252,0 +274,0 @@ return Number.isFinite(lat) && lat >= -90 && lat <= 90;

@@ -7,3 +7,3 @@ "use strict";

exports.createChainableTypeChecker = createChainableTypeChecker;
exports.userLocationType = exports.geocodedFeatureType = exports.configuredCompanyType = exports.configuredModesType = exports.configuredModeType = exports.queryType = exports.modeSelectorOptionsType = exports.modeOptionType = exports.latlngType = exports.transitIndexStopWithRoutes = exports.timeOptionsType = exports.itineraryType = exports.fareType = exports.legType = exports.stepsType = exports.encodedPolylineType = exports.configType = exports.languageConfigType = exports.transitOperatorType = void 0;
exports.userLocationType = exports.geocodedFeatureType = exports.configuredCompanyType = exports.configuredModesType = exports.configuredModeType = exports.queryType = exports.modeSelectorOptionsType = exports.modeOptionType = exports.latlngType = exports.transitiveDataType = exports.transitIndexStopWithRoutes = exports.timeOptionsType = exports.locationType = exports.itineraryType = exports.fareType = exports.legType = exports.placeType = exports.stepsType = exports.encodedPolylineType = exports.configType = exports.languageConfigType = exports.transitOperatorType = exports.leafletPathType = void 0;

@@ -19,5 +19,31 @@ var _propTypes = _interopRequireDefault(require("prop-types"));

/**
* Leaflet path properties to use to style a CircleMarker, Marker or Polyline.
*
* See https://leafletjs.com/reference-1.6.0.html#path
*/
const leafletPathType = _propTypes.default.shape({
bubblingMouseEvents: _propTypes.default.bool,
color: _propTypes.default.string,
className: _propTypes.default.string,
dashArray: _propTypes.default.string,
dashOffset: _propTypes.default.string,
fill: _propTypes.default.bool,
fillColor: _propTypes.default.string,
fillOpacity: _propTypes.default.number,
fillRule: _propTypes.default.string,
lineCap: _propTypes.default.string,
lineJoin: _propTypes.default.string,
opacity: _propTypes.default.number,
renderer: _propTypes.default.func,
stroke: _propTypes.default.bool,
weight: _propTypes.default.number
});
/**
* Describes some options to help display data about a transit agency that is
* configured in an opentripplanner instance.
*/
exports.leafletPathType = leafletPathType;
const transitOperatorType = _propTypes.default.shape({

@@ -132,2 +158,4 @@ defaultRouteColor: _propTypes.default.string,

exports.placeType = placeType;
const legType = _propTypes.default.shape({

@@ -234,3 +262,3 @@ agencyId: _propTypes.default.string,

/**
* Used to help display the time of day within the context of a particular itinerary.
* Used to model a location that is used in planning a trip.
*/

@@ -241,2 +269,20 @@

const locationType = _propTypes.default.shape({
lat: _propTypes.default.number.isRequired,
lon: _propTypes.default.number.isRequired,
name: _propTypes.default.string.isRequired,
/**
* This is only used location that a user has saved. Can be either:
* "home" or "work"
*/
type: _propTypes.default.string
});
/**
* Used to help display the time of day within the context of a particular itinerary.
*/
exports.locationType = locationType;
const timeOptionsType = _propTypes.default.shape({

@@ -280,2 +326,61 @@ /**

});
exports.transitIndexStopWithRoutes = transitIndexStopWithRoutes;
const transitivePlaceType = _propTypes.default.shape({
place_id: _propTypes.default.string.isRequired,
type: _propTypes.default.string.isRequired
});
const transitiveDataType = _propTypes.default.shape({
journeys: _propTypes.default.arrayOf(_propTypes.default.shape({
journey_id: _propTypes.default.string.isRequired,
journey_name: _propTypes.default.string.isRequired,
segments: _propTypes.default.arrayOf(_propTypes.default.shape({
arc: _propTypes.default.bool,
from: transitivePlaceType,
patterns: _propTypes.default.arrayOf(_propTypes.default.shape({
pattern_id: _propTypes.default.string.isRequired,
from_stop_index: _propTypes.default.number.isRequired,
to_stop_index: _propTypes.default.number.isRequired
})),
streetEdges: _propTypes.default.arrayOf(_propTypes.default.number),
to: transitivePlaceType,
type: _propTypes.default.string.isRequired
})).isRequired
})).isRequired,
patterns: _propTypes.default.arrayOf(_propTypes.default.shape({
pattern_id: _propTypes.default.string.isRequired,
pattern_name: _propTypes.default.string.isRequired,
route_id: _propTypes.default.string.isRequired,
stops: _propTypes.default.arrayOf(_propTypes.default.shape({
geometry: _propTypes.default.string,
stop_id: _propTypes.default.string.isRequired
})).isRequired
})).isRequired,
places: _propTypes.default.arrayOf(_propTypes.default.shape({
place_id: _propTypes.default.string.isRequired,
place_lat: _propTypes.default.number.isRequired,
place_lon: _propTypes.default.number.isRequired,
place_name: _propTypes.default.string
})).isRequired,
routes: _propTypes.default.arrayOf(_propTypes.default.shape({
agency_id: _propTypes.default.string.isRequired,
route_id: _propTypes.default.string.isRequired,
route_short_name: _propTypes.default.string.isRequired,
route_long_name: _propTypes.default.string.isRequired,
route_type: _propTypes.default.number.isRequired,
route_color: _propTypes.default.string
})).isRequired,
stops: _propTypes.default.arrayOf(_propTypes.default.shape({
stop_id: _propTypes.default.string.isRequired,
stop_name: _propTypes.default.string.isRequired,
stop_lat: _propTypes.default.number.isRequired,
stop_lon: _propTypes.default.number.isRequired
})).isRequired,
streetEdges: _propTypes.default.arrayOf(_propTypes.default.shape({
edge_id: _propTypes.default.number.isRequired,
geometry: encodedPolylineType
})).isRequired
});
/**

@@ -288,3 +393,3 @@ * Utility function to help create chained validators

exports.transitIndexStopWithRoutes = transitIndexStopWithRoutes;
exports.transitiveDataType = transitiveDataType;

@@ -291,0 +396,0 @@ function createChainableTypeChecker(validator) {

4

package.json
{
"name": "@opentripplanner/core-utils",
"version": "0.0.10",
"version": "0.0.11",
"description": "Core functionality that is shared among numerous UI components",

@@ -20,3 +20,3 @@ "main": "lib/index.js",

},
"gitHead": "0af1b7cda60bd4252b219dcf893e01c2acb2ed5d"
"gitHead": "19374a185174cc2d63dd24d11cc7a00dcbdbba31"
}
import moment from "moment";
import { isTransit, toSentenceCase } from "./itinerary";
import { getPlaceName, isTransit, toSentenceCase } from "./itinerary";

@@ -73,4 +73,3 @@ export function latlngToString(latlng) {

export function itineraryToTransitive(itin) {
// console.log('itineraryToTransitive', itin);
export function itineraryToTransitive(itin, companies) {
const tdata = {

@@ -114,9 +113,20 @@ journeys: [],

) {
const fromPlaceId = leg.from.bikeShareId
? `bicycle_rent_station_${leg.from.bikeShareId}`
: `itin_street_${streetEdgeId}_from`;
const toPlaceId = leg.to.bikeShareId
? `bicycle_rent_station_${leg.to.bikeShareId}`
: `itin_street_${streetEdgeId}_to`;
let fromPlaceId;
if (leg.from.bikeShareId) {
fromPlaceId = `bicycle_rent_station_${leg.from.bikeShareId}`;
} else if (leg.from.vertexType === "VEHICLERENTAL") {
fromPlaceId = `escooter_rent_station_${leg.from.name}`;
} else {
fromPlaceId = `itin_street_${streetEdgeId}_from`;
}
let toPlaceId;
if (leg.to.bikeShareId) {
toPlaceId = `bicycle_rent_station_${leg.to.bikeShareId}`;
} else if (leg.to.vertexType === "VEHICLERENTAL") {
toPlaceId = `escooter_rent_station_${leg.to.name}`;
} else {
toPlaceId = `itin_street_${streetEdgeId}_to`;
}
const segment = {

@@ -148,3 +158,3 @@ type: leg.mode,

place_id: toPlaceId,
place_name: leg.to.name,
place_name: getPlaceName(leg.to, companies),
place_lat: leg.to.lat,

@@ -237,4 +247,4 @@ place_lon: leg.to.lon

// add the routes and stops to the tdata arrays
tdata.routes.push(...routes);
tdata.stops.push(...stops);
tdata.routes.push(...Object.values(routes));
tdata.stops.push(...Object.values(stops));

@@ -252,2 +262,6 @@ // add the journey to the tdata journeys array

export function isEScooterStation(place) {
return place.place_id.lastIndexOf("escooter_rent_station") !== -1;
}
export function isValidLat(lat) {

@@ -254,0 +268,0 @@ return Number.isFinite(lat) && lat >= -90 && lat <= 90;

@@ -6,2 +6,25 @@ import PropTypes from "prop-types";

/**
* Leaflet path properties to use to style a CircleMarker, Marker or Polyline.
*
* See https://leafletjs.com/reference-1.6.0.html#path
*/
export const leafletPathType = PropTypes.shape({
bubblingMouseEvents: PropTypes.bool,
color: PropTypes.string,
className: PropTypes.string,
dashArray: PropTypes.string,
dashOffset: PropTypes.string,
fill: PropTypes.bool,
fillColor: PropTypes.string,
fillOpacity: PropTypes.number,
fillRule: PropTypes.string,
lineCap: PropTypes.string,
lineJoin: PropTypes.string,
opacity: PropTypes.number,
renderer: PropTypes.func,
stroke: PropTypes.bool,
weight: PropTypes.number
});
/**
* Describes some options to help display data about a transit agency that is

@@ -89,3 +112,3 @@ * configured in an opentripplanner instance.

const placeType = PropTypes.shape({
export const placeType = PropTypes.shape({
arrival: PropTypes.number,

@@ -210,2 +233,16 @@ departure: PropTypes.number,

/**
* Used to model a location that is used in planning a trip.
*/
export const locationType = PropTypes.shape({
lat: PropTypes.number.isRequired,
lon: PropTypes.number.isRequired,
name: PropTypes.string.isRequired,
/**
* This is only used location that a user has saved. Can be either:
* "home" or "work"
*/
type: PropTypes.string
});
/**
* Used to help display the time of day within the context of a particular itinerary.

@@ -249,2 +286,77 @@ */

const transitivePlaceType = PropTypes.shape({
place_id: PropTypes.string.isRequired,
type: PropTypes.string.isRequired
});
export const transitiveDataType = PropTypes.shape({
journeys: PropTypes.arrayOf(
PropTypes.shape({
journey_id: PropTypes.string.isRequired,
journey_name: PropTypes.string.isRequired,
segments: PropTypes.arrayOf(
PropTypes.shape({
arc: PropTypes.bool,
from: transitivePlaceType,
patterns: PropTypes.arrayOf(
PropTypes.shape({
pattern_id: PropTypes.string.isRequired,
from_stop_index: PropTypes.number.isRequired,
to_stop_index: PropTypes.number.isRequired
})
),
streetEdges: PropTypes.arrayOf(PropTypes.number),
to: transitivePlaceType,
type: PropTypes.string.isRequired
})
).isRequired
})
).isRequired,
patterns: PropTypes.arrayOf(
PropTypes.shape({
pattern_id: PropTypes.string.isRequired,
pattern_name: PropTypes.string.isRequired,
route_id: PropTypes.string.isRequired,
stops: PropTypes.arrayOf(
PropTypes.shape({
geometry: PropTypes.string,
stop_id: PropTypes.string.isRequired
})
).isRequired
})
).isRequired,
places: PropTypes.arrayOf(
PropTypes.shape({
place_id: PropTypes.string.isRequired,
place_lat: PropTypes.number.isRequired,
place_lon: PropTypes.number.isRequired,
place_name: PropTypes.string
})
).isRequired,
routes: PropTypes.arrayOf(
PropTypes.shape({
agency_id: PropTypes.string.isRequired,
route_id: PropTypes.string.isRequired,
route_short_name: PropTypes.string.isRequired,
route_long_name: PropTypes.string.isRequired,
route_type: PropTypes.number.isRequired,
route_color: PropTypes.string
})
).isRequired,
stops: PropTypes.arrayOf(
PropTypes.shape({
stop_id: PropTypes.string.isRequired,
stop_name: PropTypes.string.isRequired,
stop_lat: PropTypes.number.isRequired,
stop_lon: PropTypes.number.isRequired
})
).isRequired,
streetEdges: PropTypes.arrayOf(
PropTypes.shape({
edge_id: PropTypes.number.isRequired,
geometry: encodedPolylineType
})
).isRequired
});
/**

@@ -251,0 +363,0 @@ * Utility function to help create chained validators

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc