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); } }
private void commitProfile(final Session session, final String dbType, final GafProfile profile) throws Exception { final CrossSection crossSection = commitCrossSection(session, dbType, profile); /* Get PP part */ final GafPart[] parts = profile.getParts(); final GafPart ppPart = profile.findPart(GafKind.P); /* add parts */ for (final GafPart gafPart : parts) { final PDBNameGenerator partNameGenerator = new PDBNameGenerator(); final CrossSectionPart csPart = commitPart(session, dbType, crossSection, gafPart, partNameGenerator); if (csPart == null) continue; final GafPoint[] points = gafPart.getPoints(); for (int j = 0; j < points.length; j++) { final PDBNameGenerator pointNameGenerator = new PDBNameGenerator(); final GafPoint gafPoint = points[j]; commitPoint(gafPart, session, csPart, gafPoint, j, pointNameGenerator, ppPart); } addWaterlevels(session, profile, gafPart); } }
private BigDecimal calculateWidthFromDistance( final GafPart gafPart, final com.vividsolutions.jts.geom.Point location) { final GafPoint startPoint = gafPart.getPoints()[0]; final com.vividsolutions.jts.geom.Point startLocation = startPoint.getPoint(); if (location == null || startLocation == null) return null; final double distance = location.distance(startLocation); return new BigDecimal(distance).setScale(3, BigDecimal.ROUND_HALF_UP); }