A family friendly commit message updating the kml generator with
This commit is contained in:
parent
e54edd01c3
commit
9096723584
19
data/test.kml
Normal file
19
data/test.kml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||||
|
<Placemark>
|
||||||
|
<name>Polygon Placemark</name>
|
||||||
|
<description>This is a polygon</description>
|
||||||
|
<Polygon>
|
||||||
|
<altitudeMode>clampToGround</altitudeMode>
|
||||||
|
<outerBoundaryIs><LinearRing><coordinates>
|
||||||
|
-1.000000,-1.000000
|
||||||
|
-1.000000,1.000000
|
||||||
|
0.000000,2.000000
|
||||||
|
1.000000,1.000000
|
||||||
|
1.000000,-1.000000
|
||||||
|
0.000000,-2.000000
|
||||||
|
</coordinates></LinearRing></outerBoundaryIs>
|
||||||
|
</Polygon>
|
||||||
|
<Style><PolyStyle><color>#a00000ff</color><outline>0</outline></PolyStyle></Style>
|
||||||
|
</Placemark>
|
||||||
|
</kml>
|
@ -1,7 +1,54 @@
|
|||||||
package evac;
|
package evac;
|
||||||
|
|
||||||
class KmlGenerator {
|
public class KmlGenerator {
|
||||||
static String createKml(OutputModel model) {
|
private static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
||||||
|
private static final String HEADER = "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n";
|
||||||
|
|
||||||
|
private static final String FOOTER = "</kml>\n";
|
||||||
|
|
||||||
|
public static String createKml(OutputModel model) {
|
||||||
return null; // convert the model to KML that can be displayed in Google Earth
|
return null; // convert the model to KML that can be displayed in Google Earth
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String createKml(Position position) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append(XML_HEADER);
|
||||||
|
builder.append(HEADER);
|
||||||
|
|
||||||
|
builder.append("<Placemark>\n");
|
||||||
|
builder.append(" <name>Position Placemark</name>\n");
|
||||||
|
builder.append(" <description>This is a position</description>\n");
|
||||||
|
builder.append(" <Point>\n");
|
||||||
|
builder.append(String.format(" <coordinates>%f,%f</coordinates>\n", position.latitude, position.longitude));
|
||||||
|
builder.append(" </Point>\n");
|
||||||
|
builder.append("</Placemark>\n");
|
||||||
|
|
||||||
|
builder.append(FOOTER);
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String createKml(Polygon polygon) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append(XML_HEADER);
|
||||||
|
builder.append(HEADER);
|
||||||
|
|
||||||
|
builder.append("<Placemark>\n");
|
||||||
|
builder.append(" <name>Polygon Placemark</name>\n");
|
||||||
|
builder.append(" <description>This is a polygon</description>\n");
|
||||||
|
builder.append(" <Polygon>\n");
|
||||||
|
builder.append(" <altitudeMode>clampToGround</altitudeMode>\n");
|
||||||
|
builder.append(" <outerBoundaryIs><LinearRing><coordinates>\n");
|
||||||
|
for (Position position : polygon.positions) {
|
||||||
|
builder.append(String.format(" %f,%f\n", position.latitude, position.longitude));
|
||||||
|
}
|
||||||
|
builder.append(" </coordinates></LinearRing></outerBoundaryIs>\n");
|
||||||
|
builder.append(" </Polygon>\n");
|
||||||
|
builder.append(" <Style><PolyStyle><color>#a00000ff</color><outline>0</outline></PolyStyle></Style>\n");
|
||||||
|
builder.append("</Placemark>\n");
|
||||||
|
|
||||||
|
builder.append(FOOTER);
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
27
src/evac/KmlTest.java
Normal file
27
src/evac/KmlTest.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package evac;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class KmlTest {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String kml;
|
||||||
|
|
||||||
|
//Position position = new Position(0, 0);
|
||||||
|
|
||||||
|
// kml = KmlGenerator.createKml(position);
|
||||||
|
// System.out.print(kml);
|
||||||
|
|
||||||
|
List<Position> polygonPoints = new ArrayList<Position>();
|
||||||
|
polygonPoints.add(new Position(-1, -1));
|
||||||
|
polygonPoints.add(new Position(1, -1));
|
||||||
|
polygonPoints.add(new Position(2, 0));
|
||||||
|
polygonPoints.add(new Position(1, 1));
|
||||||
|
polygonPoints.add(new Position(-1, 1));
|
||||||
|
polygonPoints.add(new Position(-2, 0));
|
||||||
|
Polygon polygon = new Polygon(polygonPoints);
|
||||||
|
|
||||||
|
kml = KmlGenerator.createKml(polygon);
|
||||||
|
System.out.print(kml);
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
package evac;
|
package evac;
|
||||||
|
|
||||||
public class SolvedEdge {
|
class SolvedEdge {
|
||||||
final Edge edge;
|
final Edge edge;
|
||||||
final int flow;
|
final int flow;
|
||||||
|
|
||||||
public SolvedEdge(Edge edge, int flow) {
|
SolvedEdge(Edge edge, int flow) {
|
||||||
this.edge = edge;
|
this.edge = edge;
|
||||||
this.flow = flow;
|
this.flow = flow;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user