From 1326ab92babd2fdc780a5054d632cf9714c58d67 Mon Sep 17 00:00:00 2001 From: Wessel Tip Date: Tue, 11 Jun 2024 11:32:11 +0200 Subject: [PATCH] feat: Voeg map name support toe --- .../469f6bec-f113-4467-9d39-7ac38558045a.xml | 66 ------------------ .../.idea/.idea.REST API/.idea/workspace.xml | 7 +- src/Server/Console/JsonClasses/Database.cs | 2 + src/Server/Console/Program.cs | 5 +- src/Server/Console/Routes/RouteDatabase.cs | 13 ++-- src/Server/Console/Routes/RoutePath.cs | 3 +- .../Console/bin/Debug/net8.0/Console.dll | Bin 16384 -> 16896 bytes .../Console/bin/Debug/net8.0/Console.pdb | Bin 15692 -> 15744 bytes src/Web/src/components/mapCanvas.jsx | 28 ++++---- 9 files changed, 33 insertions(+), 91 deletions(-) diff --git a/src/Server/.idea/.idea.REST API/.idea/dataSources/469f6bec-f113-4467-9d39-7ac38558045a.xml b/src/Server/.idea/.idea.REST API/.idea/dataSources/469f6bec-f113-4467-9d39-7ac38558045a.xml index 7f75353..60d559b 100644 --- a/src/Server/.idea/.idea.REST API/.idea/dataSources/469f6bec-f113-4467-9d39-7ac38558045a.xml +++ b/src/Server/.idea/.idea.REST API/.idea/dataSources/469f6bec-f113-4467-9d39-7ac38558045a.xml @@ -44,71 +44,5 @@ replication:{'class': 'org.apache.cassandra.locator.LocalStrategy replication:{'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2'} - - caching:{'keys': 'ALL', 'rows_per_partition': 'ALL'} -compression:{'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'} -bloom_filter_fp_chance:0.01 -default_time_to_live:0 -speculative_retry:99.0PERCENTILE -gc_grace_seconds:864000 -max_index_interval:2048 -memtable_flush_period_in_ms:0 -min_index_interval:128 -read_repair_chance:0 -crc_check_chance:1 -dclocal_read_repair_chance:0 -compaction:{'class': 'SizeTieredCompactionStrategy'} - -
- - caching:{'keys': 'ALL', 'rows_per_partition': 'ALL'} -compression:{'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'} -bloom_filter_fp_chance:0.01 -default_time_to_live:0 -speculative_retry:99.0PERCENTILE -gc_grace_seconds:864000 -max_index_interval:2048 -memtable_flush_period_in_ms:0 -min_index_interval:128 -read_repair_chance:0 -crc_check_chance:1 -dclocal_read_repair_chance:0 -compaction:{'class': 'SizeTieredCompactionStrategy'} - -
- - uuid|0s - 1 - - - int|0s - 2 - - - timestamp|0s - 3 - - - text|0s - 4 - - - id -version|ASC -date|ASC - - - - uuid|0s - 1 - - - text|0s - 2 - - - id - - \ No newline at end of file diff --git a/src/Server/.idea/.idea.REST API/.idea/workspace.xml b/src/Server/.idea/.idea.REST API/.idea/workspace.xml index 1fe2d9e..231935c 100755 --- a/src/Server/.idea/.idea.REST API/.idea/workspace.xml +++ b/src/Server/.idea/.idea.REST API/.idea/workspace.xml @@ -8,9 +8,12 @@ + + - + + @@ -120,7 +123,7 @@ - + diff --git a/src/Server/Console/JsonClasses/Database.cs b/src/Server/Console/JsonClasses/Database.cs index 8fd661f..473b6bc 100755 --- a/src/Server/Console/JsonClasses/Database.cs +++ b/src/Server/Console/JsonClasses/Database.cs @@ -6,11 +6,13 @@ public class Data { public int version; public string date; public string id; + public string name; } public class RowData { public string Id; public int[][] Objects; public int Version; + public string Name; public DateTime Date; } diff --git a/src/Server/Console/Program.cs b/src/Server/Console/Program.cs index 9b5aea9..5ea247b 100755 --- a/src/Server/Console/Program.cs +++ b/src/Server/Console/Program.cs @@ -40,10 +40,11 @@ internal static class Program { session.Execute(@" CREATE TABLE IF NOT EXISTS Roommapper.Maps( Id uuid, - Objects text, Version int, + Name text, + Objects text, Date timestamp, - PRIMARY KEY (Id,Version,Date) + PRIMARY KEY (Id,Name) )"); session.Execute(@" diff --git a/src/Server/Console/Routes/RouteDatabase.cs b/src/Server/Console/Routes/RouteDatabase.cs index 2ce06f2..c0679d7 100755 --- a/src/Server/Console/Routes/RouteDatabase.cs +++ b/src/Server/Console/Routes/RouteDatabase.cs @@ -12,13 +12,13 @@ public class RouteDatabase(ISession cassandraSession): IRoute { /// public HttpResponse Get(HttpRequest request) { try { - // Prepare the select statement based on the given criteria // If no criteria is given, throw an exception. // Using a prepare due to the potential of SQL injection when accepting // any form of user data. var queries = new Dictionary> { ["id"] = id => cassandraSession.Prepare(@"SELECT * FROM Roommapper.Maps WHERE Id = ?;").Bind(Guid.Parse(id)), + ["name"] = name => cassandraSession.Prepare(@"SELECT * FROM Roommapper.Maps WHERE Name = ?;").Bind(name), ["date"] = date => cassandraSession.Prepare(@"SELECT * FROM roommapper.maps WHERE Date = ?;").Bind(DateTime.Parse(date)), ["version"] = version => cassandraSession.Prepare(@"SELECT * FROM roommapper.maps WHERE Version = ?;").Bind(int.Parse(version)), ["all"] = _ => cassandraSession.Prepare(@"SELECT * FROM roommapper.maps;").Bind() @@ -29,7 +29,7 @@ public class RouteDatabase(ISession cassandraSession): IRoute { .Select(query => query.Value(request.QueryString[query.Key])) .FirstOrDefault(); - if (selectStatement == null) throw new Exception("No valid search criteria given, give one of (id, date, version)."); + if (selectStatement == null) throw new Exception("No valid search criteria given, give one of (id, date, version, name)."); // Execute the query and return all rows in an array @@ -65,9 +65,9 @@ public class RouteDatabase(ISession cassandraSession): IRoute { var uuid = Guid.NewGuid(); var insertStatement = cassandraSession.Prepare(@" - INSERT INTO Roommapper.Maps(Id, Date, Version, Objects) - VALUES (?, toTimeStamp(now()), ?, ?); - ").Bind(uuid, 1, parsedBody.objects); + INSERT INTO Roommapper.Maps(Id, Name, Date, Version, Objects) + VALUES (?, ?, toTimeStamp(now()), ?, ?); + ").Bind(uuid, parsedBody.name, 1, parsedBody.objects); cassandraSession.Execute(insertStatement); @@ -126,7 +126,8 @@ public class RouteDatabase(ISession cassandraSession): IRoute { Id = row.GetValue("id").ToString(), Objects = $"[{row.GetValue("objects")}]".FromJson(), Version = row.GetValue("version"), - Date = row.GetValue("date") + Date = row.GetValue("date"), + Name = row.GetValue("name") }).ToList().ToJson(); } } diff --git a/src/Server/Console/Routes/RoutePath.cs b/src/Server/Console/Routes/RoutePath.cs index e68c0e3..1664a6a 100644 --- a/src/Server/Console/Routes/RoutePath.cs +++ b/src/Server/Console/Routes/RoutePath.cs @@ -18,6 +18,7 @@ public class RoutePath(ISession cassandraSession): IRoute { // any form of user data. var queries = new Dictionary> { ["id"] = id => cassandraSession.Prepare(@"SELECT * FROM Roommapper.Routes WHERE Id = ?;").Bind(Guid.Parse(id)), + ["name"] = name => cassandraSession.Prepare(@"SELECT * FROM Roommapper.Routes WHERE Id = ?;").Bind(name) }; var selectStatement = queries @@ -25,7 +26,7 @@ public class RoutePath(ISession cassandraSession): IRoute { .Select(query => query.Value(request.QueryString[query.Key])) .FirstOrDefault(); - if (selectStatement == null) throw new Exception("No valid search criteria given, give one of (id)."); + if (selectStatement == null) throw new Exception("No valid search criteria given, give one of (id, name)."); // Execute the query and return all rows in an array var rowSet = cassandraSession.Execute(selectStatement); diff --git a/src/Server/Console/bin/Debug/net8.0/Console.dll b/src/Server/Console/bin/Debug/net8.0/Console.dll index ee6bf232a9112c13270c37452557164fc89d165e..36d31f872da0f20c377d65dd1e1fc1aa13a718a2 100755 GIT binary patch delta 4935 zcmb7I3vg7`8UD|GoSWS|Hwhc^An#2Uc1aiV4i8BrMWDPRC^bS75=DiLH%y0+!UoA$ zs=VT{SSZzkjs<)ajEYWal~S!{IyTH$2DK`*jyL?R>gB8#hMO;<7bkrqHQVfp~@3Pm!!e0p8#C(_CbBTQ4W$zdwH9L?%)gNV6S{LRU z_HL-cJ{eL@4RGpD&PN*9g-rV|R)gvyeS6R+wJ?PZ-&si!QS`HJ4MnH#`CP z#&XNM*Gk)K7mBCNGM^s`KkDtKWHZ6=f5#cw!4YD6rby&trYs&Qx^4t9!jmw|uM-8} z#2#tqFNMZlELQN&Qu%BhHQ+u~JbMFNg#9v}Pt|{vKt8^`LBv{iQv&$(Rwjw8pa8uF9iIQo~P z$P-7clw>R^-fSmEzNZT}Ku`w>8RmZV2TeN2Jp zozJK;4=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ra}(-EQrtB`n8$gqAbE z`4ly<$N2;ufc}&7T5sX-dC>SP`4k?Y5Z9QG{D^fZYBR~xSvzxU;R1FD8To;C z8>Q@3s4IbWII3QywMGKmH5>IxvJkl3+)rKXC$x-pv0C2DZek0xRlr6Z<(nAO@ZL}X zdXP_+ly%WQ9$Esc_=`5)LIJI0-wlgSdu5oe;^#r7kKcIMMO zY#CdkZK4<0GHn-YWfw!@)^5-k{`BqDE{gj3s7ZW$8ZpzLl>#SJN@wuUFHpA~W-7&OUY>UM3H)9=hK+g!V1^bE5y#}?;~T5O%TCUBK_{2Yf^@FTETa(Jh)OM`cIq9wBydC*b-@BQDB6NIi?@T9X#*dLb4yo?@0MOZ z_GxLRHa1*-iisnY?*^0JE|+Ig-#y~J>%Mw%s(x){RQOMCR0vnAKN@vCl63vzA9R}c+uPAL$5u5ysc9!_#ypEZWIM{Oe*@8VPY?hA diff --git a/src/Server/Console/bin/Debug/net8.0/Console.pdb b/src/Server/Console/bin/Debug/net8.0/Console.pdb index 74b6ef266c391bcbdf957cfade23355dc1404207..5dfc8b33d4aa03c31143ac6b09f47e8b384f78e2 100755 GIT binary patch delta 1880 zcmah~3s4hB7~Z`+2;m`x@Ca%N5S~FuLLfj=1)(Sri#CR-iUlE1a8QabRD?hh8B?e7 zI4WfX25M2HLjY+7$Bw*wP>?!mTU2lW(H7L!4sAhv(EbOuWv0&bZoYrN@7sU({<+)R zy?P)oyGRnJW+LR8i;&y|p>YIUxqD~Yjt_PLMSK=QbjnjHktgtKimy^dML^pFx=jLl zWqL*;=tU%*dlvVu)Ej2@xlP6RZg`neTwLT}Y7cz^fJMViQydI4@?Q>wrN(v_A{o2Sh<7|Gk)K z>zvO-sS+m20PF?iNSNM859A1-6ShM#~K`$S2I?;((a&}$$pv+ z=aB2^PS}miq&sP-x8w}j;#c$YK)Wo^4xn8ZXg+B71zG{xbAhJj^ID+YKzlFH)O><} zb;}dF2y6O%31shwkpaFN_013z<12(^gJ3BD=ZM(Qn$7WYu?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Qgna^ zO;R3cWjxR!jv}~nKA0kW5zPn-1s`%00@#B%r=Z~mq6e`^Ny9@#2zK({hY#`NJ|9w4 ze8@y>L~K#<9YKer^xq;H_Kb5HDpfSpB91YpRA0n&0$>VeFa-#(f8-j1)z+v7kgE}9 z__IOHKCdTe)@gsI?Qp(>@#N@d-bQB%Rye*}(eO^sMqSPP%+Zr9CXVYsq)a~7Ax4a| zvoKrnZhaAI#|hdQwaWw@hFUT~vv1dRf@bU8TFiNVME8>i1tKYd-FOP@2>@;(mEnQ2 z2hBDo7vg9-&JQTeakM~)an?mD!Td`+3Gm?qz61ntluknbgtQLhN?H3j@5fjp146?~ z8HaG8gXc6Jy$A9Hy^6-u9g4rm%2zh|Opr;8n3H_uf&Hx+-`^Lx zG;etI=qsj>9DAa zThCWb{yprnUVLUKP@~S`{GPpQb3r=!@m0o<>9kURThHGN1Hq>=d1|6dNQzI z5wj{KtRkuF+poLZwfuD+hTs6#;Pw~pww14(p6yZ%e=-_zreovz^x?8}^8>tj>w;si zTP%HJ`uMxbj>_8n2YyO^L&%+9J2&XwJpCx``9}(tWZkMs9Y`3Q*6K63YosaeRGfXPF}JnLQ06~mtdA6(o?QOflUz-Q=8#$6 z0&SbKU1_LSdG~hz&cN)Ot6s)6T&vFwnzXW(d&F`q`?s2N+wP7zTnB&m=ksiAFJvqg zeUp)}cExg6lc)i!!W*yogd(JG>)qUUd%Iu_!Z+N9}B*wpr)DYeok)1JfhbS!xge4nlcEi3E9zY z%^`&7vnhQmRh&Q-_fRFtRLLV|tM6QH7#Gyc311I#oVn|}p61P=q set.Objects.forEach((coord) => map.push(coord))); + data.forEach((set) => set.Objects.forEach((coord) => map.points.push(coord))); return map; } catch (ex) { @@ -55,9 +57,8 @@ export default class MapCanvas extends React.Component { // Get the 2D context from the canvas element const ctx = this.canvasRef.current.getContext('2d'); // Get the points to draw from the server - const points = await this.getLinePoints(); - const route = await this.getLinePoints("path"); - // const route = await this.getRoutePoints(); + const map = await this.getLinePoints(); + const route = await this.getLinePoints('path', 'id', map ? map.id : ''); // Set the font for the text we will draw on the canvas ctx.font = "24px Comic Sans MS"; @@ -66,7 +67,7 @@ export default class MapCanvas extends React.Component { ctx.clearRect(0, 0, this.state.canvasWidth, this.state.canvasHeight); // If there are no points, display a message and return - if (!points || points.length < 1) { + if (!map || map.points.length < 1) { ctx.fillText("No valid entry found.", 10, this.state.canvasHeight / 2); return; } @@ -74,14 +75,14 @@ export default class MapCanvas extends React.Component { // Loop trough all coordinates, draw a dot at each point to form a top-down // view of the objects. ctx.fillStyle = "#000"; - points.forEach(point => { + map.points.forEach(point => { ctx.beginPath(); ctx.arc(point[1], point[0], 1, 0, 2 * Math.PI); ctx.fill(); }); ctx.fillStyle = "#800000"; - route.forEach(point => { + route.points.forEach(point => { ctx.beginPath(); ctx.arc(point[1], point[0], 1, 0, 2 * Math.PI); ctx.fill(); @@ -99,9 +100,8 @@ export default class MapCanvas extends React.Component { value={searchOption} onChange={(val) => this.setState({ searchOption: val })} > + - -