all.
This is my first question, so forgive if I do anything wrong. Here we go.
I have a problem while trying to send a PostGIS Object (actually a PGgeometry) through a RestFul service.
The class I'm trying to send is 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;
}
I have created my own class that implements PGgeometry in order to add the needed tags:
@XmlAccessorType(XmlAccessType.FIELD)
public class PointJaxRS extends PGgeometry {
private static final long serialVersionUID = 4624155439994995423L;
public PointJaxRS(){
super();
};
}
This is the exception that reached:
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**
I thought that adding the @XmlAccessorType(XmlAccessType.FIELD) tag was enough to recognize only the attributes from the class as fields in the json file, but it seems that this does not work for inherited attributes. In addition, I would need Geometry to have a no-arg default constructor...
I can't send them as String because they are going to be received by Openlayers, so it needs to be able to read the PGgeometry in order to draw the points in a map.
So the question is: what can I do to send PostGIS objets in JSON format through rest services?