`Здравствуйте, я пытаюсь создать код, в котором линии рисуются между разными аэропортами Франции, но проблема в том, что я могу рисовать путевые точки, но не могу провести линии между некоторыми из них.
Я использую два типа файлов: файл .txt, в котором я извлекаю координаты, используемые в координатах карты, и ArrayList, который присваивает код (строку) каждой путевой точке. У меня также есть файл .csv, в котором я получаю 2 строки. Эти две строки представляют собой путевые точки для связи, и эти строки соответствуют двум кодам, которые обычно уже используются для названия путевой точки.
Я пытаюсь создать линию между различными путевыми точками. на основе файлов .csv.
Мой код:
`Здравствуйте, я пытаюсь создать код, в котором линии рисуются между разными аэропортами Франции, но проблема в том, что я могу рисовать путевые точки, но не могу провести линии между некоторыми из них. Я использую два типа файлов: файл .txt, в котором я извлекаю координаты, используемые в координатах карты, и ArrayList, который присваивает код (строку) каждой путевой точке. У меня также есть файл .csv, в котором я получаю 2 строки. Эти две строки представляют собой путевые точки для связи, и эти строки соответствуют двум кодам, которые обычно уже используются для названия путевой точки. Я пытаюсь создать линию между различными путевыми точками. на основе файлов .csv. Мой код: [code]package saej.lectureCSV;
public AffichageMap(Map coordinates, ArrayList code) { if (coordinates != null) { this.coordinates = coordinates; } else { this.coordinates = new HashMap(); }
if (code != null) { this.code = code; } else { this.code = new ArrayList(); } this.waypoints = new HashSet(); this.codeWaypointMap = new HashMap(); initMapViewer(); ajouterWaypoints(); afficherWaypoints(); }
public AffichageMap(Map vol, String nom) { if (vol != null) { this.vol = vol; } else { this.vol = new HashMap(); }
if (nom != null) { this.nom = nom; } else { this.nom = ""; }
this.codeWaypointMap = new HashMap(); this.waypoints = new HashSet(); initMapViewer();
ajouterWaypointsFromVol(); }
private void initMapViewer() { mapViewer = new JXMapViewer(); TileFactoryInfo info = new OSMTileFactoryInfo(); DefaultTileFactory tileFactory = new DefaultTileFactory(info); mapViewer.setTileFactory(tileFactory);
mapViewer.setZoom(8); mapViewer.setAddressLocation(new GeoPosition(46.1753, 2.4650)); MouseInputListener mil = new PanMouseInputListener(mapViewer); mapViewer.addMouseListener(mil); mapViewer.addMouseMotionListener(mil); mapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCenter(mapViewer)); }
if (wp1 != null && wp2 != null && !wp1.equals(wp2)) { System.out.println("Adding edge between: " + wp1.getCode() + " and " + wp2.getCode()); LinePainter linePainter = new LinePainter(wp1.getPosition(), wp2.getPosition());
Painter currentPainter = mapViewer.getOverlayPainter(); List > painters = new ArrayList(); if (currentPainter instanceof CompoundPainter) { painters.addAll(((CompoundPainter) currentPainter).getPainters()); } else if (currentPainter != null) { painters.add((Painter) currentPainter); } painters.add(linePainter);
CompoundPainter compoundPainter = new CompoundPainter(painters); mapViewer.setOverlayPainter(compoundPainter); } else { if (wp1 == null) { System.out.println("Waypoint not found for code: " + code1); } if (wp2 == null) { System.out.println("Waypoint not found for code: " + code2); } if (wp1 != null && wp2 != null && wp1.equals(wp2)) { System.out.println("Waypoints are the same for codes: " + code1 + " and " + code2); } } }