-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform scheduled stop point IDs before importing into OTP (#231)
* Implement XSLT for transforming ScheduledStopPoints * Add documentation * Add reuse headers * Run XLST during build * Use specific Saxon directory * Update input file name * use correct file name * Exclude Amarillo feed * Add artifact * Move transformed file into data * Add SIRI-Lite feeds * Add test for EntityResolver * Remove separate script * Use un-released version to use scheduled stop points * Re-enable Amarillo * Bump actions version
- Loading branch information
1 parent
e225e9d
commit 3a00a5d
Showing
7 changed files
with
96 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,7 @@ journey/tmp | |
geocoder/.env | ||
|
||
graph.obj | ||
|
||
*.xml | ||
*.zip | ||
saxon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# SPDX-FileCopyrightText: NOI Techpark <[email protected]> | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
export OTP_IMAGE="opentripplanner/opentripplanner:2.7.0_2024-11-19T11-28" | ||
export OTP_IMAGE="lehrenfried/opentripplanner:siri-scheduled-stop-point" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,15 @@ TRANSIT_NETEX_URL="https://rapuser:[email protected]/netex/api/v4/download | |
TRANSIT_NETEX_XML=data/sta-netex.xml | ||
TRANSIT_NETEX_GZ=${TRANSIT_NETEX_XML}.gz | ||
TRANSIT_NETEX_ZIP=${TRANSIT_NETEX_XML}.zip | ||
|
||
# config for transforming the ids of scheduled stop points | ||
SAXON_URL="https://github.com/Saxonica/Saxon-HE/releases/download/SaxonHE12-5/SaxonHE12-5J.zip" | ||
SAXON_ZIP="saxon.zip" | ||
SAXON_JAR="saxon/saxon-he-12.5.jar" | ||
XSL_FILE="transform-scheduled-stop-point-ids.xsl" | ||
|
||
SSIDS_TRANSFORMED_XML="data/sta.netex.correct-ssids.xml" | ||
|
||
# parking | ||
PARKING_NETEX_URL=https://transmodel.api.opendatahub.com/netex/parking | ||
PARKING_NETEX_XML=data/shared-data.xml | ||
|
@@ -55,7 +64,24 @@ rm -f ${TRANSIT_NETEX_ZIP} | |
echo "Downloading NeTEx transit data from ${TRANSIT_NETEX_URL}" | ||
${CURL} "${TRANSIT_NETEX_URL}" -o ${TRANSIT_NETEX_GZ} | ||
gunzip --force ${TRANSIT_NETEX_GZ} | ||
zip ${TRANSIT_NETEX_ZIP} ${TRANSIT_NETEX_XML} | ||
|
||
# Configuration | ||
|
||
if [ ! -f "${SAXON_JAR}" ]; then | ||
$CURL $SAXON_URL -o $SAXON_ZIP | ||
unzip $SAXON_ZIP -d saxon | ||
fi | ||
|
||
# the scheduled stop point ids and the SIRI StopPointRefs do not match, so we have to transform | ||
# the NeTEx feed so that they do: https://github.com/noi-techpark/odh-mentor-otp/issues/215 | ||
echo "Running Saxon transformation..." | ||
java -jar "$SAXON_JAR" -s:"${TRANSIT_NETEX_XML}" -xsl:"$XSL_FILE" -o:"$SSIDS_TRANSFORMED_XML" | ||
|
||
|
||
zip ${TRANSIT_NETEX_ZIP} ${SSIDS_TRANSFORMED_XML} | ||
|
||
ls -lah | ||
ls -lah data | ||
|
||
# download parking data and put it into a zip | ||
rm -f ${PARKING_NETEX_XML} ${PARKING_NETEX_ZIP} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
SPDX-FileCopyrightText: NOI Techpark <[email protected]> | ||
SPDX-License-Identifier: CC0-1.0 | ||
--> | ||
<xsl:stylesheet version="3.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:n="http://www.netex.org.uk/netex" | ||
xsi:schemaLocation="http://www.netex.org.uk/netex https://raw.githubusercontent.com/NeTEx-CEN/NeTEx/master/xsd/NeTEx_publication.xsd" | ||
exclude-result-prefixes="n" > | ||
|
||
<!-- Identity template to copy every node and attribute by default --> | ||
<xsl:mode on-no-match="shallow-copy"/> | ||
|
||
<!-- | ||
Replace the IDs of ScheduledStopPoints from this format | ||
it:apb:ScheduledStopPoint:it-22101-7010-51-32073: | ||
to this | ||
it:22101:7010:51:32073 | ||
. | ||
This because the SIRI feeds use the latter format, and we need to match up the two sources. | ||
--> | ||
<xsl:template match="//n:ScheduledStopPoint/@id"> | ||
<xsl:attribute name="id"> | ||
<xsl:value-of select="replace(replace(., '.*ScheduledStopPoint:(.+?):$', '$1'), '-', ':')"/> | ||
</xsl:attribute> | ||
</xsl:template> | ||
|
||
<xsl:template match="//n:RoutePointRef/@ref"> | ||
<xsl:attribute name="ref"> | ||
<xsl:value-of select="replace(replace(., '.*ScheduledStopPoint:(.+?):$', '$1'), '-', ':')"/> | ||
</xsl:attribute> | ||
</xsl:template> | ||
|
||
<xsl:template match="//n:ScheduledStopPointRef/@ref"> | ||
<xsl:attribute name="ref"> | ||
<xsl:value-of select="replace(replace(., '.*ScheduledStopPoint:(.+?):$', '$1'), '-', ':')"/> | ||
</xsl:attribute> | ||
</xsl:template> | ||
</xsl:stylesheet> |