Exemplo n.º 1
0
  private static String createJsonOutput(
      String varName, DataOfInterest what, Collection<RentalZone> zones) {
    StringBuilder dataJson = new StringBuilder();

    int pos = 0;
    int max = -1;
    for (RentalZone zone : zones) {
      int actualData = extractDataOfInterest(zone, what);

      if (actualData <= 0) continue;
      if (actualData > max) max = actualData;

      dataJson.append("\t\t{\"lat\": ");
      dataJson.append(zone.getLat());
      dataJson.append(", \"lng\": ");
      dataJson.append(zone.getLng());
      dataJson.append(", \"count\": ");
      dataJson.append(actualData);
      dataJson.append("}");
      if (++pos < zones.size()) dataJson.append(',');
      dataJson.append(" // ");
      dataJson.append(zone.getBezeichnung());
      dataJson.append("\n");
    }

    return "var "
        + varName
        + " = {\n\t\"max\": "
        + max
        + ",\n\t\"data\": [\n"
        + dataJson.toString()
        + "\n\t]\n};";
  }
Exemplo n.º 2
0
 public RentalRoute(RentalZone x, RentalZone y) {
   // build deterministic pair
   if (x.getLat() > y.getLat()) {
     a = x;
     b = y;
   } else {
     b = x;
     a = y;
   }
 }
Exemplo n.º 3
0
  private static int extractDataOfInterest(RentalZone zone, DataOfInterest what) {
    switch (what) {
      case STARTS:
      case INTERPOLATION:
        return zone.getRentalStarts();

      case ENDS:
        return zone.getRentalEnds();

      case SINKS:
        int sinks = zone.getRentalEnds() - zone.getRentalStarts();
        if (sinks < 0) return -1;
        return sinks;

      case SOURCES:
        int source = zone.getRentalStarts() - zone.getRentalEnds();
        if (source < 0) return -1;
        return source;

      default:
        return -1;
    }
  }
Exemplo n.º 4
0
 public boolean equals(RentalRoute other) {
   return other.a.getHal().equals(a.getHal()) && other.b.getHal().equals(b.getHal());
 }