Skip to content

Commit

Permalink
Merge pull request #176 from noi-techpark/otp2
Browse files Browse the repository at this point in the history
First draft of migration to OTP2
  • Loading branch information
dulvui authored Jan 24, 2024
2 parents e134a66 + 86696fd commit e81633f
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 113 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ env:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1


- name: Build graph
run: |
sudo apt install osmium-tool wget
./build-graph.sh
- name: Build docker file
uses: noi-techpark/github-actions/docker-build@v2
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ journey/node_modules
journey/.env
journey/tmp
geocoder/.env

graph.obj
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,13 @@ cd odh-mentor-otp

```docker-entrypoint.sh``` download and build data graph

```otp.sh``` a script to run otp by command line

```otp-unofficial.sh``` a script to run otp unofficial version by command line

```router-config.json``` define OTP updaters(GTFS-RT) and router settings from environment vars

```build-config.json``` default OTP build config from environment vars

```osm.url``` a pregenerated urls list of downloadable Openstreetmap data for SouthTyrol area.
```south-tyrol.geojson``` the geographic extend that is extracted and processed by OTP

```journey/``` static javascript client side react/redux UI component to interact with Opentriplanner instance.
```journey/``` static javascript client side react/redux UI component to interact with OpenTripPlanner instance.

```gbfs/``` service that fetch bikesharing data from ODH and provide them as GBFS for otp.

Expand Down
27 changes: 23 additions & 4 deletions build-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
{
"useTransfersTxt": false,
"embedRouterConfig": true,
"parentStopLinking": true,
"stopClusterMode": "parentStation"
"embedRouterConfig": true,
"areaVisibility": true,
"transitFeeds": [
{
"source": "https://gtfs.api.opendatahub.com/v1/dataset/sta-time-tables/raw",
"type": "gtfs",
"feedId": "sta"
}
/*
this feed is not GTFS-compliant yet: https://github.com/noi-techpark/odh-mentor-otp/issues/168#issuecomment-1904328702
,{
"source": "https://gtfs.api.opendatahub.com/v1/dataset/skyalps-flight-data/raw",
"type": "gtfs",
"feedId": "skyalps"
}*/
],
"osm": [
{
"source": "data/south-tyrol.osm.pbf",
"timeZone": "Europe/Rome",
"osmTagMapping": "default"
}
]
}
21 changes: 21 additions & 0 deletions build-graph.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

# SPDX-FileCopyrightText: NOI Techpark <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

mkdir -p data

NORTH_EASTH_PBF=data/italy-nord-est.osm.pbf
SOUTH_TYROL_PBF=data/south-tyrol.osm.pbf

OTP_IMAGE=docker.io/opentripplanner/opentripplanner:2.5.0_2024-01-19T14-50

wget -q --show-progress --no-clobber https://download.geofabrik.de/europe/italy/nord-est-latest.osm.pbf -O ${NORTH_EASTH_PBF}
osmium extract ${NORTH_EASTH_PBF} --polygon south-tyrol.geojson -o ${SOUTH_TYROL_PBF} --overwrite

docker run \
-v .:/var/opentripplanner/:z \
--rm \
-e JAVA_TOOL_OPTIONS="-Xmx6G" \
${OTP_IMAGE} --build --save
56 changes: 5 additions & 51 deletions infrastructure/docker/otp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,8 @@
FROM node:16.14.0-alpine3.14
FROM docker.io/opentripplanner/opentripplanner:2.5.0_2024-01-19T14-50

ARG OTP_VERSION=1.5.2
ARG GTFS_URL_UPDATETIME="0 2 * * *"
WORKDIR /var/otp

ENV JAVA_MX=4G \
GBFS_VERSION=1 \
GTFS_URL=ftp://ftp.sta.bz.it/gtfs/google_transit_shp.zip \
GTFS_URL_UPDATETIME=$GTFS_URL_UPDATETIME \
GTFS_URL_UPDATEHOOK=''
ADD router-config.json /var/otp/
ADD graph.obj /var/otp/

RUN apk add --no-cache \
openjdk8-jre \
unzip \
bash \
curl \
gdal-tools

RUN mkdir -p /usr/local/share/java
RUN mkdir -p /var/otp
RUN mkdir -p /conf

# OpenTripPlanner Openmove fork https://github.com/openmove/OpenTripPlanner

#RUN curl -o /usr/local/share/java/otp.jar https://repo1.maven.org/maven2/org/opentripplanner/otp/$OTP_VERSION/otp-$OTP_VERSION-shaded.jar
#COPY otp-1.5.0-clusters-extended.jar /usr/local/share/java/otp-unofficial.jar

#RUN curl -Lo otp-unofficial.jar "https://github.com/openmove/OpenTripPlanner/releases/download/v${OTP_VERSION}/otp-${OTP_VERSION}-SNAPSHOT-shaded.jar"
#COPY otp-unofficial.jar /usr/local/share/java/otp-unofficial.jar

COPY otp-1.5.2-openmove.jar /usr/local/share/java/otp-unofficial.jar

COPY otp.sh /usr/local/bin/
COPY otp-unofficial.sh /usr/local/bin/

COPY infrastructure/docker/otp/docker-entrypoint.sh /docker-entrypoint.sh

COPY build-config.json /conf/
COPY router-config.json /conf/
COPY envconfig.js /conf/

COPY ./gtfs2bbox /gtfs2bbox
COPY ./gtfs-import-task /gtfs-import-task

RUN chmod 755 /gtfs-import-task/gtfs-download.sh

RUN cd /gtfs2bbox && \
npm install

RUN chmod 755 /usr/local/bin/*
RUN chmod 755 /docker-entrypoint.sh

ENTRYPOINT ["/bin/bash"]
CMD ["/docker-entrypoint.sh"]
ENTRYPOINT java $JAVA_OPTS -cp @/app/jib-classpath-file @/app/jib-main-class-file /var/otp/ --load --serve
Binary file removed otp-1.5.2-openmove.jar
Binary file not shown.
7 changes: 0 additions & 7 deletions otp-unofficial.sh

This file was deleted.

59 changes: 16 additions & 43 deletions router-config.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,18 @@
{
"updaters": [
{
"type": "stop-time-updater",
"sourceType": "gtfs-http",
"frequencySec": 60,
"feedId": "${GTFS_FEED_ID}",
"url": "${GTFS_RT_URL}"
},
{
"type": "bike-rental",
"frequencySec": 120,
"sourceType": "gbfs",
"network": "BZ",
"url": "${GBFS_HOST}/bz/${GBFS_VERSION}/"
},
{
"type": "bike-rental",
"frequencySec": 120,
"sourceType": "gbfs",
"network": "ME",
"url": "${GBFS_HOST}/me/${GBFS_VERSION}/"
},
{
"type": "bike-rental",
"frequencySec": 120,
"sourceType": "gbfs",
"network": "PAPIN",
"url": "${GBFS_HOST}/papin/${GBFS_VERSION}/"
},
{
"type": "car-rental-updater",
"sourceType": "car2go",
"frequencySec": 30,
"vehiclesUrl": "${CARSHARING_HOST}/carsharing/vehicles.json",
"regionsUrl": "${CARSHARING_HOST}/carsharing/regions.json"
},
{
"type": "car-park",
"sourceType": "park-and-ride",
"frequencySec": 60,
"url": "${PARKING_HOST}/parking/park-ride.json"
}
]
"routingDefaults" : {
"numItineraries": 5
},
"transit": {
"dynamicSearchWindow": {
"minWindow": "4h",
"maxWindow": "16h"
}
},
"updaters": [
{
"type": "stop-time-updater",
"url": "https://mobility.api.opendatahub.testingmachine.eu/v2/GTFS-RT",
"feedId": "sta"
}
]
}
15 changes: 15 additions & 0 deletions run-otp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# SPDX-FileCopyrightText: NOI Techpark <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

OTP_IMAGE=docker.io/opentripplanner/opentripplanner:2.5.0_2024-01-19T14-50

docker run \
-it \
-v .:/var/opentripplanner/:z \
--rm \
-e JAVA_TOOL_OPTIONS="-Xmx6G" \
-p 8080:8080 \
${OTP_IMAGE} --load --serve
100 changes: 100 additions & 0 deletions south-tyrol.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
10.596094752863905,
46.88761850922589
],
[
10.215075147765305,
46.79604829659155
],
[
9.926735987150636,
46.62658549503311
],
[
9.871814242271313,
46.252843252677394
],
[
10.323686680175655,
45.99649468969423
],
[
10.506675858631127,
45.75948870782801
],
[
10.926745068688348,
45.62536275534609
],
[
11.248044114250973,
45.6989096427684
],
[
11.692449003300908,
45.85746945760036
],
[
12.197257540618523,
45.994619692803894
],
[
12.583575395676604,
46.14830668791336
],
[
12.824759695748952,
46.54438638737474
],
[
12.644400789935446,
46.7129104660751
],
[
12.351095121931905,
46.922431853118866
],
[
12.243747099237027,
47.14271804055227
],
[
11.787210094930145,
47.117029331648155
],
[
11.272318736688703,
47.06795279562982
],
[
11.001142621347753,
46.960293764622435
],
[
11.018305666622382,
46.86180681535134
],
[
10.99771001229243,
46.81484465408542
],
[
10.596094752863905,
46.88761850922589
]
]
],
"type": "Polygon"
}
}
]
}

0 comments on commit e81633f

Please sign in to comment.