Skip to content

Commit

Permalink
Version 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hdelva authored Mar 19, 2020
2 parents 3e46d40 + d6538b6 commit 55db747
Show file tree
Hide file tree
Showing 46 changed files with 416 additions and 415 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plannerjs",
"version": "0.3.0",
"version": "0.4.0",
"description": "The JavaScript framework for journey planning.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
8 changes: 4 additions & 4 deletions src/analytics/isochrones/visualize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ export function visualizeIsochrone(registry: RoutableTileRegistry, pathTree: IPa
}
}

nodes.push({ latitude: 90, longitude: 180, id: "1" });
nodes.push({ latitude: -90, longitude: 180, id: "2" });
nodes.push({ latitude: 90, longitude: -180, id: "3" });
nodes.push({ latitude: -90, longitude: -180, id: "4" });
nodes.push({ latitude: 90, longitude: 180, id: "1", definedTags: {}, freeformTags: [] });
nodes.push({ latitude: -90, longitude: 180, id: "2", definedTags: {}, freeformTags: [] });
nodes.push({ latitude: 90, longitude: -180, id: "3", definedTags: {}, freeformTags: [] });
nodes.push({ latitude: -90, longitude: -180, id: "4", definedTags: {}, freeformTags: [] });

costs["1"] = Infinity;
costs["2"] = Infinity;
Expand Down
7 changes: 7 additions & 0 deletions src/configs/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Context from "../Context";
import ReachableStopsSearchPhase from "../enums/ReachableStopsSearchPhase";
import RoutingPhase from "../enums/RoutingPhase";
import TravelMode from "../enums/TravelMode";
import CatalogFetcherDefault from "../fetcher/catalog/CatalogFetcherDefault";
import CatalogProviderDefault from "../fetcher/catalog/CatalogProviderDefault";
import ICatalogFetcher from "../fetcher/catalog/ICatalogFetcher";
import ICatalogProvider from "../fetcher/catalog/ICatalogProvider";
import ConnectionsFetcherRaw from "../fetcher/connections/ConnectionsFetcherRaw";
import ConnectionsProviderDefault from "../fetcher/connections/ConnectionsProviderDefault";
import IConnectionsFetcher from "../fetcher/connections/IConnectionsFetcher";
Expand Down Expand Up @@ -78,6 +82,9 @@ container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
.to(ReachableStopsFinderDelaunay).whenTargetTagged("phase", ReachableStopsSearchPhase.Final);

container.bind<ICatalogFetcher>(TYPES.CatalogFetcher).to(CatalogFetcherDefault).inSingletonScope();
container.bind<ICatalogProvider>(TYPES.CatalogProvider).to(CatalogProviderDefault).inSingletonScope();

container.bind<IConnectionsProvider>(TYPES.ConnectionsProvider).to(ConnectionsProviderDefault).inSingletonScope();
container.bind<IConnectionsFetcher>(TYPES.ConnectionsFetcher).to(ConnectionsFetcherRaw);
container.bind<interfaces.Factory<IConnectionsFetcher>>(TYPES.ConnectionsFetcherFactory)
Expand Down
7 changes: 7 additions & 0 deletions src/configs/dissect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import RoutableTileRegistry from "../entities/tiles/registry";
import ReachableStopsSearchPhase from "../enums/ReachableStopsSearchPhase";
import RoutingPhase from "../enums/RoutingPhase";
import TravelMode from "../enums/TravelMode";
import CatalogFetcherDefault from "../fetcher/catalog/CatalogFetcherDefault";
import CatalogProviderDefault from "../fetcher/catalog/CatalogProviderDefault";
import ICatalogFetcher from "../fetcher/catalog/ICatalogFetcher";
import ICatalogProvider from "../fetcher/catalog/ICatalogProvider";
import ConnectionsFetcherRaw from "../fetcher/connections/ConnectionsFetcherRaw";
import ConnectionsProviderMerge from "../fetcher/connections/ConnectionsProviderDefault";
import IConnectionsFetcher from "../fetcher/connections/IConnectionsFetcher";
Expand Down Expand Up @@ -82,6 +86,9 @@ container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
.to(ReachableStopsFinderDelaunay).whenTargetTagged("phase", ReachableStopsSearchPhase.Final);

container.bind<ICatalogFetcher>(TYPES.CatalogFetcher).to(CatalogFetcherDefault).inSingletonScope();
container.bind<ICatalogProvider>(TYPES.CatalogProvider).to(CatalogProviderDefault).inSingletonScope();

container.bind<IConnectionsProvider>(TYPES.ConnectionsProvider).to(ConnectionsProviderMerge).inSingletonScope();
container.bind<IConnectionsFetcher>(TYPES.ConnectionsFetcher).to(ConnectionsFetcherRaw);
container.bind<interfaces.Factory<IConnectionsFetcher>>(TYPES.ConnectionsFetcherFactory)
Expand Down
7 changes: 7 additions & 0 deletions src/configs/flexible_profile_transit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Context from "../Context";
import ReachableStopsSearchPhase from "../enums/ReachableStopsSearchPhase";
import RoutingPhase from "../enums/RoutingPhase";
import TravelMode from "../enums/TravelMode";
import CatalogFetcherDefault from "../fetcher/catalog/CatalogFetcherDefault";
import CatalogProviderDefault from "../fetcher/catalog/CatalogProviderDefault";
import ICatalogFetcher from "../fetcher/catalog/ICatalogFetcher";
import ICatalogProvider from "../fetcher/catalog/ICatalogProvider";
import ConnectionsFetcherRaw from "../fetcher/connections/ConnectionsFetcherRaw";
import ConnectionsProviderDefault from "../fetcher/connections/ConnectionsProviderDefault";
import IConnectionsFetcher from "../fetcher/connections/IConnectionsFetcher";
Expand Down Expand Up @@ -75,6 +79,9 @@ container.bind<PathfinderProvider>(TYPES.PathfinderProvider).to(PathfinderProvid
container.bind<IProfileFetcher>(TYPES.ProfileFetcher).to(ProfileFetcherDefault).inSingletonScope();
container.bind<IProfileProvider>(TYPES.ProfileProvider).to(ProfileProviderDefault).inSingletonScope();

container.bind<ICatalogFetcher>(TYPES.CatalogFetcher).to(CatalogFetcherDefault).inSingletonScope();
container.bind<ICatalogProvider>(TYPES.CatalogProvider).to(CatalogProviderDefault).inSingletonScope();

container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
.to(ReachableStopsFinderDelaunay).whenTargetTagged("phase", ReachableStopsSearchPhase.Initial);
container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
Expand Down
7 changes: 7 additions & 0 deletions src/configs/flexible_transit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Context from "../Context";
import ReachableStopsSearchPhase from "../enums/ReachableStopsSearchPhase";
import RoutingPhase from "../enums/RoutingPhase";
import TravelMode from "../enums/TravelMode";
import CatalogFetcherDefault from "../fetcher/catalog/CatalogFetcherDefault";
import CatalogProviderDefault from "../fetcher/catalog/CatalogProviderDefault";
import ICatalogFetcher from "../fetcher/catalog/ICatalogFetcher";
import ICatalogProvider from "../fetcher/catalog/ICatalogProvider";
import ConnectionsFetcherRaw from "../fetcher/connections/ConnectionsFetcherRaw";
import ConnectionsProviderDefault from "../fetcher/connections/ConnectionsProviderDefault";
import IConnectionsFetcher from "../fetcher/connections/IConnectionsFetcher";
Expand Down Expand Up @@ -82,6 +86,9 @@ container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
.to(ReachableStopsFinderDelaunay).whenTargetTagged("phase", ReachableStopsSearchPhase.Final);

container.bind<ICatalogFetcher>(TYPES.CatalogFetcher).to(CatalogFetcherDefault).inSingletonScope();
container.bind<ICatalogProvider>(TYPES.CatalogProvider).to(CatalogProviderDefault).inSingletonScope();

container.bind<IConnectionsProvider>(TYPES.ConnectionsProvider).to(ConnectionsProviderDefault).inSingletonScope();
container.bind<IConnectionsFetcher>(TYPES.ConnectionsFetcher).to(ConnectionsFetcherRaw);
container.bind<interfaces.Factory<IConnectionsFetcher>>(TYPES.ConnectionsFetcherFactory)
Expand Down
7 changes: 7 additions & 0 deletions src/configs/geospatial_fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Context from "../Context";
import ReachableStopsSearchPhase from "../enums/ReachableStopsSearchPhase";
import RoutingPhase from "../enums/RoutingPhase";
import TravelMode from "../enums/TravelMode";
import CatalogFetcherDefault from "../fetcher/catalog/CatalogFetcherDefault";
import CatalogProviderDefault from "../fetcher/catalog/CatalogProviderDefault";
import ICatalogFetcher from "../fetcher/catalog/ICatalogFetcher";
import ICatalogProvider from "../fetcher/catalog/ICatalogProvider";
import ConnectionsFetcherRaw from "../fetcher/connections/ConnectionsFetcherRaw";
import ConnectionsProviderDefault from "../fetcher/connections/ConnectionsProviderDefault";
import IConnectionsFetcher from "../fetcher/connections/IConnectionsFetcher";
Expand Down Expand Up @@ -86,6 +90,9 @@ container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
.to(ReachableStopsFinderOnlySelf).whenTargetTagged("phase", ReachableStopsSearchPhase.Final);

container.bind<ICatalogFetcher>(TYPES.CatalogFetcher).to(CatalogFetcherDefault).inSingletonScope();
container.bind<ICatalogProvider>(TYPES.CatalogProvider).to(CatalogProviderDefault).inSingletonScope();

container.bind<IConnectionsProvider>(TYPES.ConnectionsProvider).to(ConnectionsProviderDefault).inSingletonScope();
container.bind<IConnectionsFetcher>(TYPES.ConnectionsFetcher).to(ConnectionsFetcherRaw);
container.bind<interfaces.Factory<IConnectionsFetcher>>(TYPES.ConnectionsFetcherFactory)
Expand Down
7 changes: 7 additions & 0 deletions src/configs/reduced_car.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Context from "../Context";
import ReachableStopsSearchPhase from "../enums/ReachableStopsSearchPhase";
import RoutingPhase from "../enums/RoutingPhase";
import TravelMode from "../enums/TravelMode";
import CatalogFetcherDefault from "../fetcher/catalog/CatalogFetcherDefault";
import CatalogProviderDefault from "../fetcher/catalog/CatalogProviderDefault";
import ICatalogFetcher from "../fetcher/catalog/ICatalogFetcher";
import ICatalogProvider from "../fetcher/catalog/ICatalogProvider";
import ConnectionsFetcherRaw from "../fetcher/connections/ConnectionsFetcherRaw";
import ConnectionsProviderDefault from "../fetcher/connections/ConnectionsProviderDefault";
import IConnectionsFetcher from "../fetcher/connections/IConnectionsFetcher";
Expand Down Expand Up @@ -80,6 +84,9 @@ container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
.to(ReachableStopsFinderDelaunay).whenTargetTagged("phase", ReachableStopsSearchPhase.Final);

container.bind<ICatalogFetcher>(TYPES.CatalogFetcher).to(CatalogFetcherDefault).inSingletonScope();
container.bind<ICatalogProvider>(TYPES.CatalogProvider).to(CatalogProviderDefault).inSingletonScope();

container.bind<IConnectionsProvider>(TYPES.ConnectionsProvider).to(ConnectionsProviderDefault).inSingletonScope();
container.bind<IConnectionsFetcher>(TYPES.ConnectionsFetcher).to(ConnectionsFetcherRaw);
container.bind<interfaces.Factory<IConnectionsFetcher>>(TYPES.ConnectionsFetcherFactory)
Expand Down
7 changes: 7 additions & 0 deletions src/configs/road_planner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Context from "../Context";
import ReachableStopsSearchPhase from "../enums/ReachableStopsSearchPhase";
import RoutingPhase from "../enums/RoutingPhase";
import TravelMode from "../enums/TravelMode";
import CatalogFetcherDefault from "../fetcher/catalog/CatalogFetcherDefault";
import CatalogProviderDefault from "../fetcher/catalog/CatalogProviderDefault";
import ICatalogFetcher from "../fetcher/catalog/ICatalogFetcher";
import ICatalogProvider from "../fetcher/catalog/ICatalogProvider";
import ConnectionsFetcherRaw from "../fetcher/connections/ConnectionsFetcherRaw";
import ConnectionsProviderDefault from "../fetcher/connections/ConnectionsProviderDefault";
import IConnectionsFetcher from "../fetcher/connections/IConnectionsFetcher";
Expand Down Expand Up @@ -78,6 +82,9 @@ container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
container.bind<IReachableStopsFinder>(TYPES.ReachableStopsFinder)
.to(ReachableStopsFinderDelaunay).whenTargetTagged("phase", ReachableStopsSearchPhase.Final);

container.bind<ICatalogFetcher>(TYPES.CatalogFetcher).to(CatalogFetcherDefault).inSingletonScope();
container.bind<ICatalogProvider>(TYPES.CatalogProvider).to(CatalogProviderDefault).inSingletonScope();

container.bind<IConnectionsProvider>(TYPES.ConnectionsProvider).to(ConnectionsProviderDefault).inSingletonScope();
container.bind<IConnectionsFetcher>(TYPES.ConnectionsFetcher).to(ConnectionsFetcherRaw);
container.bind<interfaces.Factory<IConnectionsFetcher>>(TYPES.ConnectionsFetcherFactory)
Expand Down
4 changes: 4 additions & 0 deletions src/configs/triangle_transit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Context from "../Context";
import ReachableStopsSearchPhase from "../enums/ReachableStopsSearchPhase";
import RoutingPhase from "../enums/RoutingPhase";
import TravelMode from "../enums/TravelMode";
import CatalogFetcherDefault from "../fetcher/catalog/CatalogFetcherDefault";
import CatalogProviderDefault from "../fetcher/catalog/CatalogProviderDefault";
import ICatalogFetcher from "../fetcher/catalog/ICatalogFetcher";
import ICatalogProvider from "../fetcher/catalog/ICatalogProvider";
import ConnectionsFetcherRaw from "../fetcher/connections/ConnectionsFetcherRaw";
import ConnectionsProviderMerge from "../fetcher/connections/ConnectionsProviderDefault";
import IConnectionsFetcher from "../fetcher/connections/IConnectionsFetcher";
Expand Down
15 changes: 15 additions & 0 deletions src/entities/catalog/catalog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Dataset } from "./dataset";

export class Catalog {
public static create(id: string) {
return new Catalog(id);
}

public id: string;
public datasets: Dataset[];
public publisher: any;

constructor(id: string) {
this.id = id;
}
}
19 changes: 19 additions & 0 deletions src/entities/catalog/dataset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import DatasetDistribution from "./dataset_distribution";

export class Dataset {
public static create(id: string) {
return new Dataset(id);
}

public id: string;
public subject: string;
public description: string;
public title: string;
public area: string;
public rights: string;
public distributions: DatasetDistribution[];

constructor(id: string) {
this.id = id;
}
}
13 changes: 13 additions & 0 deletions src/entities/catalog/dataset_distribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default class DatasetDistribution {
public static create(id: string) {
return new DatasetDistribution(id);
}

public id: string;
public accessUrl: string;
public mediatypes: string[];

constructor(id: string) {
this.id = id;
}
}
18 changes: 1 addition & 17 deletions src/entities/profile/CharacteresticProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,6 @@ export default class CharacteristicProfile extends DynamicProfile {
}

private getWayCharacteristic(way: RoutableTileWay) {
return way.reachable +
way.accessRestrictions +
way.bicycleAccessRestrictions +
way.constructionKind +
way.crossingKind +
way.cyclewayKind +
way.footwayKind +
way.highwayKind +
way.maxSpeed +
way.motorVehicleAccessRestrictions +
way.motorcarAccessRestrictions +
way.onewayBicycleKind +
way.onewayKind +
way.smoothnessKind +
way.surfaceKind +
way.trackType +
way.vehicleAccessRestrictions;
return way.reachable + Object.values(way.definedTags).join();
}
}
36 changes: 19 additions & 17 deletions src/entities/profile/DynamicProfile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import getOsmTagMapping from "../../enums/OSMTags";
import { DistanceM, DurationMs } from "../../interfaces/units";
import Geo from "../../util/Geo";
import { RoutableTileNode } from "../tiles/node";
Expand All @@ -22,12 +21,9 @@ export default class DynamicProfile extends Profile {
public maxSpeed: number;
public usePublicTransport: boolean;

private mapping;

constructor(url: string) {
super();
this.id = url;
this.mapping = getOsmTagMapping();

this.accessRules = [];
this.onewayRules = [];
Expand All @@ -50,8 +46,7 @@ export default class DynamicProfile extends Profile {
if (rule.conclusion.isOneway !== undefined) {
// should always be the case, but just in case
if (rule.condition !== undefined) {
const field = this.mapping[rule.condition.predicate];
if (way[field] === rule.condition.object) {
if (way.definedTags[rule.condition.predicate] === rule.condition.object) {
return rule.conclusion.isOneway;
}
} else {
Expand All @@ -66,8 +61,7 @@ export default class DynamicProfile extends Profile {
if (rule.conclusion.hasAccess !== undefined) {
// should always be the case, but just in case
if (rule.condition !== undefined) {
const field = this.mapping[rule.condition.predicate];
if (way[field] === rule.condition.object) {
if (way.definedTags[rule.condition.predicate] === rule.condition.object) {
return rule.conclusion.hasAccess;
}
} else {
Expand All @@ -92,8 +86,7 @@ export default class DynamicProfile extends Profile {
if (rule.conclusion.speed !== undefined) {
// should always be the case, but just in case
if (rule.condition !== undefined) {
const field = this.mapping[rule.condition.predicate];
if (way[field] === rule.condition.object) {
if (way.definedTags[rule.condition.predicate] === rule.condition.object) {
if (typeof (rule.conclusion.speed) === "number") {
return Math.min(rule.conclusion.speed, speedLimit);
}
Expand Down Expand Up @@ -125,8 +118,7 @@ export default class DynamicProfile extends Profile {
if (rule.conclusion.priority !== undefined) {
// should always be the case, but just in case
if (rule.condition !== undefined) {
const field = this.mapping[rule.condition.predicate];
if (way[field] === rule.condition.object) {
if (way.definedTags[rule.condition.predicate] === rule.condition.object) {
return 1 - (rule.conclusion.priority - 1);
}
} else {
Expand All @@ -141,12 +133,16 @@ export default class DynamicProfile extends Profile {
}

public isObstacle(node: RoutableTileNode): boolean {
if (!node.definedTags) {
// not a real OSM node, we're probably embedding a location onto the network
return false;
}

for (const rule of this.obstacleRules) {
if (rule.conclusion.isObstacle !== undefined) {
// should always be the case, but just in case
if (rule.condition !== undefined) {
const field = this.mapping[rule.condition.predicate];
if (node[field] === rule.condition.object) {
if (node.definedTags[rule.condition.predicate] === rule.condition.object) {
return rule.conclusion.isObstacle;
}
} else {
Expand All @@ -157,17 +153,23 @@ export default class DynamicProfile extends Profile {
}

public getObstacleTime(node: RoutableTileNode): DurationMs {
if (!node.definedTags) {
// not a real OSM node, we're probably embedding a location onto the network
return 0;
}

for (const rule of this.obstacleTimeRules) {
if (rule.conclusion.obstacleTime !== undefined) {
// should always be the case, but just in case
if (rule.condition !== undefined) {
const field = this.mapping[rule.condition.predicate];
if (node[field] && rule.condition.object === undefined) {
const field = rule.condition.predicate;
if (node.definedTags[field] && rule.condition.object === undefined) {
return rule.conclusion.obstacleTime * 1000;
}
if (node[field] === rule.condition.object && rule.condition.object !== undefined) {
if (node.definedTags[field] === rule.condition.object && rule.condition.object !== undefined) {
return rule.conclusion.obstacleTime * 1000;
}

} else {
return rule.conclusion.obstacleTime * 1000;
}
Expand Down
Loading

0 comments on commit 55db747

Please sign in to comment.