1 """ |
|
2 The GeometryColumns and SpatialRefSys models for the Oracle spatial |
|
3 backend. |
|
4 |
|
5 It should be noted that Oracle Spatial does not have database tables |
|
6 named according to the OGC standard, so the closest analogs are used. |
|
7 For example, the `USER_SDO_GEOM_METADATA` is used for the GeometryColumns |
|
8 model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model. |
|
9 """ |
|
10 from django.db import models |
|
11 |
|
12 class GeometryColumns(models.Model): |
|
13 "Maps to the Oracle USER_SDO_GEOM_METADATA table." |
|
14 table_name = models.CharField(max_length=32) |
|
15 column_name = models.CharField(max_length=1024) |
|
16 srid = models.IntegerField(primary_key=True) |
|
17 # TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY). |
|
18 class Meta: |
|
19 app_label = 'gis' |
|
20 db_table = 'USER_SDO_GEOM_METADATA' |
|
21 managed = False |
|
22 |
|
23 @classmethod |
|
24 def table_name_col(cls): |
|
25 """ |
|
26 Returns the name of the metadata column used to store the |
|
27 the feature table name. |
|
28 """ |
|
29 return 'table_name' |
|
30 |
|
31 @classmethod |
|
32 def geom_col_name(cls): |
|
33 """ |
|
34 Returns the name of the metadata column used to store the |
|
35 the feature geometry column. |
|
36 """ |
|
37 return 'column_name' |
|
38 |
|
39 def __unicode__(self): |
|
40 return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid) |
|
41 |
|
42 class SpatialRefSys(models.Model): |
|
43 "Maps to the Oracle MDSYS.CS_SRS table." |
|
44 cs_name = models.CharField(max_length=68) |
|
45 srid = models.IntegerField(primary_key=True) |
|
46 auth_srid = models.IntegerField() |
|
47 auth_name = models.CharField(max_length=256) |
|
48 wktext = models.CharField(max_length=2046) |
|
49 #cs_bounds = models.GeometryField() # TODO |
|
50 |
|
51 class Meta: |
|
52 abstract = True |
|
53 db_table = 'CS_SRS' |
|
54 managed = False |
|
55 |
|
56 @property |
|
57 def wkt(self): |
|
58 return self.wktext |
|
59 |
|
60 @classmethod |
|
61 def wkt_col(cls): |
|
62 return 'wktext' |
|