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;
}
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;
}
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 & with &
iconShape = iconShape.replaceAll("&", "&");
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;
}
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;
}
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;
}
Aggregations