Skip to content

Commit e7160cc

Browse files
committed
refactor: reduce complexity
1 parent c393308 commit e7160cc

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/support/map-data-services/file-data-extractors/file-extractors/geojson-file-importer.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ class GeoJsonImporter {
2727
mapViewData.isRouteData = true
2828
mapViewData.origin = constants.dataOrigins.fileImporter
2929
mapViewData.timestamp = context.options.timestamp
30-
if (mapViewData.polygons.length > 0) {
31-
mapViewData.mode = constants.modes.isochrones
32-
} else if (mapViewData.jobs.length > 0) {
33-
mapViewData.mode = constants.modes.optimization
34-
} else {
35-
mapViewData.mode = mapViewData.places.length === 1 ? constants.modes.roundTrip : constants.modes.directions
36-
}
30+
mapViewData.mode = context.getMode(mapViewData)
3731
} else {
3832
reject(Error('invalid-file-content'))
3933
}
@@ -44,6 +38,23 @@ class GeoJsonImporter {
4438
})
4539
}
4640

41+
/**
42+
* Set mode for mapViewData
43+
* @param mapViewData
44+
* @returns {*} mode
45+
*/
46+
getMode (mapViewData) {
47+
let mode
48+
if (mapViewData.polygons.length > 0) {
49+
mode = constants.modes.isochrones
50+
} else if (mapViewData.jobs.length > 0) {
51+
mode = constants.modes.optimization
52+
} else {
53+
mode = mapViewData.places.length === 1 ? constants.modes.roundTrip : constants.modes.directions
54+
}
55+
return mode
56+
}
57+
4758
/**
4859
* Parse the file content to an object
4960
* @returns {Object}

0 commit comments

Comments
 (0)