Beispiel #1
0
  private CrossSectionPart commitPart(
      final Session session,
      final String dbType,
      final CrossSection crossSection,
      final GafPart part,
      final PDBNameGenerator nameGenerator)
      throws Exception {
    final CrossSectionPart csPart = new CrossSectionPart();

    final GafKind partKind = part.getKind();

    final String name = nameGenerator.createUniqueName(partKind.toString());

    csPart.setName(name);

    if (part.getKind() == GafKind.W) {
      final String gafFileName = m_profiles.getGafFilename();
      csPart.setDescription(
          String.format(Messages.getString("Gaf2Db.5"), gafFileName)); // $NON-NLS-1$
    } else csPart.setDescription(StringUtils.EMPTY);

    final CrossSectionPartType partType = findPartType(partKind);
    csPart.setCrossSectionPartType(partType);

    final Geometry line = part.getLine(dbType);
    csPart.setLine(line);

    csPart.setCrossSection(crossSection);
    session.save(csPart);
    return csPart;
  }
Beispiel #2
0
  private void addWaterlevels(final Session session, final GafProfile profile, final GafPart part) {
    if (m_waterlevelEvent == null) return;

    final GafKind kind = part.getKind();
    if (!GafKind.W.equals(kind)) return;

    final GafPoint[] points = part.getPoints();
    for (final GafPoint point : points) {
      final WaterlevelFixation fixation = new WaterlevelFixation();

      fixation.setEvent(m_waterlevelEvent);
      fixation.setDescription(StringUtils.EMPTY);

      fixation.setCreationDate(m_waterlevelEvent.getCreationDate());
      fixation.setEditingDate(m_waterlevelEvent.getEditingDate());
      fixation.setEditingUser(m_waterlevelEvent.getEditingUser());
      fixation.setMeasurementDate(m_waterlevelEvent.getMeasurementDate());

      fixation.setLocation(point.getPoint());
      fixation.setStation(profile.getStation());

      fixation.setWaterlevel(point.getHeight());

      m_waterlevelEvent.getWaterlevelFixations().add(fixation);

      session.save(fixation);
    }
  }
Beispiel #3
0
  /**
   * Calculates the width of a point if it is not set in the gaf file.<br>
   * For PP points, it is just the distance to the first point.<br>
   * For non-pp points, it is the station of the point projected to the pp-line.
   */
  private BigDecimal getOrCalculatePoint(
      final GafPart gafPart, final GafPoint gafPoint, final GafPart projectionPart) {
    final BigDecimal width = gafPoint.getWidth();
    if (width != null) return width;

    final com.vividsolutions.jts.geom.Point location = gafPoint.getPoint();
    if (GafKind.P.equals(gafPart.getKind()) || projectionPart == null) {
      return calculateWidthFromDistance(gafPart, location);
    } else {
      final Geometry line = projectionPart.getLine(m_dbType);
      if (!(line instanceof LineString) || line.getNumPoints() < 2)
        return calculateWidthFromDistance(gafPart, location);

      final LineString ls = (LineString) line;

      final LocationIndexedLine lineRef = new LocationIndexedLine(line);
      final LinearLocation loc = lineRef.project(location.getCoordinate());
      final Coordinate closestPt = loc.getCoordinate(line);

      final double distance = ls.getCoordinateN(0).distance(closestPt);
      return new BigDecimal(distance).setScale(3, BigDecimal.ROUND_HALF_UP);
    }
  }