use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class GenerateXSD method generateXSD.
public String generateXSD() throws Exception {
CaseSensitiveXMLElement xml = new CaseSensitiveXMLElement();
InputStreamReader fis = new InputStreamReader(getClass().getClassLoader().getResourceAsStream("basenavascript.xsd"));
xml.parseFromReader(fis);
fis.close();
MapMetaData mmd = MapMetaData.getInstance();
Set<String> maps = mmd.getMapDefinitions();
Iterator<String> all = maps.iterator();
while (all.hasNext()) {
String mappie = all.next();
if (!mappie.equals("__empty__")) {
XMLElement x = createAdapterXSD(mappie, xml);
xml.addChild(x);
}
}
ArrayList<XMLElement> tags = new ArrayList<XMLElement>();
findTags(xml, "adapters:insertedadapters", tags);
for (int i = 0; i < tags.size(); i++) {
XMLElement x = tags.get(i);
XMLElement parent = x.getParent();
// <xs:element ref="map.sqlquery"/>
all = maps.iterator();
while (all.hasNext()) {
String mappie = all.next();
if (!mappie.equals("__empty__")) {
CaseSensitiveXMLElement replace = new CaseSensitiveXMLElement("xs:element");
replace.setAttribute("ref", "map." + mappie);
parent.addChild(replace);
}
}
parent.removeChild(x);
}
StringWriter sb = new StringWriter();
xml.write(sb);
return sb.toString();
}
use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class SvgRenderer method renderToBinary.
public Binary renderToBinary(InputStream is) throws XMLParseException, IOException {
XMLElement svgRoot = renderStream(is);
Binary result = new Binary();
OutputStream os = result.getOutputStream();
Writer fw = new OutputStreamWriter(os);
svgRoot.write(fw);
fw.flush();
fw.close();
os.close();
return result;
}
use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class GeoEdge method createElement.
@Override
public XMLElement createElement() {
XMLElement c = new CaseSensitiveXMLElement("LineString");
c.addTagKeyValue("extrude", "0");
c.addTagKeyValue("altitudeMode", "clampToGround");
c.addTagKeyValue("tesselate", "0");
c.addTagKeyValue("coordinates", toString());
return c;
}
use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class GeoPolygonGroup method join.
private GeoPolygon join(GeoPolygon a, GeoPolygon b, List<GeoPoint> prohibited) throws GeoException {
GeoPoint unJoinedPoint = null;
if (a == b) {
throw new GeoException("WTfuuck?");
}
for (GeoPoint aPoint : a.getPoints()) {
if (!b.getPoints().contains(aPoint) && !prohibited.contains(aPoint)) {
unJoinedPoint = aPoint;
break;
}
}
if (unJoinedPoint == null) {
if (reverseStack > 2) {
System.err.println("Reversal error. can not isolate point");
System.err.println("Getting desparate, reversing and seeing if they are identical.");
GeoPolygon temp = new GeoPolygon(a.getPoints());
temp.reverseOrder();
if (temp.equals(b)) {
System.err.println("True equality! just discarding a!");
return b;
}
XMLElement ee = a.createPlaceMarkList().get(0);
XMLElement ff = b.createPlaceMarkList().get(0);
System.err.println("<kml><Document>");
System.err.println(ee.toString() + "\n" + ff.toString());
System.err.println("</Document></kml>");
throw new GeoException("WTF?");
}
reverseStack++;
GeoPolygon join;
try {
join = join(b, a, prohibited);
if (!join.isClockwise()) {
prohibited.addAll(join.getPoints());
join = join(b, a, prohibited);
}
} catch (GeoException g) {
logger.error("Geo exception: " + g.getMessage() + " continuing", g);
return null;
}
reverseStack--;
return join;
}
List<GeoPoint> ppp = new ArrayList<GeoPoint>();
ppp.add(unJoinedPoint);
if (!a.isClockwise()) {
a.reverseOrder();
}
if (!b.isClockwise()) {
b.reverseOrder();
}
try {
join(null, a, b, ppp, prohibited);
} catch (Exception e) {
logger.error("Error: ", e);
}
GeoPolygon gp = new GeoPolygon(ppp);
if (!gp.isClockwise()) {
prohibited.addAll(ppp);
ppp.clear();
gp = join(a, b, prohibited);
ppp = gp.getPoints();
if (!gp.isClockwise()) {
}
}
return gp;
}
use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class GeoPolygonGroup method dumpMe.
private void dumpMe(String filename, List<GeoPolygon> pp) {
List<XMLElement> debugList = new ArrayList<XMLElement>();
for (GeoPolygon geoPoly : pp) {
debugList.addAll(geoPoly.createPlaceMarkList());
}
XMLElement kml = new CaseSensitiveXMLElement("kml");
XMLElement doc = new CaseSensitiveXMLElement("Document");
kml.addChild(doc);
for (XMLElement element : debugList) {
doc.addChild(element);
}
try {
writeElement(filename, kml);
} catch (IOException e) {
logger.error("Error: ", e);
}
}
Aggregations