use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class AbstractKMLMap method mapData.
public XMLElement mapData(Message m) throws XMLParseException, IOException {
Map<String, Message> messageMap = new HashMap<String, Message>();
XMLElement xe = new CaseSensitiveXMLElement();
xe.parseFromReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(mapPath), "UTF-8"));
if (m != null) {
List<Message> msgElements = m.getAllMessages();
for (Message message : msgElements) {
Property key = message.getProperty("Key");
String keyVal = "" + key.getTypedValue();
messageMap.put(keyVal, message);
}
}
// Create a map of all marker placemarks, for reference
Map<String, XMLElement> markerMap = new HashMap<String, XMLElement>();
List<XMLElement> markers = xe.getElementsByTagName("Placemark");
for (XMLElement element : markers) {
String id = element.getStringAttribute("id", "");
if (id.startsWith("marker_")) {
markerMap.put(id, element);
}
}
List<XMLElement> l = xe.getElementsByTagName("Style");
for (XMLElement element : l) {
String stringAttribute = element.getStringAttribute("id");
String id = stringAttribute.substring(8, stringAttribute.length() - 4);
Message message = messageMap.get(id);
renderStyle(element, message, markerMap);
}
return xe;
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class AbstractKMLMap method createCirclePlacemark.
protected XMLElement createCirclePlacemark(Message message) {
int members = Integer.parseInt(message.getProperty("MemberCount").getValue());
XMLElement placemark = new CaseSensitiveXMLElement("Placemark");
placemark.setAttribute("id", message.getProperty("OrganizationId").getTypedValue());
placemark.addTagKeyValue("name", message.getProperty("Name").getValue());
XMLElement style = new CaseSensitiveXMLElement("Style");
XMLElement lineStyle = new CaseSensitiveXMLElement("LineStyle");
lineStyle.addTagKeyValue("width", "1");
lineStyle.addTagKeyValue("color", "99ff0000");
XMLElement polyStyle = new CaseSensitiveXMLElement("PolyStyle");
polyStyle.addTagKeyValue("color", "99ff0000");
style.addChild(lineStyle);
style.addChild(polyStyle);
placemark.addChild(style);
XMLElement polygon = new CaseSensitiveXMLElement("Polygon");
polygon.addTagKeyValue("extrude", "0");
polygon.addTagKeyValue("tessellate", "1");
polygon.addTagKeyValue("altitudeMode", "clampToGround");
placemark.addChild(polygon);
XMLElement outerBoundaryIs = new CaseSensitiveXMLElement("outerBoundaryIs");
polygon.addChild(outerBoundaryIs);
XMLElement LinearRing = new CaseSensitiveXMLElement("LinearRing");
outerBoundaryIs.addChild(LinearRing);
// Set coordinates as tagkeyvalue for the linear ring.
String slon = message.getProperty("Longitude").getValue();
String slat = message.getProperty("Latitude").getValue();
if (slon.equals("-1.0") || slat.equals("-1.0")) {
return null;
}
// point.addTagKeyValue("coordinates", slon+","+slat);
double clat = Double.parseDouble(slat);
double clon = Double.parseDouble(slon);
double radius = 100 + members;
int sides = 25;
if (radius > 10000) {
sides = 50;
}
ArrayList<Double> coords = generateCircleCoordinates(clat, clon, radius, sides);
String coordinates = "";
for (int i = 0; i < coords.size(); i += 2) {
double lon = coords.get(i + 1);
double lat = coords.get(i);
if (i > 0) {
coordinates = coordinates + "\n";
}
coordinates = coordinates + lon + "," + lat + ",10";
}
LinearRing.addTagKeyValue("coordinates", coordinates);
return placemark;
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class SvgRenderer method createSvgRoot.
private XMLElement createSvgRoot() {
// <svg viewBox="3 50 3 4" width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
XMLElement root = new CaseSensitiveXMLElement("svg");
root.setAttribute("viewBox", "" + rootX + " " + rootY + " " + rootWidth + " " + rootHeight);
root.setAttribute("height", "100%");
root.setAttribute("width", "100%");
root.setAttribute("xmlns", "http://www.w3.org/2000/svg");
if (background != null) {
XMLElement backgroundRect = new CaseSensitiveXMLElement("rect");
backgroundRect.setAttribute("x", rootX);
backgroundRect.setAttribute("y", rootY);
backgroundRect.setAttribute("width", rootWidth);
backgroundRect.setAttribute("height", rootHeight);
backgroundRect.setAttribute("fill", background);
root.addChild(backgroundRect);
}
// <rect x="-2" y="-2" width="4" height="4" fill="#000088"/>
return root;
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class SvgRenderer method createSvgElement.
private XMLElement createSvgElement(XMLElement multi, XMLElement styleElement) {
// <MultiGeometry>
// <Polygon id="Result">
// <outerBoundaryIs>
// <LinearRing>
// <coordinates>5.623634,52.650148 5.622156,52.650151 5.618618,52.650696 5.616777,52.651468 5.616309,52.651052 5.61625,52.651061 5.601499,52.656481 5.601517,52.660075 5.598908,52.660874 5.59885,52.660892 5.598565,52.660979 5.592649,52.660091 5.592662,52.662787 5.592663,52.663039 5.592663,52.663087 5.592695,52.669884 5.592695,52.669897 5.592695,52.669977 5.592725,52.676267 5.59716,52.67626 5.607537,52.681633 5.613452,52.681622 5.625287,52.682498 5.643032,52.682461 5.641542,52.678015 5.641527,52.67797 5.641546,52.677954 5.654763,52.666258 5.642906,52.660892 5.64315,52.660683 5.643336,52.660524 5.650259,52.654585 5.648749,52.649196 5.628067,52.650139 5.627379,52.65014</coordinates>
// </LinearRing>
// </outerBoundaryIs>
// </Polygon>
// </MultiGeometry>
XMLElement group = new CaseSensitiveXMLElement("g");
Vector<XMLElement> poly = multi.getElementsByTagName("Polygon");
for (XMLElement element : poly) {
XMLElement lin = element.getElementByTagName("LinearRing");
String coordinates = lin.getElementByTagName("coordinates").getContent();
XMLElement polygon = new CaseSensitiveXMLElement("polygon");
applyPoints(polygon, coordinates);
if (styleElement != null) {
System.err.println("Applying style");
applyKmlStyle(polygon, styleElement);
}
group.addChild(polygon);
}
return group;
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class SvgRenderer method renderStream.
private XMLElement renderStream(InputStream fis) throws IOException {
XMLElement xe = new CaseSensitiveXMLElement();
xe.parseFromReader(new InputStreamReader(fis, "UTF-8"));
fis.close();
Map<String, XMLElement> styleMap = new HashMap<String, XMLElement>();
List<XMLElement> style = xe.getElementsByTagName("Style");
for (XMLElement element : style) {
String styleId = element.getStringAttribute("id");
styleMap.put(styleId, element);
}
System.err.println("# of styles: " + styleMap.size());
// Create a map of all marker placemarks, for reference
Map<String, XMLElement> markerMap = new HashMap<String, XMLElement>();
List<XMLElement> markers = xe.getElementsByTagName("Placemark");
XMLElement svgRoot = createSvgRoot();
for (XMLElement element : markers) {
String id = element.getStringAttribute("id", "");
if (id.startsWith("marker_")) {
markerMap.put(id, element);
}
XMLElement multi = element.getElementByTagName("MultiGeometry");
String styleUrl = element.getElementByTagName("styleUrl").getContent();
if (multi != null) {
XMLElement styleElement = styleMap.get(styleUrl.substring(1));
XMLElement svgElement = createSvgElement(multi, styleElement);
svgRoot.addChild(svgElement);
}
}
return svgRoot;
}
Aggregations