Ejemplo n.º 1
0
  @Override
  public void complete() {

    // if smart exclusions enabled and tile is not empty, send them to
    // writer
    if (!StatsHelper.isTileEmpty(stats) && XplaneOptionsHelper.getOptions().isSmartExclusions()) {
      String exclusions = exclusionsHelper.exportExclusions();
      writer.complete(exclusions);

    } else {
      writer.complete(null);
    }

    if (!StatsHelper.isTileEmpty(stats)) {
      Osm2xpLogger.info(
          "Tile "
              + (int) currentTile.x
              + "/"
              + (int) currentTile.y
              + " stats : "
              + stats.getBuildingsNumber()
              + " buildings, "
              + stats.getForestsNumber()
              + " forests, "
              + stats.getStreetlightsNumber()
              + " street lights, "
              + stats.getObjectsNumber()
              + " objects. (generation took "
              + MiscUtils.getTimeDiff(startTime, new Date())
              + ")");

      // stats
      try {
        if (XplaneOptionsHelper.getOptions().isGenerateXmlStats()
            || XplaneOptionsHelper.getOptions().isGeneratePdfStats()) {
          StatsHelper.getStatsList().add(stats);
        }
        if (XplaneOptionsHelper.getOptions().isGenerateXmlStats()) {
          StatsHelper.saveStats(folderPath, currentTile, stats);
        }
        if (XplaneOptionsHelper.getOptions().isGeneratePdfStats()) {
          StatsHelper.generatePdfReport(folderPath, stats);
        }
      } catch (Osm2xpBusinessException e) {
        Osm2xpLogger.error("Error saving stats file for tile " + currentTile, e);
      }
    } else if (!GuiOptionsHelper.getOptions().isSinglePass()) {
      Osm2xpLogger.info(
          "Tile "
              + (int) currentTile.x
              + "/"
              + (int) currentTile.y
              + " is empty, no dsf generated");
    }
  }
Ejemplo n.º 2
0
  /**
   * write a 3D object in the dsf file
   *
   * @param object a xplane dsf object
   * @throws Osm2xpBusinessException
   */
  private void writeObjectToDsf(XplaneDsfObject object) throws Osm2xpBusinessException {

    String objectDsfText = object.asObjDsfText();
    writer.write(objectDsfText, GeomUtils.cleanCoordinatePoint(object.getOsmPolygon().getCenter()));
    // stats
    StatsHelper.addObjectType(dsfObjectsProvider.getObjectsList().get(object.getDsfIndex()), stats);
  }
Ejemplo n.º 3
0
 @Override
 public void init() {
   // writer initialization
   writer.init(currentTile);
   // exclusionHelper
   if (XplaneOptionsHelper.getOptions().isSmartExclusions()) {
     exclusionsHelper.run();
   }
 }
Ejemplo n.º 4
0
  /**
   * write a building in the dsf file.
   *
   * @param polygon
   * @param facade
   * @param size
   */
  private void writeBuildingToDsf(OsmPolygon osmPolygon, Integer facade) {
    if (facade != null && osmPolygon.getHeight() != null) {
      StringBuffer sb = new StringBuffer();
      osmPolygon.setPolygon(GeomUtils.setClockwise(osmPolygon.getPolygon()));
      if (osmPolygon.getPolygon().getArea() * 100000000 > 0.1
          && osmPolygon.getPolygon().getVertexNumber() > 3) {

        sb.append("BEGIN_POLYGON " + facade + " " + osmPolygon.getHeight() + " 2");
        sb.append(System.getProperty("line.separator"));
        sb.append("BEGIN_WINDING");
        sb.append(System.getProperty("line.separator"));

        // on supprime le dernier point pour ne pas boucler
        osmPolygon.getPolygon().removePoint(osmPolygon.getPolygon().getLastPoint());
        for (Point2D loc : osmPolygon.getPolygon().getVertices()) {
          sb.append("POLYGON_POINT " + loc.y + " " + loc.x);
          sb.append(System.getProperty("line.separator"));
        }
        sb.append("END_WINDING");
        sb.append(System.getProperty("line.separator"));
        sb.append("END_POLYGON");
        sb.append(System.getProperty("line.separator"));

        // stats TODO not working anymore since v2 facades new features.
        if (dsfObjectsProvider.getPolygonsList().get(facade).toLowerCase().contains("building")
            || dsfObjectsProvider.getPolygonsList().get(facade).toLowerCase().contains("shape")) {
          StatsHelper.addBuildingType("Building", stats);
        } else {
          if (dsfObjectsProvider.getPolygonsList().get(facade).toLowerCase().contains("house")
              || dsfObjectsProvider
                  .getPolygonsList()
                  .get(facade)
                  .toLowerCase()
                  .contains("common")) {
            StatsHelper.addBuildingType("Residential", stats);
          } else {
            StatsHelper.addBuildingType("Facade rule", stats);
          }
        }
        writer.write(
            sb.toString(), GeomUtils.cleanCoordinatePoint(osmPolygon.getPolygon().getFirstPoint()));
      }
    }
  }
Ejemplo n.º 5
0
  /**
   * @param polygon the forest polygon
   * @param forestIndexAndDensity index and density of the forest rule
   */
  private void writeForestToDsf(OsmPolygon osmPolygon, Integer[] forestIndexAndDensity) {
    StringBuffer sb = new StringBuffer();
    sb.append("BEGIN_POLYGON " + forestIndexAndDensity[0] + " " + forestIndexAndDensity[1] + " 2");
    sb.append(System.getProperty("line.separator"));
    sb.append("BEGIN_WINDING");
    sb.append(System.getProperty("line.separator"));
    for (Point2D loc : osmPolygon.getPolygon().getVertices()) {
      sb.append("POLYGON_POINT " + loc.y + " " + loc.x);
      sb.append(System.getProperty("line.separator"));
    }
    sb.append("END_WINDING");
    sb.append(System.getProperty("line.separator"));
    sb.append("END_POLYGON");
    sb.append(System.getProperty("line.separator"));

    // stats
    StatsHelper.addForestType(
        dsfObjectsProvider.getPolygonsList().get(forestIndexAndDensity[0]), stats);

    writer.write(
        sb.toString(), GeomUtils.cleanCoordinatePoint(osmPolygon.getPolygon().getFirstPoint()));
  }
Ejemplo n.º 6
0
  /**
   * Write streetlight objects in dsf file.
   *
   * @param osmPolygon osm road polygon
   */
  public void writeStreetLightToDsf(OsmPolygon osmPolygon) {
    // init d'un entier pour modulo densité street lights
    Integer densityIndex = 0;
    if (XplaneOptionsHelper.getOptions().getLightsDensity() == 0) {
      densityIndex = 10;
    } else {
      if (XplaneOptionsHelper.getOptions().getLightsDensity() == 1) {
        densityIndex = 5;
      } else {
        if (XplaneOptionsHelper.getOptions().getLightsDensity() == 2) densityIndex = 3;
      }
    }
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < osmPolygon.getPolygon().getVertices().size(); i++) {
      if ((i % densityIndex) == 0) {
        Point2D lightLoc = osmPolygon.getPolygon().getVertex(i);
        lightLoc.x = lightLoc.x + 0.0001;
        lightLoc.y = lightLoc.y + 0.0001;
        if (GeomUtils.compareCoordinates(lightLoc, currentTile)) {
          Random randomGenerator = new Random();
          int orientation = randomGenerator.nextInt(360);
          sb.append(
              "OBJECT "
                  + dsfObjectsProvider.getRandomStreetLightObject()
                  + " "
                  + (lightLoc.y)
                  + " "
                  + (lightLoc.x)
                  + " "
                  + orientation);
          sb.append(System.getProperty("line.separator"));
          // stats
          StatsHelper.addStreetLight(stats);
        }
      }
    }

    writer.write(sb.toString());
  }