chore(assets): Upload report assets
Some checks failed
Polyglot CI / tests (push) Has been cancelled
1
.gitignore
vendored
|
|
@ -49,7 +49,6 @@ drone-black-box/drone_black_box.db*
|
||||||
*.pdf
|
*.pdf
|
||||||
|
|
||||||
*.out
|
*.out
|
||||||
*.html
|
|
||||||
|
|
||||||
drone_black_box.db*
|
drone_black_box.db*
|
||||||
app
|
app
|
||||||
|
|
|
||||||
325
docs/reports/LO3_Go_Coverage.html
Normal file
|
|
@ -0,0 +1,325 @@
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>drone-black-box: Go Coverage Report</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: black;
|
||||||
|
color: rgb(80, 80, 80);
|
||||||
|
}
|
||||||
|
body, pre, #legend span {
|
||||||
|
font-family: Menlo, monospace;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
#topbar {
|
||||||
|
background: black;
|
||||||
|
position: fixed;
|
||||||
|
top: 0; left: 0; right: 0;
|
||||||
|
height: 42px;
|
||||||
|
border-bottom: 1px solid rgb(80, 80, 80);
|
||||||
|
}
|
||||||
|
#content {
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
#nav, #legend {
|
||||||
|
float: left;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
#legend {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
#nav {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
#legend span {
|
||||||
|
margin: 0 5px;
|
||||||
|
}
|
||||||
|
.cov0 { color: rgb(192, 0, 0) }
|
||||||
|
.cov1 { color: rgb(128, 128, 128) }
|
||||||
|
.cov2 { color: rgb(116, 140, 131) }
|
||||||
|
.cov3 { color: rgb(104, 152, 134) }
|
||||||
|
.cov4 { color: rgb(92, 164, 137) }
|
||||||
|
.cov5 { color: rgb(80, 176, 140) }
|
||||||
|
.cov6 { color: rgb(68, 188, 143) }
|
||||||
|
.cov7 { color: rgb(56, 200, 146) }
|
||||||
|
.cov8 { color: rgb(44, 212, 149) }
|
||||||
|
.cov9 { color: rgb(32, 224, 152) }
|
||||||
|
.cov10 { color: rgb(20, 236, 155) }
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="topbar">
|
||||||
|
<div id="nav">
|
||||||
|
<select id="files">
|
||||||
|
|
||||||
|
<option value="file0">drone-black-box/main.go (51.6%)</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div id="legend">
|
||||||
|
<span>not tracked</span>
|
||||||
|
|
||||||
|
<span class="cov0">not covered</span>
|
||||||
|
<span class="cov8">covered</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<pre class="file" id="file0" style="display: none">package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"encoding/json"
|
||||||
|
"log/slog"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
_ "modernc.org/sqlite"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DroneEvent defines the DroneEvent struct as JSON
|
||||||
|
type DroneEvent struct {
|
||||||
|
DroneID string `json:"droneId"`
|
||||||
|
Latitude float64 `json:"latitude"`
|
||||||
|
Longitude float64 `json:"longitude"`
|
||||||
|
Timestamp string `json:"timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Server struct {
|
||||||
|
db *sql.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
var allowedOrigins = map[string]struct{}{
|
||||||
|
"http://localhost:4173": {},
|
||||||
|
"http://127.0.0.1:4173": {},
|
||||||
|
"http://localhost:5173": {},
|
||||||
|
"http://127.0.0.1:5173": {},
|
||||||
|
}
|
||||||
|
|
||||||
|
// corsMiddleware adds the headers needed for cross-origin requests from the frontend.
|
||||||
|
func corsMiddleware(next http.Handler) http.Handler <span class="cov8" title="1">{
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) </span><span class="cov8" title="1">{
|
||||||
|
origin := r.Header.Get("Origin")
|
||||||
|
if _, ok := allowedOrigins[origin]; ok </span><span class="cov8" title="1">{
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", origin)
|
||||||
|
w.Header().Set("Vary", "Origin")
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
<span class="cov8" title="1">w.Header().Set("Access-Control-Allow-Methods", "GET,POST,OPTIONS")
|
||||||
|
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||||
|
w.Header().Set("Access-Control-Max-Age", "86400")
|
||||||
|
|
||||||
|
// Handle preflight without hitting the underlying handlers.
|
||||||
|
if r.Method == http.MethodOptions </span><span class="cov8" title="1">{
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
<span class="cov8" title="1">next.ServeHTTP(w, r)</span>
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ingest handler
|
||||||
|
func (s *Server) ingestHandler(w http.ResponseWriter, r *http.Request) <span class="cov8" title="1">{
|
||||||
|
var event DroneEvent
|
||||||
|
if err := json.NewDecoder(r.Body).Decode(&event); err != nil </span><span class="cov8" title="1">{
|
||||||
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
|
slog.Error("Failed to decode request body", "error", err)
|
||||||
|
return
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
<span class="cov8" title="1">slog.Info("Ingesting event", "drone_id", event.DroneID, "timestamp", event.Timestamp)
|
||||||
|
|
||||||
|
_, err := s.db.Exec("INSERT INTO drone_events (drone_id, latitude, longitude, timestamp) VALUES (?, ?, ?, ?)",
|
||||||
|
event.DroneID, event.Latitude, event.Longitude, event.Timestamp)
|
||||||
|
if err != nil </span><span class="cov8" title="1">{
|
||||||
|
slog.Error("Failed to insert event", "error", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
<span class="cov8" title="1">w.WriteHeader(http.StatusCreated)</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Snapshot handler
|
||||||
|
func (s *Server) snapshotHandler(w http.ResponseWriter, r *http.Request) <span class="cov8" title="1">{
|
||||||
|
timeParam := r.URL.Query().Get("time")
|
||||||
|
if timeParam == "" </span><span class="cov8" title="1">{
|
||||||
|
http.Error(w, "Missing 'time' query parameter", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
<span class="cov8" title="1">query := `
|
||||||
|
SELECT drone_id, latitude, longitude, timestamp
|
||||||
|
FROM drone_events t1
|
||||||
|
WHERE timestamp = (
|
||||||
|
SELECT MAX(timestamp)
|
||||||
|
FROM drone_events t2
|
||||||
|
WHERE t2.drone_id = t1.drone_id AND t2.timestamp <= ?
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
rows, err := s.db.Query(query, timeParam)
|
||||||
|
if err != nil </span><span class="cov8" title="1">{
|
||||||
|
slog.Error("Failed to query snapshot", "error", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}</span>
|
||||||
|
<span class="cov8" title="1">defer rows.Close()
|
||||||
|
|
||||||
|
results := []DroneEvent{}
|
||||||
|
for rows.Next() </span><span class="cov8" title="1">{
|
||||||
|
var event DroneEvent
|
||||||
|
if err := rows.Scan(&event.DroneID, &event.Latitude, &event.Longitude, &event.Timestamp); err != nil </span><span class="cov0" title="0">{
|
||||||
|
slog.Error("Failed to scan row", "error", err)
|
||||||
|
continue</span>
|
||||||
|
}
|
||||||
|
<span class="cov8" title="1">results = append(results, event)</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="cov8" title="1">slog.Info("Snapshot retrieved", "time", timeParam, "count", len(results))
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
if err := json.NewEncoder(w).Encode(results); err != nil </span><span class="cov0" title="0">{
|
||||||
|
slog.Error("Failed to encode response", "error", err)
|
||||||
|
}</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Health check handler
|
||||||
|
func (s *Server) healthHandler(w http.ResponseWriter, r *http.Request) <span class="cov8" title="1">{
|
||||||
|
if err := s.db.Ping(); err != nil </span><span class="cov8" title="1">{
|
||||||
|
slog.Error("Health check failed", "error", err)
|
||||||
|
http.Error(w, "Database unavailable", http.StatusServiceUnavailable)
|
||||||
|
return
|
||||||
|
}</span>
|
||||||
|
<span class="cov8" title="1">w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte("OK"))</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() <span class="cov0" title="0">{
|
||||||
|
// Setup structured logging
|
||||||
|
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
|
||||||
|
slog.SetDefault(logger)
|
||||||
|
|
||||||
|
port := os.Getenv("BLACKBOX_PORT")
|
||||||
|
if port == "" </span><span class="cov0" title="0">{
|
||||||
|
port = "3000"
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
// Open database
|
||||||
|
<span class="cov0" title="0">db, err := sql.Open("sqlite", "./drone_black_box.db")
|
||||||
|
if err != nil </span><span class="cov0" title="0">{
|
||||||
|
slog.Error("Failed to open database", "error", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}</span>
|
||||||
|
<span class="cov0" title="0">defer db.Close()
|
||||||
|
|
||||||
|
// Performance optimizations for SQLite
|
||||||
|
// WAL mode allows simultaneous readers and one writer
|
||||||
|
if _, err := db.Exec("PRAGMA journal_mode=WAL;"); err != nil </span><span class="cov0" title="0">{
|
||||||
|
slog.Warn("Failed to enable WAL mode", "error", err)
|
||||||
|
}</span>
|
||||||
|
// Busy timeout prevents "database is locked" errors during high concurrency
|
||||||
|
<span class="cov0" title="0">if _, err := db.Exec("PRAGMA busy_timeout=5000;"); err != nil </span><span class="cov0" title="0">{
|
||||||
|
slog.Warn("Failed to set busy timeout", "error", err)
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
<span class="cov0" title="0">db.SetMaxOpenConns(1)
|
||||||
|
|
||||||
|
// Create table
|
||||||
|
createTableSQL := `CREATE TABLE IF NOT EXISTS drone_events (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
drone_id TEXT NOT NULL,
|
||||||
|
latitude REAL NOT NULL,
|
||||||
|
longitude REAL NOT NULL,
|
||||||
|
timestamp TEXT NOT NULL
|
||||||
|
);`
|
||||||
|
if _, err := db.Exec(createTableSQL); err != nil </span><span class="cov0" title="0">{
|
||||||
|
slog.Error("Failed to create table", "error", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
// Create index for performance
|
||||||
|
// Indexing drone_id and timestamp significantly speeds up the snapshot query
|
||||||
|
<span class="cov0" title="0">createIndexSQL := `CREATE INDEX IF NOT EXISTS idx_drone_timestamp ON drone_events(drone_id, timestamp);`
|
||||||
|
if _, err := db.Exec(createIndexSQL); err != nil </span><span class="cov0" title="0">{
|
||||||
|
slog.Error("Failed to create index", "error", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
<span class="cov0" title="0">server := &Server{db: db}
|
||||||
|
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
mux.HandleFunc("POST /ingest", server.ingestHandler)
|
||||||
|
mux.HandleFunc("GET /snapshot", server.snapshotHandler)
|
||||||
|
mux.HandleFunc("GET /health", server.healthHandler)
|
||||||
|
|
||||||
|
httpServer := &http.Server{
|
||||||
|
Addr: ":" + port,
|
||||||
|
Handler: corsMiddleware(mux),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Graceful shutdown
|
||||||
|
stop := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
|
go func() </span><span class="cov0" title="0">{
|
||||||
|
slog.Info("Black Box Service is running", "port", port)
|
||||||
|
if err := httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed </span><span class="cov0" title="0">{
|
||||||
|
slog.Error("HTTP server error", "error", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}</span>
|
||||||
|
}()
|
||||||
|
|
||||||
|
<span class="cov0" title="0"><-stop
|
||||||
|
slog.Info("Shutting down server...")
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
if err := httpServer.Shutdown(ctx); err != nil </span><span class="cov0" title="0">{
|
||||||
|
slog.Error("Server forced to shutdown", "error", err)
|
||||||
|
}</span>
|
||||||
|
|
||||||
|
<span class="cov0" title="0">slog.Info("Server exited properly")</span>
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var files = document.getElementById('files');
|
||||||
|
var visible;
|
||||||
|
files.addEventListener('change', onChange, false);
|
||||||
|
function select(part) {
|
||||||
|
if (visible)
|
||||||
|
visible.style.display = 'none';
|
||||||
|
visible = document.getElementById(part);
|
||||||
|
if (!visible)
|
||||||
|
return;
|
||||||
|
files.value = part;
|
||||||
|
visible.style.display = 'block';
|
||||||
|
location.hash = part;
|
||||||
|
}
|
||||||
|
function onChange() {
|
||||||
|
select(files.value);
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
}
|
||||||
|
if (location.hash != "") {
|
||||||
|
select(location.hash.substr(1));
|
||||||
|
}
|
||||||
|
if (!visible) {
|
||||||
|
select("file0");
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
BIN
docs/reports/LO3_Go_Performance.png
Normal file
|
After Width: | Height: | Size: 201 KiB |
BIN
docs/reports/LO3_Java_Coverage.png
Normal file
|
After Width: | Height: | Size: 119 KiB |
BIN
docs/reports/LO5_CI_Log.png
Normal file
|
After Width: | Height: | Size: 195 KiB |
1
docs/reports/jacoco/test/html/index.html
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="jacoco-resources/report.gif" type="image/gif"/><title>ilp-coursework</title><script type="text/javascript" src="jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="jacoco-sessions.html" class="el_session">Sessions</a></span><span class="el_report">ilp-coursework</span></div><h1>ilp-coursework</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">317 of 2,285</td><td class="ctr2">86%</td><td class="bar">97 of 254</td><td class="ctr2">61%</td><td class="ctr1">88</td><td class="ctr2">204</td><td class="ctr1">73</td><td class="ctr2">501</td><td class="ctr1">4</td><td class="ctr2">77</td><td class="ctr1">0</td><td class="ctr2">10</td></tr></tfoot><tbody><tr><td id="a2"><a href="io.github.js0ny.ilp_coursework.service/index.html" class="el_package">io.github.js0ny.ilp_coursework.service</a></td><td class="bar" id="b0"><img src="jacoco-resources/redbar.gif" width="18" height="10" title="309" alt="309"/><img src="jacoco-resources/greenbar.gif" width="101" height="10" title="1,690" alt="1,690"/></td><td class="ctr2" id="c2">84%</td><td class="bar" id="d0"><img src="jacoco-resources/redbar.gif" width="45" height="10" title="93" alt="93"/><img src="jacoco-resources/greenbar.gif" width="74" height="10" title="153" alt="153"/></td><td class="ctr2" id="e0">62%</td><td class="ctr1" id="f0">84</td><td class="ctr2" id="g0">174</td><td class="ctr1" id="h0">73</td><td class="ctr2" id="i0">429</td><td class="ctr1" id="j0">4</td><td class="ctr2" id="k0">51</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">6</td></tr><tr><td id="a0"><a href="io.github.js0ny.ilp_coursework.controller/index.html" class="el_package">io.github.js0ny.ilp_coursework.controller</a></td><td class="bar" id="b1"><img src="jacoco-resources/greenbar.gif" width="13" height="10" title="227" alt="227"/></td><td class="ctr2" id="c1">96%</td><td class="bar" id="d1"><img src="jacoco-resources/redbar.gif" width="1" height="10" title="4" alt="4"/><img src="jacoco-resources/greenbar.gif" width="1" height="10" title="4" alt="4"/></td><td class="ctr2" id="e1">50%</td><td class="ctr1" id="f1">4</td><td class="ctr2" id="g1">24</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">58</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">20</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m1">3</td></tr><tr><td id="a1"><a href="io.github.js0ny.ilp_coursework.exception/index.html" class="el_package">io.github.js0ny.ilp_coursework.exception</a></td><td class="bar" id="b2"><img src="jacoco-resources/greenbar.gif" width="3" height="10" title="51" alt="51"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">6</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">14</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">6</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m2">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CorsConfig</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.config</a> > <span class="el_class">CorsConfig</span></div><h1>CorsConfig</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 68</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">7</td><td class="ctr1">0</td><td class="ctr2">3</td></tr></tfoot><tbody><tr><td id="a0"><a href="CorsConfig.java.html#L22" class="el_method">addCorsMappings(CorsRegistry)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="45" alt="45"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">5</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a2"><a href="CorsConfig.java.html#L13" class="el_method">static {...}</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="53" height="10" title="20" alt="20"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">1</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a1"><a href="CorsConfig.java.html#L11" class="el_method">CorsConfig()</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="8" height="10" title="3" alt="3"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">1</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CorsConfig.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.config</a> > <span class="el_source">CorsConfig.java</span></div><h1>CorsConfig.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global CORS configuration so the frontend running on a different port can call the REST API.
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
<span class="fc" id="L11">public class CorsConfig implements WebMvcConfigurer {</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L13"> private static final String[] ALLOWED_ORIGINS = new String[] {</span>
|
||||||
|
"http://localhost:4173",
|
||||||
|
"http://127.0.0.1:4173",
|
||||||
|
"http://localhost:5173",
|
||||||
|
"http://127.0.0.1:5173"
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
<span class="fc" id="L22"> registry.addMapping("/**")</span>
|
||||||
|
<span class="fc" id="L23"> .allowedOrigins(ALLOWED_ORIGINS)</span>
|
||||||
|
<span class="fc" id="L24"> .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH")</span>
|
||||||
|
<span class="fc" id="L25"> .allowedHeaders("*");</span>
|
||||||
|
<span class="fc" id="L26"> }</span>
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.config</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.source.html" class="el_source">Source Files</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.config</span></div><h1>io.github.js0ny.ilp_coursework.config</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 68</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">7</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="CorsConfig.html" class="el_class">CorsConfig</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="68" alt="68"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">3</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">7</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">3</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.config</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.html" class="el_class">Classes</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.config</span></div><h1>io.github.js0ny.ilp_coursework.config</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 68</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">7</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="CorsConfig.java.html" class="el_source">CorsConfig.java</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="68" alt="68"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">3</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">7</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">3</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ApiController.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.controller</a> > <span class="el_source">ApiController.java</span></div><h1>ApiController.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.controller;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.Angle;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.Region;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.DistanceRequest;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.MovementRequest;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.RegionCheckRequest;
|
||||||
|
import io.github.js0ny.ilp_coursework.service.GpsCalculationService;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main REST Controller for the ILP Coursework 1 application.
|
||||||
|
*
|
||||||
|
* <p>This class handles incoming HTTP requests for the API under {@code /api/v1} path (defined in
|
||||||
|
* CW1) This is responsible for mapping requests to the appropriate service method and returning the
|
||||||
|
* results as responses. The business logic is delegated to {@link GpsCalculationService}
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1")
|
||||||
|
public class ApiController {
|
||||||
|
|
||||||
|
<span class="fc" id="L30"> private static final Logger log = LoggerFactory.getLogger(ApiController.class);</span>
|
||||||
|
|
||||||
|
private final GpsCalculationService gpsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor of the {@code ApiController} with the business logic dependency {@code
|
||||||
|
* GpsCalculationService}
|
||||||
|
*
|
||||||
|
* @param gpsService The service component that contains all business logic, injected by
|
||||||
|
* Spring's DI.
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L41"> public ApiController(GpsCalculationService gpsService) {</span>
|
||||||
|
<span class="fc" id="L42"> this.gpsService = gpsService;</span>
|
||||||
|
<span class="fc" id="L43"> }</span>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles GET requests to retrieve the student's Unique ID
|
||||||
|
*
|
||||||
|
* @return A string representing the student ID starting with s
|
||||||
|
*/
|
||||||
|
@GetMapping("/uid")
|
||||||
|
public String getUid() {
|
||||||
|
<span class="fc" id="L52"> log.info("GET /api/v1/uid");</span>
|
||||||
|
<span class="fc" id="L53"> return "s2522255";</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles POST requests to get the distance between two positions
|
||||||
|
*
|
||||||
|
* @param request A {@link DistanceRequest} containing the two coordinates
|
||||||
|
* @return A {@code double} representing the calculated distance
|
||||||
|
*/
|
||||||
|
@PostMapping("/distanceTo")
|
||||||
|
public double getDistance(@RequestBody DistanceRequest request) {
|
||||||
|
<span class="fc" id="L64"> LngLat position1 = request.position1();</span>
|
||||||
|
<span class="fc" id="L65"> LngLat position2 = request.position2();</span>
|
||||||
|
<span class="fc" id="L66"> log.info("POST /api/v1/distanceTo position1={} position2={}", position1, position2);</span>
|
||||||
|
<span class="fc" id="L67"> return gpsService.calculateDistance(position1, position2);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles POST requests to check if the two coordinates are close to each other
|
||||||
|
*
|
||||||
|
* @param request A {@link DistanceRequest} containing the two coordinates
|
||||||
|
* @return {@code true} if the distance is less than the predefined threshold, {@code false}
|
||||||
|
* otherwise
|
||||||
|
*/
|
||||||
|
@PostMapping("/isCloseTo")
|
||||||
|
public boolean getIsCloseTo(@RequestBody DistanceRequest request) {
|
||||||
|
<span class="fc" id="L79"> LngLat position1 = request.position1();</span>
|
||||||
|
<span class="fc" id="L80"> LngLat position2 = request.position2();</span>
|
||||||
|
<span class="fc" id="L81"> log.info("POST /api/v1/isCloseTo position1={} position2={}", position1, position2);</span>
|
||||||
|
<span class="fc" id="L82"> return gpsService.isCloseTo(position1, position2);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles POST requests to get the next position after an angle of movement
|
||||||
|
*
|
||||||
|
* @param request A {@link MovementRequest} containing the start coordinate and angle of the
|
||||||
|
* movement.
|
||||||
|
* @return A {@link LngLat} representing the destination
|
||||||
|
*/
|
||||||
|
@PostMapping("/nextPosition")
|
||||||
|
public LngLat getNextPosition(@RequestBody MovementRequest request) {
|
||||||
|
<span class="fc" id="L94"> LngLat start = request.start();</span>
|
||||||
|
<span class="fc" id="L95"> Angle angle = new Angle(request.angle());</span>
|
||||||
|
<span class="fc" id="L96"> log.info("POST /api/v1/nextPosition start={} angle={}", start, angle);</span>
|
||||||
|
<span class="fc" id="L97"> return gpsService.nextPosition(start, angle);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles POST requests to check if a point is inside a given region
|
||||||
|
*
|
||||||
|
* @param request A {@link RegionCheckRequest} containing the coordinate and the region
|
||||||
|
* @return {@code true} if the coordinate is inside the region, {@code false} otherwise
|
||||||
|
*/
|
||||||
|
@PostMapping("/isInRegion")
|
||||||
|
public boolean getIsInRegion(@RequestBody RegionCheckRequest request) {
|
||||||
|
<span class="fc" id="L108"> LngLat position = request.position();</span>
|
||||||
|
<span class="fc" id="L109"> Region region = request.region();</span>
|
||||||
|
<span class="fc" id="L110"> log.info("POST /api/v1/isInRegion position={} region={}", position, region);</span>
|
||||||
|
<span class="fc" id="L111"> return gpsService.checkIsInRegion(position, region);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DroneController.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.controller</a> > <span class="el_source">DroneController.java</span></div><h1>DroneController.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.controller;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.Drone;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.AttrQueryRequest;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.MedDispatchRecRequest;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.response.DeliveryPathResponse;
|
||||||
|
import io.github.js0ny.ilp_coursework.service.DroneAttrComparatorService;
|
||||||
|
import io.github.js0ny.ilp_coursework.service.DroneInfoService;
|
||||||
|
import io.github.js0ny.ilp_coursework.service.PathFinderService;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main Rest Controller for the ILP Coursework 2 application.
|
||||||
|
*
|
||||||
|
* <p>This class handles incoming HTTP requests for the API under {@code /api/v1} path (defined in
|
||||||
|
* CW2) The business logic is delegated to {@link DroneInfoService}
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1")
|
||||||
|
public class DroneController {
|
||||||
|
|
||||||
|
<span class="fc" id="L28"> private static final Logger log = LoggerFactory.getLogger(DroneController.class);</span>
|
||||||
|
|
||||||
|
private final DroneInfoService droneInfoService;
|
||||||
|
private final DroneAttrComparatorService droneAttrComparatorService;
|
||||||
|
private final PathFinderService pathFinderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor of the {@code DroneController} with the business logic dependency {@code
|
||||||
|
* DroneInfoService}
|
||||||
|
*
|
||||||
|
* <p>We handle the {@code baseUrl} here. Use a predefined URL if the environment variable
|
||||||
|
* {@code ILP_ENDPOINT} is not given.
|
||||||
|
*
|
||||||
|
* @param droneService The service component that contains all business logic
|
||||||
|
*/
|
||||||
|
public DroneController(
|
||||||
|
DroneInfoService droneService,
|
||||||
|
DroneAttrComparatorService droneAttrComparatorService,
|
||||||
|
<span class="fc" id="L46"> PathFinderService pathFinderService) {</span>
|
||||||
|
<span class="fc" id="L47"> this.droneInfoService = droneService;</span>
|
||||||
|
<span class="fc" id="L48"> this.droneAttrComparatorService = droneAttrComparatorService;</span>
|
||||||
|
<span class="fc" id="L49"> this.pathFinderService = pathFinderService;</span>
|
||||||
|
<span class="fc" id="L50"> }</span>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles GET requests to retrieve an array of drones (identified by id) that has the
|
||||||
|
* capability of cooling
|
||||||
|
*
|
||||||
|
* @param state The path variable that indicates the return should have or not have the
|
||||||
|
* capability
|
||||||
|
* @return An array of drone id with cooling capability.
|
||||||
|
*/
|
||||||
|
@GetMapping("/dronesWithCooling/{state}")
|
||||||
|
public List<String> getDronesWithCoolingCapability(@PathVariable boolean state) {
|
||||||
|
<span class="fc" id="L62"> log.info("GET /api/v1/dronesWithCooling/{}", state);</span>
|
||||||
|
<span class="fc" id="L63"> return droneInfoService.dronesWithCooling(state);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles GET requests to retrieve the drone detail identified by id
|
||||||
|
*
|
||||||
|
* @param id The id of the drone to be queried.
|
||||||
|
* @return 200 with {@link Drone}-style json if success, 404 if {@code id} not found, 400
|
||||||
|
* otherwise
|
||||||
|
*/
|
||||||
|
@GetMapping("/droneDetails/{id}")
|
||||||
|
public ResponseEntity<Drone> getDroneDetail(@PathVariable String id) {
|
||||||
|
try {
|
||||||
|
<span class="fc" id="L76"> log.info("GET /api/v1/droneDetails/{}", id);</span>
|
||||||
|
<span class="fc" id="L77"> Drone drone = droneInfoService.droneDetail(id);</span>
|
||||||
|
<span class="fc" id="L78"> return ResponseEntity.ok(drone);</span>
|
||||||
|
<span class="fc" id="L79"> } catch (IllegalArgumentException ex) {</span>
|
||||||
|
<span class="fc" id="L80"> log.warn("GET /api/v1/droneDetails/{} not found", id);</span>
|
||||||
|
<span class="fc" id="L81"> return ResponseEntity.notFound().build();</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles GET requests to retrieve an array of drone ids that {@code capability.attrName =
|
||||||
|
* attrVal}
|
||||||
|
*
|
||||||
|
* @param attrName The name of the attribute to be queried
|
||||||
|
* @param attrVal The value of the attribute to be queried
|
||||||
|
* @return An array of drone id that matches the attribute name and value
|
||||||
|
*/
|
||||||
|
@GetMapping("/queryAsPath/{attrName}/{attrVal}")
|
||||||
|
public List<String> getIdByAttrMap(
|
||||||
|
@PathVariable String attrName, @PathVariable String attrVal) {
|
||||||
|
<span class="fc" id="L96"> log.info("GET /api/v1/queryAsPath/{}/{}", attrName, attrVal);</span>
|
||||||
|
<span class="fc" id="L97"> return droneAttrComparatorService.dronesWithAttribute(attrName, attrVal);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/query")
|
||||||
|
public List<String> getIdByAttrMapPost(@RequestBody AttrQueryRequest[] attrComparators) {
|
||||||
|
<span class="pc bpc" id="L102" title="1 of 2 branches missed."> int count = attrComparators == null ? 0 : attrComparators.length;</span>
|
||||||
|
<span class="fc" id="L103"> log.info("POST /api/v1/query comparators={}", count);</span>
|
||||||
|
<span class="fc" id="L104"> return droneAttrComparatorService.dronesSatisfyingAttributes(attrComparators);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/queryAvailableDrones")
|
||||||
|
public List<String> queryAvailableDrones(@RequestBody MedDispatchRecRequest[] records) {
|
||||||
|
<span class="pc bpc" id="L109" title="1 of 2 branches missed."> int count = records == null ? 0 : records.length;</span>
|
||||||
|
<span class="fc" id="L110"> log.info("POST /api/v1/queryAvailableDrones records={}", count);</span>
|
||||||
|
<span class="fc" id="L111"> return droneInfoService.dronesMatchesRequirements(records);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/calcDeliveryPath")
|
||||||
|
public DeliveryPathResponse calculateDeliveryPath(@RequestBody MedDispatchRecRequest[] record) {
|
||||||
|
<span class="pc bpc" id="L116" title="1 of 2 branches missed."> int count = record == null ? 0 : record.length;</span>
|
||||||
|
<span class="fc" id="L117"> log.info("POST /api/v1/calcDeliveryPath records={}", count);</span>
|
||||||
|
<span class="fc" id="L118"> return pathFinderService.calculateDeliveryPath(record);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/calcDeliveryPathAsGeoJson")
|
||||||
|
public String calculateDeliveryPathAsGeoJson(@RequestBody MedDispatchRecRequest[] record) {
|
||||||
|
<span class="pc bpc" id="L123" title="1 of 2 branches missed."> int count = record == null ? 0 : record.length;</span>
|
||||||
|
<span class="fc" id="L124"> log.info("POST /api/v1/calcDeliveryPathAsGeoJson records={}", count);</span>
|
||||||
|
<span class="fc" id="L125"> return pathFinderService.calculateDeliveryPathAsGeoJson(record);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MapMetaController</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.controller</a> > <span class="el_class">MapMetaController</span></div><h1>MapMetaController</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 24</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">4</td><td class="ctr1">0</td><td class="ctr2">8</td><td class="ctr1">0</td><td class="ctr2">4</td></tr></tfoot><tbody><tr><td id="a0"><a href="MapMetaController.java.html#L29" class="el_method">getRestrictedAreas()</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="7" alt="7"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i1">2</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="MapMetaController.java.html#L35" class="el_method">getServicePoints()</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="7" alt="7"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i2">2</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a2"><a href="MapMetaController.java.html#L23" class="el_method">MapMetaController(DroneInfoService)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="102" height="10" title="6" alt="6"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i0">3</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a3"><a href="MapMetaController.java.html#L19" class="el_method">static {...}</a></td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="68" height="10" title="4" alt="4"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i3">1</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MapMetaController.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.controller</a> > <span class="el_source">MapMetaController.java</span></div><h1>MapMetaController.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.controller;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.RestrictedArea;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.ServicePoint;
|
||||||
|
import io.github.js0ny.ilp_coursework.service.DroneInfoService;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1")
|
||||||
|
public class MapMetaController {
|
||||||
|
|
||||||
|
<span class="fc" id="L19"> private static final Logger log = LoggerFactory.getLogger(MapMetaController.class);</span>
|
||||||
|
|
||||||
|
private final DroneInfoService droneInfoService;
|
||||||
|
|
||||||
|
<span class="fc" id="L23"> public MapMetaController(DroneInfoService droneInfoService) {</span>
|
||||||
|
<span class="fc" id="L24"> this.droneInfoService = droneInfoService;</span>
|
||||||
|
<span class="fc" id="L25"> }</span>
|
||||||
|
|
||||||
|
@GetMapping("/restrictedAreas")
|
||||||
|
public List<RestrictedArea> getRestrictedAreas() {
|
||||||
|
<span class="fc" id="L29"> log.info("GET /api/v1/restrictedAreas");</span>
|
||||||
|
<span class="fc" id="L30"> return droneInfoService.fetchRestrictedAreas();</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/servicePoints")
|
||||||
|
public List<ServicePoint> getServicePoints() {
|
||||||
|
<span class="fc" id="L35"> log.info("GET /api/v1/servicePoints");</span>
|
||||||
|
<span class="fc" id="L36"> return droneInfoService.fetchServicePoints();</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.controller</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.source.html" class="el_source">Source Files</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.controller</span></div><h1>io.github.js0ny.ilp_coursework.controller</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">8 of 235</td><td class="ctr2">96%</td><td class="bar">4 of 8</td><td class="ctr2">50%</td><td class="ctr1">4</td><td class="ctr2">24</td><td class="ctr1">0</td><td class="ctr2">58</td><td class="ctr1">0</td><td class="ctr2">20</td><td class="ctr1">0</td><td class="ctr2">3</td></tr></tfoot><tbody><tr><td id="a1"><a href="DroneController.html" class="el_class">DroneController</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="7" height="10" title="8" alt="8"/><img src="../jacoco-resources/greenbar.gif" width="112" height="10" title="117" alt="117"/></td><td class="ctr2" id="c2">93%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="60" height="10" title="4" alt="4"/><img src="../jacoco-resources/greenbar.gif" width="60" height="10" title="4" alt="4"/></td><td class="ctr2" id="e0">50%</td><td class="ctr1" id="f0">4</td><td class="ctr2" id="g0">13</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">28</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">9</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a0"><a href="ApiController.html" class="el_class">ApiController</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="82" height="10" title="86" alt="86"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">7</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">22</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">7</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m1">1</td></tr><tr><td id="a2"><a href="MapMetaController.html" class="el_class">MapMetaController</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="23" height="10" title="24" alt="24"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">4</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">8</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">4</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m2">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.controller</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.html" class="el_class">Classes</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.controller</span></div><h1>io.github.js0ny.ilp_coursework.controller</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">8 of 235</td><td class="ctr2">96%</td><td class="bar">4 of 8</td><td class="ctr2">50%</td><td class="ctr1">4</td><td class="ctr2">24</td><td class="ctr1">0</td><td class="ctr2">58</td><td class="ctr1">0</td><td class="ctr2">20</td><td class="ctr1">0</td><td class="ctr2">3</td></tr></tfoot><tbody><tr><td id="a1"><a href="DroneController.java.html" class="el_source">DroneController.java</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="7" height="10" title="8" alt="8"/><img src="../jacoco-resources/greenbar.gif" width="112" height="10" title="117" alt="117"/></td><td class="ctr2" id="c2">93%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="60" height="10" title="4" alt="4"/><img src="../jacoco-resources/greenbar.gif" width="60" height="10" title="4" alt="4"/></td><td class="ctr2" id="e0">50%</td><td class="ctr1" id="f0">4</td><td class="ctr2" id="g0">13</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">28</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">9</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a0"><a href="ApiController.java.html" class="el_source">ApiController.java</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="82" height="10" title="86" alt="86"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">7</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">22</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">7</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m1">1</td></tr><tr><td id="a2"><a href="MapMetaController.java.html" class="el_source">MapMetaController.java</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="23" height="10" title="24" alt="24"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">4</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">8</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">4</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m2">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AltitudeRange</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_class">AltitudeRange</span></div><h1>AltitudeRange</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 9</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="AltitudeRange.java.html#L12" class="el_method">AltitudeRange(double, double)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="9" alt="9"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AltitudeRange.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_source">AltitudeRange.java</span></div><h1>AltitudeRange.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.common;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.RestrictedArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a range of altitude values (that is a fly-zone in {@link RestrictedArea}).
|
||||||
|
*
|
||||||
|
* @param lower The lower bound of the altitude range.
|
||||||
|
* @param upper The upper bound of the altitude range. If {@code upper = -1}, then the region is not
|
||||||
|
* a fly zone.
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L12">public record AltitudeRange(double lower, double upper) {}</span>
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>Angle.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_source">Angle.java</span></div><h1>Angle.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the data transfer object for angle
|
||||||
|
*
|
||||||
|
* @param val value of the angle in degrees
|
||||||
|
*/
|
||||||
|
public record Angle(double degrees) {
|
||||||
|
private static final double STEP = 22.5;
|
||||||
|
private static final double EPSILON = 1e-10;
|
||||||
|
|
||||||
|
<span class="fc" id="L12"> public Angle {</span>
|
||||||
|
<span class="pc bpc" id="L13" title="1 of 4 branches missed."> if (degrees < 0 || degrees >= 360) {</span>
|
||||||
|
<span class="fc" id="L14"> throw new IllegalArgumentException("Angle must be in range [0, 360). Got: " + degrees);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should be a multiple of 22.5 (one of the 16 major directions)
|
||||||
|
<span class="fc" id="L18"> double remainder = degrees % STEP;</span>
|
||||||
|
|
||||||
|
// Floating point modulo may have tiny errors, e.g. 45.0 % 22.5 could be 0.0 or
|
||||||
|
// 1.0e-15
|
||||||
|
// So we need to check if the remainder is small enough, or close enough to STEP
|
||||||
|
// (handling negative errors)
|
||||||
|
<span class="pc bpc" id="L24" title="3 of 4 branches missed."> if (Math.abs(remainder) > EPSILON && Math.abs(remainder - STEP) > EPSILON) {</span>
|
||||||
|
<span class="nc" id="L25"> throw new IllegalArgumentException(</span>
|
||||||
|
"Angle must be a multiple of 22.5 (one of the 16 major directions). Got: "
|
||||||
|
+ degrees);
|
||||||
|
}
|
||||||
|
<span class="fc" id="L29"> }</span>
|
||||||
|
|
||||||
|
public static Angle fromIndex(int index) {
|
||||||
|
<span class="nc bnc" id="L32" title="All 4 branches missed."> if (index < 0 || index > 15) {</span>
|
||||||
|
<span class="nc" id="L33"> throw new IllegalArgumentException("Direction index must be between 0 and 15");</span>
|
||||||
|
}
|
||||||
|
<span class="nc" id="L35"> return new Angle(index * STEP);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Angle snap(double rawAngle) {
|
||||||
|
<span class="fc" id="L39"> double normalized = normalize(rawAngle);</span>
|
||||||
|
<span class="fc" id="L40"> double snapped = Math.round(normalized / STEP) * STEP;</span>
|
||||||
|
<span class="fc" id="L41"> return new Angle(normalize(snapped));</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public Angle offset(int increments) {
|
||||||
|
<span class="fc" id="L45"> double rotated = degrees + increments * STEP;</span>
|
||||||
|
<span class="fc" id="L46"> return new Angle(normalize(rotated));</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double normalize(double angle) {
|
||||||
|
<span class="fc" id="L50"> double normalized = angle % 360;</span>
|
||||||
|
<span class="fc bfc" id="L51" title="All 2 branches covered."> if (normalized < 0) {</span>
|
||||||
|
<span class="fc" id="L52"> normalized += 360;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L54"> return normalized;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double toRadians(double degrees) {
|
||||||
|
<span class="nc" id="L58"> return Math.toRadians(degrees);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public double toRadians() {
|
||||||
|
<span class="fc" id="L62"> return Math.toRadians(degrees);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DroneAvailability</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_class">DroneAvailability</span></div><h1>DroneAvailability</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">4 of 45</td><td class="ctr2">91%</td><td class="bar">4 of 8</td><td class="ctr2">50%</td><td class="ctr1">4</td><td class="ctr2">6</td><td class="ctr1">1</td><td class="ctr2">6</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="DroneAvailability.java.html#L10" class="el_method">checkAvailability(DayOfWeek, LocalTime)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="13" height="10" title="4" alt="4"/><img src="../jacoco-resources/greenbar.gif" width="106" height="10" title="32" alt="32"/></td><td class="ctr2" id="c1">88%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="60" height="10" title="4" alt="4"/><img src="../jacoco-resources/greenbar.gif" width="60" height="10" title="4" alt="4"/></td><td class="ctr2" id="e0">50%</td><td class="ctr1" id="f0">4</td><td class="ctr2" id="g0">5</td><td class="ctr1" id="h0">1</td><td class="ctr2" id="i0">5</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="DroneAvailability.java.html#L6" class="el_method">DroneAvailability(String, TimeWindow[])</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="30" height="10" title="9" alt="9"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">1</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DroneAvailability.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_source">DroneAvailability.java</span></div><h1>DroneAvailability.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.common;
|
||||||
|
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
<span class="fc" id="L6">public record DroneAvailability(String id, TimeWindow[] availability) {</span>
|
||||||
|
|
||||||
|
public boolean checkAvailability(DayOfWeek day, LocalTime time) {
|
||||||
|
|
||||||
|
<span class="pc bpc" id="L10" title="1 of 2 branches missed."> for (var a : availability) {</span>
|
||||||
|
<span class="pc bpc" id="L11" title="1 of 2 branches missed."> if (a.dayOfWeek().equals(day)) {</span>
|
||||||
|
<span class="pc bpc" id="L12" title="2 of 4 branches missed."> if (!time.isBefore(a.from()) && !time.isAfter(a.until())) {</span>
|
||||||
|
<span class="fc" id="L13"> return true;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="nc" id="L18"> return false;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DroneCapability</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_class">DroneCapability</span></div><h1>DroneCapability</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 24</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="DroneCapability.java.html#L3" class="el_method">DroneCapability(boolean, boolean, float, int, float, float, float)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="24" alt="24"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DroneCapability.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_source">DroneCapability.java</span></div><h1>DroneCapability.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.common;
|
||||||
|
|
||||||
|
<span class="fc" id="L3">public record DroneCapability(</span>
|
||||||
|
boolean cooling,
|
||||||
|
boolean heating,
|
||||||
|
float capacity,
|
||||||
|
int maxMoves,
|
||||||
|
float costPerMove,
|
||||||
|
float costInitial,
|
||||||
|
float costFinal) {}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DroneEvent</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_class">DroneEvent</span></div><h1>DroneEvent</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">238 of 238</td><td class="ctr2">0%</td><td class="bar">20 of 20</td><td class="ctr2">0%</td><td class="ctr1">14</td><td class="ctr2">14</td><td class="ctr1">43</td><td class="ctr2">43</td><td class="ctr1">4</td><td class="ctr2">4</td></tr></tfoot><tbody><tr><td id="a3"><a href="DroneEvent.java.html#L72" class="el_method">fromPathResponseWithTimestamps(DeliveryPathResponse, Map)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="87" alt="87"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="8" alt="8"/></td><td class="ctr2" id="e0">0%</td><td class="ctr1" id="f0">5</td><td class="ctr2" id="g0">5</td><td class="ctr1" id="h0">16</td><td class="ctr2" id="i0">16</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a2"><a href="DroneEvent.java.html#L52" class="el_method">fromPathResponseWithTimestamp(DeliveryPathResponse, LocalDateTime)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="96" height="10" title="70" alt="70"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="90" height="10" title="6" alt="6"/></td><td class="ctr2" id="e1">0%</td><td class="ctr1" id="f1">4</td><td class="ctr2" id="g1">4</td><td class="ctr1" id="h1">14</td><td class="ctr2" id="i1">14</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a1"><a href="DroneEvent.java.html#L31" class="el_method">fromPathResponse(DeliveryPathResponse)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="91" height="10" title="66" alt="66"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d2"><img src="../jacoco-resources/redbar.gif" width="90" height="10" title="6" alt="6"/></td><td class="ctr2" id="e2">0%</td><td class="ctr1" id="f2">4</td><td class="ctr2" id="g2">4</td><td class="ctr1" id="h2">12</td><td class="ctr2" id="i2">12</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a0"><a href="DroneEvent.java.html#L21" class="el_method">DroneEvent(String, double, double, String)</a></td><td class="bar" id="b3"><img src="../jacoco-resources/redbar.gif" width="20" height="10" title="15" alt="15"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f3">1</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h3">1</td><td class="ctr2" id="i3">1</td><td class="ctr1" id="j3">1</td><td class="ctr2" id="k3">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DroneEvent.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_source">DroneEvent.java</span></div><h1>DroneEvent.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.common;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.response.DeliveryPathResponse;
|
||||||
|
|
||||||
|
// Corresponding in Go
|
||||||
|
//
|
||||||
|
|
||||||
|
/*
|
||||||
|
* type DroneEvent struct {
|
||||||
|
* DroneID string `json:"drone_id"`
|
||||||
|
* Latitude float64 `json:"latitude"`
|
||||||
|
* Longitude float64 `json:"longitude"`
|
||||||
|
* Timestamp string `json:"timestamp"`
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
<span class="nc" id="L21">public record DroneEvent(</span>
|
||||||
|
String droneId,
|
||||||
|
double latitude,
|
||||||
|
double longitude,
|
||||||
|
String timestamp) {
|
||||||
|
|
||||||
|
final static int STEP = 1; // seconds between events
|
||||||
|
// Helper method that converts from DeliveryPathResponse to List<DroneEvent>
|
||||||
|
|
||||||
|
public static List<DroneEvent> fromPathResponse(DeliveryPathResponse resp) {
|
||||||
|
<span class="nc" id="L31"> List<DroneEvent> events = new java.util.ArrayList<>();</span>
|
||||||
|
<span class="nc bnc" id="L32" title="All 2 branches missed."> for (var p : resp.dronePaths()) {</span>
|
||||||
|
<span class="nc" id="L33"> String id = p.droneId() + "";</span>
|
||||||
|
<span class="nc bnc" id="L34" title="All 2 branches missed."> for (var d : p.deliveries()) {</span>
|
||||||
|
<span class="nc bnc" id="L35" title="All 2 branches missed."> for (var coord : d.flightPath()) {</span>
|
||||||
|
<span class="nc" id="L36"> String timestamp = java.time.Instant.now().toString();</span>
|
||||||
|
<span class="nc" id="L37"> events.add(new DroneEvent(</span>
|
||||||
|
id,
|
||||||
|
<span class="nc" id="L39"> coord.lat(),</span>
|
||||||
|
<span class="nc" id="L40"> coord.lng(),</span>
|
||||||
|
timestamp));
|
||||||
|
<span class="nc" id="L42"> }</span>
|
||||||
|
<span class="nc" id="L43"> }</span>
|
||||||
|
}
|
||||||
|
<span class="nc" id="L45"> return events;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method that converts from DeliveryPathResponse to List<DroneEvent>
|
||||||
|
// with base timestamp
|
||||||
|
public static List<DroneEvent> fromPathResponseWithTimestamp(DeliveryPathResponse resp,
|
||||||
|
LocalDateTime baseTimestamp) {
|
||||||
|
<span class="nc" id="L52"> List<DroneEvent> events = new java.util.ArrayList<>();</span>
|
||||||
|
<span class="nc" id="L53"> java.time.LocalDateTime timestamp = baseTimestamp;</span>
|
||||||
|
<span class="nc bnc" id="L54" title="All 2 branches missed."> for (var p : resp.dronePaths()) {</span>
|
||||||
|
<span class="nc" id="L55"> String id = String.valueOf(p.droneId());</span>
|
||||||
|
<span class="nc bnc" id="L56" title="All 2 branches missed."> for (var d : p.deliveries()) {</span>
|
||||||
|
<span class="nc bnc" id="L57" title="All 2 branches missed."> for (var coord : d.flightPath()) {</span>
|
||||||
|
<span class="nc" id="L58"> events.add(new DroneEvent(</span>
|
||||||
|
id,
|
||||||
|
<span class="nc" id="L60"> coord.lat(),</span>
|
||||||
|
<span class="nc" id="L61"> coord.lng(),</span>
|
||||||
|
<span class="nc" id="L62"> timestamp.toString()));</span>
|
||||||
|
<span class="nc" id="L63"> timestamp = timestamp.plusSeconds(STEP); // Increment timestamp for each event</span>
|
||||||
|
<span class="nc" id="L64"> }</span>
|
||||||
|
<span class="nc" id="L65"> }</span>
|
||||||
|
}
|
||||||
|
<span class="nc" id="L67"> return events;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<DroneEvent> fromPathResponseWithTimestamps(
|
||||||
|
DeliveryPathResponse resp, Map<Integer, LocalDateTime> deliveryTimestamps) {
|
||||||
|
<span class="nc" id="L72"> List<DroneEvent> events = new java.util.ArrayList<>();</span>
|
||||||
|
<span class="nc bnc" id="L73" title="All 2 branches missed."> for (var p : resp.dronePaths()) {</span>
|
||||||
|
<span class="nc" id="L74"> String id = String.valueOf(p.droneId());</span>
|
||||||
|
<span class="nc bnc" id="L75" title="All 2 branches missed."> for (var d : p.deliveries()) {</span>
|
||||||
|
<span class="nc" id="L76"> LocalDateTime timestamp = deliveryTimestamps.get(d.deliveryId());</span>
|
||||||
|
// Fallback to current time if the delivery does not carry a timestamp.
|
||||||
|
<span class="nc" id="L78"> System.out.println("Generated event for drone " + id + " at " + timestamp.toString());</span>
|
||||||
|
<span class="nc bnc" id="L79" title="All 2 branches missed."> LocalDateTime current = timestamp != null ? timestamp : LocalDateTime.now();</span>
|
||||||
|
<span class="nc bnc" id="L80" title="All 2 branches missed."> for (var coord : d.flightPath()) {</span>
|
||||||
|
<span class="nc" id="L81"> events.add(new DroneEvent(</span>
|
||||||
|
id,
|
||||||
|
<span class="nc" id="L83"> coord.lat(),</span>
|
||||||
|
<span class="nc" id="L84"> coord.lng(),</span>
|
||||||
|
<span class="nc" id="L85"> current.toString()));</span>
|
||||||
|
<span class="nc" id="L86"> current = current.plusSeconds(STEP);</span>
|
||||||
|
<span class="nc" id="L87"> }</span>
|
||||||
|
<span class="nc" id="L88"> }</span>
|
||||||
|
}
|
||||||
|
<span class="nc" id="L90"> return events;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>LngLat</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_class">LngLat</span></div><h1>LngLat</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">8 of 70</td><td class="ctr2">88%</td><td class="bar">5 of 14</td><td class="ctr2">64%</td><td class="ctr1">5</td><td class="ctr2">10</td><td class="ctr1">2</td><td class="ctr2">11</td><td class="ctr1">0</td><td class="ctr2">3</td></tr></tfoot><tbody><tr><td id="a1"><a href="LngLat.java.html#L13" class="el_method">LngLat(double, double)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="19" height="10" title="6" alt="6"/><img src="../jacoco-resources/greenbar.gif" width="100" height="10" title="31" alt="31"/></td><td class="ctr2" id="c2">83%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="45" height="10" title="3" alt="3"/><img src="../jacoco-resources/greenbar.gif" width="75" height="10" title="5" alt="5"/></td><td class="ctr2" id="e1">62%</td><td class="ctr1" id="f0">3</td><td class="ctr2" id="g0">5</td><td class="ctr1" id="h0">1</td><td class="ctr2" id="i0">6</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a href="LngLat.java.html#L30" class="el_method">isSamePoint(LngLat)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="6" height="10" title="2" alt="2"/><img src="../jacoco-resources/greenbar.gif" width="77" height="10" title="24" alt="24"/></td><td class="ctr2" id="c1">92%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="30" height="10" title="2" alt="2"/><img src="../jacoco-resources/greenbar.gif" width="60" height="10" title="4" alt="4"/></td><td class="ctr2" id="e0">66%</td><td class="ctr1" id="f1">2</td><td class="ctr2" id="g1">4</td><td class="ctr1" id="h1">1</td><td class="ctr2" id="i1">3</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a2"><a href="LngLat.java.html#L26" class="el_method">LngLat(LngLatAlt)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="22" height="10" title="7" alt="7"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">2</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>LngLat.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_source">LngLat.java</span></div><h1>LngLat.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the data transfer object for a point or coordinate that defines by a longitude and
|
||||||
|
* latitude
|
||||||
|
*
|
||||||
|
* @param lng longitude of the coordinate/point
|
||||||
|
* @param lat latitude of the coordinate/point
|
||||||
|
*/
|
||||||
|
public record LngLat(double lng, double lat) {
|
||||||
|
private static final double EPSILON = 1e-9;
|
||||||
|
|
||||||
|
<span class="fc" id="L13"> public LngLat {</span>
|
||||||
|
<span class="pc bpc" id="L14" title="1 of 4 branches missed."> if (lat < -90 || lat > 90) {</span>
|
||||||
|
<span class="fc" id="L15"> throw new IllegalArgumentException(</span>
|
||||||
|
"Latitude must be between -90 and +90 degrees. Got: " + lat);
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="pc bpc" id="L19" title="2 of 4 branches missed."> if (lng < -180 || lng > 180) {</span>
|
||||||
|
<span class="nc" id="L20"> throw new IllegalArgumentException(</span>
|
||||||
|
"Longitude must be between -180 and +180 degrees. Got: " + lng);
|
||||||
|
}
|
||||||
|
<span class="fc" id="L23"> }</span>
|
||||||
|
|
||||||
|
public LngLat(LngLatAlt coord) {
|
||||||
|
<span class="fc" id="L26"> this(coord.lng(), coord.lat());</span>
|
||||||
|
<span class="fc" id="L27"> }</span>
|
||||||
|
|
||||||
|
public boolean isSamePoint(LngLat other) {
|
||||||
|
<span class="pc bpc" id="L30" title="1 of 2 branches missed."> if (other == null) {</span>
|
||||||
|
<span class="nc" id="L31"> return false;</span>
|
||||||
|
}
|
||||||
|
<span class="pc bpc" id="L33" title="1 of 4 branches missed."> return (Math.abs(lng - other.lng()) < EPSILON && Math.abs(lat - other.lat()) < EPSILON);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>LngLatAlt</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_class">LngLatAlt</span></div><h1>LngLatAlt</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 12</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="LngLatAlt.java.html#L11" class="el_method">LngLatAlt(double, double, double)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>LngLatAlt.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_source">LngLatAlt.java</span></div><h1>LngLatAlt.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the data transfer object for a point or coordinate that defines by a longitude and
|
||||||
|
* latitude
|
||||||
|
*
|
||||||
|
* @param lng longitude of the coordinate/point
|
||||||
|
* @param lat latitude of the coordinate/point
|
||||||
|
* @param alt altitude of the coordinate/point
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L11">public record LngLatAlt(double lng, double lat, double alt) {}</span>
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>Region</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_class">Region</span></div><h1>Region</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">51 of 84</td><td class="ctr2">39%</td><td class="bar">1 of 4</td><td class="ctr2">75%</td><td class="ctr1">4</td><td class="ctr2">7</td><td class="ctr1">11</td><td class="ctr2">17</td><td class="ctr1">3</td><td class="ctr2">5</td></tr></tfoot><tbody><tr><td id="a3"><a href="Region.java.html#L52" class="el_method">toGeoJson()</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="25" alt="25"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h0">6</td><td class="ctr2" id="i0">6</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a4"><a href="Region.java.html#L66" class="el_method">toGeoJsonString()</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="86" height="10" title="18" alt="18"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h1">5</td><td class="ctr2" id="i1">5</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a1"><a href="Region.java.html#L55" class="el_method">lambda$toGeoJson$0(LngLat)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="38" height="10" title="8" alt="8"/></td><td class="ctr2" id="c4">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h2">1</td><td class="ctr2" id="i3">1</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a0"><a href="Region.java.html#L42" class="el_method">isClosed()</a></td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="115" height="10" title="24" alt="24"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="30" height="10" title="1" alt="1"/><img src="../jacoco-resources/greenbar.gif" width="90" height="10" title="3" alt="3"/></td><td class="ctr2" id="e0">75%</td><td class="ctr1" id="f3">1</td><td class="ctr2" id="g0">3</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i2">5</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a2"><a href="Region.java.html#L26" class="el_method">Region(String, List)</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="43" height="10" title="9" alt="9"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">1</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>Region.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_source">Region.java</span></div><h1>Region.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.RegionCheckRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the data transfer object for a region definition
|
||||||
|
*
|
||||||
|
* <p>This record encapsulates the data for calculating if a coordinate is inside the region
|
||||||
|
*
|
||||||
|
* <p>A built-in method {@code isClosedTo} is defined to check this DTO is valid or not in the mean
|
||||||
|
* of closing polygon
|
||||||
|
*
|
||||||
|
* @param name The human-readable name for the region
|
||||||
|
* @param vertices list of coordinates that forms a polygon as a region.
|
||||||
|
* <p>In order to define a valid region, the last element of the list should be the same as the
|
||||||
|
* first, or known as closed
|
||||||
|
* @see RegionCheckRequest
|
||||||
|
* @see io.github.js0ny.ilp_coursework.service.GpsCalculationService#checkIsInRegion(LngLat, Region)
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L26">public record Region(String name, List<LngLat> vertices) {</span>
|
||||||
|
/**
|
||||||
|
* Magic number 4: For a polygon, 3 edges is required.
|
||||||
|
*
|
||||||
|
* <p>In this dto, edges + 1 vertices is required.
|
||||||
|
*/
|
||||||
|
private static final int MINIMUM_VERTICES = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to check if the region has a valid polygon by checking if the {@code vertices} forms a
|
||||||
|
* closed polygon
|
||||||
|
*
|
||||||
|
* @return {@code true} if the {@code vertices} are able to form a polygon and form a closed
|
||||||
|
* polygon
|
||||||
|
*/
|
||||||
|
public boolean isClosed() {
|
||||||
|
<span class="pc bpc" id="L42" title="1 of 4 branches missed."> if (vertices == null || vertices.size() < MINIMUM_VERTICES) {</span>
|
||||||
|
<span class="fc" id="L43"> return false;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L45"> LngLat first = vertices.getFirst();</span>
|
||||||
|
<span class="fc" id="L46"> LngLat last = vertices.getLast();</span>
|
||||||
|
<span class="fc" id="L47"> return Objects.equals(last, first);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> toGeoJson() {
|
||||||
|
try {
|
||||||
|
<span class="nc" id="L52"> ObjectMapper mapper = new ObjectMapper();</span>
|
||||||
|
|
||||||
|
<span class="nc" id="L54"> List<List<Double>> ring =</span>
|
||||||
|
<span class="nc" id="L55"> vertices.stream().map(v -> List.of(v.lng(), v.lat())).toList();</span>
|
||||||
|
|
||||||
|
<span class="nc" id="L57"> return Map.of("type", "Polygon", "coordinates", List.of(ring));</span>
|
||||||
|
|
||||||
|
<span class="nc" id="L59"> } catch (Exception e) {</span>
|
||||||
|
<span class="nc" id="L60"> throw new RuntimeException("Failed to generate GeoJSON", e);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toGeoJsonString() {
|
||||||
|
try {
|
||||||
|
<span class="nc" id="L66"> ObjectMapper mapper = new ObjectMapper();</span>
|
||||||
|
|
||||||
|
<span class="nc" id="L68"> var geoJson = toGeoJson();</span>
|
||||||
|
|
||||||
|
<span class="nc" id="L70"> return mapper.writeValueAsString(geoJson);</span>
|
||||||
|
<span class="nc" id="L71"> } catch (Exception e) {</span>
|
||||||
|
<span class="nc" id="L72"> throw new RuntimeException("Failed to generate GeoJSON", e);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>TimeWindow</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_class">TimeWindow</span></div><h1>TimeWindow</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 12</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="TimeWindow.java.html#L6" class="el_method">TimeWindow(DayOfWeek, LocalTime, LocalTime)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>TimeWindow.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.common</a> > <span class="el_source">TimeWindow.java</span></div><h1>TimeWindow.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.common;
|
||||||
|
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
<span class="fc" id="L6">public record TimeWindow(DayOfWeek dayOfWeek, LocalTime from, LocalTime until) {}</span>
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>Drone</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.external</a> > <span class="el_class">Drone</span></div><h1>Drone</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">4 of 21</td><td class="ctr2">80%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">2</td><td class="ctr1">1</td><td class="ctr2">4</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a1"><a href="Drone.java.html#L10" class="el_method">parseId()</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="40" height="10" title="4" alt="4"/><img src="../jacoco-resources/greenbar.gif" width="50" height="10" title="5" alt="5"/></td><td class="ctr2" id="c1">55%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">1</td><td class="ctr2" id="i0">3</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a href="Drone.java.html#L6" class="el_method">Drone(String, String, DroneCapability)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">1</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>Drone.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.external</a> > <span class="el_source">Drone.java</span></div><h1>Drone.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.external;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.DroneCapability;
|
||||||
|
|
||||||
|
/** Represents the data transfer object for a drone, gained from the endpoints */
|
||||||
|
<span class="fc" id="L6">public record Drone(String name, String id, DroneCapability capability) {</span>
|
||||||
|
|
||||||
|
public int parseId() {
|
||||||
|
try {
|
||||||
|
<span class="nc" id="L10"> return Integer.parseInt(id);</span>
|
||||||
|
<span class="fc" id="L11"> } catch (NumberFormatException e) {</span>
|
||||||
|
<span class="fc" id="L12"> return id.hashCode();</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>RestrictedArea</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.external</a> > <span class="el_class">RestrictedArea</span></div><h1>RestrictedArea</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 53</td><td class="ctr2">100%</td><td class="bar">0 of 2</td><td class="ctr2">100%</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">5</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a1"><a href="RestrictedArea.java.html#L13" class="el_method">toRegion()</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="38" alt="38"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="2" alt="2"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">2</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">4</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a href="RestrictedArea.java.html#L11" class="el_method">RestrictedArea(String, int, AltitudeRange, LngLatAlt[])</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="47" height="10" title="15" alt="15"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">1</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>RestrictedArea.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.external</a> > <span class="el_source">RestrictedArea.java</span></div><h1>RestrictedArea.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.external;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.AltitudeRange;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLatAlt;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.Region;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
<span class="fc" id="L11">public record RestrictedArea(String name, int id, AltitudeRange limits, LngLatAlt[] vertices) {</span>
|
||||||
|
public Region toRegion() {
|
||||||
|
<span class="fc" id="L13"> List<LngLat> vertices2D = new ArrayList<>();</span>
|
||||||
|
<span class="fc bfc" id="L14" title="All 2 branches covered."> for (var vertex : vertices) {</span>
|
||||||
|
<span class="fc" id="L15"> vertices2D.add(new LngLat(vertex.lng(), vertex.lat()));</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L17"> return new Region(name, vertices2D);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ServicePoint</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.external</a> > <span class="el_class">ServicePoint</span></div><h1>ServicePoint</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 12</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="ServicePoint.java.html#L5" class="el_method">ServicePoint(String, int, LngLatAlt)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ServicePoint.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.external</a> > <span class="el_source">ServicePoint.java</span></div><h1>ServicePoint.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.external;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLatAlt;
|
||||||
|
|
||||||
|
<span class="fc" id="L5">public record ServicePoint(String name, int id, LngLatAlt location) {}</span>
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ServicePointDrones</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.external</a> > <span class="el_class">ServicePointDrones</span></div><h1>ServicePointDrones</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">4 of 35</td><td class="ctr2">88%</td><td class="bar">2 of 4</td><td class="ctr2">50%</td><td class="ctr1">2</td><td class="ctr2">4</td><td class="ctr1">1</td><td class="ctr2">5</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="ServicePointDrones.java.html#L11" class="el_method">locateDroneById(String)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="18" height="10" title="4" alt="4"/><img src="../jacoco-resources/greenbar.gif" width="101" height="10" title="22" alt="22"/></td><td class="ctr2" id="c1">84%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="60" height="10" title="2" alt="2"/><img src="../jacoco-resources/greenbar.gif" width="60" height="10" title="2" alt="2"/></td><td class="ctr2" id="e0">50%</td><td class="ctr1" id="f0">2</td><td class="ctr2" id="g0">3</td><td class="ctr1" id="h0">1</td><td class="ctr2" id="i0">4</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="ServicePointDrones.java.html#L7" class="el_method">ServicePointDrones(int, DroneAvailability[])</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="41" height="10" title="9" alt="9"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">1</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ServicePointDrones.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.external</a> > <span class="el_source">ServicePointDrones.java</span></div><h1>ServicePointDrones.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.external;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.DroneAvailability;
|
||||||
|
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
|
<span class="fc" id="L7">public record ServicePointDrones(int servicePointId, DroneAvailability[] drones) {</span>
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public DroneAvailability locateDroneById(String droneId) {
|
||||||
|
<span class="pc bpc" id="L11" title="1 of 2 branches missed."> for (var drone : drones) {</span>
|
||||||
|
<span class="pc bpc" id="L12" title="1 of 2 branches missed."> if (drone.id().equals(droneId)) {</span>
|
||||||
|
<span class="fc" id="L13"> return drone;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<span class="nc" id="L16"> return null;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AttrQueryRequest</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_class">AttrQueryRequest</span></div><h1>AttrQueryRequest</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 12</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="AttrQueryRequest.java.html#L6" class="el_method">AttrQueryRequest(String, String, String)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AttrQueryRequest.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_source">AttrQueryRequest.java</span></div><h1>AttrQueryRequest.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.request;
|
||||||
|
|
||||||
|
// TODO: Convert operator to Enum
|
||||||
|
// import io.github.js0ny.ilp_coursework.util.AttrOperator;
|
||||||
|
|
||||||
|
<span class="fc" id="L6">public record AttrQueryRequest(String attribute, String operator, String value) {}</span>
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DistanceRequest</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_class">DistanceRequest</span></div><h1>DistanceRequest</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 9</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="DistanceRequest.java.html#L14" class="el_method">DistanceRequest(LngLat, LngLat)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="9" alt="9"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DistanceRequest.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_source">DistanceRequest.java</span></div><h1>DistanceRequest.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.request;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the data transfer object for a distance operation request.
|
||||||
|
*
|
||||||
|
* <p>This record encapsulates the data for several endpoints that involves two {@code LngLatDto}
|
||||||
|
* and serves as the data contract for those API operation
|
||||||
|
*
|
||||||
|
* @param position1 Nested object of {@link LngLat}
|
||||||
|
* @param position2 Nested object of {@link LngLat}
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L14">public record DistanceRequest(LngLat position1, LngLat position2) {}</span>
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MedDispatchRecRequest.MedRequirement</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_class">MedDispatchRecRequest.MedRequirement</span></div><h1>MedDispatchRecRequest.MedRequirement</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 15</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="MedDispatchRecRequest.java.html#L14" class="el_method">MedDispatchRecRequest.MedRequirement(float, boolean, boolean, float)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="15" alt="15"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MedDispatchRecRequest</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_class">MedDispatchRecRequest</span></div><h1>MedDispatchRecRequest</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 18</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="MedDispatchRecRequest.java.html#L11" class="el_method">MedDispatchRecRequest(int, LocalDate, LocalTime, MedDispatchRecRequest.MedRequirement, LngLat)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="18" alt="18"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MedDispatchRecRequest.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_source">MedDispatchRecRequest.java</span></div><h1>MedDispatchRecRequest.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.request;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
<span class="fc" id="L11">public record MedDispatchRecRequest(</span>
|
||||||
|
int id, LocalDate date, LocalTime time, MedRequirement requirements, LngLat delivery) {
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
<span class="fc" id="L14"> public record MedRequirement(float capacity, boolean cooling, boolean heating, float maxCost) {}</span>
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MovementRequest</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_class">MovementRequest</span></div><h1>MovementRequest</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 9</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="MovementRequest.java.html#L16" class="el_method">MovementRequest(LngLat, double)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="9" alt="9"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MovementRequest.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_source">MovementRequest.java</span></div><h1>MovementRequest.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.request;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the data transfer object for a movement action request.
|
||||||
|
*
|
||||||
|
* <p>This record encapsulates the data for endpoint /api/v1/nextPosition and serves as the data
|
||||||
|
* contract for this API operation
|
||||||
|
*
|
||||||
|
* @param start The starting coordinate of the movement
|
||||||
|
* @param angle The angle to movement in degree. This corresponds to compass directions. For
|
||||||
|
* example: 0 for East, 90 for North
|
||||||
|
* @see io.github.js0ny.ilp_coursework.controller.ApiController#getNextPosition(MovementRequest)
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L16">public record MovementRequest(LngLat start, double angle) {}</span>
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>RegionCheckRequest</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_class">RegionCheckRequest</span></div><h1>RegionCheckRequest</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 9</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="RegionCheckRequest.java.html#L18" class="el_method">RegionCheckRequest(LngLat, Region)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="9" alt="9"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>RegionCheckRequest.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.request</a> > <span class="el_source">RegionCheckRequest.java</span></div><h1>RegionCheckRequest.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.request;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.Region;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the data transfer object for a region check request.
|
||||||
|
*
|
||||||
|
* <p>This record encapsulates the data for endpoint /api/v1/isInRegion and serves as the data
|
||||||
|
* contract for this API operation
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param position The coordinate to be checked
|
||||||
|
* @param region The region for the check. This is a nested object represented by {@link Region}
|
||||||
|
* @see io.github.js0ny.ilp_coursework.controller.ApiController#getIsInRegion(RegionCheckRequest)
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L18">public record RegionCheckRequest(LngLat position, Region region) {}</span>
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DeliveryPathResponse.DronePath.Delivery</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.response</a> > <span class="el_class">DeliveryPathResponse.DronePath.Delivery</span></div><h1>DeliveryPathResponse.DronePath.Delivery</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 9</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="DeliveryPathResponse.java.html#L9" class="el_method">DeliveryPathResponse.DronePath.Delivery(int, List)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="9" alt="9"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DeliveryPathResponse.DronePath</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.response</a> > <span class="el_class">DeliveryPathResponse.DronePath</span></div><h1>DeliveryPathResponse.DronePath</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 9</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="DeliveryPathResponse.java.html#L8" class="el_method">DeliveryPathResponse.DronePath(int, List)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="9" alt="9"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DeliveryPathResponse</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.data.response</a> > <span class="el_class">DeliveryPathResponse</span></div><h1>DeliveryPathResponse</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 12</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="DeliveryPathResponse.java.html#L7" class="el_method">DeliveryPathResponse(float, int, DeliveryPathResponse.DronePath[])</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DeliveryPathResponse.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.data.response</a> > <span class="el_source">DeliveryPathResponse.java</span></div><h1>DeliveryPathResponse.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.data.response;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
<span class="fc" id="L7">public record DeliveryPathResponse(float totalCost, int totalMoves, DronePath[] dronePaths) {</span>
|
||||||
|
<span class="fc" id="L8"> public record DronePath(int droneId, List<Delivery> deliveries) {</span>
|
||||||
|
<span class="fc" id="L9"> public record Delivery(int deliveryId, List<LngLat> flightPath) {}</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.data.response</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.source.html" class="el_source">Source Files</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.data.response</span></div><h1>io.github.js0ny.ilp_coursework.data.response</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 30</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">3</td></tr></tfoot><tbody><tr><td id="a0"><a href="DeliveryPathResponse.html" class="el_class">DeliveryPathResponse</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a1"><a href="DeliveryPathResponse$DronePath.html" class="el_class">DeliveryPathResponse.DronePath</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="90" height="10" title="9" alt="9"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">1</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m1">1</td></tr><tr><td id="a2"><a href="DeliveryPathResponse$DronePath$Delivery.html" class="el_class">DeliveryPathResponse.DronePath.Delivery</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="90" height="10" title="9" alt="9"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">1</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m2">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.data.response</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.html" class="el_class">Classes</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.data.response</span></div><h1>io.github.js0ny.ilp_coursework.data.response</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 30</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">3</td></tr></tfoot><tbody><tr><td id="a0"><a href="DeliveryPathResponse.java.html" class="el_source">DeliveryPathResponse.java</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="30" alt="30"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">3</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">3</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">3</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">3</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>GlobalExceptionHandler.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.exception</a> > <span class="el_source">GlobalExceptionHandler.java</span></div><h1>GlobalExceptionHandler.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.exception;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/** Class that handles exception or failed request. Map all error requests to 400. */
|
||||||
|
@RestControllerAdvice
|
||||||
|
<span class="fc" id="L16">public class GlobalExceptionHandler {</span>
|
||||||
|
|
||||||
|
/// Use a logger to save logs instead of passing them to user
|
||||||
|
<span class="fc" id="L19"> private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);</span>
|
||||||
|
<span class="fc" id="L20"> private final Map<String, String> badRequestMap =</span>
|
||||||
|
<span class="fc" id="L21"> Map.of("status", "400", "error", "Bad Request");</span>
|
||||||
|
|
||||||
|
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
public Map<String, String> handleHttpMessageNotReadable(HttpMessageNotReadableException ex) {
|
||||||
|
<span class="fc" id="L26"> log.warn("Malformed JSON received: {}", ex.getMessage());</span>
|
||||||
|
<span class="fc" id="L27"> return badRequestMap;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(IllegalArgumentException.class)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
public Map<String, String> handleIllegalArgument(IllegalArgumentException ex) {
|
||||||
|
<span class="fc" id="L33"> String errorMessage =</span>
|
||||||
|
<span class="fc" id="L34"> Optional.ofNullable(ex.getMessage()).orElse("Invalid argument provided.");</span>
|
||||||
|
<span class="fc" id="L35"> log.warn("Illegal argument in request: {}", errorMessage);</span>
|
||||||
|
<span class="fc" id="L36"> return badRequestMap;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(NullPointerException.class)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
public Map<String, String> handleNullPointerException(Exception ex) {
|
||||||
|
<span class="fc" id="L42"> log.error("NullPointerException occurred. Return 400 by default.", ex);</span>
|
||||||
|
<span class="fc" id="L43"> return badRequestMap;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
public Map<String, String> handleGeneralException(Exception ex) {
|
||||||
|
<span class="fc" id="L49"> log.error("Fallback exception received: {}", ex.getMessage());</span>
|
||||||
|
<span class="fc" id="L50"> return badRequestMap;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.exception</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.source.html" class="el_source">Source Files</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.exception</span></div><h1>io.github.js0ny.ilp_coursework.exception</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 51</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">6</td><td class="ctr1">0</td><td class="ctr2">14</td><td class="ctr1">0</td><td class="ctr2">6</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="GlobalExceptionHandler.html" class="el_class">GlobalExceptionHandler</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="51" alt="51"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">6</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">14</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">6</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.exception</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.html" class="el_class">Classes</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.exception</span></div><h1>io.github.js0ny.ilp_coursework.exception</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 51</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">6</td><td class="ctr1">0</td><td class="ctr2">14</td><td class="ctr1">0</td><td class="ctr2">6</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="GlobalExceptionHandler.java.html" class="el_source">GlobalExceptionHandler.java</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="51" alt="51"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">6</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">14</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">6</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DroneAttrComparatorService.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.service</a> > <span class="el_source">DroneAttrComparatorService.java</span></div><h1>DroneAttrComparatorService.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.service;
|
||||||
|
|
||||||
|
import static io.github.js0ny.ilp_coursework.util.AttrComparator.isValueMatched;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.Drone;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.AttrQueryRequest;
|
||||||
|
import io.github.js0ny.ilp_coursework.util.AttrOperator;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DroneAttrComparatorService {
|
||||||
|
|
||||||
|
private final String baseUrl;
|
||||||
|
<span class="fc" id="L27"> private final String dronesEndpoint = "drones";</span>
|
||||||
|
<span class="fc" id="L28"> private final RestTemplate restTemplate = new RestTemplate();</span>
|
||||||
|
|
||||||
|
/** Constructor, handles the base url here. */
|
||||||
|
<span class="fc" id="L31"> public DroneAttrComparatorService() {</span>
|
||||||
|
<span class="fc" id="L32"> String baseUrl = System.getenv("ILP_ENDPOINT");</span>
|
||||||
|
<span class="pc bpc" id="L33" title="3 of 4 branches missed."> if (baseUrl == null || baseUrl.isBlank()) {</span>
|
||||||
|
<span class="fc" id="L34"> this.baseUrl = "https://ilp-rest-2025-bvh6e9hschfagrgy.ukwest-01.azurewebsites.net/";</span>
|
||||||
|
} else {
|
||||||
|
// Defensive: Add '/' to the end of the URL
|
||||||
|
<span class="nc bnc" id="L37" title="All 2 branches missed."> if (!baseUrl.endsWith("/")) {</span>
|
||||||
|
<span class="nc" id="L38"> baseUrl += "/";</span>
|
||||||
|
}
|
||||||
|
<span class="nc" id="L40"> this.baseUrl = baseUrl;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L42"> }</span>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of ids of drones with a given attribute name and value.
|
||||||
|
*
|
||||||
|
* <p>Associated service method with {@code /queryAsPath/{attrName}/{attrVal}}
|
||||||
|
*
|
||||||
|
* @param attrName the attribute name to filter on
|
||||||
|
* @param attrVal the attribute value to filter on
|
||||||
|
* @return array of drone ids matching the attribute name and value
|
||||||
|
* @see #dronesWithAttributeCompared(String, String, AttrOperator)
|
||||||
|
* @see io.github.js0ny.ilp_coursework.controller.DroneController#getIdByAttrMap
|
||||||
|
*/
|
||||||
|
public List<String> dronesWithAttribute(String attrName, String attrVal) {
|
||||||
|
// Call the helper with EQ operator
|
||||||
|
<span class="fc" id="L57"> return dronesWithAttributeCompared(attrName, attrVal, AttrOperator.EQ);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of ids of drones which matches all given complex comparing rules
|
||||||
|
*
|
||||||
|
* @param attrComparators The filter rule with Name, Value and Operator
|
||||||
|
* @return array of drone ids that matches all rules
|
||||||
|
*/
|
||||||
|
public List<String> dronesSatisfyingAttributes(AttrQueryRequest[] attrComparators) {
|
||||||
|
<span class="fc" id="L67"> Set<String> matchingDroneIds = null;</span>
|
||||||
|
<span class="fc bfc" id="L68" title="All 2 branches covered."> for (var comparator : attrComparators) {</span>
|
||||||
|
<span class="fc" id="L69"> String attribute = comparator.attribute();</span>
|
||||||
|
<span class="fc" id="L70"> String operator = comparator.operator();</span>
|
||||||
|
<span class="fc" id="L71"> String value = comparator.value();</span>
|
||||||
|
<span class="fc" id="L72"> AttrOperator op = AttrOperator.fromString(operator);</span>
|
||||||
|
<span class="fc" id="L73"> List<String> ids = dronesWithAttributeCompared(attribute, value, op);</span>
|
||||||
|
<span class="fc bfc" id="L74" title="All 2 branches covered."> if (matchingDroneIds == null) {</span>
|
||||||
|
<span class="fc" id="L75"> matchingDroneIds = new HashSet<>(ids);</span>
|
||||||
|
} else {
|
||||||
|
<span class="fc" id="L77"> matchingDroneIds.retainAll(ids);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<span class="fc bfc" id="L80" title="All 2 branches covered."> if (matchingDroneIds == null) {</span>
|
||||||
|
<span class="fc" id="L81"> return new ArrayList<>();</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L83"> return matchingDroneIds.stream().toList();</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper that wraps the dynamic querying with different comparison operators
|
||||||
|
*
|
||||||
|
* <p>This method act as a concatenation of {@link
|
||||||
|
* io.github.js0ny.ilp_coursework.util.AttrComparator#isValueMatched(JsonNode, String,
|
||||||
|
* AttrOperator)}
|
||||||
|
*
|
||||||
|
* @param attrName the attribute name to filter on
|
||||||
|
* @param attrVal the attribute value to filter on
|
||||||
|
* @param op the comparison operator
|
||||||
|
* @return array of drone ids matching the attribute name and value (filtered by {@code op})
|
||||||
|
* @see io.github.js0ny.ilp_coursework.util.AttrComparator#isValueMatched(JsonNode, String,
|
||||||
|
* AttrOperator)
|
||||||
|
*/
|
||||||
|
private List<String> dronesWithAttributeCompared(
|
||||||
|
String attrName, String attrVal, AttrOperator op) {
|
||||||
|
<span class="fc" id="L102"> URI droneUrl = URI.create(baseUrl).resolve(dronesEndpoint);</span>
|
||||||
|
// This is required to make sure the response is valid
|
||||||
|
<span class="fc" id="L104"> Drone[] drones = restTemplate.getForObject(droneUrl, Drone[].class);</span>
|
||||||
|
|
||||||
|
<span class="pc bpc" id="L106" title="1 of 2 branches missed."> if (drones == null) {</span>
|
||||||
|
<span class="nc" id="L107"> return new ArrayList<>();</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use Jackson's ObjectMapper to convert DroneDto to JsonNode for dynamic
|
||||||
|
// querying
|
||||||
|
<span class="fc" id="L112"> ObjectMapper mapper = new ObjectMapper();</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L114"> return Arrays.stream(drones)</span>
|
||||||
|
<span class="fc" id="L115"> .filter(</span>
|
||||||
|
drone -> {
|
||||||
|
<span class="fc" id="L117"> JsonNode node = mapper.valueToTree(drone);</span>
|
||||||
|
<span class="fc" id="L118"> JsonNode attrNode = node.findValue(attrName);</span>
|
||||||
|
<span class="pc bpc" id="L119" title="1 of 2 branches missed."> if (attrNode != null) {</span>
|
||||||
|
// Manually handle different types of JsonNode
|
||||||
|
<span class="fc" id="L121"> return isValueMatched(attrNode, attrVal, op);</span>
|
||||||
|
} else {
|
||||||
|
<span class="nc" id="L123"> return false;</span>
|
||||||
|
}
|
||||||
|
})
|
||||||
|
<span class="fc" id="L126"> .map(Drone::id)</span>
|
||||||
|
<span class="fc" id="L127"> .collect(Collectors.toList());</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,271 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DroneInfoService.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.service</a> > <span class="el_source">DroneInfoService.java</span></div><h1>DroneInfoService.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.service;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.Drone;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.RestrictedArea;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.ServicePoint;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.ServicePointDrones;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.MedDispatchRecRequest;
|
||||||
|
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
<span class="fc" id="L21">@Service</span>
|
||||||
|
public class DroneInfoService {
|
||||||
|
|
||||||
|
private final String baseUrl;
|
||||||
|
<span class="fc" id="L25"> private final String dronesForServicePointsEndpoint = "drones-for-service-points";</span>
|
||||||
|
public static final String servicePointsEndpoint = "service-points";
|
||||||
|
public static final String restrictedAreasEndpoint = "restricted-areas";
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate;
|
||||||
|
|
||||||
|
/** Constructor, handles the base url here. */
|
||||||
|
public DroneInfoService() {
|
||||||
|
<span class="fc" id="L33"> this(new RestTemplate());</span>
|
||||||
|
<span class="fc" id="L34"> }</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L36"> public DroneInfoService(RestTemplate restTemplate) {</span>
|
||||||
|
<span class="fc" id="L37"> this.restTemplate = restTemplate;</span>
|
||||||
|
<span class="fc" id="L38"> String baseUrl = System.getenv("ILP_ENDPOINT");</span>
|
||||||
|
<span class="pc bpc" id="L39" title="3 of 4 branches missed."> if (baseUrl == null || baseUrl.isBlank()) {</span>
|
||||||
|
<span class="fc" id="L40"> this.baseUrl = "https://ilp-rest-2025-bvh6e9hschfagrgy.ukwest-01.azurewebsites.net/";</span>
|
||||||
|
} else {
|
||||||
|
// Defensive: Add '/' to the end of the URL
|
||||||
|
<span class="nc bnc" id="L43" title="All 2 branches missed."> if (!baseUrl.endsWith("/")) {</span>
|
||||||
|
<span class="nc" id="L44"> baseUrl += "/";</span>
|
||||||
|
}
|
||||||
|
<span class="nc" id="L46"> this.baseUrl = baseUrl;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L48"> }</span>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of ids of drones with/without cooling capability
|
||||||
|
*
|
||||||
|
* <p>Associated service method with {@code /dronesWithCooling/{state}}
|
||||||
|
*
|
||||||
|
* @param state determines the capability filtering
|
||||||
|
* @return if {@code state} is true, return ids of drones with cooling capability, else without
|
||||||
|
* cooling
|
||||||
|
* @see
|
||||||
|
* io.github.js0ny.ilp_coursework.controller.DroneController#getDronesWithCoolingCapability(boolean)
|
||||||
|
*/
|
||||||
|
public List<String> dronesWithCooling(boolean state) {
|
||||||
|
// URI droneUrl = URI.create(baseUrl).resolve(dronesEndpoint);
|
||||||
|
// Drone[] drones = restTemplate.getForObject(droneUrl, Drone[].class);
|
||||||
|
<span class="fc" id="L64"> List<Drone> drones = fetchAllDrones();</span>
|
||||||
|
|
||||||
|
<span class="pc bpc" id="L66" title="1 of 2 branches missed."> if (drones == null) {</span>
|
||||||
|
<span class="nc" id="L67"> return new ArrayList<>();</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L70"> return drones.stream()</span>
|
||||||
|
<span class="fc bfc" id="L71" title="All 2 branches covered."> .filter(drone -> drone.capability().cooling() == state)</span>
|
||||||
|
<span class="fc" id="L72"> .map(Drone::id)</span>
|
||||||
|
<span class="fc" id="L73"> .collect(Collectors.toList());</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a {@link Drone}-style json data structure with the given {@code id}
|
||||||
|
*
|
||||||
|
* <p>Associated service method with {@code /droneDetails/{id}}
|
||||||
|
*
|
||||||
|
* @param id The id of the drone
|
||||||
|
* @return drone json body of given id
|
||||||
|
* @throws NullPointerException when cannot fetch available drones from remote
|
||||||
|
* @throws IllegalArgumentException when drone with given {@code id} cannot be found this should
|
||||||
|
* lead to a 404
|
||||||
|
* @see io.github.js0ny.ilp_coursework.controller.DroneController#getDroneDetail(String)
|
||||||
|
*/
|
||||||
|
public Drone droneDetail(String id) {
|
||||||
|
<span class="fc" id="L89"> List<Drone> drones = fetchAllDrones();</span>
|
||||||
|
|
||||||
|
<span class="fc bfc" id="L91" title="All 2 branches covered."> for (var drone : drones) {</span>
|
||||||
|
<span class="fc bfc" id="L92" title="All 2 branches covered."> if (drone.id().equals(id)) {</span>
|
||||||
|
<span class="fc" id="L93"> return drone;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L95"> }</span>
|
||||||
|
|
||||||
|
// This will result in 404
|
||||||
|
<span class="fc" id="L98"> throw new IllegalArgumentException("drone with that ID cannot be found");</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of ids of drones that match all the requirements in the medical dispatch
|
||||||
|
* records
|
||||||
|
*
|
||||||
|
* <p>Associated service method with
|
||||||
|
*
|
||||||
|
* @param rec array of medical dispatch records
|
||||||
|
* @return List of drone ids that match all the requirements
|
||||||
|
* @see io.github.js0ny.ilp_coursework.controller.DroneController#queryAvailableDrones
|
||||||
|
*/
|
||||||
|
public List<String> dronesMatchesRequirements(MedDispatchRecRequest[] rec) {
|
||||||
|
<span class="fc" id="L112"> List<Drone> drones = fetchAllDrones();</span>
|
||||||
|
|
||||||
|
<span class="fc bfc" id="L114" title="All 4 branches covered."> if (rec == null || rec.length == 0) {</span>
|
||||||
|
<span class="fc" id="L115"> return drones.stream()</span>
|
||||||
|
<span class="fc" id="L116"> .filter(Objects::nonNull)</span>
|
||||||
|
<span class="fc" id="L117"> .map(Drone::id)</span>
|
||||||
|
<span class="fc" id="L118"> .collect(Collectors.toList());</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Traverse and filter drones, pass every record's requirement to helper
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L124"> return drones.stream()</span>
|
||||||
|
<span class="pc bpc" id="L125" title="2 of 4 branches missed."> .filter(d -> d != null && d.capability() != null)</span>
|
||||||
|
<span class="fc" id="L126"> .filter(</span>
|
||||||
|
d ->
|
||||||
|
<span class="fc" id="L128"> Arrays.stream(rec)</span>
|
||||||
|
<span class="pc bpc" id="L129" title="2 of 4 branches missed."> .filter(r -> r != null && r.requirements() != null)</span>
|
||||||
|
<span class="fc" id="L130"> .allMatch(r -> droneMatchesRequirement(d, r)))</span>
|
||||||
|
<span class="fc" id="L131"> .map(Drone::id)</span>
|
||||||
|
<span class="fc" id="L132"> .collect(Collectors.toList());</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to check if a drone meets the requirement of a medical dispatch.
|
||||||
|
*
|
||||||
|
* @param drone the drone to be checked
|
||||||
|
* @param record the medical dispatch record containing the requirement
|
||||||
|
* @return true if the drone meets the requirement, false otherwise
|
||||||
|
* @throws IllegalArgumentException when record requirements or drone capability is invalid
|
||||||
|
* (capacity and id cannot be null in {@code MedDispathRecDto})
|
||||||
|
*/
|
||||||
|
public boolean droneMatchesRequirement(Drone drone, MedDispatchRecRequest record) {
|
||||||
|
<span class="fc" id="L145"> var requirements = record.requirements();</span>
|
||||||
|
<span class="fc bfc" id="L146" title="All 2 branches covered."> if (requirements == null) {</span>
|
||||||
|
<span class="fc" id="L147"> throw new IllegalArgumentException("requirements cannot be null");</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L149"> var capability = drone.capability();</span>
|
||||||
|
<span class="fc bfc" id="L150" title="All 2 branches covered."> if (capability == null) {</span>
|
||||||
|
<span class="fc" id="L151"> throw new IllegalArgumentException("drone capability cannot be null");</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L154"> float requiredCapacity = requirements.capacity();</span>
|
||||||
|
<span class="pc bpc" id="L155" title="1 of 4 branches missed."> if (requiredCapacity <= 0 || capability.capacity() < requiredCapacity) {</span>
|
||||||
|
<span class="fc" id="L156"> return false;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use boolean wrapper to allow null (not specified) values
|
||||||
|
<span class="fc" id="L160"> boolean requiredCooling = requirements.cooling();</span>
|
||||||
|
<span class="fc" id="L161"> boolean requiredHeating = requirements.heating();</span>
|
||||||
|
|
||||||
|
// Case 1: required is null: We don't care about it
|
||||||
|
// Case 2: required is false: We don't care about it (high capability adapts to
|
||||||
|
// low requirements)
|
||||||
|
// Case 3: capability is true: Then always matches
|
||||||
|
// See: https://piazza.com/class/me9vp64lfgf4sn/post/100
|
||||||
|
<span class="pc bpc" id="L168" title="2 of 4 branches missed."> boolean matchesCooling = !requiredCooling || capability.cooling();</span>
|
||||||
|
<span class="pc bpc" id="L169" title="3 of 4 branches missed."> boolean matchesHeating = !requiredHeating || capability.heating();</span>
|
||||||
|
|
||||||
|
// Conditions: All requirements matched + availability matched, use helper
|
||||||
|
// For minimal privilege, only pass drone id to check availability
|
||||||
|
<span class="pc bpc" id="L173" title="3 of 6 branches missed."> return (matchesCooling && matchesHeating && checkAvailability(drone.id(), record)); // &&</span>
|
||||||
|
// checkCost(drone, record) // checkCost is more expensive than
|
||||||
|
// checkAvailability
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to check if a drone is available at the required date and time
|
||||||
|
*
|
||||||
|
* @param droneId the id of the drone to be checked
|
||||||
|
* @param record the medical dispatch record containing the required date and time
|
||||||
|
* @return true if the drone is available, false otherwise
|
||||||
|
*/
|
||||||
|
private boolean checkAvailability(String droneId, MedDispatchRecRequest record) {
|
||||||
|
<span class="fc" id="L186"> URI droneUrl = URI.create(baseUrl).resolve(dronesForServicePointsEndpoint);</span>
|
||||||
|
<span class="fc" id="L187"> ServicePointDrones[] servicePoints =</span>
|
||||||
|
<span class="fc" id="L188"> restTemplate.getForObject(droneUrl, ServicePointDrones[].class);</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L190"> LocalDate requiredDate = record.date();</span>
|
||||||
|
<span class="fc" id="L191"> DayOfWeek requiredDay = requiredDate.getDayOfWeek();</span>
|
||||||
|
<span class="fc" id="L192"> LocalTime requiredTime = record.time();</span>
|
||||||
|
|
||||||
|
<span class="pc bpc" id="L194" title="1 of 2 branches missed."> assert servicePoints != null;</span>
|
||||||
|
<span class="pc bpc" id="L195" title="1 of 2 branches missed."> for (var servicePoint : servicePoints) {</span>
|
||||||
|
<span class="fc" id="L196"> var drone = servicePoint.locateDroneById(droneId); // Nullable</span>
|
||||||
|
<span class="pc bpc" id="L197" title="1 of 2 branches missed."> if (drone != null) {</span>
|
||||||
|
<span class="fc" id="L198"> return drone.checkAvailability(requiredDay, requiredTime);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="nc" id="L202"> return false;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
private LngLat queryServicePointLocationByDroneId(String droneId) {
|
||||||
|
<span class="nc" id="L206"> URI droneUrl = URI.create(baseUrl).resolve(dronesForServicePointsEndpoint);</span>
|
||||||
|
<span class="nc" id="L207"> ServicePointDrones[] servicePoints =</span>
|
||||||
|
<span class="nc" id="L208"> restTemplate.getForObject(droneUrl, ServicePointDrones[].class);</span>
|
||||||
|
|
||||||
|
<span class="nc bnc" id="L210" title="All 2 branches missed."> assert servicePoints != null;</span>
|
||||||
|
<span class="nc bnc" id="L211" title="All 2 branches missed."> for (var sp : servicePoints) {</span>
|
||||||
|
<span class="nc" id="L212"> var drone = sp.locateDroneById(droneId); // Nullable</span>
|
||||||
|
<span class="nc bnc" id="L213" title="All 2 branches missed."> if (drone != null) {</span>
|
||||||
|
<span class="nc" id="L214"> return queryServicePointLocation(sp.servicePointId());</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="nc" id="L218"> return null;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private LngLat queryServicePointLocation(int id) {
|
||||||
|
<span class="nc" id="L223"> URI servicePointUrl = URI.create(baseUrl).resolve(servicePointsEndpoint);</span>
|
||||||
|
|
||||||
|
<span class="nc" id="L225"> ServicePoint[] servicePoints =</span>
|
||||||
|
<span class="nc" id="L226"> restTemplate.getForObject(servicePointUrl, ServicePoint[].class);</span>
|
||||||
|
|
||||||
|
<span class="nc bnc" id="L228" title="All 2 branches missed."> assert servicePoints != null;</span>
|
||||||
|
<span class="nc bnc" id="L229" title="All 2 branches missed."> for (var sp : servicePoints) {</span>
|
||||||
|
<span class="nc bnc" id="L230" title="All 2 branches missed."> if (sp.id() == id) {</span>
|
||||||
|
// We dont consider altitude
|
||||||
|
<span class="nc" id="L232"> return new LngLat(sp.location());</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<span class="nc" id="L235"> return null;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Drone> fetchAllDrones() {
|
||||||
|
<span class="fc" id="L239"> System.out.println("fetchAllDrones called");</span>
|
||||||
|
<span class="fc" id="L240"> String dronesEndpoint = "drones";</span>
|
||||||
|
<span class="fc" id="L241"> URI droneUrl = URI.create(baseUrl).resolve(dronesEndpoint);</span>
|
||||||
|
<span class="fc" id="L242"> System.out.println("Fetching from URL: " + droneUrl);</span>
|
||||||
|
<span class="fc" id="L243"> Drone[] drones = restTemplate.getForObject(droneUrl, Drone[].class);</span>
|
||||||
|
<span class="fc bfc" id="L244" title="All 2 branches covered."> return drones == null ? new ArrayList<>() : Arrays.asList(drones);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RestrictedArea> fetchRestrictedAreas() {
|
||||||
|
<span class="fc" id="L248"> URI restrictedUrl = URI.create(baseUrl).resolve(restrictedAreasEndpoint);</span>
|
||||||
|
<span class="fc" id="L249"> RestrictedArea[] restrictedAreas =</span>
|
||||||
|
<span class="fc" id="L250"> restTemplate.getForObject(restrictedUrl, RestrictedArea[].class);</span>
|
||||||
|
<span class="pc bpc" id="L251" title="1 of 2 branches missed."> assert restrictedAreas != null;</span>
|
||||||
|
<span class="fc" id="L252"> return Arrays.asList(restrictedAreas);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ServicePoint> fetchServicePoints() {
|
||||||
|
<span class="fc" id="L256"> URI servicePointUrl = URI.create(baseUrl).resolve(servicePointsEndpoint);</span>
|
||||||
|
<span class="fc" id="L257"> ServicePoint[] servicePoints =</span>
|
||||||
|
<span class="fc" id="L258"> restTemplate.getForObject(servicePointUrl, ServicePoint[].class);</span>
|
||||||
|
<span class="pc bpc" id="L259" title="1 of 2 branches missed."> assert servicePoints != null;</span>
|
||||||
|
<span class="fc" id="L260"> return Arrays.asList(servicePoints);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ServicePointDrones> fetchDronesForServicePoints() {
|
||||||
|
<span class="fc" id="L264"> URI servicePointDronesUrl = URI.create(baseUrl).resolve(dronesForServicePointsEndpoint);</span>
|
||||||
|
<span class="fc" id="L265"> ServicePointDrones[] servicePointDrones =</span>
|
||||||
|
<span class="fc" id="L266"> restTemplate.getForObject(servicePointDronesUrl, ServicePointDrones[].class);</span>
|
||||||
|
<span class="pc bpc" id="L267" title="1 of 2 branches missed."> assert servicePointDrones != null;</span>
|
||||||
|
<span class="fc" id="L268"> return Arrays.asList(servicePointDrones);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,190 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>GpsCalculationService.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.service</a> > <span class="el_source">GpsCalculationService.java</span></div><h1>GpsCalculationService.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.service;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.Angle;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.Region;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.DistanceRequest;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.MovementRequest;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.RegionCheckRequest;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that handles calculations about Coordinates
|
||||||
|
*
|
||||||
|
* @see LngLat
|
||||||
|
* @see Region
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
<span class="fc" id="L21">public class GpsCalculationService {</span>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given step size
|
||||||
|
*
|
||||||
|
* @see #nextPosition(LngLat, double)
|
||||||
|
*/
|
||||||
|
private static final double STEP = 0.00015;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given threshold to judge if two points are close to each other
|
||||||
|
*
|
||||||
|
* @see #isCloseTo(LngLat, LngLat)
|
||||||
|
*/
|
||||||
|
private static final double CLOSE_THRESHOLD = 0.00015;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the Euclidean distance between {@code position1} and {@code position2}, which are
|
||||||
|
* coordinates defined as {@link LngLat}
|
||||||
|
*
|
||||||
|
* @param position1 The coordinate of the first position
|
||||||
|
* @param position2 The coordinate of the second position
|
||||||
|
* @return The Euclidean distance between {@code position1} and {@code position2}
|
||||||
|
* @see io.github.js0ny.ilp_coursework.controller.ApiController#getDistance(DistanceRequest)
|
||||||
|
*/
|
||||||
|
public double calculateDistance(LngLat position1, LngLat position2) {
|
||||||
|
<span class="fc" id="L47"> double lngDistance = position2.lng() - position1.lng();</span>
|
||||||
|
<span class="fc" id="L48"> double latDistance = position2.lat() - position1.lat();</span>
|
||||||
|
// Euclidean: \sqrt{a^2 + b^2}
|
||||||
|
<span class="fc" id="L50"> return Math.sqrt(lngDistance * lngDistance + latDistance * latDistance);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
public double calculateSteps(LngLat position1, LngLat position2) {
|
||||||
|
<span class="nc" id="L54"> double distance = calculateDistance(position1, position2);</span>
|
||||||
|
<span class="nc" id="L55"> return distance / STEP;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if {@code position1} and {@code position2} are close to each other, the threshold is <
|
||||||
|
* 0.00015
|
||||||
|
*
|
||||||
|
* <p>Note that = 0.00015 will be counted as not close to and will return {@code false}
|
||||||
|
*
|
||||||
|
* @param position1 The coordinate of the first position
|
||||||
|
* @param position2 The coordinate of the second position
|
||||||
|
* @return {@code true} if {@code position1} and {@code position2} are close to each other
|
||||||
|
* @see #CLOSE_THRESHOLD
|
||||||
|
* @see io.github.js0ny.ilp_coursework.controller.ApiController#getIsCloseTo(DistanceRequest)
|
||||||
|
*/
|
||||||
|
public boolean isCloseTo(LngLat position1, LngLat position2) {
|
||||||
|
<span class="fc" id="L71"> double distance = calculateDistance(position1, position2);</span>
|
||||||
|
<span class="fc bfc" id="L72" title="All 2 branches covered."> return distance < CLOSE_THRESHOLD;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next position moved from {@code start} in the direction with {@code angle}, with
|
||||||
|
* step size 0.00015
|
||||||
|
*
|
||||||
|
* @param start The coordinate of the original start point.
|
||||||
|
* @param angle The direction to be moved in angle.
|
||||||
|
* @return The next position moved from {@code start}
|
||||||
|
* @see #STEP
|
||||||
|
* @see io.github.js0ny.ilp_coursework.controller.ApiController#getNextPosition(MovementRequest)
|
||||||
|
*/
|
||||||
|
public LngLat nextPosition(LngLat start, Angle angle) {
|
||||||
|
<span class="fc" id="L86"> double rad = angle.toRadians();</span>
|
||||||
|
<span class="fc" id="L87"> double newLng = Math.cos(rad) * STEP + start.lng();</span>
|
||||||
|
<span class="fc" id="L88"> double newLat = Math.sin(rad) * STEP + start.lat();</span>
|
||||||
|
<span class="fc" id="L89"> return new LngLat(newLng, newLat);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to check if the given {@code position} is inside the {@code region}, on edge and vertex
|
||||||
|
* is considered as inside.
|
||||||
|
*
|
||||||
|
* @param position The coordinate of the position.
|
||||||
|
* @param region A {@link Region} that contains name and a list of {@code LngLatDto}
|
||||||
|
* @return {@code true} if {@code position} is inside the {@code region}.
|
||||||
|
* @throws IllegalArgumentException If {@code region} is not closed
|
||||||
|
* @see
|
||||||
|
* io.github.js0ny.ilp_coursework.controller.ApiController#getIsInRegion(RegionCheckRequest)
|
||||||
|
* @see Region#isClosed()
|
||||||
|
*/
|
||||||
|
public boolean checkIsInRegion(LngLat position, Region region) throws IllegalArgumentException {
|
||||||
|
<span class="fc bfc" id="L105" title="All 2 branches covered."> if (!region.isClosed()) {</span>
|
||||||
|
// call method from RegionDto to check if not closed
|
||||||
|
<span class="fc" id="L107"> throw new IllegalArgumentException("Region is not closed.");</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L109"> return rayCasting(position, region.vertices());</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to {@code checkIsInRegion}, use of ray-casting algorithm to check if inside
|
||||||
|
* the polygon
|
||||||
|
*
|
||||||
|
* @param point The point to check
|
||||||
|
* @param polygon The region that forms a polygon to check if {@code point} sits inside.
|
||||||
|
* @return If the {@code point} sits inside the {@code polygon} then return {@code true}
|
||||||
|
* @see #isPointOnEdge(LngLat, LngLat, LngLat)
|
||||||
|
* @see #checkIsInRegion(LngLat, Region)
|
||||||
|
*/
|
||||||
|
private boolean rayCasting(LngLat point, List<LngLat> polygon) {
|
||||||
|
<span class="fc" id="L123"> int intersections = 0;</span>
|
||||||
|
<span class="fc" id="L124"> int n = polygon.size();</span>
|
||||||
|
<span class="fc bfc" id="L125" title="All 2 branches covered."> for (int i = 0; i < n; ++i) {</span>
|
||||||
|
<span class="fc" id="L126"> LngLat a = polygon.get(i);</span>
|
||||||
|
<span class="fc" id="L127"> LngLat b = polygon.get((i + 1) % n); // Next vertex</span>
|
||||||
|
|
||||||
|
<span class="fc bfc" id="L129" title="All 2 branches covered."> if (isPointOnEdge(point, a, b)) {</span>
|
||||||
|
<span class="fc" id="L130"> return true;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure that `a` is norther than `b`, in order to easy classification
|
||||||
|
<span class="fc bfc" id="L134" title="All 2 branches covered."> if (a.lat() > b.lat()) {</span>
|
||||||
|
<span class="fc" id="L135"> LngLat temp = a;</span>
|
||||||
|
<span class="fc" id="L136"> a = b;</span>
|
||||||
|
<span class="fc" id="L137"> b = temp;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
// The point is not between a and b in latitude mean, skip this loop
|
||||||
|
<span class="fc bfc" id="L141" title="All 4 branches covered."> if (point.lat() < a.lat() || point.lat() >= b.lat()) {</span>
|
||||||
|
<span class="fc" id="L142"> continue;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip the case of horizontal edge, already handled in `isPointOnEdge`:w
|
||||||
|
<span class="pc bpc" id="L146" title="1 of 2 branches missed."> if (a.lat() == b.lat()) {</span>
|
||||||
|
<span class="nc" id="L147"> continue;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L150"> double xIntersection =</span>
|
||||||
|
<span class="fc" id="L151"> a.lng() + ((point.lat() - a.lat()) * (b.lng() - a.lng())) / (b.lat() - a.lat());</span>
|
||||||
|
|
||||||
|
<span class="fc bfc" id="L153" title="All 2 branches covered."> if (xIntersection > point.lng()) {</span>
|
||||||
|
<span class="fc" id="L154"> ++intersections;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If intersections are odd, ray-casting returns true, which the point sits
|
||||||
|
// inside the polygon;
|
||||||
|
// If intersections are even, the point does not sit inside the polygon.
|
||||||
|
<span class="fc bfc" id="L160" title="All 2 branches covered."> return intersections % 2 == 1;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function from {@code rayCasting} that used to simply calculation <br>
|
||||||
|
* Used to check if point {@code p} is on the edge formed by {@code a} and {@code b}
|
||||||
|
*
|
||||||
|
* @param p point to be checked on the edge
|
||||||
|
* @param a point that forms the edge
|
||||||
|
* @param b point that forms the edge
|
||||||
|
* @return {@code true} if {@code p} is on {@code ab}
|
||||||
|
* @see #rayCasting(LngLat, List)
|
||||||
|
*/
|
||||||
|
private boolean isPointOnEdge(LngLat p, LngLat a, LngLat b) {
|
||||||
|
// Cross product: (p - a) × (b - a)
|
||||||
|
<span class="fc" id="L175"> double crossProduct =</span>
|
||||||
|
<span class="fc" id="L176"> (p.lng() - a.lng()) * (b.lat() - a.lat())</span>
|
||||||
|
<span class="fc" id="L177"> - (p.lat() - a.lat()) * (b.lng() - a.lng());</span>
|
||||||
|
<span class="fc bfc" id="L178" title="All 2 branches covered."> if (Math.abs(crossProduct) > 1e-9) {</span>
|
||||||
|
<span class="fc" id="L179"> return false;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L182"> boolean isWithinLng =</span>
|
||||||
|
<span class="pc bpc" id="L183" title="1 of 4 branches missed."> p.lng() >= Math.min(a.lng(), b.lng()) && p.lng() <= Math.max(a.lng(), b.lng());</span>
|
||||||
|
<span class="fc" id="L184"> boolean isWithinLat =</span>
|
||||||
|
<span class="fc bfc" id="L185" title="All 4 branches covered."> p.lat() >= Math.min(a.lat(), b.lat()) && p.lat() <= Math.max(a.lat(), b.lat());</span>
|
||||||
|
|
||||||
|
<span class="fc bfc" id="L187" title="All 4 branches covered."> return isWithinLng && isWithinLat;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>PathFinderService.PathSegment</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.service</a> > <span class="el_class">PathFinderService.PathSegment</span></div><h1>PathFinderService.PathSegment</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 27</td><td class="ctr2">100%</td><td class="bar">0 of 2</td><td class="ctr2">100%</td><td class="ctr1">0</td><td class="ctr2">3</td><td class="ctr1">0</td><td class="ctr2">4</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="PathFinderService.java.html#L538" class="el_method">appendSkippingStart(List)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="18" alt="18"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="2" alt="2"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">2</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">3</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="PathFinderService.java.html#L530" class="el_method">PathFinderService.PathSegment(List, int)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="60" height="10" title="9" alt="9"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">1</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>PathFinderService.TripResult</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.service</a> > <span class="el_class">PathFinderService.TripResult</span></div><h1>PathFinderService.TripResult</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 12</td><td class="ctr2">100%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="PathFinderService.java.html#L548" class="el_method">PathFinderService.TripResult(DeliveryPathResponse.DronePath, int, float)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">1</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,550 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>PathFinderService.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.service</a> > <span class="el_source">PathFinderService.java</span></div><h1>PathFinderService.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.controller.DroneController;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.Angle;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.DroneAvailability;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.LngLat;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.Region;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.Drone;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.RestrictedArea;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.ServicePoint;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.external.ServicePointDrones;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.request.MedDispatchRecRequest;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.response.DeliveryPathResponse;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.response.DeliveryPathResponse.DronePath;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.response.DeliveryPathResponse.DronePath.Delivery;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that handles calculations about deliverypath
|
||||||
|
*
|
||||||
|
* @see DroneInfoService
|
||||||
|
* @see DroneController
|
||||||
|
* @see DeliveryPathResponse
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PathFinderService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hard stop on how many pathfinding iterations we attempt for a single segment before bailing,
|
||||||
|
* useful for preventing infinite loops caused by precision quirks or unexpected map data.
|
||||||
|
*
|
||||||
|
* @see #computePath(LngLat, LngLat)
|
||||||
|
*/
|
||||||
|
private static final int MAX_SEGMENT_ITERATIONS = 8_000;
|
||||||
|
|
||||||
|
// Services
|
||||||
|
private final GpsCalculationService gpsCalculationService;
|
||||||
|
private final DroneInfoService droneInfoService;
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
private final List<Drone> drones;
|
||||||
|
private final Map<String, Drone> droneById;
|
||||||
|
private final Map<String, Integer> droneServicePointMap;
|
||||||
|
private final Map<Integer, LngLat> servicePointLocations;
|
||||||
|
private final List<Region> restrictedRegions;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private TelemetryService telemetryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for PathFinderService. The dependencies are injected by Spring and the
|
||||||
|
* constructor pre-computes reference maps used throughout the request lifecycle.
|
||||||
|
*
|
||||||
|
* @param gpsCalculationService Service handling geometric operations.
|
||||||
|
* @param droneInfoService Service that exposes drone metadata and capability information.
|
||||||
|
*/
|
||||||
|
public PathFinderService(
|
||||||
|
<span class="fc" id="L75"> GpsCalculationService gpsCalculationService, DroneInfoService droneInfoService) {</span>
|
||||||
|
<span class="fc" id="L76"> this.gpsCalculationService = gpsCalculationService;</span>
|
||||||
|
<span class="fc" id="L77"> this.droneInfoService = droneInfoService;</span>
|
||||||
|
<span class="fc" id="L78"> this.objectMapper = new ObjectMapper();</span>
|
||||||
|
<span class="fc" id="L79"> objectMapper.registerModule(new JavaTimeModule());</span>
|
||||||
|
<span class="fc" id="L80"> objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);</span>
|
||||||
|
<span class="fc" id="L81"> objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L83"> this.drones = droneInfoService.fetchAllDrones();</span>
|
||||||
|
<span class="fc" id="L84"> List<ServicePoint> servicePoints = droneInfoService.fetchServicePoints();</span>
|
||||||
|
<span class="fc" id="L85"> List<ServicePointDrones> servicePointAssignments =</span>
|
||||||
|
<span class="fc" id="L86"> droneInfoService.fetchDronesForServicePoints();</span>
|
||||||
|
<span class="fc" id="L87"> List<RestrictedArea> restrictedAreas = droneInfoService.fetchRestrictedAreas();</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L89"> this.droneById = this.drones.stream().collect(Collectors.toMap(Drone::id, drone -> drone));</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L91"> this.droneServicePointMap = new HashMap<>();</span>
|
||||||
|
<span class="fc bfc" id="L92" title="All 2 branches covered."> for (ServicePointDrones assignment : servicePointAssignments) {</span>
|
||||||
|
<span class="pc bpc" id="L93" title="2 of 4 branches missed."> if (assignment == null || assignment.drones() == null) {</span>
|
||||||
|
<span class="nc" id="L94"> continue;</span>
|
||||||
|
}
|
||||||
|
<span class="fc bfc" id="L96" title="All 2 branches covered."> for (DroneAvailability availability : assignment.drones()) {</span>
|
||||||
|
<span class="pc bpc" id="L97" title="2 of 4 branches missed."> if (availability == null || availability.id() == null) {</span>
|
||||||
|
<span class="nc" id="L98"> continue;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L100"> droneServicePointMap.put(availability.id(), assignment.servicePointId());</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L102"> }</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L104"> this.servicePointLocations =</span>
|
||||||
|
<span class="fc" id="L105"> servicePoints.stream()</span>
|
||||||
|
<span class="fc" id="L106"> .collect(</span>
|
||||||
|
<span class="fc" id="L107"> Collectors.toMap(</span>
|
||||||
|
<span class="fc" id="L108"> ServicePoint::id, sp -> new LngLat(sp.location())));</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L110"> this.restrictedRegions = restrictedAreas.stream().map(RestrictedArea::toRegion).toList();</span>
|
||||||
|
<span class="fc" id="L111"> }</span>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produce a delivery plan for the provided dispatch records. Deliveries are grouped per
|
||||||
|
* compatible drone and per trip to satisfy each drone move limit.
|
||||||
|
*
|
||||||
|
* @param records Dispatch records to be fulfilled.
|
||||||
|
* @return Aggregated path response with cost and move totals.
|
||||||
|
* @see #calculateDeliveryPathAsGeoJson(MedDispatchRecRequest[])
|
||||||
|
*/
|
||||||
|
public DeliveryPathResponse calculateDeliveryPath(MedDispatchRecRequest[] records) {
|
||||||
|
<span class="pc bpc" id="L122" title="2 of 4 branches missed."> if (records == null || records.length == 0) {</span>
|
||||||
|
<span class="nc" id="L123"> return new DeliveryPathResponse(0f, 0, new DronePath[0]);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L126"> Map<Integer, LocalDateTime> deliveryTimestamps = new HashMap<>();</span>
|
||||||
|
<span class="fc bfc" id="L127" title="All 2 branches covered."> for (var r : records) {</span>
|
||||||
|
<span class="pc bpc" id="L128" title="1 of 2 branches missed."> if (isRestricted(r.delivery())) {</span>
|
||||||
|
<span class="nc" id="L129"> throw new IllegalStateException(</span>
|
||||||
|
"Delivery "
|
||||||
|
<span class="nc" id="L131"> + r.id()</span>
|
||||||
|
+ " is located within a restricted area and cannot be fulfilled");
|
||||||
|
}
|
||||||
|
<span class="pc bpc" id="L134" title="2 of 4 branches missed."> if (r.date() != null && r.time() != null) {</span>
|
||||||
|
<span class="fc" id="L135"> deliveryTimestamps.put(r.id(), LocalDateTime.of(r.date(), r.time()));</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L139"> Map<String, List<MedDispatchRecRequest>> assigned = assignDeliveries(records);</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L141"> List<DronePath> paths = new ArrayList<>();</span>
|
||||||
|
<span class="fc" id="L142"> float totalCost = 0f;</span>
|
||||||
|
<span class="fc" id="L143"> int totalMoves = 0;</span>
|
||||||
|
|
||||||
|
<span class="fc bfc" id="L145" title="All 2 branches covered."> for (Map.Entry<String, List<MedDispatchRecRequest>> entry : assigned.entrySet()) {</span>
|
||||||
|
<span class="fc" id="L146"> String droneId = entry.getKey();</span>
|
||||||
|
<span class="fc" id="L147"> Drone drone = droneById.get(droneId);</span>
|
||||||
|
<span class="pc bpc" id="L148" title="1 of 2 branches missed."> if (drone == null) {</span>
|
||||||
|
<span class="nc" id="L149"> continue;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L151"> Integer spId = droneServicePointMap.get(droneId);</span>
|
||||||
|
<span class="pc bpc" id="L152" title="1 of 2 branches missed."> if (spId == null) {</span>
|
||||||
|
<span class="nc" id="L153"> continue;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L155"> LngLat servicePointLocation = servicePointLocations.get(spId);</span>
|
||||||
|
<span class="pc bpc" id="L156" title="1 of 2 branches missed."> if (servicePointLocation == null) {</span>
|
||||||
|
<span class="nc" id="L157"> continue;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L160"> List<MedDispatchRecRequest> sortedDeliveries =</span>
|
||||||
|
<span class="fc" id="L161"> entry.getValue().stream()</span>
|
||||||
|
<span class="fc" id="L162"> .sorted(</span>
|
||||||
|
<span class="fc" id="L163"> Comparator.comparingDouble(</span>
|
||||||
|
rec ->
|
||||||
|
<span class="nc" id="L165"> gpsCalculationService.calculateDistance(</span>
|
||||||
|
<span class="nc" id="L166"> servicePointLocation, rec.delivery())))</span>
|
||||||
|
<span class="fc" id="L167"> .toList();</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L169"> List<List<MedDispatchRecRequest>> trips =</span>
|
||||||
|
<span class="fc" id="L170"> splitTrips(sortedDeliveries, drone, servicePointLocation);</span>
|
||||||
|
|
||||||
|
<span class="fc bfc" id="L172" title="All 2 branches covered."> for (List<MedDispatchRecRequest> trip : trips) {</span>
|
||||||
|
<span class="fc" id="L173"> TripResult result = buildTrip(drone, servicePointLocation, trip);</span>
|
||||||
|
<span class="pc bpc" id="L174" title="1 of 2 branches missed."> if (result != null) {</span>
|
||||||
|
<span class="fc" id="L175"> totalCost += result.cost();</span>
|
||||||
|
<span class="fc" id="L176"> totalMoves += result.moves();</span>
|
||||||
|
<span class="fc" id="L177"> paths.add(result.path());</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L179"> }</span>
|
||||||
|
<span class="fc" id="L180"> }</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L182"> var resp = new DeliveryPathResponse(totalCost, totalMoves, paths.toArray(new DronePath[0]));</span>
|
||||||
|
|
||||||
|
<span class="pc bpc" id="L184" title="1 of 2 branches missed."> if (telemetryService != null) {</span>
|
||||||
|
<span class="nc" id="L185"> telemetryService.sendEventAsyncByPathResponse(resp, deliveryTimestamps);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L188"> return resp;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convenience wrapper around {@link #calculateDeliveryPath} that serializes the
|
||||||
|
* result into a
|
||||||
|
* GeoJSON FeatureCollection suitable for mapping visualization.
|
||||||
|
*
|
||||||
|
* @param records Dispatch records to be fulfilled.
|
||||||
|
*
|
||||||
|
* @return GeoJSON payload representing every delivery flight path.
|
||||||
|
*
|
||||||
|
* @throws IllegalStateException When the payload cannot be serialized.
|
||||||
|
*/
|
||||||
|
public String calculateDeliveryPathAsGeoJson(MedDispatchRecRequest[] records) {
|
||||||
|
<span class="fc" id="L203"> DeliveryPathResponse response = calculateDeliveryPath(records);</span>
|
||||||
|
<span class="fc" id="L204"> Map<String, Object> featureCollection = new LinkedHashMap<>();</span>
|
||||||
|
<span class="fc" id="L205"> featureCollection.put("type", "FeatureCollection");</span>
|
||||||
|
<span class="fc" id="L206"> List<Map<String, Object>> features = new ArrayList<>();</span>
|
||||||
|
|
||||||
|
<span class="pc bpc" id="L208" title="2 of 4 branches missed."> if (response != null && response.dronePaths() != null) {</span>
|
||||||
|
<span class="fc bfc" id="L209" title="All 2 branches covered."> for (DronePath dronePath : response.dronePaths()) {</span>
|
||||||
|
<span class="pc bpc" id="L210" title="2 of 4 branches missed."> if (dronePath == null || dronePath.deliveries() == null) {</span>
|
||||||
|
<span class="nc" id="L211"> continue;</span>
|
||||||
|
}
|
||||||
|
<span class="fc bfc" id="L213" title="All 2 branches covered."> for (Delivery delivery : dronePath.deliveries()) {</span>
|
||||||
|
<span class="fc" id="L214"> Map<String, Object> feature = new LinkedHashMap<>();</span>
|
||||||
|
<span class="fc" id="L215"> feature.put("type", "Feature");</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L217"> Map<String, Object> properties = new LinkedHashMap<>();</span>
|
||||||
|
<span class="fc" id="L218"> properties.put("droneId", dronePath.droneId());</span>
|
||||||
|
<span class="fc" id="L219"> properties.put("deliveryId", delivery.deliveryId());</span>
|
||||||
|
<span class="fc" id="L220"> feature.put("properties", properties);</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L222"> Map<String, Object> geometry = new LinkedHashMap<>();</span>
|
||||||
|
<span class="fc" id="L223"> geometry.put("type", "LineString");</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L225"> List<List<Double>> coordinates = new ArrayList<>();</span>
|
||||||
|
<span class="pc bpc" id="L226" title="1 of 2 branches missed."> if (delivery.flightPath() != null) {</span>
|
||||||
|
<span class="fc bfc" id="L227" title="All 2 branches covered."> for (LngLat point : delivery.flightPath()) {</span>
|
||||||
|
<span class="fc" id="L228"> coordinates.add(List.of(point.lng(), point.lat()));</span>
|
||||||
|
<span class="fc" id="L229"> }</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L231"> geometry.put("coordinates", coordinates);</span>
|
||||||
|
<span class="fc" id="L232"> feature.put("geometry", geometry);</span>
|
||||||
|
<span class="fc" id="L233"> features.add(feature);</span>
|
||||||
|
<span class="fc" id="L234"> }</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L238"> featureCollection.put("features", features);</span>
|
||||||
|
|
||||||
|
try {
|
||||||
|
<span class="fc" id="L241"> return objectMapper.writeValueAsString(featureCollection);</span>
|
||||||
|
<span class="nc" id="L242"> } catch (JsonProcessingException e) {</span>
|
||||||
|
<span class="nc" id="L243"> throw new IllegalStateException("Failed to generate GeoJSON payload", e);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Group dispatch records by their assigned drone, ensuring every record is routed through
|
||||||
|
* {@link #findBestDrone(MedDispatchRecRequest)} exactly once and discarding invalid entries.
|
||||||
|
*
|
||||||
|
* @param records Dispatch records to be grouped.
|
||||||
|
* @return Map keyed by drone ID with the deliveries it should service.
|
||||||
|
*/
|
||||||
|
private Map<String, List<MedDispatchRecRequest>> assignDeliveries(
|
||||||
|
MedDispatchRecRequest[] records) {
|
||||||
|
<span class="fc" id="L256"> Map<String, List<MedDispatchRecRequest>> assignments = new LinkedHashMap<>();</span>
|
||||||
|
<span class="fc bfc" id="L257" title="All 2 branches covered."> for (MedDispatchRecRequest record : records) {</span>
|
||||||
|
<span class="pc bpc" id="L258" title="2 of 4 branches missed."> if (record == null || record.delivery() == null) {</span>
|
||||||
|
<span class="nc" id="L259"> continue;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L261"> String droneId = findBestDrone(record);</span>
|
||||||
|
<span class="fc" id="L262"> assignments.computeIfAbsent(droneId, id -> new ArrayList<>()).add(record);</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L264"> return assignments;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Choose the best drone for the provided record. Currently that equates to picking the closest
|
||||||
|
* compatible drone to the delivery location.
|
||||||
|
*
|
||||||
|
* @param record Dispatch record that needs fulfillment.
|
||||||
|
* @return Identifier of the drone that should fly the mission.
|
||||||
|
* @throws IllegalStateException If no available drone can serve the request.
|
||||||
|
*/
|
||||||
|
private String findBestDrone(MedDispatchRecRequest record) {
|
||||||
|
<span class="fc" id="L276"> double bestScore = Double.MAX_VALUE;</span>
|
||||||
|
<span class="fc" id="L277"> String bestDrone = null;</span>
|
||||||
|
|
||||||
|
<span class="fc bfc" id="L279" title="All 2 branches covered."> for (Drone drone : drones) {</span>
|
||||||
|
<span class="pc bpc" id="L280" title="1 of 2 branches missed."> if (!droneInfoService.droneMatchesRequirement(drone, record)) {</span>
|
||||||
|
<span class="nc" id="L281"> continue;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L283"> String droneId = drone.id();</span>
|
||||||
|
<span class="fc" id="L284"> Integer servicePointId = droneServicePointMap.get(droneId);</span>
|
||||||
|
<span class="pc bpc" id="L285" title="1 of 2 branches missed."> if (servicePointId == null) {</span>
|
||||||
|
<span class="nc" id="L286"> continue;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L288"> LngLat servicePointLocation = servicePointLocations.get(servicePointId);</span>
|
||||||
|
<span class="pc bpc" id="L289" title="1 of 2 branches missed."> if (servicePointLocation == null) {</span>
|
||||||
|
<span class="nc" id="L290"> continue;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L293"> double distance =</span>
|
||||||
|
<span class="fc" id="L294"> gpsCalculationService.calculateDistance(</span>
|
||||||
|
<span class="fc" id="L295"> servicePointLocation, record.delivery());</span>
|
||||||
|
|
||||||
|
<span class="pc bpc" id="L297" title="1 of 2 branches missed."> if (distance < bestScore) {</span>
|
||||||
|
<span class="fc" id="L298"> bestScore = distance;</span>
|
||||||
|
<span class="fc" id="L299"> bestDrone = droneId;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L301"> }</span>
|
||||||
|
<span class="pc bpc" id="L302" title="1 of 2 branches missed."> if (bestDrone == null) {</span>
|
||||||
|
<span class="nc" id="L303"> throw new IllegalStateException("No available drone for delivery " + record.id());</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L305"> return bestDrone;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Break a sequence of deliveries into several trips that each respect the drone move limit. The
|
||||||
|
* deliveries should already be ordered by proximity for sensible grouping.
|
||||||
|
*
|
||||||
|
* @param deliveries Deliveries assigned to a drone.
|
||||||
|
* @param drone Drone that will service the deliveries.
|
||||||
|
* @param servicePoint Starting and ending point of every trip.
|
||||||
|
* @return Partitioned trips with at least one delivery each.
|
||||||
|
* @throws IllegalStateException If a single delivery exceeds the drone's move limit.
|
||||||
|
*/
|
||||||
|
private List<List<MedDispatchRecRequest>> splitTrips(
|
||||||
|
List<MedDispatchRecRequest> deliveries, Drone drone, LngLat servicePoint) {
|
||||||
|
<span class="fc" id="L320"> List<List<MedDispatchRecRequest>> trips = new ArrayList<>();</span>
|
||||||
|
<span class="fc" id="L321"> List<MedDispatchRecRequest> currentTrip = new ArrayList<>();</span>
|
||||||
|
<span class="fc bfc" id="L322" title="All 2 branches covered."> for (MedDispatchRecRequest delivery : deliveries) {</span>
|
||||||
|
<span class="fc" id="L323"> currentTrip.add(delivery);</span>
|
||||||
|
<span class="fc" id="L324"> int requiredMoves = estimateTripMoves(servicePoint, currentTrip);</span>
|
||||||
|
<span class="pc bpc" id="L325" title="1 of 2 branches missed."> if (requiredMoves > drone.capability().maxMoves()) {</span>
|
||||||
|
<span class="nc" id="L326"> currentTrip.remove(currentTrip.size() - 1);</span>
|
||||||
|
<span class="nc bnc" id="L327" title="All 2 branches missed."> if (currentTrip.isEmpty()) {</span>
|
||||||
|
<span class="nc" id="L328"> throw new IllegalStateException(</span>
|
||||||
|
"Delivery "
|
||||||
|
<span class="nc" id="L330"> + delivery.id()</span>
|
||||||
|
+ " exceeds drone "
|
||||||
|
<span class="nc" id="L332"> + drone.id()</span>
|
||||||
|
+ " move limit");
|
||||||
|
}
|
||||||
|
<span class="nc" id="L335"> trips.add(new ArrayList<>(currentTrip));</span>
|
||||||
|
<span class="nc" id="L336"> currentTrip.clear();</span>
|
||||||
|
<span class="nc" id="L337"> currentTrip.add(delivery);</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L339"> }</span>
|
||||||
|
<span class="pc bpc" id="L340" title="1 of 2 branches missed."> if (!currentTrip.isEmpty()) {</span>
|
||||||
|
<span class="fc" id="L341"> int requiredMoves = estimateTripMoves(servicePoint, currentTrip);</span>
|
||||||
|
<span class="pc bpc" id="L342" title="1 of 2 branches missed."> if (requiredMoves > drone.capability().maxMoves()) {</span>
|
||||||
|
<span class="nc" id="L343"> throw new IllegalStateException(</span>
|
||||||
|
<span class="nc" id="L344"> "Delivery plan exceeds move limit for drone " + drone.id());</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L346"> trips.add(new ArrayList<>(currentTrip));</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L348"> return trips;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a single trip for the provided drone, including the entire flight path to every
|
||||||
|
* delivery and back home. The resulting structure contains the {@link DronePath} representation
|
||||||
|
* as well as cost and moves consumed.
|
||||||
|
*
|
||||||
|
* @param drone Drone executing the trip.
|
||||||
|
* @param servicePoint Starting/ending location of the trip.
|
||||||
|
* @param deliveries Deliveries to include in the trip in execution order.
|
||||||
|
* @return Trip information or {@code null} if no deliveries are provided.
|
||||||
|
* @see DeliveryPathResponse.DronePath
|
||||||
|
*/
|
||||||
|
private TripResult buildTrip(
|
||||||
|
Drone drone, LngLat servicePoint, List<MedDispatchRecRequest> deliveries) {
|
||||||
|
<span class="pc bpc" id="L364" title="2 of 4 branches missed."> if (deliveries == null || deliveries.isEmpty()) {</span>
|
||||||
|
<span class="nc" id="L365"> return null;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L367"> List<Delivery> flightPlans = new ArrayList<>();</span>
|
||||||
|
<span class="fc" id="L368"> LngLat current = servicePoint;</span>
|
||||||
|
<span class="fc" id="L369"> int moves = 0;</span>
|
||||||
|
|
||||||
|
<span class="fc bfc" id="L371" title="All 2 branches covered."> for (int i = 0; i < deliveries.size(); i++) {</span>
|
||||||
|
<span class="fc" id="L372"> MedDispatchRecRequest delivery = deliveries.get(i);</span>
|
||||||
|
<span class="fc" id="L373"> PathSegment toDelivery = computePath(current, delivery.delivery());</span>
|
||||||
|
<span class="fc" id="L374"> List<LngLat> flightPath = new ArrayList<>(toDelivery.positions());</span>
|
||||||
|
<span class="pc bpc" id="L375" title="1 of 2 branches missed."> if (!flightPath.isEmpty()) {</span>
|
||||||
|
<span class="fc" id="L376"> LngLat last = flightPath.get(flightPath.size() - 1);</span>
|
||||||
|
<span class="pc bpc" id="L377" title="1 of 2 branches missed."> if (!last.isSamePoint(delivery.delivery())) {</span>
|
||||||
|
<span class="nc" id="L378"> flightPath.add(delivery.delivery());</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L380"> } else {</span>
|
||||||
|
<span class="nc" id="L381"> flightPath.add(current);</span>
|
||||||
|
<span class="nc" id="L382"> flightPath.add(delivery.delivery());</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L384"> flightPath.add(delivery.delivery());</span>
|
||||||
|
<span class="fc" id="L385"> moves += toDelivery.moves();</span>
|
||||||
|
|
||||||
|
<span class="pc bpc" id="L387" title="1 of 2 branches missed."> if (i == deliveries.size() - 1) {</span>
|
||||||
|
<span class="fc" id="L388"> PathSegment backHome = computePath(delivery.delivery(), servicePoint);</span>
|
||||||
|
<span class="fc" id="L389"> backHome.appendSkippingStart(flightPath);</span>
|
||||||
|
<span class="fc" id="L390"> moves += backHome.moves();</span>
|
||||||
|
<span class="fc" id="L391"> current = servicePoint;</span>
|
||||||
|
<span class="fc" id="L392"> } else {</span>
|
||||||
|
<span class="nc" id="L393"> current = delivery.delivery();</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L395"> flightPlans.add(new Delivery(delivery.id(), flightPath));</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fc" id="L398"> float cost =</span>
|
||||||
|
<span class="fc" id="L399"> drone.capability().costInitial()</span>
|
||||||
|
<span class="fc" id="L400"> + drone.capability().costFinal()</span>
|
||||||
|
<span class="fc" id="L401"> + (float) (drone.capability().costPerMove() * moves);</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L403"> DronePath path = new DronePath(drone.parseId(), flightPlans);</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L405"> return new TripResult(path, moves, cost);</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimate the number of moves a prospective trip would need by replaying the path calculation
|
||||||
|
* without mutating any persistent state.
|
||||||
|
*
|
||||||
|
* @param servicePoint Trip origin.
|
||||||
|
* @param deliveries Deliveries that would compose the trip.
|
||||||
|
* @return Total moves required to fly the proposed itinerary.
|
||||||
|
*/
|
||||||
|
private int estimateTripMoves(LngLat servicePoint, List<MedDispatchRecRequest> deliveries) {
|
||||||
|
<span class="pc bpc" id="L417" title="1 of 2 branches missed."> if (deliveries.isEmpty()) {</span>
|
||||||
|
<span class="nc" id="L418"> return 0;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L420"> int moves = 0;</span>
|
||||||
|
<span class="fc" id="L421"> LngLat current = servicePoint;</span>
|
||||||
|
<span class="fc bfc" id="L422" title="All 2 branches covered."> for (MedDispatchRecRequest delivery : deliveries) {</span>
|
||||||
|
<span class="fc" id="L423"> PathSegment segment = computePath(current, delivery.delivery());</span>
|
||||||
|
<span class="fc" id="L424"> moves += segment.moves();</span>
|
||||||
|
<span class="fc" id="L425"> current = delivery.delivery();</span>
|
||||||
|
<span class="fc" id="L426"> }</span>
|
||||||
|
<span class="fc" id="L427"> moves += computePath(current, servicePoint).moves();</span>
|
||||||
|
<span class="fc" id="L428"> return moves;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a path between {@code start} and {@code target} by repeatedly moving in snapped
|
||||||
|
* increments while avoiding restricted zones.
|
||||||
|
*
|
||||||
|
* @param start Start coordinate.
|
||||||
|
* @param target Destination coordinate.
|
||||||
|
* @return Sequence of visited coordinates and move count.
|
||||||
|
* @see #nextPosition(LngLat, LngLat)
|
||||||
|
*/
|
||||||
|
private PathSegment computePath(LngLat start, LngLat target) {
|
||||||
|
<span class="fc" id="L441"> List<LngLat> positions = new ArrayList<>();</span>
|
||||||
|
<span class="pc bpc" id="L442" title="2 of 4 branches missed."> if (start == null || target == null) {</span>
|
||||||
|
<span class="nc" id="L443"> return new PathSegment(positions, 0);</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L445"> positions.add(start);</span>
|
||||||
|
<span class="fc" id="L446"> LngLat current = start;</span>
|
||||||
|
<span class="fc" id="L447"> int iterations = 0;</span>
|
||||||
|
<span class="pc bpc" id="L448" title="1 of 4 branches missed."> while (!gpsCalculationService.isCloseTo(current, target)</span>
|
||||||
|
&& iterations < MAX_SEGMENT_ITERATIONS) {
|
||||||
|
<span class="fc" id="L450"> LngLat next = nextPosition(current, target);</span>
|
||||||
|
<span class="pc bpc" id="L451" title="1 of 2 branches missed."> if (next.isSamePoint(current)) {</span>
|
||||||
|
<span class="nc" id="L452"> break;</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L454"> positions.add(next);</span>
|
||||||
|
<span class="fc" id="L455"> current = next;</span>
|
||||||
|
<span class="fc" id="L456"> iterations++;</span>
|
||||||
|
<span class="fc" id="L457"> }</span>
|
||||||
|
<span class="pc bpc" id="L458" title="1 of 2 branches missed."> if (!positions.get(positions.size() - 1).isSamePoint(target)) {</span>
|
||||||
|
<span class="nc" id="L459"> positions.add(target);</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L461"> return new PathSegment(positions, Math.max(0, positions.size() - 1));</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the next position on the path from {@code current} toward {@code target},
|
||||||
|
* preferring the snapped angle closest to the desired heading that does not infiltrate a
|
||||||
|
* restricted region.
|
||||||
|
*
|
||||||
|
* @param current Current coordinate.
|
||||||
|
* @param target Destination coordinate.
|
||||||
|
* @return Next admissible coordinate or the original point if none can be found.
|
||||||
|
*/
|
||||||
|
private LngLat nextPosition(LngLat current, LngLat target) {
|
||||||
|
<span class="fc" id="L474"> double desiredAngle =</span>
|
||||||
|
<span class="fc" id="L475"> Math.toDegrees(</span>
|
||||||
|
<span class="fc" id="L476"> Math.atan2(target.lat() - current.lat(), target.lng() - current.lng()));</span>
|
||||||
|
<span class="fc" id="L477"> List<Angle> candidateAngles = buildAngleCandidates(desiredAngle);</span>
|
||||||
|
<span class="pc bpc" id="L478" title="1 of 2 branches missed."> for (Angle angle : candidateAngles) {</span>
|
||||||
|
<span class="fc" id="L479"> LngLat next = gpsCalculationService.nextPosition(current, angle);</span>
|
||||||
|
<span class="pc bpc" id="L480" title="1 of 2 branches missed."> if (!isRestricted(next)) {</span>
|
||||||
|
<span class="fc" id="L481"> return next;</span>
|
||||||
|
}
|
||||||
|
<span class="nc" id="L483"> }</span>
|
||||||
|
<span class="nc" id="L484"> return current;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a sequence of candidate angles centered on the desired heading, expanding symmetrically
|
||||||
|
* clockwise and counter-clockwise to explore alternative headings if the primary path is
|
||||||
|
* blocked.
|
||||||
|
*
|
||||||
|
* @param desiredAngle Bearing in degrees between current and target positions.
|
||||||
|
* @return Ordered list of candidate snapped angles.
|
||||||
|
* @see Angle#snap(double)
|
||||||
|
*/
|
||||||
|
private List<Angle> buildAngleCandidates(double desiredAngle) {
|
||||||
|
<span class="fc" id="L497"> List<Angle> angles = new LinkedList<>();</span>
|
||||||
|
<span class="fc" id="L498"> Angle snapped = Angle.snap(desiredAngle);</span>
|
||||||
|
<span class="fc" id="L499"> angles.add(snapped);</span>
|
||||||
|
<span class="fc bfc" id="L500" title="All 2 branches covered."> for (int offset = 1; offset <= 8; offset++) {</span>
|
||||||
|
<span class="fc" id="L501"> angles.add(snapped.offset(offset));</span>
|
||||||
|
<span class="fc" id="L502"> angles.add(snapped.offset(-offset));</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L504"> return angles;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the provided coordinate falls inside any restricted region.
|
||||||
|
*
|
||||||
|
* @param position Coordinate to inspect.
|
||||||
|
* @return {@code true} if the position intersects a restricted area.
|
||||||
|
* @see #restrictedRegions
|
||||||
|
*/
|
||||||
|
private boolean isRestricted(LngLat position) {
|
||||||
|
<span class="pc bpc" id="L515" title="1 of 2 branches missed."> for (Region region : restrictedRegions) {</span>
|
||||||
|
<span class="nc bnc" id="L516" title="All 2 branches missed."> if (gpsCalculationService.checkIsInRegion(position, region)) {</span>
|
||||||
|
<span class="nc" id="L517"> return true;</span>
|
||||||
|
}
|
||||||
|
<span class="nc" id="L519"> }</span>
|
||||||
|
<span class="fc" id="L520"> return false;</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of a computed path segment wrapping the visited positions and the number of
|
||||||
|
* moves taken to traverse them.
|
||||||
|
*
|
||||||
|
* @param positions Ordered coordinates that describe the path.
|
||||||
|
* @param moves Number of moves consumed by the path.
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L530"> private record PathSegment(List<LngLat> positions, int moves) {</span>
|
||||||
|
/**
|
||||||
|
* Append the positions from this segment to {@code target}, skipping the first coordinate
|
||||||
|
* as it is already represented by the last coordinate in the consumer path.
|
||||||
|
*
|
||||||
|
* @param target Mutable list to append to.
|
||||||
|
*/
|
||||||
|
private void appendSkippingStart(List<LngLat> target) {
|
||||||
|
<span class="fc bfc" id="L538" title="All 2 branches covered."> for (int i = 1; i < positions.size(); i++) {</span>
|
||||||
|
<span class="fc" id="L539"> target.add(positions.get(i));</span>
|
||||||
|
}
|
||||||
|
<span class="fc" id="L541"> }</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bundle containing the calculated {@link DronePath}, total moves and financial cost for a
|
||||||
|
* single trip.
|
||||||
|
*/
|
||||||
|
<span class="fc" id="L548"> private record TripResult(DronePath path, int moves, float cost) {}</span>
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>TelemetryService.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.service</a> > <span class="el_source">TelemetryService.java</span></div><h1>TelemetryService.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import io.github.js0ny.ilp_coursework.data.common.DroneEvent;
|
||||||
|
import io.github.js0ny.ilp_coursework.data.response.DeliveryPathResponse;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.net.http.HttpClient;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TelemetryService {
|
||||||
|
<span class="fc" id="L20"> private static final Logger log = LoggerFactory.getLogger(TelemetryService.class);</span>
|
||||||
|
|
||||||
|
private final HttpClient client;
|
||||||
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
|
private final String BLACKBOX_URL;
|
||||||
|
|
||||||
|
<span class="fc" id="L27"> public TelemetryService() {</span>
|
||||||
|
<span class="fc" id="L28"> this.client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(2)).build();</span>
|
||||||
|
|
||||||
|
<span class="fc" id="L30"> this.mapper = new ObjectMapper();</span>
|
||||||
|
<span class="fc" id="L31"> this.BLACKBOX_URL =</span>
|
||||||
|
<span class="fc" id="L32"> System.getenv().getOrDefault("BLACKBOX_ENDPOINT", "http://localhost:3000");</span>
|
||||||
|
<span class="fc" id="L33"> }</span>
|
||||||
|
|
||||||
|
public void sendEventAsyncByPathResponse(DeliveryPathResponse resp) {
|
||||||
|
<span class="nc" id="L36"> var events = DroneEvent.fromPathResponse(resp);</span>
|
||||||
|
<span class="nc bnc" id="L37" title="All 2 branches missed."> for (var event : events) {</span>
|
||||||
|
<span class="nc" id="L38"> sendEventAsync(event);</span>
|
||||||
|
<span class="nc" id="L39"> }</span>
|
||||||
|
<span class="nc" id="L40"> }</span>
|
||||||
|
|
||||||
|
public void sendEventAsyncByPathResponse(
|
||||||
|
DeliveryPathResponse resp, LocalDateTime baseTimestamp) {
|
||||||
|
<span class="nc" id="L44"> var events = DroneEvent.fromPathResponseWithTimestamp(resp, baseTimestamp);</span>
|
||||||
|
<span class="nc bnc" id="L45" title="All 2 branches missed."> for (var event : events) {</span>
|
||||||
|
<span class="nc" id="L46"> sendEventAsync(event);</span>
|
||||||
|
<span class="nc" id="L47"> }</span>
|
||||||
|
<span class="nc" id="L48"> }</span>
|
||||||
|
|
||||||
|
public void sendEventAsyncByPathResponse(
|
||||||
|
DeliveryPathResponse resp, Map<Integer, LocalDateTime> deliveryTimestamps) {
|
||||||
|
<span class="nc" id="L52"> var events = DroneEvent.fromPathResponseWithTimestamps(resp, deliveryTimestamps);</span>
|
||||||
|
<span class="nc bnc" id="L53" title="All 2 branches missed."> for (var event : events) {</span>
|
||||||
|
<span class="nc" id="L54"> sendEventAsync(event);</span>
|
||||||
|
<span class="nc" id="L55"> }</span>
|
||||||
|
<span class="nc" id="L56"> }</span>
|
||||||
|
|
||||||
|
public void sendEventAsync(DroneEvent event) {
|
||||||
|
<span class="nc" id="L59"> CompletableFuture.runAsync(</span>
|
||||||
|
() -> {
|
||||||
|
try {
|
||||||
|
<span class="nc" id="L62"> String json = mapper.writeValueAsString(event);</span>
|
||||||
|
<span class="nc" id="L63"> log.debug("Sending telemetry event: {}", json);</span>
|
||||||
|
var request =
|
||||||
|
<span class="nc" id="L65"> java.net.http.HttpRequest.newBuilder()</span>
|
||||||
|
<span class="nc" id="L66"> .uri(java.net.URI.create(BLACKBOX_URL + "/ingest"))</span>
|
||||||
|
<span class="nc" id="L67"> .header("Content-Type", "application/json")</span>
|
||||||
|
<span class="nc" id="L68"> .POST(</span>
|
||||||
|
<span class="nc" id="L69"> java.net.http.HttpRequest.BodyPublishers.ofString(</span>
|
||||||
|
json))
|
||||||
|
<span class="nc" id="L71"> .build();</span>
|
||||||
|
|
||||||
|
<span class="nc" id="L73"> client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString());</span>
|
||||||
|
<span class="nc" id="L74"> } catch (Exception e) {</span>
|
||||||
|
<span class="nc" id="L75"> log.error("Failed to send telemetry event: {}", e.getMessage());</span>
|
||||||
|
<span class="nc" id="L76"> }</span>
|
||||||
|
<span class="nc" id="L77"> });</span>
|
||||||
|
<span class="nc" id="L78"> }</span>
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AttrComparator.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.util</a> > <span class="el_source">AttrComparator.java</span></div><h1>AttrComparator.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.util;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comparator for attribute values in {@code JsonNode}.
|
||||||
|
*
|
||||||
|
* <p>This is a helper for dynamic querying.
|
||||||
|
*/
|
||||||
|
<span class="nc" id="L12">public class AttrComparator {</span>
|
||||||
|
/**
|
||||||
|
* Helper for dynamic querying, to compare the json value with given value in {@code String}.
|
||||||
|
*
|
||||||
|
* @param node The {@code JsonNode} to be compared
|
||||||
|
* @param attrVal The Value passed, in {@code String}
|
||||||
|
* @param op The comparison operator
|
||||||
|
* @return {@code true} if given values are equal, otherwise false.
|
||||||
|
*/
|
||||||
|
public static boolean isValueMatched(JsonNode node, String attrVal, AttrOperator op) {
|
||||||
|
<span class="nc bnc" id="L22" title="All 2 branches missed."> if (node.isTextual()) {</span>
|
||||||
|
<span class="nc" id="L23"> return compareStrings(node.asText(), attrVal, op);</span>
|
||||||
|
<span class="nc bnc" id="L24" title="All 2 branches missed."> } else if (node.isNumber()) {</span>
|
||||||
|
// return Double.compare(node.asDouble(), Double.parseDouble(attrVal)) == 0;
|
||||||
|
<span class="nc" id="L26"> return compareNumbers(node.decimalValue(), new BigDecimal(attrVal), op);</span>
|
||||||
|
<span class="nc bnc" id="L27" title="All 2 branches missed."> } else if (node.isBoolean()) {</span>
|
||||||
|
<span class="nc" id="L28"> return compareBooleans(node.asBoolean(), Boolean.parseBoolean(attrVal), op);</span>
|
||||||
|
} else {
|
||||||
|
<span class="nc" id="L30"> return false;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean compareNumbers(BigDecimal nodeVal, BigDecimal attrVal, AttrOperator op) {
|
||||||
|
<span class="nc" id="L35"> int comparison = nodeVal.compareTo(attrVal);</span>
|
||||||
|
<span class="nc bnc" id="L36" title="All 4 branches missed."> return switch (op) {</span>
|
||||||
|
<span class="nc bnc" id="L37" title="All 2 branches missed."> case EQ -> comparison == 0;</span>
|
||||||
|
<span class="nc bnc" id="L38" title="All 2 branches missed."> case GT -> comparison > 0;</span>
|
||||||
|
<span class="nc bnc" id="L39" title="All 2 branches missed."> case LT -> comparison < 0;</span>
|
||||||
|
<span class="nc bnc" id="L40" title="All 2 branches missed."> case NE -> comparison != 0;</span>
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean compareStrings(String nodeVal, String attrVal, AttrOperator op) {
|
||||||
|
<span class="nc bnc" id="L45" title="All 2 branches missed."> return switch (op) {</span>
|
||||||
|
<span class="nc" id="L46"> case EQ -> nodeVal.equals(attrVal);</span>
|
||||||
|
<span class="nc bnc" id="L47" title="All 2 branches missed."> default -> !nodeVal.equals(attrVal);</span>
|
||||||
|
// case NE -> !nodeVal.equals(attrVal);
|
||||||
|
// case GT -> !nodeVal.equals(attrVal);// > 0;
|
||||||
|
// case LT -> !nodeVal.equals(attrVal);// < 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean compareBooleans(boolean nodeVal, boolean attrVal, AttrOperator op) {
|
||||||
|
<span class="nc bnc" id="L55" title="All 2 branches missed."> return switch (op) {</span>
|
||||||
|
<span class="nc bnc" id="L56" title="All 2 branches missed."> case EQ -> nodeVal == attrVal;</span>
|
||||||
|
<span class="nc bnc" id="L57" title="All 2 branches missed."> default -> nodeVal != attrVal;</span>
|
||||||
|
// case NE -> nodeVal != attrVal;
|
||||||
|
// case GT -> !nodeVal && attrVal; // false < true
|
||||||
|
// case LT -> nodeVal && !attrVal; // true > false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AttrOperator</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework.util</a> > <span class="el_class">AttrOperator</span></div><h1>AttrOperator</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">68 of 68</td><td class="ctr2">0%</td><td class="bar">4 of 4</td><td class="ctr2">0%</td><td class="ctr1">5</td><td class="ctr2">5</td><td class="ctr1">12</td><td class="ctr2">12</td><td class="ctr1">3</td><td class="ctr2">3</td></tr></tfoot><tbody><tr><td id="a2"><a href="AttrOperator.java.html#L3" class="el_method">static {...}</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="31" alt="31"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h0">5</td><td class="ctr2" id="i0">5</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="AttrOperator.java.html#L16" class="el_method">fromString(String)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="112" height="10" title="29" alt="29"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="4" alt="4"/></td><td class="ctr2" id="e0">0%</td><td class="ctr1" id="f0">3</td><td class="ctr2" id="g0">3</td><td class="ctr1" id="h1">4</td><td class="ctr2" id="i1">4</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a0"><a href="AttrOperator.java.html#L11" class="el_method">AttrOperator(String, int, String)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="30" height="10" title="8" alt="8"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h2">3</td><td class="ctr2" id="i2">3</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AttrOperator.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework.util</a> > <span class="el_source">AttrOperator.java</span></div><h1>AttrOperator.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework.util;
|
||||||
|
|
||||||
|
<span class="nc" id="L3">public enum AttrOperator {</span>
|
||||||
|
<span class="nc" id="L4"> EQ("="),</span>
|
||||||
|
<span class="nc" id="L5"> NE("!="),</span>
|
||||||
|
<span class="nc" id="L6"> GT(">"),</span>
|
||||||
|
<span class="nc" id="L7"> LT("<");</span>
|
||||||
|
|
||||||
|
private final String symbol;
|
||||||
|
|
||||||
|
<span class="nc" id="L11"> AttrOperator(String symbol) {</span>
|
||||||
|
<span class="nc" id="L12"> this.symbol = symbol;</span>
|
||||||
|
<span class="nc" id="L13"> }</span>
|
||||||
|
|
||||||
|
public static AttrOperator fromString(String symbol) {
|
||||||
|
<span class="nc bnc" id="L16" title="All 2 branches missed."> for (AttrOperator op : AttrOperator.values()) {</span>
|
||||||
|
<span class="nc bnc" id="L17" title="All 2 branches missed."> if (op.symbol.equals(symbol)) {</span>
|
||||||
|
<span class="nc" id="L18"> return op;</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<span class="nc" id="L21"> throw new IllegalArgumentException("Unknown operator: " + symbol);</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.util</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.source.html" class="el_source">Source Files</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.util</span></div><h1>io.github.js0ny.ilp_coursework.util</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">173 of 173</td><td class="ctr2">0%</td><td class="bar">32 of 32</td><td class="ctr2">0%</td><td class="ctr1">25</td><td class="ctr2">25</td><td class="ctr1">32</td><td class="ctr2">32</td><td class="ctr1">8</td><td class="ctr2">8</td><td class="ctr1">2</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="AttrComparator.html" class="el_class">AttrComparator</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="105" alt="105"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="28" alt="28"/></td><td class="ctr2" id="e0">0%</td><td class="ctr1" id="f0">20</td><td class="ctr2" id="g0">20</td><td class="ctr1" id="h0">20</td><td class="ctr2" id="i0">20</td><td class="ctr1" id="j0">5</td><td class="ctr2" id="k0">5</td><td class="ctr1" id="l0">1</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a1"><a href="AttrOperator.html" class="el_class">AttrOperator</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="77" height="10" title="68" alt="68"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="4" alt="4"/></td><td class="ctr2" id="e1">0%</td><td class="ctr1" id="f1">5</td><td class="ctr2" id="g1">5</td><td class="ctr1" id="h1">12</td><td class="ctr2" id="i1">12</td><td class="ctr1" id="j1">3</td><td class="ctr2" id="k1">3</td><td class="ctr1" id="l1">1</td><td class="ctr2" id="m1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework.util</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.html" class="el_class">Classes</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework.util</span></div><h1>io.github.js0ny.ilp_coursework.util</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">173 of 173</td><td class="ctr2">0%</td><td class="bar">32 of 32</td><td class="ctr2">0%</td><td class="ctr1">25</td><td class="ctr2">25</td><td class="ctr1">32</td><td class="ctr2">32</td><td class="ctr1">8</td><td class="ctr2">8</td><td class="ctr1">2</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="AttrComparator.java.html" class="el_source">AttrComparator.java</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="105" alt="105"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="28" alt="28"/></td><td class="ctr2" id="e0">0%</td><td class="ctr1" id="f0">20</td><td class="ctr2" id="g0">20</td><td class="ctr1" id="h0">20</td><td class="ctr2" id="i0">20</td><td class="ctr1" id="j0">5</td><td class="ctr2" id="k0">5</td><td class="ctr1" id="l0">1</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a1"><a href="AttrOperator.java.html" class="el_source">AttrOperator.java</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="77" height="10" title="68" alt="68"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="4" alt="4"/></td><td class="ctr2" id="e1">0%</td><td class="ctr1" id="f1">5</td><td class="ctr2" id="g1">5</td><td class="ctr1" id="h1">12</td><td class="ctr2" id="i1">12</td><td class="ctr1" id="j1">3</td><td class="ctr2" id="k1">3</td><td class="ctr1" id="l1">1</td><td class="ctr2" id="m1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>IlpCourseworkApplication</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.html" class="el_package">io.github.js0ny.ilp_coursework</a> > <span class="el_class">IlpCourseworkApplication</span></div><h1>IlpCourseworkApplication</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">5 of 8</td><td class="ctr2">37%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">1</td><td class="ctr2">2</td><td class="ctr1">2</td><td class="ctr2">3</td><td class="ctr1">1</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a1"><a href="IlpCourseworkApplication.java.html#L10" class="el_method">main(String[])</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="5" alt="5"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">2</td><td class="ctr2" id="i0">2</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a href="IlpCourseworkApplication.java.html#L7" class="el_method">IlpCourseworkApplication()</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="72" height="10" title="3" alt="3"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">1</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>IlpCourseworkApplication.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <a href="index.source.html" class="el_package">io.github.js0ny.ilp_coursework</a> > <span class="el_source">IlpCourseworkApplication.java</span></div><h1>IlpCourseworkApplication.java</h1><pre class="source lang-java linenums">package io.github.js0ny.ilp_coursework;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
<span class="fc" id="L7">public class IlpCourseworkApplication {</span>
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
<span class="nc" id="L10"> SpringApplication.run(IlpCourseworkApplication.class, args);</span>
|
||||||
|
<span class="nc" id="L11"> }</span>
|
||||||
|
}
|
||||||
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.source.html" class="el_source">Source Files</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework</span></div><h1>io.github.js0ny.ilp_coursework</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">5 of 8</td><td class="ctr2">37%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">1</td><td class="ctr2">2</td><td class="ctr1">2</td><td class="ctr2">3</td><td class="ctr1">1</td><td class="ctr2">2</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="IlpCourseworkApplication.html" class="el_class">IlpCourseworkApplication</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="75" height="10" title="5" alt="5"/><img src="../jacoco-resources/greenbar.gif" width="45" height="10" title="3" alt="3"/></td><td class="ctr2" id="c0">37%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">2</td><td class="ctr1" id="h0">2</td><td class="ctr2" id="i0">3</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">2</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>io.github.js0ny.ilp_coursework</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.html" class="el_class">Classes</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">ilp-coursework</a> > <span class="el_package">io.github.js0ny.ilp_coursework</span></div><h1>io.github.js0ny.ilp_coursework</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">5 of 8</td><td class="ctr2">37%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">1</td><td class="ctr2">2</td><td class="ctr1">2</td><td class="ctr2">3</td><td class="ctr1">1</td><td class="ctr2">2</td><td class="ctr1">0</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="IlpCourseworkApplication.java.html" class="el_source">IlpCourseworkApplication.java</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="75" height="10" title="5" alt="5"/><img src="../jacoco-resources/greenbar.gif" width="45" height="10" title="3" alt="3"/></td><td class="ctr2" id="c0">37%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">2</td><td class="ctr1" id="h0">2</td><td class="ctr2" id="i0">3</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">2</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>
|
||||||
BIN
docs/reports/jacoco/test/html/jacoco-resources/branchfc.gif
Normal file
|
After Width: | Height: | Size: 91 B |
BIN
docs/reports/jacoco/test/html/jacoco-resources/branchnc.gif
Normal file
|
After Width: | Height: | Size: 91 B |
BIN
docs/reports/jacoco/test/html/jacoco-resources/branchpc.gif
Normal file
|
After Width: | Height: | Size: 91 B |
BIN
docs/reports/jacoco/test/html/jacoco-resources/bundle.gif
Normal file
|
After Width: | Height: | Size: 709 B |
BIN
docs/reports/jacoco/test/html/jacoco-resources/class.gif
Normal file
|
After Width: | Height: | Size: 586 B |