Search in sources :

Example 51 with XMLElement

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();
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) InputStreamReader(java.io.InputStreamReader) StringWriter(java.io.StringWriter) ArrayList(java.util.ArrayList) MapMetaData(com.dexels.navajo.mapping.compiler.meta.MapMetaData) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 52 with XMLElement

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;
}
Also used : OutputStream(java.io.OutputStream) OutputStreamWriter(java.io.OutputStreamWriter) Binary(com.dexels.navajo.document.types.Binary) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) FileWriter(java.io.FileWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Example 53 with XMLElement

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;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 54 with XMLElement

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;
}
Also used : ArrayList(java.util.ArrayList) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 55 with XMLElement

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);
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) ArrayList(java.util.ArrayList) IOException(java.io.IOException) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Aggregations

XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)120 CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)109 MapTag (com.dexels.navajo.document.navascript.tags.MapTag)12 IOException (java.io.IOException)12 NS3Compatible (com.dexels.navajo.document.navascript.tags.NS3Compatible)10 ArrayList (java.util.ArrayList)8 ParamTag (com.dexels.navajo.document.navascript.tags.ParamTag)7 InputStreamReader (java.io.InputStreamReader)7 HashMap (java.util.HashMap)7 APIException (com.dexels.navajo.article.APIException)6 ExpressionTag (com.dexels.navajo.document.navascript.tags.ExpressionTag)5 FieldTag (com.dexels.navajo.document.navascript.tags.FieldTag)5 FileInputStream (java.io.FileInputStream)5 FileReader (java.io.FileReader)5 Property (com.dexels.navajo.document.Property)4 IncludeTag (com.dexels.navajo.document.navascript.tags.IncludeTag)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 File (java.io.File)4 Message (com.dexels.navajo.document.Message)3 BlockTag (com.dexels.navajo.document.navascript.tags.BlockTag)3