Mercurial > dive4elements > river
view flys-backend/src/main/java/de/intevation/flys/backend/SpatialInfo.java @ 1246:e334314e8eb2
Added schema buildings.
flys-backend/trunk@2724 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Schilberg <bjoern@intevation.de> |
---|---|
date | Wed, 14 Sep 2011 07:20:26 +0000 |
parents | 22eea1c9e907 |
children | 61cb16549eb1 |
line wrap: on
line source
package de.intevation.flys.backend; import java.util.List; import org.apache.log4j.Logger; import org.hibernate.Query; import org.hibernate.Session; import com.vividsolutions.jts.geom.LineString; import de.intevation.flys.backend.SessionFactoryProvider; import de.intevation.flys.model.Building; import de.intevation.flys.model.CrossSectionTrack; import de.intevation.flys.model.Fixpoint; import de.intevation.flys.model.Line; import de.intevation.flys.model.River; import de.intevation.flys.model.RiverAxis; public class SpatialInfo { private static Logger logger = Logger.getLogger(SpatialInfo.class); protected static String RIVERNAME = System.getProperty( "flys.backend.spatial.river", "Saar"); protected Session session; public static void main(String[] args) { logger.info("Start SpatialInfo application."); SpatialInfo spatial = null; try { spatial = new SpatialInfo(); River river = spatial.getRiver(RIVERNAME); if (river == null) { logger.warn("Could not find river '" + RIVERNAME + "'!"); return; } logger.info("Spatial information of River '" + RIVERNAME + "'"); spatial.doRiverAxisInfo(river); spatial.doCrossSectionTracksInfo(river); spatial.doLinesInfo(river); spatial.doBuildingsInfo(river); spatial.doFixpointsInfo(river); } finally { if (spatial != null) { spatial.close(); } } logger.info("Finish SpatialInfo application."); } public SpatialInfo() { session = SessionFactoryProvider .createSessionFactory() .openSession(); } public void close() { session.close(); } protected River getRiver(String rivername) { Query query = session.createQuery( "from River where name =:name"); query.setParameter("name", rivername); List<River> list = query.list(); if (list == null || list.size() == 0) { logger.warn("No river '" + rivername + "' found!"); return null; } return list.get(0); } protected void doRiverAxisInfo(River river) { RiverAxis axis = RiverAxis.getRiverAxis(river.getName()); if (axis != null) { LineString ls = axis.getGeom(); logger.info("River axis is " + ls.getLength() + " long."); logger.info("River boundary: " + ls.getBoundary()); } else { logger.warn("River has no RiverAxis."); } } protected void doCrossSectionTracksInfo(River river) { Query query = session.createQuery( "from CrossSectionTrack where river =:river"); query.setParameter("river", river); List<CrossSectionTrack> list = query.list(); if (list == null || list.size() == 0) { logger.warn("No CrossSectionTracks for '" + river.getName() + "' found!"); return; } else { logger.info("River contains " + list.size() + " CrossSectionTracks."); } } protected void doLinesInfo(River river) { Query query = session.createQuery( "from Line where river =:river"); query.setParameter("river", river); List<Line> list = query.list(); if (list == null || list.size() == 0) { logger.warn("No Lines for '" + river.getName() + "' found!"); return; } else { logger.info("River contains " + list.size() + " Lines."); } } protected void doBuildingsInfo(River river) { Query query = session.createQuery( "from Building where river =:river"); query.setParameter("river", river); List<Building> list = query.list(); if (list == null || list.size() == 0) { logger.warn("No Buildings for '" + river.getName() + "' found!"); return; } else { logger.info("River contains " + list.size() + " Buildings."); } } protected void doFixpointsInfo(River river) { Query query = session.createQuery( "from Fixpoint where river =:river"); query.setParameter("river", river); List<Fixpoint> list = query.list(); if (list == null || list.size() == 0) { logger.warn("No Fixpoints for '" + river.getName() + "' found!"); return; } else { logger.info("River contains " + list.size() + " Fixpoints."); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :