Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#111 - make feaures list a compact list of floors per feature #112

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion core/model/buildings.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Building struct {
Latitude float64
Longitude float64
Floors []string
Features []BuildingFeature
Features []BuildingFeatureLocation
}

// CompactBuilding represents minimal building informaiton needed to display a builgins details on the details panel
Expand All @@ -63,6 +63,19 @@ type CompactBuilding struct {
ImageURL string
Latitude float64
Longitude float64
Features []BuildingFeatureLocation
}

// BuildingFeatureLocation represents a list of where each feature belonging to a building can be found
type BuildingFeatureLocation struct {
Key string `json:"key" bson:"key"`
Value FeatureMapEntry `json:"value" bson:"value"`
}

// FeatureMapEntry represents the floor data associated with a feature key for a building
type FeatureMapEntry struct {
Name string `json:"name" bson:"name"`
Floors []string `json:"floors" bson:"floors"`
}

// BuildingFeature represents a feature found in buildings
Expand Down
24 changes: 23 additions & 1 deletion core/model/uiuc/buildingdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package uiuc

import (
model "application/core/model"
"slices"
"strconv"
)

Expand Down Expand Up @@ -153,9 +154,28 @@ func NewBuilding(bldg CampusBuilding) *model.Building {
}

newBldg.Floors = append(newBldg.Floors, bldg.Floors...)
var featuredata = make(map[string]model.FeatureMapEntry, 0)

for _, n := range bldg.Features {

newBldg.Features = append(newBldg.Features, *NewFeature(n))
val, ok := featuredata[n.EQIndicator]
if ok {
if !slices.Contains(val.Floors, n.FoundOnFloor) {
val.Floors = append(val.Floors, n.FoundOnFloor)
featuredata[n.EQIndicator] = val
}

} else {
var floors = make([]string, 1)
floors[0] = n.FoundOnFloor
fme := model.FeatureMapEntry{Name: n.Name, Floors: floors}
featuredata[n.EQIndicator] = fme
}
//newBldg.Features = append(newBldg.Features, *NewFeature(n))
}
for key, value := range featuredata {
var feature = model.BuildingFeatureLocation{Key: key, Value: value}
newBldg.Features = append(newBldg.Features, feature)
}

return &newBldg
Expand Down Expand Up @@ -184,3 +204,5 @@ func NewFeature(f CampusBuildingFeature) *model.BuildingFeature {
IsADA: f.IsADA, IsExternal: f.IsExternal, Latitude: f.Latitude, Longitude: f.Longitude, Comments: f.Comments}
return &newFeature
}

// AddToFeatureMap adds the features floor and name
Loading