Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • d1656298/client-project
  • d1634883/client-project
2 results
Show changes
Commits on Source (17)
Showing
with 580 additions and 251 deletions
......@@ -11,7 +11,7 @@ public class Location {
private String locationEmail;
private String locationDescription;
private String locationPlace;
private int locationTrailID;
private String locationTrailID;
private boolean locationApproved;
......@@ -47,11 +47,36 @@ public class Location {
return locationPlace;
}
public int getLocationTrailID() {
public String getLocationTrailID() {
return locationTrailID;
}
public boolean isLocationApproved() {
return locationApproved;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public void setLocationEmail(String locationEmail) {
this.locationEmail = locationEmail;
}
public void setLocationDescription(String locationDescription) {
this.locationDescription = locationDescription;
}
public void setLocationPlace(String locationPlace) {
this.locationPlace = locationPlace;
}
public void setLocationTrailID(String locationTrailID) {
this.locationTrailID = locationTrailID;
}
public void setLocationApproved(boolean locationApproved) {
this.locationApproved = locationApproved;
}
}
......@@ -9,11 +9,11 @@ public interface LocationRepository {
void addLocation(Location loc);
List<Location> getApprovedLocations();
List<Location> getAllApprovedLocations();
// List<Location> getApprovedLocations2(List<Location> list);
List<Location> getUnapprovedLocations();
List<Location> getAllUnapprovedLocations();
// List<Location> approvedLocations();
......
......@@ -33,7 +33,7 @@ public class LocationRepositoryJDBC implements LocationRepository {
rs.getString("locationEmail"),
rs.getString("locationDescription"),
rs.getString("locationPlace"),
rs.getInt("locationTrailID"),
rs.getString("locationTrailID"),
rs.getBoolean("locationApproved")
);
}
......@@ -52,24 +52,50 @@ public class LocationRepositoryJDBC implements LocationRepository {
// this.locationMapper = locationMapper;
// }
@Override
public List<Location> getAllApprovedLocations(){
String sql= "SELECT * FROM locations";
List<Location> lis = jdbc.query(sql, locationMapper);
List<Location> lisFiltered = new ArrayList<>();
for (Location li : lis){
if (li.isLocationApproved()){
lisFiltered.add(li);
}
}
return lisFiltered;
}
@Override
public List<Location> getAllUnapprovedLocations(){
String sql= "SELECT * FROM locations";
List<Location> lis = jdbc.query(sql, locationMapper);
List<Location> lisFiltered = new ArrayList<>();
for (Location li : lis){
if (!li.isLocationApproved()){
lisFiltered.add(li);
}
}
return lisFiltered;
}
@Override // intended implementation at current: user data from templates/Landmarks/LandmarkFormTh.html is added to the Location table
public void addLocation(Location loc) {
String sql = "insert into locations( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) values (?,?,?,?,?,?)";
jdbc.update(sql,loc.getLocationName(),loc.getLocationEmail(),loc.getLocationDescription(),loc.getLocationPlace(),loc.getLocationTrailID());
jdbc.update(sql,loc.getLocationName(),loc.getLocationEmail(),loc.getLocationDescription(),loc.getLocationPlace(),loc.getLocationTrailID(), false);
}
@Override
public List<Location> getApprovedLocations(){
JdbcTemplate jdbc = new JdbcTemplate();
List<Location> locations = new LocationRepositoryJDBC(jdbc).getAllLocation();
List<Location> locationApprovalList= new ArrayList<Location>();
for (Location loc :locations){
if (loc.isLocationApproved()) {
locationApprovalList.add(loc);
}
} return locationApprovalList;
}
// @Override
// public List<Location> getApprovedLocations(){
// JdbcTemplate jdbc = new JdbcTemplate();
// List<Location> locations = new LocationRepositoryJDBC(jdbc).getAllLocation();
// List<Location> locationApprovalList= new ArrayList<Location>();
// for (Location loc :locations){
// if (loc.isLocationApproved()) {
// locationApprovalList.add(loc);
// }
// } return locationApprovalList;
// }
//
// @Override
// public List<Location> getApprovedLocations2(List<Location> list){
......@@ -84,16 +110,16 @@ public class LocationRepositoryJDBC implements LocationRepository {
//
@Override
public List<Location> getUnapprovedLocations(){
List<Location> locations = getAllLocation();
List<Location> locationUnapprovedList= new ArrayList<Location>();
for (Location loc :locations){
if (!loc.isLocationApproved()) {
locationUnapprovedList.add(loc);
}
} return locationUnapprovedList;
}
// @Override
// public List<Location> getUnapprovedLocations(){
// List<Location> locations = getAllLocation();
// List<Location> locationUnapprovedList= new ArrayList<Location>();
// for (Location loc :locations){
// if (!loc.isLocationApproved()) {
// locationUnapprovedList.add(loc);
// }
// } return locationUnapprovedList;
// }
// public JdbcTemplate getJdbc() {
......
......@@ -7,7 +7,22 @@ import lombok.Data;
@Data
@AllArgsConstructor
public class Trail {
private int trailsId;
private String name;
private Boolean tru;
private String trailsId;
private String trailName;
private String trailNumber;
public String getTrailsId() {
return trailsId;
}
public String getTrailName() {
return trailName;
}
public String getTrailNumber() {
return trailNumber;
}
}
......@@ -5,4 +5,5 @@ import java.util.List;
public interface TrailsRepository {
List<Trail> getAllTrails();
String getTrailNameWithID(String trailsID);
}
......@@ -17,13 +17,23 @@ public class TrailsRepositoryJDBC implements TrailsRepository {
}
private void settrailsMapper(){
trailMapper = (rs, i) -> new Trail(
rs.getInt("trailID"),
rs.getString("name"),
rs.getBoolean("tru")
rs.getString("trailID"),
rs.getString("trailName"),
rs.getString("trailNumber")
);
}
public List<Trail> getAllTrails(){
String sql= "SELECT * FROM trails";
return jdbc.query(sql, trailMapper);
}
@Override
public String getTrailNameWithID(String trailsID){
String resultName = jdbc.queryForObject(
"SELECT trailName FROM trails WHERE trailID=?", String.class, trailsID);
return resultName;
}
}
......@@ -20,7 +20,7 @@ public class Landmarks {
new Landmarks( 1, "A scent of...Dragon", "The Dragon has been spotted near by, find the QR code to continue" , "Start your discovery, at the sweet shop."),
new Landmarks( 2, "They've been found!", "Don't let them escape, find the next QR code to continue!", "Location test")
);
private Integer trailID;
private String trailID;
private int landmarkID;
@NotEmpty(message = "You must type in a username.")
private String landmarkName;
......
......@@ -38,7 +38,6 @@ public class LandmarksController {
} else{
// converts valid response using Location constructor into a submittable format to the sql table
Location loc= new Location(landmarks.getLandmarkName(), landmarks.getLandmarkEmail(), landmarks.getLandmarkDescription(), landmarks.getLandmarkLocation(), landmarks.getTrailID(), false);
System.out.println(loc);
locationRepository.addLocation(loc); // adds valid landmark to locations table
ModelAndView modelAndView = new ModelAndView("redirect:/home");
return modelAndView;
......
......@@ -92,16 +92,16 @@ public class LocationsCoordinates {
// JdbcTemplate jdbcSuper= new LocationRepositoryJDBC().getJdbc();
// return new LocationRepositoryJDBC(jdbcSuper).getApprovedLocations();
// }
public List<Location> getFullUnapprovedLocations(JdbcTemplate aJdbc){
// LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
return new LocationRepositoryJDBC(aJdbc).getUnapprovedLocations();
}
//
// public List<Location> getFullUnapprovedLocations(JdbcTemplate aJdbc){
//// LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
// return new LocationRepositoryJDBC(aJdbc).getUnapprovedLocations();
// }
/// Need a constructor to create a lcoations list, approved lcoatiosn lsit, unapproved lcoations list.
/// Need a constructor to create a locations list, approved collation list, unapproved locations list.
......
......@@ -2,6 +2,9 @@ package Team5.SmartTowns.placeswithcoordinates;
import Team5.SmartTowns.data.Location;
import Team5.SmartTowns.data.LocationRepository;
import Team5.SmartTowns.data.Trail;
import Team5.SmartTowns.data.TrailsRepository;
import jakarta.validation.constraints.Max;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
......@@ -22,55 +25,91 @@ public class PlacesController {
@Autowired
private LocationRepository locationRepo;
@Autowired
private TrailsRepository trailsRepo;
@GetMapping("/checkpoints")
public ModelAndView getLocationPages(){
ModelAndView modelAndView = new ModelAndView("landmarks/locationPage.html");
List<Location> locations = locationRepo.getAllLocation();
// List<Location> approvedLocations = locationRepo.getApprovedLocations2(locations);
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Integer> locationIDIndex = new ArrayList<Integer>();
List<Location> locationCoordsWorkaround = new ArrayList<Location>();
for (LocationsCoordinates coord: locCoords){
locationIDIndex.add(coord.getLocationID()-1);
locationCoordsWorkaround.add(locations.get(coord.getLocationID()-1));
}
modelAndView.addObject("location", locationCoordsWorkaround);
List<Location> approvedLocations = locationRepo.getAllApprovedLocations();
modelAndView.addObject("location", approvedLocations);
modelAndView.addObject("locationCoords", locCoords);
return modelAndView;
}
@RequestMapping(value="/location", method= RequestMethod.POST)
public String sendHtmlFragment(Model map) {
public String sendHtmlFragmentLocation(Model map) {
map.addAttribute("foo", "bar");
return "checkpoint/checkpoint";
}
@GetMapping("/checkpoints/{location}")
public ModelAndView getResultBySearchKey(@PathVariable String location) {
List<Location> locations = locationRepo.getAllLocation();
public ModelAndView getResultBySearchKeyLocation(@PathVariable String location) {
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Location> approvedLocations = locationRepo.getAllApprovedLocations();
List<Integer> locationIDIndex = new ArrayList<Integer>();
List<Location> locationCoordsWorkaround = new ArrayList<Location>();
int locationID = 999;
int workAroundID=0;// otherwise cases errors e.g. null used. 999 unlikely to be used so safe until then
for (int i=0;i<locCoords.size();i++){ /// for loop iterating over coordinates table need to match coordinate index with lcoation index manually
locationIDIndex.add(locCoords.get(i).getLocationID()-1); // gets location ID and therefore location list index number
locationCoordsWorkaround.add(locations.get(locCoords.get(i).getLocationID()-1));
if ( (locations.get(locCoords.get(i).getLocationID() - 1).getLocationName().replace(' ', '-').trim().equals(location)) ){
for (int i=0;i<approvedLocations.size();i++){
if ( (approvedLocations.get(i).getLocationName().replace(' ', '-').trim().equals(location)) ){
locationID= i;
break;
} workAroundID++;
}System.out.println(locationCoordsWorkaround);
System.out.println("ag"+locationID);
}
}
String trailName=trailsRepo.getTrailNameWithID(approvedLocations.get(locationID).getLocationTrailID()).replace(' ', '-').trim();
ModelAndView modelAndView= new ModelAndView("fragments/locationPageFrags :: locationSection");
System.out.println("ag"+locationID);
modelAndView.addObject("locCoord", locCoords.get(locationID));
System.out.println("sd"+workAroundID);
modelAndView.addObject("location", locationCoordsWorkaround.get(locationID));
modelAndView.addObject("trail", trailName);
modelAndView.addObject("location", approvedLocations.get(locationID));
return modelAndView;
}
/// Trail webpage mapping
@GetMapping("/trails")
public ModelAndView getTrailsPage(){
ModelAndView modelAndView = new ModelAndView("landmarks/trailsPage.html");
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Location> approvedLocations = locationRepo.getAllApprovedLocations();
List<Trail> trailslocations = trailsRepo.getAllTrails();
List<Location> locationCoordsWorkaround = new ArrayList<Location>();
modelAndView.addObject("trails", trailslocations);
modelAndView.addObject("locations", approvedLocations);
modelAndView.addObject("locationCoords", locCoords);
return modelAndView;
}
@RequestMapping(value="/trail", method= RequestMethod.POST)
public String sendHtmlFragmentTrail(Model map) {
map.addAttribute("foo", "bar");
return "trail/trail";
}
@GetMapping("/trails/{trail}")
public ModelAndView getResultBySearchKeyTrails(@PathVariable String trail) {
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Location> approvedLocations = locationRepo.getAllApprovedLocations();
List<Trail> trailslocations = trailsRepo.getAllTrails();
int trailID = 999;// otherwise cases errors e.g. null used. 999 unlikely to be used so safe until then
for (int i=0;i<trailslocations.size();i++){
if (trailslocations.get(i).getTrailName().replace(' ', '-').trim().equals(trail)){
trailID=i;
break;}
}
ModelAndView modelAndView= new ModelAndView("fragments/trailsPageFrags :: trailsSection");
modelAndView.addObject("trail", trailslocations.get(trailID));
modelAndView.addObject("locCoords", locCoords);
modelAndView.addObject("locations", approvedLocations);
return modelAndView;
}
......
......@@ -13,7 +13,7 @@ public interface PlacesCoordinatesRepository {
List<TownWithTrails> getAllTownCoords();
void addTownWithCoords(TownWithTrails town);
List<Location> getFullApprovedLocations(JdbcTemplate aJdbc);
// List<Location> getFullApprovedLocations(JdbcTemplate aJdbc);
......
......@@ -53,6 +53,9 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
String sql= "SELECT * FROM locationCoordinates";
return jdbc.query(sql, locationCoordMapper);
}
public List<TownWithTrails> getAllTownCoords(){
String sql= "SELECT * FROM townswithtrails";
return jdbc.query(sql, townCoordMapper);
......@@ -74,10 +77,10 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
}
public List<Location> getFullApprovedLocations(JdbcTemplate aJdbc) {
// LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
return new LocationRepositoryJDBC(aJdbc).getApprovedLocations();
}
// public List<Location> getFullApprovedLocations(JdbcTemplate aJdbc) {
//// LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
// return new LocationRepositoryJDBC(aJdbc).getApprovedLocations();
// }
// @Override //TODO CHECK
// public List<Location> getFullApprovedLocations(JdbcTemplate aJdbc) {
......
# delete from users;
# insert into users (email, name) value ('hannah@gmail.com', 'Hannah');
# insert into users (email, name) value ('nigel@gmail.com', 'Nigel');
delete from trails;
insert into trails ( Name,tru) value ( 'Caerphilly Coffee Trail',false);
insert into trails ( Name,tru) value ( 'Penarth Dragon Trail',true);
insert into trails ( trailID, trailName, trailNumber) value ( 0101,'Caerphilly Castle Trail','0101');
insert into trails ( trailID, trailName, trailNumber) value ( 0102,'Caerphilly Pub Trail','0102');
insert into trails ( trailID, trailName, trailNumber) value ( 0103,'Caerphilly Heritage Trail','0103');
insert into trails ( trailID, trailName, trailNumber) value ( 0201,'Risca Heritage Trail','0201');
insert into trails ( trailID, trailName, trailNumber) value ( 0301,'Penarth Esplanade Trail','0301');
delete from locations;
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'St Cenydd','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'St Cenydd','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Castle','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Medieval Trades','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Queen''s War','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Green Lady','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Armoury','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Architecture','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( '21st Century Landmark','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Green Lady','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Armoury','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Architecture','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( '21st Century Landmark','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'JD Wetherspoons-Malcolm Uphill','','Location description here','Caerphilly',0102, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Cwtch','','Location description here','Caerphilly',0102, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Conservative Club','','Location description here','Caerphilly',0102, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The King''s Arms','','Location description here','Caerphilly',0102, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Conservative Club','','Location description here','Caerphilly',0102, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The King''s Arms','','Location description here','Caerphilly',0102, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Bus Station','','Location description here','Caerphilly',0103, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Medieval Courthouse','','Location description here','Caerphilly',0103, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ('Caerphilly Castle','','Location description here','Caerphilly',0103, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Ty Vaughan House','','Location description here','Caerphilly',0103, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ('Caerphilly Castle','','Location description here','Caerphilly',0103, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Ty Vaughan House','','Location description here','Caerphilly',0103, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Risca Colliery','','Location description here','Risca',0201, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Black Vein Colliery Disaster','','Location description here','Risca',0201, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Esplanade','','Location description here','Penarth',0301, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Old Swimming Baths','','Location description here','Penarth',0301, true);
# delete from badges;
# insert into badges (name, description, difficulty) value ('TownConnoisseur', 'You know the town very well!', '2');
# insert into badges (name, description, difficulty) value ('TownRegular', 'You visited the town 3 days in a row!', '1');
# insert into badges (name, description, difficulty) value ('TownMaster', 'You visited the town 7 days in a row!', '1');
# insert into badges (name, description, difficulty) value ('TownRegular', 'You visited the town 3 days in a row!', '1');
# insert into badges (name, description, difficulty) value ('TownRegular', 'You visited the town 3 days in a row!', '1');
delete from packs;
insert into packs (name, description) value ('Wales Football Team', 'Pack of Welsh Football Players in the National Team');
insert into packs (name, description) value ('Wales Rugby Team', 'Pack of Welsh Rugby Players in the National Team');
insert into packs (name, description) value ('Welsh Heritage', 'Pack About Welsh Heritage');
DELETE FROM packs;
INSERT INTO packs (name, description) VALUE ('Wales Football Team', 'Pack of Welsh Football Players in the National Team');
INSERT INTO packs (name, description) VALUE ('Wales Rugby Team', 'Pack of Welsh Rugby Players in the National Team');
INSERT INTO packs (name, description) VALUE ('Welsh Heritage', 'Pack About Welsh Heritage');
DELETE FROM stickers;
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 1, 'wayne_hennessey', 'Wales Football Team Player', '2');
......@@ -50,3 +66,39 @@ INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 1,
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 2, 'Welsh Outline', 'Welsh Heritage', '1');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 3, 'Welsh Spoon', 'Welsh Heritage', '1');
# delete from stickerprogress;
# insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '1', true);
# insert into stickerprogress (userID, stickerID, hasSticker) value ('1', '3', true);
# insert into stickerprogress (userID, stickerID, hasSticker) value ('2', '2', true);
delete from locationCoordinates;
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (2, 51.57623, -3.21910 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (3, 51.575372, -3.219186);
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (4, 51.576363, -3.220712 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (9, 51.57239, -3.21992);
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (10, 51.57230, -3.21938 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (13, 51.57168, -3.21861);
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (14, 51.57465, -3.22022 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (17, 51.61117, -3.10198 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (18, 51.61655, -3.12371 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (19, 51.43484, -3.16492 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (20, 51.43547, -3.16789 );
# insert into stickerprogress (userID, packID, stickerID) value (1, 1, 1);
# insert into stickerprogress (userID, packID, stickerID) value (1, 1, 2);
# insert into stickerprogress (userID, packID, stickerID) value (1, 1, 3);
# insert into stickerprogress (userID, packID, stickerID) value (1, 1, 5);
# insert into stickerprogress (userID, packID, stickerID) value (1, 2, 1);
# insert into stickerprogress (userID, packID, stickerID) value (1, 2, 3);
#
delete from townsWithTrails;
insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Caerphilly', '51.57903','-3.22075 ','51.60418','51.55093','-3.25222','-3.17696');
insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Risca','51.61195','-3.09648','51.63039','51.59175','-3.12129','-3.06438');
insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Penarth','51.43893','-3.17354','51.44878','51.41233','-3.20271','-3.16005');
\ No newline at end of file
/* DELETES AND RECREATES DATABASE EVERY TIME THE SYSTEM IS BOOTED*/
DROP DATABASE IF EXISTS towns;
CREATE DATABASE IF NOT EXISTS towns;
......@@ -5,20 +6,25 @@ USE towns;
/****************************************************************/
/* DROPS ALL TABLES IF THEY EXIST (they wont but just in case) */
DROP TABLE IF EXISTS trails;
DROP TABLE IF EXISTS locations;
drop table if exists locationCoordinates;
drop table if exists locations;
drop table if exists trails;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS stickers;
DROP TABLE IF EXISTS packs;
DROP TABLE IF EXISTS stickerProgress;
/****************************************************************/
/* CREATES ALL TABLES */
CREATE TABLE IF NOT EXISTS trails (
trailID bigint auto_increment primary key,
name varchar(128),
tru boolean
create table if not exists trails
(
trailID varchar(128) primary key,
trailName varchar(128),
trailNumber varchar(128)
) engine=InnoDB;
drop table if exists locationCoordinates;
......@@ -66,7 +72,6 @@ CREATE TABLE IF NOT EXISTS stickers (
description text NOT NULL,
rarity tinyint
);
CREATE TABLE IF NOT EXISTS stickerProgress (
id bigint auto_increment primary key,
username varchar(30) NOT NULL,
......
......@@ -14,6 +14,9 @@
color: wheat;
}
#return{
padding-bottom: 10px;
}
iframe{
margin-top: 20px;
margin-bottom: 60px;
......
.trailsFragment{
background-color: rgb(206, 153, 253);
color: black;
border-color: white;
align-content: center;
text-align: center;
border-radius: 25px;
max-width: 800px;
margin: 0 auto;
}
.trailsPageFrag{
background: rgb(41, 41, 41);
color: wheat;
}
iframe{
margin-top: 20px;
margin-bottom: 20px;
border: white 2px solid;
}
H1{
padding-top: 15px;
padding-bottom:3px ;
margin-bottom: 0;
}
#trailHeader{
margin: 0;
padding: 0;
}
#checkpointList{
list-style: none;
padding-bottom: 10px;
}
\ No newline at end of file
import GeoJSON from '/nodeMods/node_modules/ol/format/GeoJSON.js';
import Map from '/nodeMods/node_modules/ol/Map.js';
import VectorLayer from '/nodeMods/node_modules/ol/source/Vector.js'
import VectorSource from '/nodeMods/node_modules/ol/source/Vector.js';
import View from '/nodeMods/node_modules/ol/View.js';
import {DragBox, Select} from '/nodeMods/node_modules/ol/interaction.js';
import {Fill, Stroke, Style} from '/nodeMods/node_modules/ol/style.js';
import {getWidth} from '/nodeMods/node_modules/ol/extent.js';
import {platformModifierKeyOnly} from '/nodeMods/node_modules/ol/events/condition.js';
// //Invesitgate created directories mnode module mapstest and extent.js
// import GeoJSON from '/node_modules/ol/format/GeoJSON.js';
// import Map from '/ol/Map.js';
// import VectorLayer from '/ol/layer/Vector.js';
// import VectorSource from '/ol/source/Vector.js';
// import View from '/ol/View.js';
// import {DragBox, Select} from '/ol/interaction.js';
// import {Fill, Stroke, Style} from '/ol/style.js';
// import {getWidth} from '/ol/extent.js';
// import {platformModifierKeyOnly} from '/ol/events/condition.js';
const vectorSource = new VectorSource({
url: 'https://openlayers.org/data/vector/ecoregions.json',
format: new GeoJSON(),
});
const style = new Style({
fill: new Fill({
color: '#eeeeee',
}),
});
const map = new Map({
layers: [
new VectorLayer({
source: vectorSource,
background: '#1a2b39',
style: function (feature) {
const color = feature.get('COLOR_BIO') || '#eeeeee';
style.getFill().setColor(color);
return style;
},
}),
],
target: 'map',
view: new View({
center: [0, 0],
zoom: 2,
constrainRotation: 16,
}),
});
const selectedStyle = new Style({
fill: new Fill({
color: 'rgba(255, 255, 255, 0.6)',
}),
stroke: new Stroke({
color: 'rgba(255, 255, 255, 0.7)',
width: 2,
}),
});
// a normal select interaction to handle click
const select = new Select({
style: function (feature) {
const color = feature.get('COLOR_BIO') || '#eeeeee';
selectedStyle.getFill().setColor(color);
return selectedStyle;
},
});
map.addInteraction(select);
const selectedFeatures = select.getFeatures();
// a DragBox interaction used to select features by drawing boxes
const dragBox = new DragBox({
condition: platformModifierKeyOnly,
});
map.addInteraction(dragBox);
dragBox.on('boxend', function () {
const boxExtent = dragBox.getGeometry().getExtent();
// if the extent crosses the antimeridian process each world separately
const worldExtent = map.getView().getProjection().getExtent();
const worldWidth = getWidth(worldExtent);
const startWorld = Math.floor((boxExtent[0] - worldExtent[0]) / worldWidth);
const endWorld = Math.floor((boxExtent[2] - worldExtent[0]) / worldWidth);
for (let world = startWorld; world <= endWorld; ++world) {
const left = Math.max(boxExtent[0] - world * worldWidth, worldExtent[0]);
const right = Math.min(boxExtent[2] - world * worldWidth, worldExtent[2]);
const extent = [left, boxExtent[1], right, boxExtent[3]];
const boxFeatures = vectorSource
.getFeaturesInExtent(extent)
.filter(
(feature) =>
!selectedFeatures.getArray().includes(feature) &&
feature.getGeometry().intersectsExtent(extent)
);
// features that intersect the box geometry are added to the
// collection of selected features
// if the view is not obliquely rotated the box geometry and
// its extent are equalivalent so intersecting features can
// be added directly to the collection
const rotation = map.getView().getRotation();
const oblique = rotation % (Math.PI / 2) !== 0;
// when the view is obliquely rotated the box extent will
// exceed its geometry so both the box and the candidate
// feature geometries are rotated around a common anchor
// to confirm that, with the box geometry aligned with its
// extent, the geometries intersect
if (oblique) {
const anchor = [0, 0];
const geometry = dragBox.getGeometry().clone();
geometry.translate(-world * worldWidth, 0);
geometry.rotate(-rotation, anchor);
const extent = geometry.getExtent();
boxFeatures.forEach(function (feature) {
const geometry = feature.getGeometry().clone();
geometry.rotate(-rotation, anchor);
if (geometry.intersectsExtent(extent)) {
selectedFeatures.push(feature);
}
});
} else {
selectedFeatures.extend(boxFeatures);
}
}
});
// clear selection when drawing a new box and when clicking on the map
dragBox.on('boxstart', function () {
selectedFeatures.clear();
});
const infoBox = document.getElementById('info');
selectedFeatures.on(['add', 'remove'], function () {
const names = selectedFeatures.getArray().map((feature) => {
return feature.get('ECO_NAME');
});
if (names.length > 0) {
infoBox.innerHTML = names.join(', ');
} else {
infoBox.innerHTML = 'None';
}
});
\ No newline at end of file
// import GeoJSON from '/nodeMods/node_modules/ol/format/GeoJSON.js';
// import Map from '/nodeMods/node_modules/ol/Map.js';
// import VectorLayer from '/nodeMods/node_modules/ol/source/Vector.js'
// import VectorSource from '/nodeMods/node_modules/ol/source/Vector.js';
// import View from '/nodeMods/node_modules/ol/View.js';
// import {DragBox, Select} from '/nodeMods/node_modules/ol/interaction.js';
// import {Fill, Stroke, Style} from '/nodeMods/node_modules/ol/style.js';
// import {getWidth} from '/nodeMods/node_modules/ol/extent.js';
// import {platformModifierKeyOnly} from '/nodeMods/node_modules/ol/events/condition.js';
// // //Invesitgate created directories mnode module mapstest and extent.js
// // import GeoJSON from '/node_modules/ol/format/GeoJSON.js';
// // import Map from '/ol/Map.js';
// // import VectorLayer from '/ol/layer/Vector.js';
// // import VectorSource from '/ol/source/Vector.js';
// // import View from '/ol/View.js';
// // import {DragBox, Select} from '/ol/interaction.js';
// // import {Fill, Stroke, Style} from '/ol/style.js';
// // import {getWidth} from '/ol/extent.js';
// // import {platformModifierKeyOnly} from '/ol/events/condition.js';
// //
//
// const vectorSource = new VectorSource({
// url: 'https://openlayers.org/data/vector/ecoregions.json',
// format: new GeoJSON(),
// });
//
// const style = new Style({
// fill: new Fill({
// color: '#eeeeee',
// }),
// });
//
// const map = new Map({
// layers: [
// new VectorLayer({
// source: vectorSource,
// background: '#1a2b39',
// style: function (feature) {
// const color = feature.get('COLOR_BIO') || '#eeeeee';
// style.getFill().setColor(color);
// return style;
// },
// }),
// ],
// target: 'map',
// view: new View({
// center: [0, 0],
// zoom: 2,
// constrainRotation: 16,
// }),
// });
//
// const selectedStyle = new Style({
// fill: new Fill({
// color: 'rgba(255, 255, 255, 0.6)',
// }),
// stroke: new Stroke({
// color: 'rgba(255, 255, 255, 0.7)',
// width: 2,
// }),
// });
//
// // a normal select interaction to handle click
// const select = new Select({
// style: function (feature) {
// const color = feature.get('COLOR_BIO') || '#eeeeee';
// selectedStyle.getFill().setColor(color);
// return selectedStyle;
// },
// });
// map.addInteraction(select);
//
// const selectedFeatures = select.getFeatures();
//
// // a DragBox interaction used to select features by drawing boxes
// const dragBox = new DragBox({
// condition: platformModifierKeyOnly,
// });
//
// map.addInteraction(dragBox);
//
// dragBox.on('boxend', function () {
// const boxExtent = dragBox.getGeometry().getExtent();
//
// // if the extent crosses the antimeridian process each world separately
// const worldExtent = map.getView().getProjection().getExtent();
// const worldWidth = getWidth(worldExtent);
// const startWorld = Math.floor((boxExtent[0] - worldExtent[0]) / worldWidth);
// const endWorld = Math.floor((boxExtent[2] - worldExtent[0]) / worldWidth);
//
// for (let world = startWorld; world <= endWorld; ++world) {
// const left = Math.max(boxExtent[0] - world * worldWidth, worldExtent[0]);
// const right = Math.min(boxExtent[2] - world * worldWidth, worldExtent[2]);
// const extent = [left, boxExtent[1], right, boxExtent[3]];
//
// const boxFeatures = vectorSource
// .getFeaturesInExtent(extent)
// .filter(
// (feature) =>
// !selectedFeatures.getArray().includes(feature) &&
// feature.getGeometry().intersectsExtent(extent)
// );
//
// // features that intersect the box geometry are added to the
// // collection of selected features
//
// // if the view is not obliquely rotated the box geometry and
// // its extent are equalivalent so intersecting features can
// // be added directly to the collection
// const rotation = map.getView().getRotation();
// const oblique = rotation % (Math.PI / 2) !== 0;
//
// // when the view is obliquely rotated the box extent will
// // exceed its geometry so both the box and the candidate
// // feature geometries are rotated around a common anchor
// // to confirm that, with the box geometry aligned with its
// // extent, the geometries intersect
// if (oblique) {
// const anchor = [0, 0];
// const geometry = dragBox.getGeometry().clone();
// geometry.translate(-world * worldWidth, 0);
// geometry.rotate(-rotation, anchor);
// const extent = geometry.getExtent();
// boxFeatures.forEach(function (feature) {
// const geometry = feature.getGeometry().clone();
// geometry.rotate(-rotation, anchor);
// if (geometry.intersectsExtent(extent)) {
// selectedFeatures.push(feature);
// }
// });
// } else {
// selectedFeatures.extend(boxFeatures);
// }
// }
// });
//
// // clear selection when drawing a new box and when clicking on the map
// dragBox.on('boxstart', function () {
// selectedFeatures.clear();
// });
//
// const infoBox = document.getElementById('info');
//
// selectedFeatures.on(['add', 'remove'], function () {
// const names = selectedFeatures.getArray().map((feature) => {
// return feature.get('ECO_NAME');
// });
// if (names.length > 0) {
// infoBox.innerHTML = names.join(', ');
// } else {
// infoBox.innerHTML = 'None';
// }
// });
\ No newline at end of file
<!DOCTYPE html>
<html lang="en" th:fragment="locationSection" class="locationPageFrag">
<!-- todo check if this is ok here-->
<head>
<meta charset="UTF-8">
<title th:text="${location.getLocationName()}"></title>
......@@ -29,6 +28,8 @@
marginwidth="0"
th:src="'https://maps.google.com/maps?q='+ ${locCoord.getLocationCoordsLat()} +','+ ${locCoord.getLocationCoordsLong()} +'&hl=en&z=20&amp;output=embed'">
</iframe>
<H2 id="return">
<a th:href="@{'/trails/'+${trail}}">Return</a></H2>
</article>
<hr style="height:40px; visibility:hidden;" />
......
<!DOCTYPE html>
<html lang="en" th:fragment="trailsSection" class="trailsPageFrag">
<head>
<meta charset="UTF-8">
<title th:text="${trail.getTrailName()}"></title>
<link rel="stylesheet" th:href="@{/css/templatingstyle.css}">
<link rel="stylesheet" th:href="@{/css/trailsPageFragsStyle.css}">
</head>
<body >
<header th:insert="~{/fragments/Templating.html::header}"></header>
<main>
<hr style="height:40px; visibility:hidden;" />
<article class="trailsFragment">
<H1 th:text="*{trail.getTrailName()}" id="trailHeader"></H1>
<div th:if="*{trail.getTrailName()=='Caerphilly Castle Trail'}">
<iframe
width="600"
height="400"
frameborder="0"
scrolling="yes"
marginheight="0"
marginwidth="0"
src="https://www.google.com/maps/dir/51.57623,-3.21910/51.575372,-3.219186/51.576363,-3.220712//@11z">
</iframe>
<div><a href="https://www.google.com/maps/dir/51.57623,-3.21910/51.575372,-3.219186/51.576363,-3.220712//@11z">Trail Map</a></div>
</div>
<div th:if="*{trail.getTrailName()=='Caerphilly Pub Trail'}">
<iframe
width="600"
height="400"
frameborder="0"
scrolling="yes"
marginheight="0"
marginwidth="0"
th:src="'https://www.google.com/maps/dir/51.57239,-3.21992/51.57230,-3.21938//@&hl=en&z=20&amp;output=embed'">
</iframe>
<div><a href="https://www.google.com/maps/dir/51.57239,-3.21992/51.57230,-3.21938//@11z">Trail Map</a></div>
</div>
<div th:if="*{trail.getTrailName()=='Caerphilly Heritage Trail'}">
<iframe
width="600"
height="400"
frameborder="0"
scrolling="yes"
marginheight="0"
marginwidth="0"
th:src="'https://www.google.com/maps/dir/51.57168,-3.21861/51.57465,-3.22022//@11z'">
</iframe>
<div>
<a href="https://www.google.com/maps/dir/51.57168,-3.21861/51.57465,-3.22022//@11z">Trail Map</a></div>
</div>
<div th:if="*{trail.getTrailName()=='Risca Heritage Trail'}">
<iframe
width="600"
height="400"
frameborder="0"
scrolling="yes"
marginheight="0"
marginwidth="0"
th:src="'https://www.google.com/maps/dir/51.61117,-3.10198/51.61655,-3.12371 //@11z'">
</iframe>
<div><a href="https://www.google.com/maps/dir/51.61117,-3.10198/51.61655,-3.12371 //@11z">Trail Map</a></div>
</div>
<div th:if="*{trail.getTrailName()=='Penarth Esplanade Trail'}">
<iframe
width="600"
height="400"
frameborder="0"
scrolling="yes"
marginheight="0"
marginwidth="0"
th:src="'https://www.google.com/maps/dir/51.43484,-3.16492/51.43547,-3.16789//@11z'">
</iframe>
<div>
<a href="https://www.google.com/maps/dir/51.43484,-3.16492/51.43547,-3.16789//@11z">Trail Map</a>
</div>
</div>
<H3>Checkpoints:</H3>
<!-- With the trial name, we go through locations list to get -->
<div th:each="locationCoord, indexValue:${locCoords}" >
<div th:if="${locations[indexValue.index].getLocationTrailID()==trail.getTrailsId()}">
<li id="checkpointList">
<div><a th:href="'/checkpoints/'+${locations[indexValue.index].getLocationName().replace(' ', '-')}" th:text="${locations[indexValue.index].getLocationName()}"></a></div>
<ul></ul>
</li>
</div>
</div>
</article>
<hr style="height:40px; visibility:hidden;" />
</main>
<footer th:insert="~{/fragments/Templating.html::footer}"></footer>
</body>
</html>
......@@ -42,7 +42,7 @@
<select th:field="*{trailID}">
<option value=0 hidden="true">Select Trail</option>
<option value=0 disabled selected>Select Trail</option>
<option value=0101>(Caerphilly) Castle Trail</option>
<option value=101>(Caerphilly) Castle Trail</option>
<option value=0102>(Caerphilly) Pub Trail</option>
<option value=0103>(Caerphilly) Heritage Trail</option>
<option value=0201>(Risca) Heritage and Culture Trail</option>
......