-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
926b8f6
commit 8c7b533
Showing
14 changed files
with
1,281 additions
and
120 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,8 @@ | |
.read-the-docs { | ||
color: #888; | ||
} | ||
|
||
.rotate-90 { | ||
position: absolute; | ||
transform: rotate(90deg) !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { MapContainer, TileLayer, Marker, Popup, useMap } from 'react-leaflet' | ||
|
||
import L from 'leaflet' | ||
|
||
const ComponentResize = () => { | ||
const map = useMap() | ||
|
||
setTimeout(() => { | ||
map.invalidateSize() | ||
}, 0) | ||
|
||
return null | ||
} | ||
|
||
interface IMap { | ||
children: React.ReactNode | ||
} | ||
|
||
const LMap = ({ children }: IMap) => { | ||
return ( | ||
<MapContainer | ||
style={{ | ||
height: '100%', | ||
width: '100%', | ||
}} | ||
center={[56.15674, 10.21076]} | ||
attributionControl={true} | ||
zoom={8} | ||
minZoom={3} | ||
scrollWheelZoom={true} | ||
> | ||
<ComponentResize /> | ||
<TileLayer | ||
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' | ||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" | ||
/> | ||
{children} | ||
</MapContainer> | ||
) | ||
} | ||
|
||
export default LMap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import { IDetailedVessel } from '../models/detailedVessel'; | ||
import { IDetailedVessel } from '../models/detailedVessel' | ||
|
||
interface IPopupProps { | ||
vessel: IDetailedVessel; | ||
vessel: IDetailedVessel | ||
} | ||
|
||
export default function Popup({ vessel }: IPopupProps) { | ||
return ( | ||
<div> | ||
<h2>ID: {vessel.id}</h2> | ||
<p>Name: {vessel.name}</p> | ||
<p>Callsign: {vessel.callSign}</p> | ||
<p>Length: {vessel.length}</p> | ||
<p>pos fixing device: {vessel.positionFixingDevice}</p> | ||
<p>MMSI: {vessel.mmsi}</p> | ||
</div> | ||
); | ||
return ( | ||
<div> | ||
<h2>ID: {vessel.id}</h2> | ||
<p>Name: {vessel.name}</p> | ||
<p>Callsign: {vessel.callSign}</p> | ||
<p>Length: {vessel.length}</p> | ||
<p>pos fixing device: {vessel.positionFixingDevice}</p> | ||
<p>MMSI: {vessel.mmsi}</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ISimpleVessel } from '../models/simpleVessel' | ||
import L from 'leaflet' | ||
import { MapContainer, TileLayer, Marker, Popup as LPopup, useMap } from 'react-leaflet' | ||
import Popup from './popup' | ||
import IVesselDetail from '../models/detailedVessel' | ||
import { useState } from 'react' | ||
|
||
interface IVesselMarker { | ||
vessel: ISimpleVessel | ||
} | ||
|
||
export default function VesselMarker({ vessel }: IVesselMarker) { | ||
const [vesselDetails, setVesselDetails] = useState<IVesselDetail | undefined>(undefined) | ||
|
||
const icon = L.divIcon({ | ||
className: 'custom-div-icon', | ||
html: `<div style='width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 40px solid #c30b82; transform: rotate(${ | ||
vessel.location.heading || 0 | ||
}deg) translate(-5px, -20px);'></div> | ||
`, | ||
iconAnchor: [0, 0], | ||
popupAnchor: [0, -25], | ||
}) | ||
|
||
return ( | ||
<Marker position={[vessel.location.point.lat, vessel.location.point.lon]} icon={icon}> | ||
{vesselDetails && ( | ||
<LPopup> | ||
<Popup vessel={vesselDetails} /> | ||
</LPopup> | ||
)} | ||
</Marker> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,62 @@ | ||
import { createContext, useContext, useState } from 'react'; | ||
import { ISelectionArea } from '../models/selectionArea'; | ||
import { createContext, useContext, useState } from 'react' | ||
import { ISelectionArea } from '../models/selectionArea' | ||
|
||
enum ActiveGuiTool { | ||
ZoomIn, | ||
ZoomOut, | ||
Rectangle, | ||
Lasso, | ||
Mouse | ||
ZoomIn, | ||
ZoomOut, | ||
Rectangle, | ||
Lasso, | ||
Mouse, | ||
} | ||
|
||
interface IVesselGuiContext { | ||
pathHistory: boolean; | ||
setPathHistory: React.Dispatch<React.SetStateAction<boolean>>; | ||
pathForecast: boolean; | ||
setPathForecast: React.Dispatch<React.SetStateAction<boolean>>; | ||
activeTool: ActiveGuiTool; | ||
setActiveTool: React.Dispatch<React.SetStateAction<ActiveGuiTool>>; | ||
activeTime: Date; | ||
setActiveTime: React.Dispatch<React.SetStateAction<Date>>; | ||
selectionArea?: ISelectionArea; | ||
setSelectionArea: React.Dispatch< | ||
React.SetStateAction<ISelectionArea | undefined> | ||
>; | ||
pathHistory: boolean | ||
setPathHistory: React.Dispatch<React.SetStateAction<boolean>> | ||
pathForecast: boolean | ||
setPathForecast: React.Dispatch<React.SetStateAction<boolean>> | ||
activeTool: ActiveGuiTool | ||
setActiveTool: React.Dispatch<React.SetStateAction<ActiveGuiTool>> | ||
activeTime: Date | ||
setActiveTime: React.Dispatch<React.SetStateAction<Date>> | ||
selectionArea?: ISelectionArea | ||
setSelectionArea: React.Dispatch<React.SetStateAction<ISelectionArea | undefined>> | ||
} | ||
|
||
const VesselGuiContext = createContext<IVesselGuiContext | undefined>( | ||
undefined | ||
); | ||
const VesselGuiContext = createContext<IVesselGuiContext | undefined>(undefined) | ||
|
||
export const useVesselGuiContext = () => { | ||
const context = useContext(VesselGuiContext); | ||
if (context === undefined) { | ||
throw new Error( | ||
'useVesselGuiContext must be used within a AppContextProvider' | ||
); | ||
} | ||
return context; | ||
}; | ||
const context = useContext(VesselGuiContext) | ||
if (context === undefined) { | ||
throw new Error('useVesselGuiContext must be used within a AppContextProvider') | ||
} | ||
return context | ||
} | ||
|
||
export default VesselGuiContext; | ||
export default VesselGuiContext | ||
|
||
export const VesselGuiContextProvider = ({ | ||
children | ||
}: { | ||
children: React.ReactNode; | ||
}) => { | ||
const [pathHistory, setPathHistory] = useState<boolean>(false); | ||
const [pathForecast, setPathForecast] = useState<boolean>(false); | ||
const [activeTool, setActiveTool] = useState<ActiveGuiTool>( | ||
ActiveGuiTool.Mouse | ||
); | ||
const [activeTime, setActiveTime] = useState<Date>(new Date()); | ||
const [selectionArea, setSelectionArea] = useState< | ||
ISelectionArea | undefined | ||
>(); | ||
export const VesselGuiContextProvider = ({ children }: { children: React.ReactNode }) => { | ||
const [pathHistory, setPathHistory] = useState<boolean>(false) | ||
const [pathForecast, setPathForecast] = useState<boolean>(false) | ||
const [activeTool, setActiveTool] = useState<ActiveGuiTool>(ActiveGuiTool.Mouse) | ||
const [activeTime, setActiveTime] = useState<Date>(new Date()) | ||
const [selectionArea, setSelectionArea] = useState<ISelectionArea | undefined>() | ||
|
||
return ( | ||
<VesselGuiContext.Provider | ||
value={{ | ||
pathHistory, | ||
setPathHistory, | ||
pathForecast, | ||
setPathForecast, | ||
activeTool, | ||
setActiveTool, | ||
activeTime, | ||
setActiveTime, | ||
selectionArea, | ||
setSelectionArea | ||
}}> | ||
{children} | ||
</VesselGuiContext.Provider> | ||
); | ||
}; | ||
return ( | ||
<VesselGuiContext.Provider | ||
value={{ | ||
pathHistory, | ||
setPathHistory, | ||
pathForecast, | ||
setPathForecast, | ||
activeTool, | ||
setActiveTool, | ||
activeTime, | ||
setActiveTime, | ||
selectionArea, | ||
setSelectionArea, | ||
}} | ||
> | ||
{children} | ||
</VesselGuiContext.Provider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
export interface IMonitoredVessel { | ||
mmsi: number | ||
import { ILocation } from "./location" | ||
import { ISimpleVessel } from "./simpleVessel" | ||
|
||
export interface IMonitoredVessel extends ISimpleVessel { | ||
trustwortiness: number | ||
reason?: string | ||
} | ||
|
||
export default class MonitoredVessel implements IMonitoredVessel { | ||
constructor(public mmsi: number, public trustwortiness: number, public reason?: string) {} | ||
constructor(public mmsi: number, public trustwortiness: number, public location: ILocation, public reason?: string) { } | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.