Oracle SDO_POINT_TYPE

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Oracle SDO_POINT_TYPE

Sergio Teixeira
Hi,

I've been trying to test HS for Oracle features and came across a limitation which is the fact that currently HS doesn't support SDO_POINT_TYPE offering a work-around which is to store the point's coordinates as a SDO_ORDINATE_ARRAY. This limitation has a reference in the JIRA: http://www.hibernatespatial.org/jira/browse/HIBSPA-21

However this patch isn't probably the best approach although it's close to it, because making the decision based on the 2D vs 3D to decide if it's a point or a line doesn't make sense.

I've applied a slightly different version of the patch which I believe solves the problem; the approach is to check if we have more than 3 variable coordinates. If we have a single point we have at most (x,y,z) so 3 variables to define a coordinate. If we have a line we need at least 4 variables to define 2 points (x1,y1) + (x2,y2). Therefore although it's a bit crude, I've used this test as the decision process according to SDO_POINT_TYPE and SDO_ORDINATE_ARRAY.

So in the class  OracleJDBCTypeFactory I have put the decision like the code below. Do you think this is an ok approach? Is is possible to make this change in the next versions of HS-oracle?

Boolean isNotPoint = geom.getOrdinates().getOrdinateArray().length > 3;  

if ((geom.getOrdinates() != null) && (isNotPoint)) {
attributes[4] = createOrdinatesArray(geom.getOrdinates(), oracleConnection);

} else {
attributes[3] = null;    

if (pointStructDescriptor == null) {
pointStructDescriptor = StructDescriptor.createDescriptor(POINT_TYPE_NAME, oracleConnection);
}
Datum[] pointAttributes = new Datum[3];
Double[] ordinateArray = geom.getOrdinates().getOrdinateArray();
// X
pointAttributes[0] = new NUMBER(ordinateArray[0]);
// Y
pointAttributes[1] = new NUMBER(ordinateArray[1]);
attributes[2] = new STRUCT(pointStructDescriptor, oracleConnection, pointAttributes);
}

return new STRUCT(structDescriptor, oracleConnection, attributes);

Regards,
Sergio
Reply | Threaded
Open this post in threaded view
|

Re: Oracle SDO_POINT_TYPE

Pedro Mendes
Hi,

I think one can determine if the geom object is a Point comparing the GType object like:

  if (geom.getGType().equals(TypeGeometry.POINT)) {
    ...
  }

I've updated the issue in http://www.hibernatespatial.org/jira/browse/HIBSPA-21

regards,
Mendes