comparison flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java @ 5170:c1b60f8c3390

Made river mapfile generator more tolerant. * Ignores missing river axes. * Ignores invalid river axes. * Ignores invalid geometries.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 04 Mar 2013 17:11:31 +0100
parents d4fdd98a04f7
children 14d19313268a
comparison
equal deleted inserted replaced
5169:db1a000a21a9 5170:c1b60f8c3390
8 import javax.persistence.Id; 8 import javax.persistence.Id;
9 import javax.persistence.JoinColumn; 9 import javax.persistence.JoinColumn;
10 import javax.persistence.OneToOne; 10 import javax.persistence.OneToOne;
11 import javax.persistence.Table; 11 import javax.persistence.Table;
12 12
13 import org.hibernate.HibernateException;
13 import org.hibernate.Session; 14 import org.hibernate.Session;
14 import org.hibernate.Query; 15 import org.hibernate.Query;
15 import org.hibernate.annotations.Type; 16 import org.hibernate.annotations.Type;
16 17
17 import com.vividsolutions.jts.geom.MultiLineString; 18 import com.vividsolutions.jts.geom.MultiLineString;
98 public void setGeom(MultiLineString geom) { 99 public void setGeom(MultiLineString geom) {
99 this.geom = geom; 100 this.geom = geom;
100 } 101 }
101 102
102 103
103 public static List<RiverAxis> getRiverAxis(String river) { 104 public static List<RiverAxis> getRiverAxis(String river)
105 throws RuntimeException {
104 return getRiverAxis(river, KIND_CURRENT); 106 return getRiverAxis(river, KIND_CURRENT);
105 } 107 }
106 108
107 public static List<RiverAxis> getRiverAxis(String river, int kind) { 109 public static List<RiverAxis> getRiverAxis(String river, int kind)
110 throws RuntimeException {
108 Session session = SessionHolder.HOLDER.get(); 111 Session session = SessionHolder.HOLDER.get();
109
110 Query query = session.createQuery( 112 Query query = session.createQuery(
111 "from RiverAxis where river.name =:river AND kind.id =:kind"); 113 "from RiverAxis where river.name =:river AND kind.id =:kind");
112 query.setParameter("river", river); 114 query.setParameter("river", river);
113 query.setParameter("kind", kind); 115 query.setParameter("kind", kind);
114 116
115 List<RiverAxis> list = query.list(); 117 try {
118 List<RiverAxis> list = query.list();
119 return list.isEmpty() ? null : list;
120 }
121 catch (RuntimeException re) {
122 throw iae;
123 }
116 124
117 return list.isEmpty() ? null : list; 125
118 } 126 }
119 } 127 }
120 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 128 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org