Search in sources :

Example 36 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class GeoPoint method createElement.

public XMLElement createElement(String label) {
    XMLElement c = new CaseSensitiveXMLElement("Point");
    c.addTagKeyValue("extrude", "0");
    c.addTagKeyValue("altitudeMode", "clampToGround");
    c.addTagKeyValue("coordinates", getCoordinates());
    if (label == null) {
        c.addTagKeyValue("name", id);
    } else {
        c.addTagKeyValue("name", label);
    }
    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 37 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class GeoPoint method createPlaceMark.

public XMLElement createPlaceMark(String label) {
    XMLElement c = new CaseSensitiveXMLElement("Placemark");
    c.setAttribute("id", label);
    c.addTagKeyValue("name", label);
    XMLElement point = createElement();
    c.addChild(point);
    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 38 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class AbstractKMLMap method createPointKmlFile.

public File createPointKmlFile(Navajo n, String messagePath) throws XMLParseException, IOException {
    Message m = n.getMessage(messagePath);
    List<Message> ll = (m != null ? m.getAllMessages() : null);
    XMLElement kml = new CaseSensitiveXMLElement("kml");
    XMLElement document = new CaseSensitiveXMLElement("Document");
    kml.addChild(document);
    Message c = n.getMessage("Styles");
    if (c != null) {
        List<Message> colors = c.getAllMessages();
        for (Message message : colors) {
            XMLElement style = new CaseSensitiveXMLElement("Style");
            XMLElement iconStyle = new CaseSensitiveXMLElement("IconStyle");
            style.setAttribute("id", message.getProperty("StyleRef").getTypedValue());
            style.addChild(iconStyle);
            if (message.getProperty("IconColor") != null) {
                iconStyle.addTagKeyValue("color", "ff" + message.getProperty("IconColor").getTypedValue() + "");
            } else {
                iconStyle.addTagKeyValue("colorMode", "random");
            }
            XMLElement icon = new CaseSensitiveXMLElement("Icon");
            iconStyle.addChild(icon);
            String iconShape = "http://maps.google.com/mapfiles/kml/shapes/play.png";
            if (message.getProperty("IconURL") != null) {
                iconShape = message.getProperty("IconURL").getValue();
                // Make sure to replace &amp; with &
                iconShape = iconShape.replaceAll("&amp;", "&");
                logger.debug("Using url: {}", iconShape);
            } else if (message.getProperty("Icon") != null) {
                iconShape = "http://maps.google.com/mapfiles/kml/" + message.getProperty("Icon").getTypedValue();
            }
            icon.addTagKeyValue("href", iconShape);
            document.addChild(style);
        }
    }
    Message hasFolders = n.getMessage("Folders");
    if (hasFolders != null) {
        List<Message> folders = hasFolders.getAllMessages();
        for (Message folder : folders) {
            String name = folder.getProperty("Name").getValue();
            XMLElement folderElt = createFolder(name);
            m = folder.getMessage(messagePath);
            if (m != null) {
                ll = m.getAllMessages();
                for (Message message : ll) {
                    XMLElement placemark = createPointPlaceMark(message);
                    if (placemark != null) {
                        folderElt.addChild(placemark);
                    }
                }
            }
            if (folderElt != null) {
                document.addChild(folderElt);
            }
        }
    } else {
        if (ll != null) {
            for (Message message : ll) {
                XMLElement placemark = createPointPlaceMark(message);
                // XMLElement placemark = createCirclePlacemark(message);
                if (placemark != null) {
                    document.addChild(placemark);
                }
            }
        }
    }
    File res = File.createTempFile("pointData", ".kml");
    FileWriter fw = new FileWriter(res);
    kml.write(fw);
    fw.flush();
    fw.close();
    return res;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) Message(com.dexels.navajo.document.Message) FileWriter(java.io.FileWriter) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) File(java.io.File)

Example 39 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class AbstractKMLMap method createPointPlaceMark.

private XMLElement createPointPlaceMark(Message message) {
    XMLElement placemark = new CaseSensitiveXMLElement("Placemark");
    placemark.setAttribute("id", message.getProperty("Id").getTypedValue());
    placemark.addTagKeyValue("name", message.getProperty("Name").getValue());
    XMLElement point = new CaseSensitiveXMLElement("Point");
    placemark.addChild(point);
    String lon = message.getProperty("Longitude").getValue();
    String lat = message.getProperty("Latitude").getValue();
    if (lon.equals("-1.0") || lat.equals("-1.0")) {
        return null;
    }
    point.addTagKeyValue("coordinates", lon + "," + lat);
    // Introspect other properties.
    StringBuffer descr = new StringBuffer();
    List<Property> properties = message.getAllProperties();
    for (Iterator<Property> iterator = properties.iterator(); iterator.hasNext(); ) {
        Property property = iterator.next();
        if (!(property.getName().equals("Longitude") || property.getName().equals("Latitude") || property.getName().equals("Id") || property.getName().equals("Name"))) {
            descr.append(property.getDescription() + ": " + property.getValue() + "<br/>");
        }
    }
    placemark.addTagKeyValue("description", descr.toString());
    logger.debug("Description: {}", descr);
    XMLElement region = new CaseSensitiveXMLElement("Region");
    if (useLOD) {
        placemark.addChild(region);
    }
    XMLElement latLonAltBox = new CaseSensitiveXMLElement("LatLonAltBox");
    region.addChild(latLonAltBox);
    latLonAltBox.addTagKeyValue("north", lat);
    latLonAltBox.addTagKeyValue("south", "" + (Double.parseDouble(lat) - 0.1));
    latLonAltBox.addTagKeyValue("east", lon);
    latLonAltBox.addTagKeyValue("west", "" + (Double.parseDouble(lon) - 0.1));
    XMLElement lod = new CaseSensitiveXMLElement("Lod");
    lod.addTagKeyValue("minLodPixels", "64");
    // lod.addTagKeyValue("maxLodPixels", "5024");
    lod.addTagKeyValue("minFadeExtent", "828");
    lod.addTagKeyValue("maxFadeExtent", "428");
    region.addChild(lod);
    if (message.getProperty("StyleRef") != null) {
        placemark.addTagKeyValue("styleUrl", "#" + message.getProperty("StyleRef").getTypedValue());
    }
    return placemark;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) Property(com.dexels.navajo.document.Property)

Example 40 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class AbstractKMLMap method createFolder.

private XMLElement createFolder(String name) {
    XMLElement folder = new CaseSensitiveXMLElement("Folder");
    XMLElement nameElt = new CaseSensitiveXMLElement("name");
    nameElt.setContent(name);
    folder.addChild(nameElt);
    return folder;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Aggregations

CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)53 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)49 IOException (java.io.IOException)10 InputStreamReader (java.io.InputStreamReader)7 FileReader (java.io.FileReader)5 HashMap (java.util.HashMap)5 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 APIException (com.dexels.navajo.article.APIException)2 Message (com.dexels.navajo.document.Message)2 Property (com.dexels.navajo.document.Property)2 BufferedReader (java.io.BufferedReader)2 InputStream (java.io.InputStream)2 PrintWriter (java.io.PrintWriter)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 XMLParseException (com.dexels.navajo.document.nanoimpl.XMLParseException)1 AdapterFieldDependency (com.dexels.navajo.mapping.compiler.meta.AdapterFieldDependency)1