Element zoneElement = iterator.next();
if ("zone".equals(zoneElement.getName()))
{
zoneDat.set("name", zoneElement.attribute("name").getValue());
zoneDat.set("type", zoneElement.attribute("type").getValue());
Territory territory = null;
boolean isShape;
for (Iterator<Element> i = zoneElement.elementIterator(); i.hasNext();)
{
Element n = i.next();
if ("set".equals(n.getName()))
{
zoneDat.set(n.attributeValue("name"), n.attributeValue("val"));
}
else if ("restart_point".equals(n.getName()))
{
List<Location> restartPoints = new ArrayList<>();
for (Iterator<?> ii = n.elementIterator(); ii.hasNext();)
{
Element d = (Element) ii.next();
if ("coords".equalsIgnoreCase(d.getName()))
{
Location loc = Location.parseLoc(d.attribute("loc").getValue());
restartPoints.add(loc);
}
}
zoneDat.set("restart_points", restartPoints);
}
else if ("PKrestart_point".equals(n.getName()))
{
List<Location> PKrestartPoints = new ArrayList<>();
for (Iterator<?> ii = n.elementIterator(); ii.hasNext();)
{
Element d = (Element) ii.next();
if ("coords".equalsIgnoreCase(d.getName()))
{
Location loc = Location.parseLoc(d.attribute("loc").getValue());
PKrestartPoints.add(loc);
}
}
zoneDat.set("PKrestart_points", PKrestartPoints);
}
else if ((isShape = "rectangle".equalsIgnoreCase(n.getName())) || "banned_rectangle".equalsIgnoreCase(n.getName()))
{
Shape shape = parseRectangle(n);
if (territory == null)
{
territory = new Territory();
zoneDat.set("territory", territory);
}
if (isShape)
{
territory.add(shape);
}
else
{
territory.addBanned(shape);
}
}
else if ((isShape = "circle".equalsIgnoreCase(n.getName())) || "banned_cicrcle".equalsIgnoreCase(n.getName()))
{
Shape shape = parseCircle(n);
if (territory == null)
{
territory = new Territory();
zoneDat.set("territory", territory);
}
if (isShape)
{
territory.add(shape);
}
else
{
territory.addBanned(shape);
}
}
else if ((isShape = "polygon".equalsIgnoreCase(n.getName())) || "banned_polygon".equalsIgnoreCase(n.getName()))
{
Polygon shape = parsePolygon(n);
if (!shape.validate())
{
error("ZoneParser: invalid territory data : " + shape + ", zone: " + zoneDat.getString("name") + "!");
}
if (territory == null)
{
territory = new Territory();
zoneDat.set("territory", territory);
}
if (isShape)
{
territory.add(shape);
}
else
{
territory.addBanned(shape);
}
}
}
if ((territory == null) || territory.getTerritories().isEmpty())
{
error("Empty territory for zone: " + zoneDat.get("name"));
}
ZoneTemplate template = new ZoneTemplate(zoneDat);
getHolder().addTemplate(template);