/**
   * DOCUMENT ME!
   *
   * @param routeBean DOCUMENT ME!
   * @return DOCUMENT ME!
   */
  private double getPointInCurrentBB(final CidsBean routeBean) {
    // Geometrie für BoundingBox erzeugen
    final XBoundingBox boundingBox = (XBoundingBox) MAPPING_COMPONENT.getCurrentBoundingBox();
    final Collection<Coordinate> coordinates = new ArrayList<Coordinate>();
    coordinates.add(new Coordinate(boundingBox.getX1(), boundingBox.getY1()));
    coordinates.add(new Coordinate(boundingBox.getX2(), boundingBox.getY1()));
    coordinates.add(new Coordinate(boundingBox.getX2(), boundingBox.getY2()));
    coordinates.add(new Coordinate(boundingBox.getX1(), boundingBox.getY2()));
    coordinates.add(new Coordinate(boundingBox.getX1(), boundingBox.getY1()));
    final GeometryFactory gf = new GeometryFactory();
    final LinearRing shell =
        gf.createLinearRing(coordinates.toArray(new Coordinate[coordinates.size()]));
    final Polygon boundingBoxGeom = gf.createPolygon(shell, new LinearRing[0]);

    // Testen, ob Punkt 0 in der BoundingBox liegt
    final Geometry routeGeom =
        (Geometry) routeBean.getProperty(PROP_ROUTE_GEOM + "." + PROP_GEOM_GEOFIELD);
    final Geometry pointZero = LinearReferencedPointFeature.getPointOnLine(0d, routeGeom);

    if (pointZero.within(boundingBoxGeom)) {
      return 0d;
    } else {
      // niedrigster Stationierungswert, der die Boundingbox schneidet, bestimmen
      final LineString boundingBoxLineGeom =
          gf.createLineString(coordinates.toArray(new Coordinate[coordinates.size()]));
      double bestPosition = 0;

      // Coordinaten durchlaufen und anhand der Position auf der Linie sortieren
      final Geometry intersectionGeom = routeGeom.intersection(boundingBoxLineGeom);
      for (final Coordinate coord : intersectionGeom.getCoordinates()) {
        final double position = LinearReferencedPointFeature.getPositionOnLine(coord, routeGeom);
        if (bestPosition == 0) {
          bestPosition = position;
        } else if (position < bestPosition) {
          bestPosition = position;
        }
      }

      return bestPosition;
    }
  }
  /** DOCUMENT ME! */
  private void switchBadGeomVisibility() {
    if (isEditable()) {
      final Feature badGeomFeature = getBadGeomFeature();
      final Feature pointFeature = getFeature();

      final boolean selected = getBadGeomButton().isSelected();

      if (selected) {
        boundingbox = (XBoundingBox) MAPPING_COMPONENT.getCurrentBoundingBox();

        MAPPING_COMPONENT.getFeatureCollection().addFeature(badGeomFeature);
        MAPPING_COMPONENT.getFeatureCollection().select(pointFeature);

        zoomToBadFeature();
      } else {
        MAPPING_COMPONENT.getFeatureCollection().removeFeature(badGeomFeature);
        MAPPING_COMPONENT.gotoBoundingBoxWithoutHistory(boundingbox);
      }

      getBadGeomCorrectButton().setVisible(selected);
    }
  }