package de.tud.kom.p2psim.impl.topology.movement.vehicular.sumo.simulation.controller.xml;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;

public class SimulationSetupInformationHandler extends DefaultHandler {

	private Location _upperLeft;
	private Location _lowerRight;

	@Override
	public void startElement(String pUri, String pLocalName, String pQName, Attributes pAttributes)
			throws SAXException {
		if (pQName.equals("location")) {
			String meterBoundary = pAttributes.getValue("convBoundary");
			if (meterBoundary != null) {
				String[] edges = meterBoundary.split(",");
				_upperLeft = new PositionVector(Double.valueOf(edges[0]), Double.valueOf(edges[1]), 0);
				_lowerRight = new PositionVector(Double.valueOf(edges[2]), Double.valueOf(edges[3]), 0);
			}
			throw new CancelParsingSAXException();
		}
	}

	public Location getLowerRight() {
		return _lowerRight;
	}

	public Location getUpperLeft() {
		return _upperLeft;
	}
}
