Skip to content

Commit d9813d2

Browse files
committed
fix(editor): fix upload of route shapefile for use as visual aid
fixes #20
1 parent 3d23502 commit d9813d2

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

lib/editor/components/FeedInfoPanel.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { browserHistory } from 'react-router'
55

66
import CreateSnapshotModal from './CreateSnapshotModal'
77
import SelectFileModal from '../../common/components/SelectFileModal.js'
8+
import {isValidZipFile} from '../../common/util/util'
89
import { GTFS_ICONS } from '../util/ui'
910

1011
const PANEL_WIDTH = 400
@@ -64,16 +65,17 @@ export default class FeedInfoPanel extends Component {
6465
_openSnapshotModal = () => this.refs.snapshotModal.open()
6566

6667
showUploadFileModal = () => {
68+
const {displayRoutesShapefile, feedSource} = this.props
6769
this.refs.selectFileModal.open({
6870
title: 'Upload route shapefile',
69-
body: 'Select a zipped shapefile to display on map:',
71+
body: `Select a zipped shapefile to display on map. Note: this is only for use as a visual aid.`,
7072
onConfirm: (files) => {
71-
const nameArray = files[0].name.split('.')
72-
if (files[0].type !== 'application/zip' || nameArray[nameArray.length - 1] !== 'zip') {
73-
return false
74-
} else {
75-
this.props.displayRoutesShapefile(this.props.feedSource, files[0])
73+
const file = files[0]
74+
if (isValidZipFile(file)) {
75+
displayRoutesShapefile(feedSource, file)
7676
return true
77+
} else {
78+
return false
7779
}
7880
},
7981
errorMessage: 'Uploaded file must be a valid zip file (.zip).'

lib/editor/components/map/EditorMap.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {Component} from 'react'
2-
import {Map, ZoomControl, FeatureGroup} from 'react-leaflet'
2+
import {Map, ZoomControl, FeatureGroup, GeoJSON} from 'react-leaflet'
33
import {shallowEqual} from 'react-pure-render'
44

55
import AddableStopsLayer from './AddableStopsLayer'
@@ -276,9 +276,16 @@ export default class EditorMap extends Component {
276276
tripPatterns={tripPatterns}
277277
user={user}
278278
stops={tableData.stop} />
279+
{/* Primary editor map components (routes, stops, etc.) to be rendered based on active components */}
279280
{!hidden &&
280281
this._getMapComponents(activeComponent, activeEntity, subEntityId, activePattern, tableData.stop, editSettings, mapState)
281282
}
283+
{/* Routes GeoJSON to display as a visual aid in constructing trip patterns */}
284+
{mapState.routesGeojson &&
285+
<GeoJSON
286+
key={mapState.routesGeojson.key}
287+
data={mapState.routesGeojson} />
288+
}
282289
</Map>
283290
)
284291
}

0 commit comments

Comments
 (0)