@@ -72,10 +72,10 @@ class vehicle_location extends React.Component {
7272 }
7373 getShapeData = ( newProps = this . props ) => {
7474 let showIcons = true
75- let url = `${ local . endpoint } /nz-akl /stops/trip/${ newProps . params . trip_id } `
75+ let url = `${ local . endpoint } /${ newProps . params . region } /stops/trip/${ newProps . params . trip_id } `
7676 if ( 'line_id' in newProps . params ) {
7777 if ( typeof ( newProps . tripInfo . shape_id ) !== 'undefined' ) {
78- url = `${ local . endpoint } /nz-akl /stops/shape/${ newProps . tripInfo . shape_id } `
78+ url = `${ local . endpoint } /${ newProps . params . region } /stops/shape/${ encodeURIComponent ( newProps . tripInfo . shape_id ) } `
7979 } else {
8080 return
8181 }
@@ -105,8 +105,19 @@ class vehicle_location extends React.Component {
105105 getWKB = ( newProps = this . props , force = false ) => {
106106 if ( typeof ( this . state . line ) === 'undefined' || force === true ) {
107107 if ( typeof ( newProps . tripInfo . shape_id ) !== 'undefined' ) {
108- fetch ( `${ local . endpoint } /nz-akl/shape/${ newProps . tripInfo . shape_id } ` ) . then ( ( response ) => {
109- response . text ( ) . then ( this . convert )
108+ fetch ( `${ local . endpoint } /${ newProps . params . region } /shapejson/${ encodeURIComponent ( newProps . tripInfo . shape_id ) } ` ) . then ( ( response ) => {
109+ response . json ( ) . then ( ( geoJson ) => {
110+ let newState = {
111+ line : geoJson
112+ }
113+ // this centers the line if we're looking at the line
114+ if ( 'line_id' in this . props . params ) {
115+ // it's opposite for some reason, also we shouldn't mutate it
116+ let center = geoJson . coordinates [ Math . round ( geoJson . coordinates . length / 2 ) ]
117+ newState . position = center . slice ( ) . reverse ( )
118+ }
119+ this . setState ( newState )
120+ } )
110121 } )
111122 }
112123 }
@@ -125,22 +136,6 @@ class vehicle_location extends React.Component {
125136 CurrentLocation . stopWatch ( )
126137 }
127138 }
128-
129- convert = ( data ) => {
130- let wkb = new Buffer ( data , 'hex' )
131- let geoJson = wkx . Geometry . parse ( wkb ) . toGeoJSON ( )
132-
133- let newState = {
134- line : geoJson
135- }
136- // this centers the line if we're looking at the line
137- if ( 'line_id' in this . props . params ) {
138- // it's opposite for some reason, also we shouldn't mutate it
139- let center = geoJson . coordinates [ Math . round ( geoJson . coordinates . length / 2 ) ]
140- newState . position = center . slice ( ) . reverse ( )
141- }
142- this . setState ( newState )
143- }
144139
145140 componentDidMount ( ) {
146141 CurrentLocation . bind ( 'pinmove' , this . pinmove )
@@ -235,14 +230,14 @@ class vehicle_location extends React.Component {
235230
236231 viewServices = ( stop ) => {
237232 return ( ) => {
238- this . props . history . push ( `/s/nz-akl /${ stop } ` )
233+ this . props . history . push ( `/s/${ this . props . params . region } /${ stop } ` )
239234 }
240235 }
241236
242237 viewTimetable = ( stop ) => {
243238 return ( ) => {
244239 const line_id = this . props . params . line_id || this . props . tripInfo . route_short_name
245- this . props . history . push ( `/s/nz-akl /${ stop } /timetable/${ line_id } -2` )
240+ this . props . history . push ( `/s/${ this . props . params . region } /${ stop } /timetable/${ line_id } -2` )
246241 }
247242 }
248243
0 commit comments