Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from jalapeno-api-gateway/coordinates
Browse files Browse the repository at this point in the history
Coordinates
  • Loading branch information
mbongard authored Nov 26, 2021
2 parents 9034560 + 4cff05b commit 2bec577
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 0 deletions.
8 changes: 8 additions & 0 deletions arango/document-types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,11 @@ type LSNode_Edge struct {
To string `json:"_to,omitempty"`
Link string `json:"link,omitempty"`
}

type LSNode_Coordinates struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
LsNodeKey string `json:"ls_node_key,omitempty"`
Latitude float64 `json:"latitude,omitempty"`
Longitude float64 `json:"longitude,omitempty"`
}
21 changes: 21 additions & 0 deletions arango/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ func FetchLsNode(ctx context.Context, key string) LSNode {
return document
}

func FetchLsNodeCoordinates(ctx context.Context, key string) LSNode_Coordinates {
cursor := queryArangoDbDatabase(ctx, "FOR d IN LSNode_Coordinates FILTER d._key == \"" + key + "\" RETURN d");
var document LSNode_Coordinates
readDocument(cursor.ReadDocument(ctx, &document))
return document
}

func FetchLsLink(ctx context.Context, key string) LSLink {
cursor := queryArangoDbDatabase(ctx, "FOR d IN LSLink FILTER d._key == \"" + key + "\" RETURN d");
var document LSLink
Expand Down Expand Up @@ -60,6 +67,20 @@ func FetchAllLsNodes(ctx context.Context) []LSNode {
return documents
}

func FetchAllLsNodeCoordinates(ctx context.Context) []LSNode_Coordinates {
cursor := queryArangoDbDatabase(ctx, "FOR d IN LSNode_Coordinates RETURN d");
var documents []LSNode_Coordinates
for {
var document LSNode_Coordinates
if (!readDocument(cursor.ReadDocument(ctx, &document))) {
break
}
documents = append(documents, document)
}
return documents
}


func FetchAllLsLinks(ctx context.Context) []LSLink {
cursor := queryArangoDbDatabase(ctx, "FOR d IN LSLink RETURN d");
var documents []LSLink
Expand Down
1 change: 1 addition & 0 deletions model/class/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (
LsPrefix Class = "LSPrefix"
LsSrv6Sid Class = "LSSRv6SID"
LsNodeEdge Class = "LSNode_Edge"
LsNodeCoordinates Class = "LSNode_Coordinates"
PhysicalInterface Class = "PhysicalInterface"
LoopbackInterface Class = "LoopbackInterface"
)
8 changes: 8 additions & 0 deletions model/property/class-properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ var AllLsNodeEdgeProperties = []string{
Link,
}

var AllLsNodeCoordinatesProperties = []string{
Key,
Id,
LsNodeKey,
Latitude,
Longitude,
}

var AllPhysicalInterfaceProperties = []string{
DataRate,
PacketsSent,
Expand Down
3 changes: 3 additions & 0 deletions model/property/property.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ const (
From = "From"
To = "To"
Link = "Link"
LsNodeKey = "LsNodeKey"
Latitude = "Latitude"
Longitude = "Longitude"
)
10 changes: 10 additions & 0 deletions model/topology/document-converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ func ConvertLsNode(doc arango.LSNode) LsNode {
}
}

func ConvertLsNodeCoordinates(doc arango.LSNode_Coordinates) LsNodeCoordinates {
return LsNodeCoordinates{
Id: doc.ID,
Key: doc.Key,
LsNodeKey: doc.LsNodeKey,
Latitude: doc.Latitude,
Longitude: doc.Longitude,
}
}

func ConvertLsLink(doc arango.LSLink) LsLink {
return LsLink{
Id: doc.ID,
Expand Down
8 changes: 8 additions & 0 deletions model/topology/documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ type LsNode struct {
IsAdjRibIn bool
}

type LsNodeCoordinates struct {
Id string
Key string
LsNodeKey string
Latitude float64
Longitude float64
}

type LsLink struct {
Id string
Key string
Expand Down
4 changes: 4 additions & 0 deletions model/topology/marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ func (doc LsNode) MarshalBinary() ([]byte, error) {
return json.Marshal(doc)
}

func (doc LsNodeCoordinates) MarshalBinary() ([]byte, error) {
return json.Marshal(doc)
}

func (doc LsLink) MarshalBinary() ([]byte, error) {
return json.Marshal(doc)
}
Expand Down

0 comments on commit 2bec577

Please sign in to comment.