【生产地图公里标信息】
This commit is contained in:
parent
30c4210a5d
commit
0aa3290e73
@ -33,7 +33,7 @@ func NewButtonEntity(w ecs.World, data *repository.Button, entityMap map[string]
|
||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||
// 带灯按钮
|
||||
if data.HasLight() {
|
||||
entry.AddComponent(component.SingleLightType, unsafe.Pointer(NewLightHEntity(w)))
|
||||
entry.AddComponent(component.SingleLightType, unsafe.Pointer(NewLightEntity(w)))
|
||||
}
|
||||
entityMap[uid] = entry
|
||||
}
|
||||
@ -56,7 +56,7 @@ func NewAlarmEntity(w ecs.World, alarm *repository.Alarm, entityMap map[string]*
|
||||
func NewIBPLightEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
||||
entry, ok := entityMap[uid]
|
||||
if !ok {
|
||||
entry = w.Entry(w.Create(component.LightTag, component.HdTag, component.UidType, component.LightDriveType, component.BitStateType))
|
||||
entry = w.Entry(w.Create(component.LightTag, component.UidType, component.LightDriveType, component.BitStateType))
|
||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||
entityMap[uid] = entry
|
||||
}
|
||||
|
8
repository/coordinate.go
Normal file
8
repository/coordinate.go
Normal file
@ -0,0 +1,8 @@
|
||||
package repository
|
||||
|
||||
// 检测点
|
||||
type MapCoordinate struct {
|
||||
Coordinate string // 坐标系
|
||||
MinCoordinate int64 // 坐标系最小值
|
||||
MaxCoordinate int64 // 坐标系最大值
|
||||
}
|
@ -2,6 +2,7 @@ package repository
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
)
|
||||
@ -9,6 +10,7 @@ import (
|
||||
type Repository struct {
|
||||
id string
|
||||
version string
|
||||
coordinate *MapCoordinate // 基准坐标系类型,在列车画图时统一坐标系
|
||||
physicalSectionMap map[string]*PhysicalSection
|
||||
checkPointMap map[string]*CheckPoint
|
||||
turnoutMap map[string]*Turnout
|
||||
@ -244,6 +246,41 @@ func (repo *Repository) getKilometerConvert(cs1, cs2 string) (*proto.KilometerCo
|
||||
return convert, nil
|
||||
}
|
||||
|
||||
// 获取地图坐标信息
|
||||
func (repo Repository) generateCoordinateInfo() *MapCoordinate {
|
||||
if repo.coordinate != nil {
|
||||
return repo.coordinate
|
||||
}
|
||||
coordinate := &MapCoordinate{
|
||||
MinCoordinate: int64(math.MaxInt64),
|
||||
MaxCoordinate: int64(math.MinInt64),
|
||||
}
|
||||
for _, data := range repo.checkPointMap {
|
||||
if data.km == nil || data.km.CoordinateSystem == "" {
|
||||
continue
|
||||
}
|
||||
if coordinate.Coordinate == "" {
|
||||
coordinate.Coordinate = data.km.CoordinateSystem
|
||||
}
|
||||
km := repo.ConvertKilometer(data.km, coordinate.Coordinate)
|
||||
if km.Value < coordinate.MinCoordinate {
|
||||
coordinate.MinCoordinate = km.Value
|
||||
}
|
||||
if km.Value > coordinate.MaxCoordinate {
|
||||
coordinate.MaxCoordinate = km.Value
|
||||
}
|
||||
}
|
||||
if coordinate.Coordinate == "" {
|
||||
panic("无计轴公里标信息")
|
||||
}
|
||||
repo.coordinate = coordinate
|
||||
return repo.coordinate
|
||||
}
|
||||
|
||||
func (repo Repository) GetCoordinateInfo() *MapCoordinate {
|
||||
return repo.coordinate
|
||||
}
|
||||
|
||||
func buildKilometerConvertKey(cs1 string, cs2 string) string {
|
||||
return cs1 + cs2
|
||||
}
|
||||
|
@ -114,8 +114,8 @@ func buildModels(source *proto.Repository, repository *Repository) {
|
||||
for _, protoData := range source.Mkxs {
|
||||
m := NewMkx(protoData.Id)
|
||||
repository.mkxMap[m.Id()] = m
|
||||
|
||||
}
|
||||
repository.generateCoordinateInfo()
|
||||
}
|
||||
|
||||
func buildModelRelationship(source *proto.Repository, repository *Repository) error {
|
||||
|
Loading…
Reference in New Issue
Block a user