se_asgml.sql 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. ---------------------------------------------------------------------
  2. -- The SE_AsGML function converts spatial primitives into their
  3. -- GML representation.
  4. ---------------------------------------------------------------------
  5. ----------------------------------------------------------------------
  6. -- First create an entry in the spatial_references table which
  7. -- is used by many of the examples.
  8. -----------------------------------------------------------------------
  9. INSERT INTO spatial_references VALUES
  10. (1000, NULL, 'AUTHNAME', 1234, -50000, -50000, 1000, -50000, 1000, -50000, 1000, 'UNKNOWN');
  11. --------------------------------- Point -------------------------------
  12. -- A table holding ST_Point geometries is created.
  13. --
  14. -- When ST_Point geometries are created by the ST_PointFromText
  15. -- function they are assigned the SRID value of 1000.
  16. --
  17. -- When SE_AsGML() UDR is used to retrieve the GML representation, the
  18. -- 'auth_name' and 'auth_srid' values for the SRID form the srsName
  19. -- attribute to identify the spatial reference system. See below:
  20. --
  21. -- <gml:Point srsName="AUTHNAME:1234">
  22. -- <gml:coord><gml:X>10.02</gml:X><gml:Y>20.01</gml:Y></gml:coord>
  23. -- </gml:Point>
  24. ------------------------------------------------------------------------
  25. CREATE TABLE point_t (id varchar(10),
  26. p1 ST_Point);
  27. INSERT INTO point_t VALUES(
  28. 'xy',
  29. ST_PointFromText('point (10.02 20.01)', 1000)
  30. );
  31. INSERT INTO point_t VALUES(
  32. 'z',
  33. ST_PointFromText('point z (10.02 20.01 5.0)', 1000)
  34. );
  35. INSERT INTO point_t VALUES(
  36. 'm',
  37. ST_PointFromText('point m (10.02 20.01 7.0)', 1000)
  38. );
  39. INSERT INTO point_t VALUES(
  40. 'zm',
  41. ST_PointFromText('point zm (10.02 20.01 5.0 7.0)', 1000)
  42. );
  43. INSERT INTO point_t VALUES(
  44. 'empty', ST_PointFromText('point empty',1000)
  45. );
  46. SELECT id, SE_AsGML(p1) FROM point_t order by id asc;
  47. --------------------------- LineString --------------------------------
  48. -- Create a table holding ST_LineString geometries. Insert several
  49. -- ST_LineString values, then call SE_AsGML() to retrieve their
  50. -- GML representation.
  51. ------------------------------------------------------------------------
  52. CREATE TABLE line_t (id varchar(10),
  53. p1 ST_LineString);
  54. INSERT INTO line_t VALUES(
  55. 'xy',
  56. ST_LineFromText('linestring (0.0 0.0,0.0 1.0,1.0 0.0,1.0 1.0)',1000)
  57. );
  58. INSERT INTO line_t VALUES(
  59. 'z',
  60. ST_LineFromText('linestring z (0.0 0.0 0,0.0 1.0 1,1.0 0.0 1,1.0 1.0 1)',1000)
  61. );
  62. INSERT INTO line_t VALUES(
  63. 'm',
  64. ST_LineFromText('linestring m (0.0 0.0 0,0.0 1.0 1,1.0 0.0 1,1.0 1.0 1)',1000)
  65. );
  66. INSERT INTO line_t VALUES(
  67. 'zm',
  68. ST_LineFromText('linestring zm (0.0 0.0 0 0,0.0 1.0 1 1,1.0 0.0 1 1,1.0 1.0 1 1)',1000)
  69. );
  70. INSERT INTO line_t VALUES(
  71. 'empty',
  72. ST_LineFromText('linestring empty',1000)
  73. );
  74. SELECT id, SE_AsGML(p1) FROM line_t order by id asc;
  75. --------------------------- Polygon -----------------------------------
  76. -- Create a table holding ST_Polygon geometries. Insert several
  77. -- ST_Polygon values, then call SE_AsGML() to retrieve their
  78. -- GML representation.
  79. ------------------------------------------------------------------------
  80. CREATE TABLE polygon_t (id varchar(20),
  81. p1 ST_Polygon);
  82. INSERT INTO polygon_t VALUES(
  83. 'xy-1ring',
  84. ST_PolyFromText('polygon ((0.0 0.0,0.0 1.0,1.0 0.0,0.0 0.0))',1000)
  85. );
  86. INSERT INTO polygon_t VALUES(
  87. 'xy-2ring',
  88. ST_PolyFromText('polygon ((0.0 0.0,0.0 1.0,1.0 0.0,0.0 0.0),(0.25 0.25,0.25 0.5,0.5 0.25,0.25 0.250))',1000)
  89. );
  90. INSERT INTO polygon_t VALUES(
  91. 'xy-3ring',
  92. ST_PolyFromText('polygon ((0.0 0.0,0.0 1.0,1.0 0.0,0.0 0.0),(0.25 0.25,0.25 0.5,0.5 0.25,0.25 0.250),(0.125 0.125,0.125 0.25,0.25 0.125,0.125 0.1250))',1000)
  93. );
  94. INSERT INTO polygon_t VALUES(
  95. 'xyz-1ring',
  96. ST_PolyFromText('polygon z ((0.0 0.0 0.0,0.0 1.0 1.0,1.0 0.0 1.0,0.0 0.0 0.0))',1000)
  97. );
  98. INSERT INTO polygon_t VALUES(
  99. 'xym-1ring',
  100. ST_PolyFromText('polygon m ((0.0 0.0 0.0,0.0 1.0 1.0,1.0 0.0 1.0,0.0 0.0 0.0))',1000)
  101. );
  102. INSERT INTO polygon_t VALUES(
  103. 'xyzm-1ring',
  104. ST_PolyFromText('polygon zm ((0.0 0.0 0.0 0,0.0 1.0 1.0 -1,1.0 0.0 1.0 -1,0.0 0.0 0.0 0))',1000)
  105. );
  106. INSERT INTO polygon_t VALUES(
  107. 'empty',
  108. ST_PolyFromText('polygon empty',1000)
  109. );
  110. SELECT id, SE_AsGML(p1) FROM polygon_t order by id asc;
  111. -------------------------- MultiPoint ---------------------------------
  112. -- Create a table holding ST_MultiPoint geometries. Insert several
  113. -- ST_MultiPoint values, then call SE_AsGML() to retrieve their
  114. -- GML representation.
  115. ------------------------------------------------------------------------
  116. CREATE TABLE multipoint_t (id varchar(10),
  117. p1 ST_MultiPoint);
  118. INSERT INTO multipoint_t VALUES(
  119. 'xy',
  120. ST_MPointFromText('multipoint (0 0,0 1,1 1)',1000)
  121. );
  122. INSERT INTO multipoint_t VALUES(
  123. 'z',
  124. ST_MPointFromText('multipoint z (0 0 0,0 1 1,1 1 1)',1000)
  125. );
  126. INSERT INTO multipoint_t VALUES(
  127. 'm',
  128. ST_MPointFromText('multipoint m (0 0 0,0 1 1,1 1 1)',1000)
  129. );
  130. INSERT INTO multipoint_t VALUES(
  131. 'zm',
  132. ST_MPointFromText('multipoint zm (0 0 0 0,0 1 1 1,1 1 1 0)',1000)
  133. );
  134. INSERT INTO multipoint_t VALUES(
  135. '1xy',
  136. ST_MPointFromText('multipoint (0 0)',1000)
  137. );
  138. INSERT INTO multipoint_t VALUES(
  139. '1zm',
  140. ST_MPointFromText('multipoint zm (0 0 0 0)',1000)
  141. );
  142. INSERT INTO multipoint_t VALUES(
  143. 'empty',
  144. ST_MPointFromText('multipoint empty',1000)
  145. );
  146. SELECT id, SE_AsGML(p1) FROM multipoint_t order by id asc;
  147. ------------------------- MultiLineString -----------------------------
  148. -- Create a table holding ST_MultiLineString geometries. Insert several
  149. -- ST_MultiLineString values, then call SE_AsGML() to retrieve their
  150. -- GML representation.
  151. ------------------------------------------------------------------------
  152. CREATE TABLE multiline_t (id varchar(10),
  153. p1 ST_MultiLineString);
  154. INSERT INTO multiline_t VALUES(
  155. 'xy',
  156. ST_MLineFromText('multilinestring ((0 0,0 1,1 0),(0 0,0 1,1 0),(0 0,0 1,1 0))',1000)
  157. );
  158. INSERT INTO multiline_t VALUES(
  159. 'z',
  160. ST_MLineFromText('multilinestring z ((0 0 0,0 1 0,1 0 0),(0 0 0,0 1 0,1 0 0))',1000)
  161. );
  162. INSERT INTO multiline_t VALUES(
  163. 'm',
  164. ST_MLineFromText('multilinestring m ((0 0 0,0 1 0,1 0 0),(0 0 0,0 1 0,1 0 0))',1000)
  165. );
  166. INSERT INTO multiline_t VALUES(
  167. 'zm',
  168. ST_MLineFromText('multilinestring zm ((0 0 0 0,0 1 0 0,1 0 0 0),(0 0 0 0,0 1 0 0,1 0 0 0))',1000)
  169. );
  170. INSERT INTO multiline_t VALUES(
  171. '1xy',
  172. ST_MLineFromText('multilinestring ((0 0,0 1,1 0))',1000)
  173. );
  174. INSERT INTO multiline_t VALUES(
  175. '1zm',
  176. ST_MLineFromText('multilinestring zm ((0 0 0 0,0 1 0 0,1 0 0 0))',1000)
  177. );
  178. INSERT INTO multiline_t VALUES(
  179. 'empty',
  180. ST_MLineFromText('multilinestring empty',1000)
  181. );
  182. SELECT id, SE_AsGML(p1) FROM multiline_t order by id asc;
  183. --------------------------- MultiPolygon ------------------------------
  184. -- Create a table holding ST_MultiPolygon geometries. Insert several
  185. -- ST_MultiPolygon values, then call SE_AsGML() to retrieve their
  186. -- GML representation.
  187. ------------------------------------------------------------------------
  188. CREATE TABLE mpolygon_t (id varchar(20),
  189. p1 ST_MultiPolygon);
  190. INSERT INTO mpolygon_t VALUES(
  191. 'xy-1poly-1ring',
  192. ST_MPolyFromText('multipolygon (((0 0,0 1,1 0,0 0)))',1000)
  193. );
  194. INSERT INTO mpolygon_t VALUES(
  195. 'xyzm-1poly-2ring',
  196. ST_MPolyFromText('multipolygon (((0 0,0 1,1 0,0 0),(0.25 0.25,0.25 0.5,0.5 0.25,0.25 0.25)))',1000)
  197. );
  198. INSERT INTO mpolygon_t VALUES(
  199. 'xyzm-2poly-1ring',
  200. ST_MPolyFromText('multipolygon (((0 0,0 1,1 0,0 0)),((1 1,1 2,2 1,1 1)))',1000)
  201. );
  202. INSERT INTO mpolygon_t VALUES(
  203. 'xy-2poly-2ring',
  204. ST_MPolyFromText('multipolygon (((0 0,0 1,1 0,0 0),(0.25 0.25,0.25 0.5,0.5 0.25,0.25 0.25)),((1 1,1 2,2 1,1 1),(1.3 1.3,1.3 1.5,1.5 1.3,1.3 1.3)))',1000)
  205. );
  206. INSERT INTO mpolygon_t VALUES(
  207. 'xyzm-1poly-1ring',
  208. ST_MPolyFromText('multipolygon zm (((0 0 0 0,0 1 0 0,1 0 0 0,0 0 0 0)))',1000)
  209. );
  210. INSERT INTO mpolygon_t VALUES(
  211. 'xyzm-2poly-2ring',
  212. ST_MPolyFromText('multipolygon zm (((0 0 0 0,0 1 0 0,1 0 0 0,0 0 0 0),(0.25 0.25 0 0,0.25 0.5 0 0,0.5 0.25 0 0,0.25 0.25 0 0)),((1 1 0 0,1 2 0 0,2 1 0 0,1 1 0 0),(1.3 1.3 0 0,1.3 1.5 0 0,1.5 1.3 0 0,1.3 1.3 0 0)))',1000)
  213. );
  214. INSERT INTO mpolygon_t VALUES(
  215. 'empty',
  216. ST_MPolyFromText('multipolygon empty',1000)
  217. );
  218. SELECT id, SE_AsGML(p1) FROM mpolygon_t order by id asc;
  219. ----------------------- srsName ---------------------------------------
  220. -- When the 'auth_name' or 'auth_srid' values of a Spatial Reference
  221. -- System (SRS) associated with a geometry are NULL, the Well-Known Text
  222. -- representation of the SRS stored in the sde.spatial_references table,
  223. -- column 'srtext' is returned in the srsName attribute.
  224. ------------------------------------------------------------------------
  225. INSERT INTO spatial_references
  226. VALUES
  227. (1001, NULL, NULL, NULL, -50000, -50000, 1000, -50000, 1000, -50000, 1000, 'UNKNOWN');
  228. INSERT INTO point_t VALUES(
  229. 'unknown',
  230. ST_PointFromText('point (0 0)', 1001)
  231. );
  232. SELECT SE_AsGML(p1) FROM point_t WHERE id='unknown';