Skip to content
Snippets Groups Projects
Commit 9356db39 authored by Rhys Evans's avatar Rhys Evans
Browse files

Further streamlining of trails controller code

parent 69dce865
No related branches found
No related tags found
1 merge request!40Resolve "As a user I would like to see a map containing all landmarks for a trail and a suggested path between them, so that I can easily follow the trail"
......@@ -81,18 +81,11 @@ public class PlacesController {
ModelAndView modelAndView = new ModelAndView("landmarks/trailsPage.html");
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Location> approvedLocations = locationRepo.getAllApprovedLocations();
List<Trail> trailslocations = trailsRepo.getAllTrails();
List<Location> locations = locationRepo.getAllLocation();
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("trails", trailslocations);
modelAndView.addObject("locations", locationCoordsWorkaround);
modelAndView.addObject("locations", approvedLocations);
modelAndView.addObject("locationCoords", locCoords);
return modelAndView;
}
......@@ -105,18 +98,10 @@ public class PlacesController {
@GetMapping("/trails/{trail}")
public ModelAndView getResultBySearchKeyTrails(@PathVariable String trail) {
List<Location> locations = locationRepo.getAllLocation();
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Location> approvedLocations = locationRepo.getAllApprovedLocations();
List<Trail> trailslocations = trailsRepo.getAllTrails();
List<Integer> locationIDIndex = new ArrayList<Integer>();
List<Location> locationCoordsWorkaround = new ArrayList<Location>();
int trailID = 999;
int workAroundID=0;// otherwise cases errors e.g. null used. 999 unlikely to be used so safe until then
for (LocationsCoordinates coord: locCoords){
locationIDIndex.add(coord.getLocationID()-1);
locationCoordsWorkaround.add(locations.get(coord.getLocationID()-1));
}
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)){
......@@ -126,24 +111,8 @@ public class PlacesController {
ModelAndView modelAndView= new ModelAndView("fragments/trailsPageFrags :: trailsSection");
modelAndView.addObject("trail", trailslocations.get(trailID));
modelAndView.addObject("locCoords", locCoords);
modelAndView.addObject("locations", locationCoordsWorkaround);
modelAndView.addObject("locations", approvedLocations);
return modelAndView;
// List<Trail> trailslocations = trailsRepo.getAllTrails();
// List<Location> locations = locationRepo.getAllLocation();
// 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("trails", trailslocations);
// modelAndView.addObject("locations", locationCoordsWorkaround);
// modelAndView.addObject("locationCoords", locCoords);
// return modelAndView;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment