Files
fire-safety-ymd/internal/domain/spatial.go
2026-09-05 15:46:37 +08:00

113 lines
4.4 KiB
Go

package domain
// Coordinate is a WGS84 longitude/latitude pair.
type Coordinate struct {
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
}
// SpatialScope is a trusted, server-derived data scope.
type SpatialScope struct {
// AllTowns authorizes every town in the MCP's fixed query tables, including records with no town value.
AllTowns bool
// AllowedTowns is used only when AllTowns is false.
AllowedTowns []string
}
// NearbyQuery contains a bounded spatial search requested by a service use case.
type NearbyQuery struct {
Point Coordinate
RadiusMeters float64
Limit int
Scope SpatialScope
}
// PlaceSearchQuery searches existing fire-safety records for user-confirmable place candidates.
type PlaceSearchQuery struct {
PlaceName string
Limit int
Scope SpatialScope
}
// PlaceCandidate is a recorded or representative location that still requires user confirmation.
type PlaceCandidate struct {
SourceRecordID string `json:"source_record_id"`
PlaceType string `json:"place_type"`
Name string `json:"name,omitempty"`
Town string `json:"town,omitempty"`
Village string `json:"village,omitempty"`
MatchedField string `json:"matched_field"`
MatchedText string `json:"matched_text"`
MatchKind string `json:"match_kind"`
Location Coordinate `json:"location"`
LocationKind string `json:"location_kind"`
}
// IncidentContext is a fire-grid area covering the supplied incident point.
type IncidentContext struct {
GridID string `json:"grid_id"`
Town string `json:"town,omitempty"`
AreaLabel string `json:"area_label,omitempty"`
}
// WaterSource is a spatially nearby water candidate from an existing source table.
type WaterSource struct {
SourceRecordID string `json:"source_record_id"`
Category string `json:"category"`
Name string `json:"name,omitempty"`
Town string `json:"town,omitempty"`
Village string `json:"village,omitempty"`
Location Coordinate `json:"location"`
DistanceMeters float64 `json:"distance_meters"`
CapacityCubicMeters *float64 `json:"capacity_cubic_meters,omitempty"`
ResourceType string `json:"resource_type,omitempty"`
ReportedStatus string `json:"reported_status,omitempty"`
SourceTimestampRaw *int64 `json:"source_timestamp_raw,omitempty"`
}
// CommandPostCandidate is a nearby existing facility, not a confirmed command post.
type CommandPostCandidate struct {
SourceRecordID string `json:"source_record_id"`
FacilityType string `json:"facility_type"`
Name string `json:"name,omitempty"`
Town string `json:"town,omitempty"`
Village string `json:"village,omitempty"`
Location Coordinate `json:"location"`
DistanceMeters float64 `json:"distance_meters"`
ReportedStatus string `json:"reported_status,omitempty"`
ManagementUnit string `json:"management_unit,omitempty"`
}
// AccessLine is a nearby fire-access-line candidate and its closest point.
type AccessLine struct {
SourceRecordID string `json:"source_record_id"`
Name string `json:"name,omitempty"`
Town string `json:"town,omitempty"`
DistanceMeters float64 `json:"distance_meters"`
NearestPoint Coordinate `json:"nearest_point"`
LengthMeters *float64 `json:"length_meters,omitempty"`
SourceUpdatedRaw string `json:"source_updated_raw,omitempty"`
}
// ResponsibleUnit is the non-personal responsibility information stored on a fire grid.
type ResponsibleUnit struct {
GridID string `json:"grid_id"`
Town string `json:"town,omitempty"`
AreaLabel string `json:"area_label,omitempty"`
FireTeam string `json:"fire_team,omitempty"`
LiveLocationAvailable bool `json:"live_location_available"`
AssemblySiteAvailable bool `json:"assembly_site_available"`
}
// RiskArea is a cemetery or forest-area enterprise polygon near the supplied point.
type RiskArea struct {
SourceRecordID string `json:"source_record_id"`
RiskType string `json:"risk_type"`
Name string `json:"name,omitempty"`
Town string `json:"town,omitempty"`
Village string `json:"village,omitempty"`
Direction string `json:"direction,omitempty"`
CoversPoint bool `json:"covers_point"`
DistanceMeters float64 `json:"distance_meters"`
}