通过RestFul服务(JSON)发送PostGIS对象

时间:2012-01-31 10:21:22

标签: java json rest postgis

所有

这是我的第一个问题,如果我做错了,请原谅。我们走了。

尝试通过RestFul服务发送PostGIS对象(实际上是PGgeometry)时遇到问题。

我要发送的课程是GPSMessageFormat:

@XmlRootElement(name="position")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType( propOrder = {
    "latitude",
    "longitude",
    "position",
    } )
public class GPSMessageFormat implements Serializable{

  private static final long serialVersionUID = 4178516023632486216L;

  public Double latitude;

  public Double longitude;

  public PointJaxRS position;
}

我创建了自己的类来实现PGgeometry,以便添加所需的标签:

@XmlAccessorType(XmlAccessType.FIELD)
public class PointJaxRS extends PGgeometry {

  private static final long serialVersionUID = 4624155439994995423L;

  public PointJaxRS(){
    super();
  };
}

这是达到的例外情况:

org.postgis.Geometry does not have a no-arg default constructor.
    this problem is related to the following location:
        at org.postgis.Geometry
        at org.postgis.Point
        at es.datatype.PointJaxRS
        at public es.datatype.PointJaxRS es.datatype.GPSMessageFormat.position
        at es.datatype.GPSMessageFormat
Class has two properties of the same name "m"
    this problem is related to the following location:
        at public double org.postgis.Point.getM()
        at org.postgis.Point
        at es.datatype.PointJaxRS
        at public es.datatype.PointJaxRS es.datatype.GPSMessageFormat.position
        at es.datatype.GPSMessageFormat
    this problem is related to the following location:
        at public double org.postgis.Point.m
        at org.postgis.Point
        at es.datatype.PointJaxRS
        at public es.datatype.PointJaxRS es.datatype.GPSMessageFormat.position
        at es.datatype.GPSMessageFormat

[...] **Other similar errors with all the other fields from PGgeometry**

我认为添加 @XmlAccessorType(XmlAccessType.FIELD) 标记足以只识别类中的属性作为json文件中的字段,但似乎这不适用于继承的属性。另外,我需要Geometry有一个no-arg默认构造函数......

我不能将它们作为String发送,因为它们将被Openlayers接收,因此它需要能够读取PGgeometry才能在地图中绘制点。

所以问题是:如何通过休息服务以JSON格式发送PostGIS对象?

0 个答案:

没有答案
相关问题