Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
juhomakkonen committed Aug 1, 2024
1 parent 175fa68 commit 93aaed4
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,33 @@ const ParkAndRideAreas = () => {
showParkAndRideAreas,
);

/**
* Swap coordinates to be in correct order for Leaflet
* @param {array} inputData
* @returns array of coordinates
*/
const swapCoords = inputData => {
if (inputData.length > 0) {
return inputData.map(item => item.map(v => v.map(j => [j[1], j[0]])));
}
return inputData;
};

/**
* Get center point of polygon geometry
* @param {array} coordinates
* @returns object
*/
const getCenter = coordinates => {
const leafletPolygon = polygon(coordinates);
return leafletPolygon.getBounds().getCenter();
};

/**
* Swap coordinates and then get center value of the polygon.
* @param {array} coordinatesData
* @returns array of lat and lng values
*/
const swapAndGetCoordinates = coordinatesData => {
const swapped = swapCoords(coordinatesData);
const center = getCenter(swapped);
Expand Down

0 comments on commit 93aaed4

Please sign in to comment.