20 package org.matsim.vis.kml;
22 import org.apache.log4j.Logger;
36 import net.opengis.kml.v_2_2_0.AbstractFeatureType;
37 import net.opengis.kml.v_2_2_0.FolderType;
38 import net.opengis.kml.v_2_2_0.LineStringType;
39 import net.opengis.kml.v_2_2_0.ObjectFactory;
40 import net.opengis.kml.v_2_2_0.PlacemarkType;
41 import net.opengis.kml.v_2_2_0.PointType;
42 import net.opengis.kml.v_2_2_0.StyleType;
53 public static final String
ENDP =
"</p>";
54 public static final String
STARTP =
"<p>";
55 public static final String
ENDH3 =
"</h3>";
56 public static final String
STARTH3 =
"<h3>";
57 public static final String
ENDH2 =
"</h2>";
59 public static final String
STARTH2 =
"<h2>";
62 private static final String
STARTUL =
"<ul>";
63 private static final String
ENDUL =
"</ul>";
64 private static final String
STARTLI =
"<li>";
65 private static final String
ENDLI =
"</li>";
76 FolderType folder = this.kmlObjectFactory.createFolderType();
78 folder.setName(l.
getId().toString());
80 PlacemarkType p = this.kmlObjectFactory.createPlacemarkType();
81 p.setName(l.
getId().toString());
85 LineStringType line = this.kmlObjectFactory.createLineStringType();
86 line.getCoordinates().add(Double.toString(fromCoord.
getX()) +
"," + Double.toString(fromCoord.
getY()) +
",0.0");
87 line.getCoordinates().add(Double.toString(toCoord.
getX()) +
"," + Double.toString(toCoord.
getY()) +
",0.0");
88 p.setAbstractGeometryGroup(this.kmlObjectFactory.createLineString(line));
89 p.setStyleUrl(networkStyle.getId());
90 p.setDescription(description);
92 PlacemarkType pointPlacemark = this.kmlObjectFactory.createPlacemarkType();
94 PointType point = this.kmlObjectFactory.createPointType();
95 point.getCoordinates().add(Double.toString(centerCoord.
getX()) +
"," + Double.toString(centerCoord.
getY()) +
",0.0");
96 pointPlacemark.setAbstractGeometryGroup(this.kmlObjectFactory.createPoint(point));
97 pointPlacemark.setStyleUrl(networkStyle.getId());
98 pointPlacemark.setDescription(description);
100 folder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(pointPlacemark));
101 folder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark(p));
107 PlacemarkType p = this.kmlObjectFactory.createPlacemarkType();
108 p.setName(n.
getId().toString());
111 PointType point = this.kmlObjectFactory.createPointType();
112 point.getCoordinates().add(Double.toString(coord.
getX()) +
"," + Double.toString(coord.
getY()) +
",0.0");
113 p.setAbstractGeometryGroup(this.kmlObjectFactory.createPoint(point));
115 p.setStyleUrl(networkStyle.getId());
123 PlacemarkType p = this.kmlObjectFactory.createPlacemarkType();
124 p.setName(
"Activity on link: " + act.
getLinkId().toString());
127 PointType point = this.kmlObjectFactory.createPointType();
128 point.getCoordinates().add(Double.toString(coord.
getX()) +
"," + Double.toString(coord.
getY()) +
",0.0");
129 p.setAbstractGeometryGroup(this.kmlObjectFactory.createPoint(point));
131 p.setStyleUrl(style.getId());
136 FolderType folder = this.kmlObjectFactory.createFolderType();
143 if (abstractFeature.getClass().equals(FolderType.class)) {
144 folder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createFolder((FolderType) abstractFeature));
146 log.warn(
"Not yet implemented: Adding link KML features of type" + abstractFeature.getClass());
152 if (abstractFeature.getClass().equals(PlacemarkType.class)) {
153 folder.getAbstractFeatureGroup().add(this.kmlObjectFactory.createPlacemark((PlacemarkType) abstractFeature));
155 log.warn(
"Not yet implemented: Adding node KML features of type" + abstractFeature.getClass());
163 StringBuilder buffer =
new StringBuilder(100);
166 buffer.append(
"Link: " );
167 buffer.append(l.
getId());
170 buffer.append(
"From Node: ");
176 buffer.append(
"To Node: ");
183 buffer.append(
"Attributes: ");
186 buffer.append(STARTUL);
187 buffer.append(STARTLI);
188 buffer.append(
"Freespeed: ");
190 buffer.append(ENDLI);
191 buffer.append(STARTLI);
192 buffer.append(
"Capacity: ");
194 buffer.append(ENDLI);
195 buffer.append(STARTLI);
196 buffer.append(
"Number of Lanes: ");
198 buffer.append(ENDLI);
199 buffer.append(STARTLI);
200 buffer.append(
"Length: ");
202 buffer.append(ENDLI);
203 buffer.append(ENDUL);
208 return buffer.toString();
212 StringBuilder buffer =
new StringBuilder(100);
215 buffer.append(
"Node: " );
216 buffer.append(n.
getId());
219 buffer.append(
"Inlinks");
222 buffer.append(STARTUL);
224 buffer.append(STARTLI);
225 buffer.append(
"Link: " );
226 buffer.append(l.getId());
227 buffer.append(
" from Node: " );
228 buffer.append(l.getFromNode().getId());
229 buffer.append(ENDLI);
231 buffer.append(ENDUL);
234 buffer.append(
"Outlinks");
237 buffer.append(STARTUL);
239 buffer.append(STARTLI);
240 buffer.append(
"Link: " );
241 buffer.append(l.getId());
242 buffer.append(
" to Node: ");
243 buffer.append(l.getToNode().getId());
244 buffer.append(ENDLI);
246 buffer.append(ENDUL);
249 return buffer.toString();
static final String ENDH2
static final String STARTH3
static final String STARTLI
static final String ENDLI
AbstractFeatureType createLinkFeature(final Link l, StyleType networkStyle)
Map< Id< Link >, ? extends Link > getInLinks()
OptionalTime getDepartureTime()
static final String ENDUL
String createNodeDescription(Node n)
static final String STARTP
double getNumberOfLanes()
static final String ENDCDATA
static final String STARTCDATA
static final String writeTime(final double seconds, final String timeformat)
static final String STARTUL
static final String ENDH3
Map< Id< Link >, ? extends Link > getLinks()
AbstractFeatureType createNodeFeature(final Node n, StyleType networkStyle)
static List< Node > getNodes(final NetworkRoute route, final Network network)
NetworkFeatureFactory(CoordinateTransformation coordTransform, final Network network)
AbstractFeatureType createLegFeature(Leg leg, StyleType style)
Map< Id< Link >, ? extends Link > getOutLinks()
static final String STARTH2
AbstractFeatureType createActFeature(Activity act, StyleType style)
String createLinkDescription(Link l)
CoordinateTransformation coordTransform
ObjectFactory kmlObjectFactory