Skip to content

Commit

Permalink
refactoring in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
grunde73 committed May 29, 2024
1 parent 38a71f5 commit 668b471
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/maritime_schema/types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Maritime schema types
"""

# from .state import Position, StateVector


__all__ = []
42 changes: 42 additions & 0 deletions src/maritime_schema/types/environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class WaveSpectra(Enum):
JONSWAP = "JONSWAP"
PiersonMoskowitz = "Pierson-Moskowitz"
Bretschneider = "Bretschneider"


class WeatherCondition(Enum):
Clear = "Clear"
Cloudy = "Cloudy"
Foggy = "Foggy"
Rainy = "Rainy"
Snowy = "Snowy"


class PrecipitationType(Enum):
None_ = "None"
Rain = "Rain"
Snow = "Snow"
Sleet = "Sleet"
Hail = "Hail"


class Environment(BaseModelConfig):
air_temperature: float = Field(None, description="The air temperature in degrees Celsius", examples=[20.0])
water_remperature: float = Field(None, description="The water temperature in degrees Celsius", examples=[15.0])
precipitation: PrecipitationType = Field(
None, description="The type of precipitation", examples=[PrecipitationType.Rain]
)
wind_speed: float = Field(None, description="The wind speed in m/s", examples=[10.0])
wind_direction: float = Field(None, description="The wind direction in degrees", examples=[180.0])
current_speed: float = Field(None, description="The current speed in m/s", examples=[1.0])
current_direction: float = Field(None, description="The current direction in degrees", examples=[90.0])
wave_spectrum: WaveSpectra = Field(None, description="The wave spectrum", examples=[WaveSpectra.JONSWAP])
significant_wave_height: float = Field(None, description="The significant wave height in meters", examples=[3.0])
wave_period: float = Field(None, description="The wave period in seconds", examples=[12.0])
wave_direction: float = Field(None, description="The wave direction in degrees", examples=[270.0])
visibility: float = Field(None, description="The visibility in nautical miles", examples=[5.0])
conditions: WeatherCondition = Field(
None,
description="The overall weather conditions",
examples=[WeatherCondition.Clear],
)
Empty file.
Empty file.
Empty file.
90 changes: 90 additions & 0 deletions src/maritime_schema/types/ship.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import logging
import os
from datetime import datetime
from enum import Enum
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
from uuid import UUID, uuid4

from pydantic import BaseModel, ConfigDict
from pydantic.fields import Field # , FieldInfo
from pyproj import Geod

logger = logging.getLogger(__name__)


class AISNavStatus(str, Enum):
UNDER_WAY_USING_ENGINE = "Under way using engine"
AT_ANCHOR = "At anchor"
NOT_UNDER_COMMAND = "Not under command"
RESTRICTED_MANOEUVERABILITY = "Restricted manoeuverability"
CONSTRAINED_BY_HER_DRAUGHT = "Constrained by her draught"
MOORED = "Moored"
AGROUND = "Aground"
ENGAGED_IN_FISHING = "Engaged in fishing"
UNDER_WAY_SAILING = "Under way sailing"
RESERVED_FOR_FUTURE_AMENDMENT_OF_NAVIGATIONAL_STATUS_FOR_HSC = (
"Reserved for future amendment of navigational status for HSC"
)
RESERVED_FOR_FUTURE_AMENDMENT_OF_NAVIGATIONAL_STATUS_FOR_WIG = (
"Reserved for future amendment of navigational status for WIG"
)
RESERVED_FOR_FUTURE_USE_1 = "Reserved for future use 1"
RESERVED_FOR_FUTURE_USE_2 = "Reserved for future use 2"
RESERVED_FOR_FUTURE_USE_3 = "Reserved for future use 3"
AIS_SART_IS_ACTIVE = "AIS SART is active"
NOT_DEFINED_DEFAULT = "Not defined (default)"


class GeneralShipType(str, Enum):
WING_IN_GROUND = "Wing in ground"
FISHING = "Fishing"
TOWING = "Towing"
DREDGING_OR_UNDERWATER_OPS = "Dredging or underwater ops"
DIVING_OPS = "Diving ops"
MILITARY_OPS = "Military ops"
SAILING = "Sailing"
PLEASURE_CRAFT = "Pleasure Craft"
HIGH_SPEED_CRAFT = "High speed craft"
PILOT_VESSEL = "Pilot Vessel"
SEARCH_AND_RESCUE_VESSEL = "Search and Rescue vessel"
TUG = "Tug"
PORT_TENDER = "Port Tender"
ANTI_POLLUTION = "Anti-pollution"
LAW_ENFORCEMENT = "Law Enforcement"
MEDICAL_TRANSPORT = "Medical Transport"
NONCOMBATANT_SHIP = "Noncombatant ship"
PASSENGER = "Passenger"
CARGO = "Cargo"
TANKER = "Tanker"
OTHER_TYPE = "Other Type"


class InterpolationMethod(str, Enum):
LINEAR = "linear"
COSINE = "cosine"
SMOOTHSTEP = "smoothstep"
ACCELERATE = "accelerate"
DECELERATE = "decelerate"
ORDINAL = "ordinal"


class ShipStatic(BaseModelConfig):
"""Static ship data that will not change during the scenario."""

id: UUID = Field(..., description="Unique Identifier", examples=[uuid4()])
length: float = Field(None, gt=0, description="Length of the ship in meters", examples=[230.0])
width: float = Field(None, gt=0, description="Width of the ship in meters", examples=[30.0])
height: Optional[float] = Field(None, gt=0, description="Height of the ship in meters", examples=[15.0])
speed_max: Optional[float] = Field(None, gt=0, description="Maximum speed of the ship in knots", examples=[15.0])
mmsi: Optional[int] = Field(
None,
ge=100000000,
le=999999999,
description="Maritime Mobile Service Identity (MMSI)",
examples=[123456789],
)
imo: Optional[int] = Field(None, ge=1000000, le=9999999, description="IMO Number", examples=[1234567])
name: Optional[str] = Field(None, description="Ship name", examples=["RMS Titanic"])
ship_type: Optional[GeneralShipType] = Field(None, description="General ship type, based on AIS")
model_config = ConfigDict(extra="allow")
8 changes: 8 additions & 0 deletions src/maritime_schema/types/state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

class Position(BaseModelConfig):
latitude: float = Field(None, ge=-90, le=90, description="WGS-84 latitude",
examples=[51.2131])
longitude: float = Field(None, ge=-180, le=180,
description="WGS-84 longitude",
examples=[11.2131])
model_config = ConfigDict(extra="allow")

0 comments on commit 668b471

Please sign in to comment.