public void buildeWorldStructure() {
HashMap<String, NodeModel> eNodes = new HashMap<String, NodeModel>();
HashMap<String, TrafficLightModel> eTrafficLights = new HashMap<String, TrafficLightModel>();
HashMap<String, WayModel> eWays = new HashMap<String, WayModel>();
ModelManager model = ModelManager.getInstance();
model.clearModel();
model.setChanged();
model.notifyObservers(new ObserverNotification(NotificationType.startBatchProcess));
model.clearChanged();
for(String id : nodes.keySet()) {
MyNode n = nodes.get(id);
NodeModel newNode = new NodeModel(n.lat, n.lon);
if (n.isTrafficLight){
TrafficLightModel trafficLight = new TrafficLightModel(newNode);
eTrafficLights.put(id, trafficLight);
}
// if (n.isTrafficLight)
// newNode = new TrafficLightModel(n.lat, n.lon);
// else
// newNode = new NodeModel(n.lat, n.lon);
eNodes.put(id, newNode);
model.addModelElement(newNode);
}
for(Entry<String, MyEdge> edgePair : edges.entrySet()) {
MyEdge e = edgePair.getValue();
EdgeModel newEdge = new EdgeModel(edgePair.getKey(), eNodes.get(e.first), eNodes.get(e.second));
for(int i=0; i<e.nolanes; i++) {
newEdge.addLane(new LaneModel());
}
model.addModelElement(newEdge);
if (eWays.keySet().contains(e.second + "|" + e.first)) {
eWays.get(e.second+"|"+e.first).addBackwardEdge(newEdge);
newEdge.setComplementaryEdge(eWays.get(e.second+"|"+e.first).getFirstForwardEdge());
eWays.get(e.second+"|"+e.first).getFirstForwardEdge().setComplementaryEdge(newEdge);
newEdge.setParentWay(eWays.get(e.second+"|"+e.first));
} else {
WayModel newWay = new WayModel("");
newWay.addForwardEdge(newEdge);
newEdge.setParentWay(newWay);
eWays.put(e.first+"|"+e.second, newWay);
model.addModelElement(newWay);
}
}
model.setChanged();
model.notifyObservers(new ObserverNotification(NotificationType.endBatchProcess, true, false));
model.clearChanged();
}