Issue #2181 Convert geometry types to use hibernate-spatial

Former-commit-id: ded324e06f81fc63e6567a535cfa8a843a39902d
This commit is contained in:
Ben Steffensmeier 2013-07-16 12:07:13 -05:00
parent d620283c3b
commit a655380bad
18 changed files with 89 additions and 243 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="hibernate-spatial-1.0.jar"/>
<classpathentry exported="true" kind="lib" path="hibernate-spatial-postgis-1.0.jar"/>
<classpathentry exported="true" kind="lib" path="hibernate-spatial-1.0.jar" sourcepath="hibernate-spatial-1.0-source.zip"/>
<classpathentry exported="true" kind="lib" path="hibernate-spatial-postgis-1.0.jar" sourcepath="hibernate-spatial-1.0-source.zip"/>
<classpathentry exported="true" kind="lib" path="hibernate3.5.6-Final.jar" sourcepath="hibernate-3.5.6-Final-source.zip"/>
<classpathentry exported="true" kind="lib" path="javassist-3.9.0.GA.jar"/>
<classpathentry exported="true" kind="lib" path="jta-1.1.jar"/>

Binary file not shown.

View file

@ -1,184 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
/*
* GeometryType.java
*
* PostGIS extension for PostgreSQL JDBC driver - EJB3 Tutorial
*
* (C) 2006 Norman Barker <norman.barker@gmail.com>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
* http://www.gnu.org.
*
* $Id: GeometryType.java 2531 2006-11-22 10:42:17Z mschaber $
*/
// Note that for now I have "imported" this class from the postgis ejb3 source
// tree. Currently there is no postgis jar that exposes this class.
// package org.postgis.hibernate;
package com.raytheon.edex.db.objects.hibernate;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import org.hibernate.HibernateException;
import org.hibernate.usertype.UserType;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKBReader;
import com.vividsolutions.jts.io.WKBWriter;
/**
* @author nbarker $date 16/8/06
*/
public class GeometryType implements UserType {
private static final int[] SQL_TYPES = { Types.BLOB };
/**
* @see org.hibernate.usertype.UserType#deepCopy(java.lang.Object)
*/
public Object deepCopy(Object value) throws HibernateException {
return value;
}
/**
* @see org.hibernate.usertype.UserType#equals(java.lang.Object,
* java.lang.Object)
*/
public boolean equals(Object x, Object y) throws HibernateException {
if (x == y) {
return true;
} else if (x == null || y == null) {
return false;
} else {
return x.equals(y);
}
}
/**
* @see org.hibernate.usertype.UserType#hashCode(java.lang.Object)
*/
public int hashCode(Object arg0) throws HibernateException {
// TODO Auto-generated method stub
return 0;
}
/**
* @see org.hibernate.usertype.UserType#isMutable()
*/
public boolean isMutable() {
return false;
}
/**
* )
*
* @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet,
* java.lang.String[], java.lang.Object)
*/
public Geometry nullSafeGet(ResultSet resultSet, String[] names,
Object owner) throws HibernateException, SQLException {
WKBReader wkbReader = new WKBReader();
Geometry result = null;
String hex = resultSet.getString(names[0]);
if (hex != null) {
try {
result = wkbReader.read(WKBReader.hexToBytes(hex));
} catch (ParseException e) {
throw new HibernateException(
"Error parsing JTS geometry object", e);
}
}
return result;
}
/**
* @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement,
* java.lang.Object, int)
*/
public void nullSafeSet(PreparedStatement statement, Object value, int index)
throws HibernateException, SQLException {
if (value == null) {
statement.setBytes(index, null);
} else {
statement.setBytes(index, new WKBWriter().write((Geometry) value));
}
}
/*
* (non-Javadoc)
*
* @see org.hibernate.usertype.UserType#replace(java.lang.Object,
* java.lang.Object, java.lang.Object)
*/
public Object replace(Object original, Object target, Object owner)
throws HibernateException {
return original;
}
/*
* (non-Javadoc)
*
* @see org.hibernate.usertype.UserType#returnedClass()
*/
public Class<?> returnedClass() {
return Geometry.class;
}
/**
* @see org.hibernate.usertype.UserType#sqlTypes()
*/
public int[] sqlTypes() {
return GeometryType.SQL_TYPES;
}
/**
* @see org.hibernate.usertype.UserType#assemble(java.io.Serializable,
* java.lang.Object)
*/
public Object assemble(Serializable cached, Object owner)
throws HibernateException {
return cached;
}
/**
* @see org.hibernate.usertype.UserType#disassemble(java.lang.Object)
*/
public Serializable disassemble(Object value) throws HibernateException {
return (Serializable) value;
}
}

View file

@ -45,9 +45,11 @@ import com.vividsolutions.jts.geom.Geometry;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 09/25/08 1532 bphillip initial creation
* 09/16/09 3027 njensen Moved dataURI off geometry
* 09/17/09 3072 bsteffen Fixed type of geometry
* Sep 25, 2008 1532 bphillip initial creation
* Sep 16, 2009 3027 njensen Moved dataURI off geometry
* Sep 17, 2009 3072 bsteffen Fixed type of geometry
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
*
* </pre>
@ -62,8 +64,8 @@ public class CcfpLocation implements ISpatialObject {
private static final long serialVersionUID = 8890315829188793187L;
@Column(name = "location", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "location")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
private Geometry geometry;

View file

@ -53,6 +53,8 @@ import com.vividsolutions.jts.geom.Geometry;
* Mar 24, 2009 njensen Initial creation
* Feb 26, 2013 1447 dgilling Implement equals().
* May 10, 2013 1951 rjpeter Added own id sequence tagging
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
* </pre>
*
* @author njensen
@ -141,8 +143,8 @@ public abstract class ActiveTableRecord extends PersistableDataObject {
@DynamicSerializeElement
protected boolean ufn;
@Column(name = "geometry", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column
@Type(type = "org.hibernatespatial.GeometryUserType")
@DynamicSerializeElement
protected Geometry geometry;

View file

@ -87,8 +87,12 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/24/08 @1047 randerso Added fields to store projection information
* 10/10/12 #1260 randerso Added new constructor that takes a GridCoverage
* Apr 24, 2008 @1047 randerso Added fields to store projection
* information
* Oct 10, 2012 1260 randerso Added new constructor that takes a
* GridCoverage
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
*
* </pre>
@ -184,8 +188,8 @@ public class GridLocation extends PersistableDataObject implements
@DynamicSerializeElement
private Coordinate extent;
@Column(name = "coverage", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "coverage")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlElement
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement

View file

@ -62,6 +62,8 @@ import com.vividsolutions.jts.geom.Geometry;
* May 07, 2013 1869 bsteffen Remove dataURI column from
* PluginDataObject.
* May 15, 2013 1869 bsteffen Remove DataURI from goes/poes soundings.
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
* </pre>
*
@ -94,8 +96,8 @@ public class GOESSounding extends PersistablePluginDataObject implements
private SurfaceObsLocation location;
// The bounding box that contains this observation.
@Column(name = "boxGeometry", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column
@Type(type = "org.hibernatespatial.GeometryUserType")
@DynamicSerializeElement
private Geometry boxGeometry;

View file

@ -51,7 +51,9 @@ import com.vividsolutions.jts.geom.Point;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 7/24/07 353 bphillip Initial Check in
* Jul 24, 2007 353 bphillip Initial Check in
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
* </pre>
*
@ -115,8 +117,8 @@ public class RadarStation extends PersistableDataObject implements
@DynamicSerializeElement
private Float lon;
@Column(name = "the_geom", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
private Point station;

View file

@ -58,9 +58,10 @@ import com.vividsolutions.jts.geom.Polygon;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 7/24/07 353 bphillip Initial Checkin
* - AWIPS2 Baseline Repository --------
* 07/12/2012 798 jkorman Changed projection "magic" numbers
* Jul 24, 2007 353 bphillip Initial Checkin
* Jul 12, 2012 798 jkorman Changed projection "magic" numbers
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
* </pre>
*/
@ -177,8 +178,8 @@ public class SatMapCoverage extends PersistableDataObject implements
private CoordinateReferenceSystem crsObject;
/** The map coverage */
@Column(name = "the_geom", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
private Polygon location;

View file

@ -49,9 +49,12 @@ import com.vividsolutions.jts.geom.Geometry;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 03/12/2007 1003 bwoodle initial creation
* 04/12/2013 1857 bgonzale Added SequenceGenerator annotation.
* 05/02/2013 1949 rjpeter Moved ugcZones to be a column inside table.
* Mar 12, 2007 1003 bwoodle initial creation
* Apr 12, 2013 1857 bgonzale Added SequenceGenerator annotation.
* May 02, 2013 1949 rjpeter Moved ugcZones to be a column inside
* table.
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
* </pre>
*
* @author bwoodle
@ -143,8 +146,8 @@ public abstract class AbstractWarningRecord extends PluginDataObject {
@DynamicSerializeElement
private boolean ufn;
@Column(name = "geometry", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column
@Type(type = "org.hibernatespatial.GeometryUserType")
@DynamicSerializeElement
private Geometry geometry;

View file

@ -68,10 +68,12 @@ import com.vividsolutions.jts.geom.Geometry;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
* Apr 07, 2009 1994 bphillip Initial Creation
* Sep 07, 2012 1102 djohnson Add missing JAXB annotations.
* 09/10/2012 DR 15270 D. Friedman Fix subgrid model name handling.
* Sep 10, 2012 15270 D. Friedman Fix subgrid model name handling.
* Nov 02, 2012 1302 djohnson Remove commented out code.
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
* </pre>
*
@ -113,8 +115,8 @@ public abstract class GridCoverage extends PersistableDataObject<Integer>
protected String description;
/** Geometry object holding the corner points of the grid */
@Column(name = "the_geom", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
protected Geometry geometry;

View file

@ -50,8 +50,10 @@ import com.vividsolutions.jts.geom.Point;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20071026 384 jkorman Initial Coding.
* 20090408 952 jsanchez Added @DynamicSerializeElement tags.
* Oct 26, 2007 384 jkorman Initial Coding.
* Apr 08, 2009 952 jsanchez Added @DynamicSerializeElement tags.
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
* </pre>
*
@ -94,8 +96,8 @@ public class AircraftObsLocation implements ISpatialObject {
@DynamicSerializeElement
private double longitude;
@Column(name = "location", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
private Point location;

View file

@ -50,7 +50,9 @@ import com.vividsolutions.jts.geom.Point;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 7/24/07 353 bphillip Initial Check in
* Jul 24, 2007 353 bphillip Initial Check in
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
* </pre>
*
@ -197,15 +199,15 @@ public class ObStation extends PersistableDataObject implements ISpatialObject {
private String rbsnIndicator;
/** The upper air geometry information */
@Column(name = "upperairgeom", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "upperairgeom")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
private Point upperAirGeometry;
/** The station location */
@Column(name = "the_geom", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
private Point location;

View file

@ -56,6 +56,8 @@ import com.vividsolutions.jts.geom.Point;
* Oct 26, 2007 391 jkorman Initial Coding.
* May 17, 2013 1869 bsteffen Remove DataURI column from sat plot
* types.
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
* </pre>
*
@ -99,8 +101,8 @@ public class SurfaceObsLocation implements ISpatialObject, Cloneable {
@DynamicSerializeElement
private Boolean locationDefined = Boolean.FALSE;
@Column(name = "location", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
private Point location;

View file

@ -46,8 +46,10 @@ import com.vividsolutions.jts.geom.Polygon;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 29, 2011 bclement Initial creation
* 04/22/2013 1746 dhladky Removed DB dependency from WFS code
* Mar 29, 2011 bclement Initial creation
* Apr 22, 2013 1746 dhladky Removed DB dependency from WFS code
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
**/
@ -89,7 +91,7 @@ public abstract class SimpleLayer<DIMENSION extends SimpleDimension> {
@DynamicSerializeElement
protected double targetMaxy;
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
protected Polygon crs84Bounds;

View file

@ -43,9 +43,9 @@ import org.hibernate.annotations.Type;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.ProjectedCRS;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.adapters.GeometryAdapter;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.serialization.adapters.GeometryAdapter;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.vividsolutions.jts.geom.Geometry;
@ -179,8 +179,8 @@ public class McidasMapCoverage extends PersistableDataObject implements ISpatial
private CoordinateReferenceSystem crsObject;
/** The map coverage */
@Column(name = "the_geom", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
private Polygon location;

View file

@ -11,8 +11,8 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.hibernate.annotations.Type;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.serialization.adapters.GeometryAdapter;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
@ -31,6 +31,7 @@ import com.vividsolutions.jts.geom.Geometry;
* 12/14/09 155 F. J. Yen Updated from to11d3 to to11d6 (changed import of
* IspatialObject package to ...geospatial.ISpatialObject)
* 05/26/10 155 F. J. Yen Refactored from plugin for migration to to11dr11
* 07/16/13 2181 bsteffen Convert geometry types to use hibernate-spatial
*
* </pre>
*
@ -45,8 +46,8 @@ public class NcccfpLocation implements ISpatialObject {
private static final long serialVersionUID = 8890315829188793187L;
@DataURI(position=0)
@Column(name = "location", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "location")
@Type(type = "org.hibernatespatial.GeometryUserType")
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
@DynamicSerializeElement
private Geometry geometry;

View file

@ -20,6 +20,9 @@
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@ -38,8 +41,6 @@ import org.hibernate.annotations.Type;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.geospatial.MapUtil;
@ -57,8 +58,10 @@ import com.vividsolutions.jts.geom.Polygon;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
* 5/23/12 xguo Merged 4 coverage tables into one
* Apr 07, 2009 1994 bphillip Initial Creation
* May 23, 2012 xguo Merged 4 coverage tables into one
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
* spatial
*
* </pre>
*
@ -93,8 +96,8 @@ public abstract class NcgridCoverage extends PersistableDataObject implements
protected String description;
/** Geometry object holding the corner points of the grid */
@Column(name = "the_geom", columnDefinition = "geometry")
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
@Column(name = "the_geom")
@Type(type = "org.hibernatespatial.GeometryUserType")
@DynamicSerializeElement
protected Polygon geometry;