Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java @ 5146:d4fdd98a04f7
Add kind_id to river_axes table and add AxisKind object to model
There are currently three kinds: 0 for unkown, 1 for current,
2 for everything else.
Only current is used for calculation
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 28 Feb 2013 18:04:19 +0100 |
parents | 18ef819a7c92 |
children | c1b60f8c3390 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java Thu Feb 28 17:12:46 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java Thu Feb 28 18:04:19 2013 +0100 @@ -17,14 +17,13 @@ import com.vividsolutions.jts.geom.MultiLineString; import de.intevation.flys.backend.SessionHolder; +import de.intevation.flys.model.AxisKind; /** - * There is a modeling problem with the RiverAxis. The initial idea was, that a - * river can have a riveraxis that consist of exact one geometry. Now, it has - * turned out, that a single geometry is not enough for a riveraxis (arm of a - * river, inflows, ...). As workaround, we now expect, that a river can just - * have a single riveraxis. + * A river has one axis that is used for calculation. + * Additional axes of a river can be used to be painted int maps etc. + * which one is the main river axis can be determined over the axis kind. */ @Entity @Table(name = "river_axes") @@ -32,14 +31,13 @@ implements Serializable { private Integer id; - private Integer kind; + private AxisKind kind; private River river; private MultiLineString geom; - public static final int DEFAULT_KIND = 0; - - public static final int KIND_OFFICIAL = 1; - public static final int KIND_OUTSOURCED = 2; + public static final int KIND_UNKOWN = 0; + public static final int KIND_CURRENT = 1; + public static final int KIND_OTHER = 2; public RiverAxis() { } @@ -69,13 +67,23 @@ } - @Column(name = "kind") - public Integer getKind() { + /** + * Get kind. + * + * @return kind as AxisKind. + */ + @OneToOne + @JoinColumn(name = "kind_id") + public AxisKind getKind() { return kind; } - - public void setKind(Integer kind) { + /** + * Set kind. + * + * @param kind the value to set. + */ + public void setKind(AxisKind kind) { this.kind = kind; } @@ -93,14 +101,14 @@ public static List<RiverAxis> getRiverAxis(String river) { - return getRiverAxis(river, DEFAULT_KIND); + return getRiverAxis(river, KIND_CURRENT); } public static List<RiverAxis> getRiverAxis(String river, int kind) { Session session = SessionHolder.HOLDER.get(); Query query = session.createQuery( - "from RiverAxis where river.name =:river AND kind =:kind"); + "from RiverAxis where river.name =:river AND kind.id =:kind"); query.setParameter("river", river); query.setParameter("kind", kind);