private ArrayList<ArrayList> getShapes(List shapes, Traject traject) throws UnsupportedEncodingException, FileNotFoundException, IOException {

        FileInputStream stream = new FileInputStream("json/shapes.csv");
        CSVReader reader = new CSVReader(new InputStreamReader(stream, "UTF-8"));
        String[] nextLine;
        ArrayList<ArrayList> allTraject = new ArrayList<ArrayList>();
        HashMap<Integer, ShapesTraject> trajectStart = new HashMap<Integer, ShapesTraject>();
        HashMap<Integer, ShapesTraject> trajectEnd = new HashMap<Integer, ShapesTraject>();

        for (int i = 0; i < shapes.size(); i++) {
            ArrayList<ShapesTraject> shapesArray = new ArrayList<ShapesTraject>();
            allTraject.add(i, shapesArray);
        }

        List positionsStopArray = getPositionsStop(traject);
        while ((nextLine = reader.readNext()) != null) {

            for (int i = 0; i < shapes.size(); i++) {
                if (nextLine[0].equals(shapes.get(i))) {
                    List positionsStop = (ArrayList) positionsStopArray.get(i);
                    List positionsStopstart = (ArrayList) positionsStop.get(0);
                    List positionsStopend = (ArrayList) positionsStop.get(1);

                    ShapesTraject st = new ShapesTraject(nextLine[1], nextLine[2]);
                    ArrayList<ShapesTraject> shapesArray = (ArrayList) allTraject.get(i);
                    shapesArray.add(st);
                    if (positionsStopstart.contains(nextLine[1] + "" + nextLine[2])) {
                        trajectStart.put(i, st);
                    } else if (positionsStopend.contains(nextLine[1] + "" + nextLine[2])) {
                        trajectEnd.put(i, st);
                    }
                }
            }
        }
        for (int i = 0; i < shapes.size(); i++) {
            ArrayList<ShapesTraject> shapesArray = (ArrayList) allTraject.get(i);
            int indexStart = shapesArray.indexOf(trajectStart.get(i));
            int indexEnd = shapesArray.indexOf(trajectEnd.get(i));

            if (indexStart < indexEnd) {
                allTraject.set(i,new ArrayList<ShapesTraject>(shapesArray.subList(indexStart, indexEnd)));
            } else {
                 allTraject.set(i,new ArrayList<ShapesTraject>(shapesArray.subList(indexEnd, indexStart)));
            }
        }
        return allTraject;
    }