Skip to content

Commit

Permalink
Merge pull request #150 from entur/map_for_servicejourney
Browse files Browse the repository at this point in the history
Adding functionality to show map for servicejourney
  • Loading branch information
testower authored Apr 4, 2024
2 parents cc0911d + c44dfc8 commit b36aed8
Show file tree
Hide file tree
Showing 5 changed files with 4,303 additions and 4,001 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: yarn --immutable
- name: Install dependencies
if: steps.cache-npm.outputs.cache-hit != 'true'
run: yarn --immutable
- run: yarn test
- run: yarn build
env:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: yarn --immutable
- name: Install dependencies
if: steps.cache-npm.outputs.cache-hit != 'true'
run: yarn --immutable
- run: yarn test
- run: yarn build
env:
Expand All @@ -40,6 +42,7 @@ jobs:
preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- name: Download all workflow run artifacts
Expand Down
18 changes: 6 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"graphiql": "^1.3.2",
"graphiql-explorer": "^0.9.0",
"graphql": "^15.4.0",
"graphql-ws": "^5.16.0",
"history": "^4.10.1",
"html-webpack-plugin": "4.5.2",
"husky": "^3.1.0",
Expand Down Expand Up @@ -102,18 +103,11 @@
"format:check": "prettier --check .",
"format": "prettier --write ."
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
],
"husky": {
"hooks": {
"pre-commit": "lint-staged"
Expand Down
25 changes: 23 additions & 2 deletions src/components/Map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,42 @@ function getFlexibleAreas(responseData) {
return [...quayAreas, ...fromPlaceAreas];
}

// Returns an array of LineString GeoJSON features
function getServiceJourneyLines(responseData) {
if (!responseData) return;

const serviceJourney = responseData.data?.serviceJourney;

if (!serviceJourney?.pointsOnLink?.points) {
return [];
}

const polyline = lineString(
toGeoJSON(serviceJourney.pointsOnLink.points).coordinates,
{
color: getTransportColor(serviceJourney.transportMode),
}
);

return [polyline];
}

function getMapData(responseData) {
if (!responseData) return;

return {
legLines: getLegLines(responseData),
flexibleAreas: getFlexibleAreas(responseData),
serviceJourney: getServiceJourneyLines(responseData),
};
}

function MapContent({ mapData }) {
const map = useMap();

const collection = useMemo(() => {
const { legLines, flexibleAreas } = mapData;
const allFeatures = [...legLines, ...flexibleAreas];
const { legLines, flexibleAreas, serviceJourney } = mapData;
const allFeatures = [...legLines, ...flexibleAreas, ...serviceJourney];
return allFeatures.length > 0 ? featureCollection(allFeatures) : null;
}, [mapData]);

Expand Down
Loading

0 comments on commit b36aed8

Please sign in to comment.