Skip to content

Commit

Permalink
feat: changes done in isochrrone
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebubeker committed Nov 14, 2023
1 parent c282ead commit 5123330
Show file tree
Hide file tree
Showing 17 changed files with 1,054 additions and 196 deletions.
8 changes: 2 additions & 6 deletions apps/web/components/common/LayerMetadataForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { LayerMetadata } from "@/lib/validations/layer";
import { layerMetadataSchema } from "@/lib/validations/layer";
import { zodResolver } from "@hookform/resolvers/zod";
import { Box, TextField } from "@mui/material";
import { Box } from "@mui/material";
import { useForm } from "react-hook-form";

interface LayerMetadataFormProps {
Expand All @@ -18,8 +18,6 @@ const LayerMetadataForm: React.FC<LayerMetadataFormProps> = ({
}) => {
const {
handleSubmit,
register,
formState: { errors },
} = useForm<LayerMetadata>({
mode: "onChange",
resolver: zodResolver(layerMetadataSchema),
Expand All @@ -30,9 +28,7 @@ const LayerMetadataForm: React.FC<LayerMetadataFormProps> = ({
console.log(data);
};
return (
<Box component="form" onSubmit={handleSubmit(onSubmit)} {...props}>

</Box>
<Box component="form" onSubmit={handleSubmit(onSubmit)} {...props} />
);
};

Expand Down
13 changes: 8 additions & 5 deletions apps/web/components/dashboard/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { Icon, ICON_NAME } from "@p4b/ui/components/Icon";
import NextLink from "next/link";
import { usePathname } from "next/navigation";
import { useTranslation } from "@/i18n/client";

const openedMixin = (theme: Theme): CSSObject => ({
transition: theme.transitions.create("width", {
Expand Down Expand Up @@ -42,6 +43,8 @@ const DashboardSidebar = (props: Props) => {
const theme = useTheme();
const pathname = usePathname();

const {t} = useTranslation("dashboard");

const MobileDrawerProps = {
open: navVisible,
onOpen: () => setNavVisible(true),
Expand All @@ -61,31 +64,31 @@ const DashboardSidebar = (props: Props) => {
{
link: "/home",
icon: ICON_NAME.HOUSE,
label: "Home",
label: t("sidebar.home"),
current: pathname?.includes("/home"),
},
{
link: "/projects",
icon: ICON_NAME.MAP,
label: "Projects",
label: t("sidebar.projects"),
current: pathname?.includes("/projects"),
},
{
link: "/datasets",
icon: ICON_NAME.DATABASE,
label: "Datasets",
label: t("sidebar.datasets"),
current: pathname?.includes("/data"),
},
{
link: "/catalog",
icon: ICON_NAME.GLOBE,
label: "Catalog",
label: t("sidebar.catalog"),
current: pathname?.includes("/catalog"),
},
{
link: "/settings",
icon: ICON_NAME.SETTINGS,
label: "Settings",
label: t("sidebar.settings"),
current: pathname?.includes("/settings"),
},
];
Expand Down
63 changes: 19 additions & 44 deletions apps/web/components/map/controls/Geocoder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ import search from "@/lib/services/geocoder";
import type { FeatureCollection } from "geojson";
import { match } from "@/lib/utils/match";

import type {
Result,
// Feature,
// Context,
// Geometry,
// Properties,
} from "@/types/map/controllers";

type Props = {
endpoint?: string;
source?: string;
Expand All @@ -36,42 +44,6 @@ type Props = {
pointZoom?: number;
};

export interface Result {
feature: Feature;
label: string;
}

interface Feature {
id: string;
type: string;
place_type: string[];
relevance: number;
properties: Properties;
text: string;
place_name: string;
center: [number, number];
geometry: Geometry;
address: string;
context: Context[];
}

interface Context {
id: string;
text: string;
wikidata?: string;
short_code?: string;
}

interface Geometry {
type: string;
coordinates: [number, number];
interpolated: boolean;
}

interface Properties {
accuracy: string;
}

const COORDINATE_REGEX_STRING =
"^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?),\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)";
const COORDINATE_REGEX = RegExp(COORDINATE_REGEX_STRING);
Expand Down Expand Up @@ -222,7 +194,11 @@ export default function Geocoder({
},
}}
>
<Icon iconName={ICON_NAME.SEARCH} htmlColor={theme.palette.secondary.light} fontSize="small" />
<Icon
iconName={ICON_NAME.SEARCH}
htmlColor={theme.palette.secondary.light}
fontSize="small"
/>
</Fab>
</Tooltip>
)}
Expand Down Expand Up @@ -289,7 +265,7 @@ export default function Geocoder({
display: "flex",
alignItems: "center",
width: 350,
[theme.breakpoints.down('sm')]: {
[theme.breakpoints.down("sm")]: {
width: 270,
},
}}
Expand All @@ -299,9 +275,9 @@ export default function Geocoder({
fontSize="small"
sx={{
color: focused
? theme.palette.primary.main
: theme.palette.text.secondary,
margin: theme.spacing(2),
? theme.palette.primary.main
: theme.palette.text.secondary,
margin: theme.spacing(2),
}}
/>
<Divider
Expand Down Expand Up @@ -384,8 +360,7 @@ export default function Geocoder({
sx={{
paddingLeft: theme.spacing(3),
"&:hover": {
backgroundColor:
theme.palette.background.default,
backgroundColor: theme.palette.background.default,
},
}}
>
Expand Down Expand Up @@ -430,4 +405,4 @@ export default function Geocoder({
)}
</>
);
}
}
10 changes: 10 additions & 0 deletions apps/web/components/map/panels/ProjectNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Charts from "@/components/map/panels/Charts";
import Toolbox from "@/components/map/panels/toolbox/Toolbox";
import Filter from "@/components/map/panels/filter/Filter";
import Scenario from "@/components/map/panels/Scenario";
import Isochrone from "@/components/map/panels/isochrone/Isochrone";
import MapStyle from "@/components/map/panels/mapStyle/MapStyle";
import MapSidebar from "@/components/map/Sidebar";
import { Zoom } from "@/components/map/controls/Zoom";
Expand Down Expand Up @@ -115,6 +116,15 @@ const ProjectNavigation = ({ projectId }) => {
/>
),
},
{
icon: ICON_NAME.BULLSEYE,
name: t("panels.isochrone.isochrone"),
component: (
<Isochrone
setActiveRight={setActiveRight}
/>
),
},
{
icon: ICON_NAME.SCENARIO,
name: t("panels.scenario.scenario"),
Expand Down
118 changes: 118 additions & 0 deletions apps/web/components/map/panels/isochrone/Isochrone.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React, { useState } from "react";
import Container from "@/components/map/panels/Container";
import { Box, Button, useTheme } from "@mui/material";
import IsochroneSettings from "@/components/map/panels/isochrone/IsochroneSettings";
import StartingPoint from "@/components/map/panels/isochrone/StartingPoint";
import { useTranslation } from "@/i18n/client";
import SaveResult from "@/components/map/panels/toolbox/tools/SaveResult";

import type { MapSidebarItem } from "@/types/map/sidebar";
import type { StartingPointType } from "@/types/map/isochrone";

type IsochroneProps = {
setActiveRight: (item: MapSidebarItem | undefined) => void;
};

type RoutingTypes =
| "bus"
| "tram"
| "rail"
| "subway"
| "ferry"
| "cable_car"
| "gondola"
| "funicular"
| "walk"
| "bicycle"
| "car";

const Isochrone = (props: IsochroneProps) => {
// Isochrone Settings states
const [routing, setRouting] = useState<RoutingTypes | undefined>(undefined);
const [speed, setSpeed] = useState<number | undefined>(undefined);
const [distance, setDistance] = useState<number | undefined>(undefined);
const [travelTime, setTravelTime] = useState<number | undefined>(undefined);
const [steps, setSteps] = useState<number | undefined>(undefined);
const [outputName, setOutputName] = useState<string | undefined>(undefined);
const [folderSaveID, setFolderSaveID] = useState<string | undefined>(
undefined,
);

// Sarting point states
const [startingType, setStartingType] = useState<
StartingPointType | undefined
>(undefined);
const [startingPoint, setStartingPoint] = useState<string | undefined>(
undefined,
);

const theme = useTheme();
const { t } = useTranslation("maps");
const { setActiveRight } = props;

return (
<Container
title="Legend"
close={setActiveRight}
direction="left"
body={
<Box
display="flex"
flexDirection="column"
justifyContent="space-between"
sx={{ height: "100%" }}
>
<Box sx={{ maxHeight: "95%", overflow: "scroll" }}>
<IsochroneSettings
routing={routing}
setRouting={setRouting}
distance={distance}
setDistance={setDistance}
speed={speed}
setSpeed={setSpeed}
travelTime={travelTime}
setTravelTime={setTravelTime}
steps={steps}
setSteps={setSteps}
/>
<StartingPoint
startingType={startingType}
setStartingType={setStartingType}
startingPoint={startingPoint}
setStartingPoint={setStartingPoint}
/>
<SaveResult
outputName={outputName}
setOutputName={setOutputName}
folderSaveId={folderSaveID}
setFolderSaveID={setFolderSaveID}
/>
</Box>
<Box
sx={{
display: "flex",
gap: theme.spacing(2),
alignItems: "center",
}}
>
<Button
variant="outlined"
sx={{ flexGrow: "1" }}
// onClick={handleReset}
>
{t("panels.tools.reset")}
</Button>
<Button
sx={{ flexGrow: "1" }}
// onClick={handleRun}
>
{t("panels.tools.run")}
</Button>
</Box>
</Box>
}
/>
);
};

export default Isochrone;
Loading

0 comments on commit 5123330

Please sign in to comment.