46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
from sqlalchemy import String, Integer, Float, BigInteger
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from app.db.models.base import Base
|
|
|
|
|
|
class Location(Base):
|
|
|
|
__tablename__ = "locations"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
|
|
|
# OSM Identifiers
|
|
place_id: Mapped[int] = mapped_column(BigInteger, unique=True, index=True)
|
|
osm_id: Mapped[int] = mapped_column(BigInteger)
|
|
osm_type: Mapped[str] = mapped_column(String(20))
|
|
|
|
# Coordinates
|
|
latitude: Mapped[float] = mapped_column(Float)
|
|
longitude: Mapped[float] = mapped_column(Float)
|
|
|
|
# Address Info
|
|
house_number: Mapped[str] = mapped_column(String(20), nullable=True)
|
|
road: Mapped[str] = mapped_column(String(150))
|
|
city: Mapped[str] = mapped_column(String(100))
|
|
county: Mapped[str] = mapped_column(String(100))
|
|
state: Mapped[str] = mapped_column(String(100))
|
|
postcode: Mapped[str] = mapped_column(String(20))
|
|
country: Mapped[str] = mapped_column(String(100))
|
|
country_code: Mapped[str] = mapped_column(String(10))
|
|
|
|
# Display name
|
|
display_name: Mapped[str] = mapped_column(String(300))
|
|
|
|
# Bounding Box
|
|
bbox_lat_min: Mapped[float] = mapped_column(Float)
|
|
bbox_lat_max: Mapped[float] = mapped_column(Float)
|
|
bbox_lon_min: Mapped[float] = mapped_column(Float)
|
|
bbox_lon_max: Mapped[float] = mapped_column(Float)
|
|
|
|
property = relationship(
|
|
"Property",
|
|
back_populates="location",
|
|
uselist=False,
|
|
cascade="all, delete-orphan"
|
|
) |