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.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information.Position;

public class SimulationSetupInformationHandler extends DefaultHandler {

    private Position _upperLeft;
    private Position _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 Position(Double.valueOf(edges[0]), Double.valueOf(edges[1]), 0, 0);
                _lowerRight = new Position(Double.valueOf(edges[2]), Double.valueOf(edges[3]), 0, 0);
            }
            throw new CancelParsingSAXException();
        }
    }

    public Position getLowerRight() {
        return _lowerRight;
    }

    public Position getUpperLeft() {
        return _upperLeft;
    }
}
