﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21273	Add read only support for Oracle XE to django.contrib.gis	vinhussey	nobody	"django.contrib.gis.backends supports Oracle but does not support the spatial component of Oracle XE.  Oracle XE has a more lenient licence than Oracle and may be useful for accessing legacy spatial data.

Oracle XE may be accessed using cx_Oracle, but spatial data is not converted into a usable form.  The spatial data stored in oracle is documented (search for 'oracle sdo_geometry').

The following is a short description of the point attribute - I will expand with other types asap.

Example - Oracle spatial table named Floods with a spatial field geoloc:
{{{
>>> from import_data.models import *
>>> floods = Floods.objects.all()
>>> f = floods[99]
>>> g = f.geoloc
>>> g
<cx_Oracle.OBJECT object at 0xa02a3e0>
>>> dir(g)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'type']
>>> gtype = str(int(g.__getattribute__('SDO_GTYPE')))
>>> print gtype
2001
>>> gdims = gtype[0]
>>> gdims
'2'
>>> gtopo = gtype[1]
>>> gtopo
'0'
>>> ggeomtype = gtype[2:]
>>> ggeomtype
'01'
>>> gsrid = g.__getattribute__('SDO_SRID')
>>> gsrid
82086.0
>>> gpoint_x = g.__getattribute__('SDO_POINT').X
>>> gpoint_y = g.__getattribute__('SDO_POINT').Y
>>> gpoint_z = g.__getattribute__('SDO_POINT').Z
>>> print gpoint_x, gpoint_y, gpoint_z
162913.389524 340748.357977 None
>>> g_ewkt = ""SRID:%s:POINT(%f %f)"" % (str(int(g.__getattribute__('SDO_SRID'))), g.__getattribute__('SDO_POINT').X, g.__getattribute__('SDO_POINT').Y)
>>> g_ewkt
'SRID:82086:POINT(162913.389524 340748.357977)'
}}}
From the Oracle docs, this is a 2 dimensional (gdims), null topology (gtopo), POINT geometry, srid = 82086 (Irish Grid), with x and y co-ordinates and null z coordinates.


Further information is stored in other attributes for more complex geometries - a very wide range is available.  For a point, these may not necessarily be used.
{{{
>>> print g.__getattribute__('SDO_ELEM_INFO')
None
>>> print g.__getattribute__('SDO_ORDINATES')
None
}}}

"	Cleanup/optimization	new	GIS	dev	Normal			vinhussey	Accepted	0	1	1	0	0	0
