21 package org.matsim.counts;
25 import java.io.BufferedWriter;
26 import java.io.IOException;
27 class CountsWriterHandlerImplV1
implements CountsWriterHandler {
28 private final CoordinateTransformation coordinateTransformation;
30 CountsWriterHandlerImplV1(CoordinateTransformation coordinateTransformation) {
31 this.coordinateTransformation = coordinateTransformation;
35 public void startCounts(
final Counts counts,
final BufferedWriter out)
throws IOException {
36 out.write(
"<counts ");
37 out.write(
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
38 out.write(
"xsi:noNamespaceSchemaLocation=\"http://matsim.org/files/dtd/counts_v1.xsd\"\n");
40 if (counts.getName() != null) {
41 out.write(
" name=\"" + counts.getName() +
"\"");
43 out.write(
" name=\"\"");
45 if (counts.getDescription() != null) {
46 out.write(
" desc=\"" + counts.getDescription() +
"\"");
48 out.write(
" year=\"" + counts.getYear() +
"\" ");
53 public void endCounts(
final BufferedWriter out)
throws IOException {
54 out.write(
"</counts>\n");
58 public void startCount(
final Count count,
final BufferedWriter out)
throws IOException {
59 out.write(
"\t<count");
60 out.write(
" loc_id=\"" + count.getId() +
"\"");
61 out.write(
" cs_id=\"" + count.getCsLabel() +
"\"");
62 if (count.getCoord() != null) {
63 final Coord coord = coordinateTransformation.
transform( count.getCoord() );
64 out.write(
" x=\"" + coord.getX() +
"\"");
65 out.write(
" y=\"" + coord.getY() +
"\"");
71 public void endCount(
final BufferedWriter out)
throws IOException {
72 out.write(
"\t</count>\n\n");
76 public void startVolume(
final Volume volume,
final BufferedWriter out)
throws IOException {
77 out.write(
"\t\t<volume");
78 out.write(
" h=\"" + volume.getHourOfDayStartingWithOne() +
"\"");
79 out.write(
" val=\"" + volume.getValue() +
"\"");
84 public void endVolume(
final BufferedWriter out)
throws IOException {
88 public void writeSeparator(
final BufferedWriter out)
throws IOException {
89 out.write(
"<!-- ====================================================================== -->\n\n");