WfsServerBase.php 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635
  1. <?php
  2. Lib::loadClass('Api_WfsException');
  3. Lib::loadClass('Api_WfsGeomTypeConverter');
  4. class Api_WfsServerBase {
  5. public $_usrAcl;
  6. public $_typeConverter;
  7. public $_apiBaseUri;
  8. protected $_logFile;
  9. public function __construct($usrAcl) {
  10. $this->_usrAcl = $usrAcl;
  11. $this->_typeConverter = new Api_WfsGeomTypeConverter();
  12. $this->_apiBaseUri = '';
  13. }
  14. public function setBaseUri($uri) {
  15. $this->_apiBaseUri = $uri;
  16. }
  17. public function getBaseUri() {
  18. return $this->_apiBaseUri;
  19. }
  20. public function getBaseNamespaceUri() {
  21. $baseNsUri = $this->_apiBaseUri;
  22. $protocolType = '';
  23. if (!empty($baseNsUri)) {
  24. if ('https://' == substr($baseNsUri, 0, 8)) {
  25. $protocolType = 'https';
  26. $baseNsUri = substr($baseNsUri, 8);
  27. } else if ('http://' == substr($baseNsUri, 0, 7)) {
  28. $protocolType = 'http';
  29. $baseNsUri = substr($baseNsUri, 6);
  30. }
  31. }
  32. if (!empty($baseNsUri)) {
  33. if (false !== ($pos = strpos($baseNsUri, '/'))) {
  34. $baseNsUri = substr($baseNsUri, 0, $pos);
  35. }
  36. }
  37. return "{$protocolType}://{$baseNsUri}/wfs";
  38. }
  39. public function isAllowedFeatureType($nsPrefix, $type) {
  40. if ('p5_' != substr($nsPrefix, 0, 3)) return false;
  41. if ('p5_default_db' == $nsPrefix) {
  42. $typeName = "p5_default_db:{$type}";
  43. try {
  44. $acl = $this->getAclFromTypeName($typeName);
  45. } catch (Exception $e) {
  46. return false;
  47. }
  48. if ($acl) {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. /**
  55. * @param string $typeName - 'p5_default_db:TEST_PERMS'
  56. */
  57. public function getAclFromTypeName($typeName) {
  58. $typeEx = explode(':', $typeName);
  59. if (2 != count($typeEx)) throw new Api_WfsException("Could not get acl for '{$typeName}' - syntax error");
  60. if ('p5_' != substr($typeEx[0], 0, 3)) throw new Api_WfsException("Could not get acl for '{$typeName}' - prefix error");
  61. $sourceName = substr($typeEx[0], 3);
  62. $objName = $typeEx[1];
  63. $acl = $this->_usrAcl->getObjectAcl($sourceName, $objName);
  64. if (!$acl) throw new Api_WfsException("Could not get acl for '{$typeName}'");
  65. $forceTblAclInit = 0;//('1' == V::get('_force', '', $_GET));
  66. $acl->init($forceTblAclInit);
  67. return $acl;
  68. }
  69. public function _getCapabilities($wfsServerUrl, $serviceTitle, $serviceDescription) {
  70. echo '<?xml version="1.0" encoding="UTF-8"?>';
  71. ?>
  72. <WFS_Capabilities
  73. xmlns="http://www.opengis.net/wfs"
  74. xmlns:ogc="http://www.opengis.net/ogc"
  75. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  76. <?php echo $this->_getXmlNamespaceList(); ?>
  77. <?php echo $this->_getXmlSchemaLocation(); ?>
  78. version="1.0.0">
  79. <Service>
  80. <Name>WFS</Name>
  81. <Title><?php echo $serviceTitle; ?></Title>
  82. <Abstract><?php echo $serviceDescription; ?></Abstract>
  83. <Keywords>WFS, WMS</Keywords>
  84. <OnlineResource><?php echo $wfsServerUrl; ?></OnlineResource>
  85. <Fees>NONE</Fees>
  86. <AccessConstraints>NONE</AccessConstraints>
  87. </Service>
  88. <Capability>
  89. <Request>
  90. <?php $this->_printGetCapabilitiesXml($wfsServerUrl); ?>
  91. <?php $this->_printDescribeFeatureTypeXml($wfsServerUrl); ?>
  92. <?php $this->_printGetFeatureXml($wfsServerUrl); ?>
  93. <?php $this->_printTransactionXml($wfsServerUrl); ?>
  94. <?php $this->_printLockFeatureXml($wfsServerUrl); ?>
  95. <?php $this->_printGetFeatureWithLockXml($wfsServerUrl); ?>
  96. </Request>
  97. </Capability>
  98. <FeatureTypeList>
  99. <Operations>
  100. <Query />
  101. <Insert />
  102. <Update />
  103. <Delete />
  104. <Lock />
  105. </Operations>
  106. <?php $this->_printFeatureTypeListXml(); ?>
  107. </FeatureTypeList>
  108. <ogc:Filter_Capabilities>
  109. <ogc:Spatial_Capabilities>
  110. <ogc:Spatial_Operators>
  111. <ogc:Disjoint />
  112. <ogc:Equals />
  113. <ogc:DWithin />
  114. <ogc:Beyond />
  115. <ogc:Intersect />
  116. <ogc:Touches />
  117. <ogc:Crosses />
  118. <ogc:Within />
  119. <ogc:Contains />
  120. <ogc:Overlaps />
  121. <ogc:BBOX />
  122. </ogc:Spatial_Operators>
  123. </ogc:Spatial_Capabilities>
  124. <ogc:Scalar_Capabilities>
  125. <ogc:Logical_Operators />
  126. <ogc:Comparison_Operators>
  127. <ogc:Simple_Comparisons />
  128. <ogc:Between />
  129. <ogc:Like />
  130. <ogc:NullCheck />
  131. </ogc:Comparison_Operators>
  132. <ogc:Arithmetic_Operators>
  133. <ogc:Simple_Arithmetic />
  134. <ogc:Functions>
  135. <ogc:Function_Names>
  136. <ogc:Function_Name nArgs="1">abs</ogc:Function_Name>
  137. <ogc:Function_Name nArgs="1">abs_2</ogc:Function_Name>
  138. <ogc:Function_Name nArgs="1">abs_3</ogc:Function_Name>
  139. <ogc:Function_Name nArgs="1">abs_4</ogc:Function_Name>
  140. <ogc:Function_Name nArgs="1">acos</ogc:Function_Name>
  141. <ogc:Function_Name nArgs="2">AddCoverages</ogc:Function_Name>
  142. <ogc:Function_Name nArgs="4">Aggregate</ogc:Function_Name>
  143. <ogc:Function_Name nArgs="1">Area</ogc:Function_Name>
  144. <ogc:Function_Name nArgs="1">area2</ogc:Function_Name>
  145. <ogc:Function_Name nArgs="3">AreaGrid</ogc:Function_Name>
  146. <ogc:Function_Name nArgs="1">asin</ogc:Function_Name>
  147. <ogc:Function_Name nArgs="1">atan</ogc:Function_Name>
  148. <ogc:Function_Name nArgs="2">atan2</ogc:Function_Name>
  149. <ogc:Function_Name nArgs="14">BarnesSurface</ogc:Function_Name>
  150. <ogc:Function_Name nArgs="3">between</ogc:Function_Name>
  151. <ogc:Function_Name nArgs="1">boundary</ogc:Function_Name>
  152. <ogc:Function_Name nArgs="1">boundaryDimension</ogc:Function_Name>
  153. <ogc:Function_Name nArgs="1">Bounds</ogc:Function_Name>
  154. <ogc:Function_Name nArgs="2">buffer</ogc:Function_Name>
  155. <ogc:Function_Name nArgs="3">BufferFeatureCollection</ogc:Function_Name>
  156. <ogc:Function_Name nArgs="3">bufferWithSegments</ogc:Function_Name>
  157. <ogc:Function_Name nArgs="7">Categorize</ogc:Function_Name>
  158. <ogc:Function_Name nArgs="1">ceil</ogc:Function_Name>
  159. <ogc:Function_Name nArgs="1">Centroid</ogc:Function_Name>
  160. <ogc:Function_Name nArgs="2">classify</ogc:Function_Name>
  161. <ogc:Function_Name nArgs="2">Clip</ogc:Function_Name>
  162. <ogc:Function_Name nArgs="1">CollectGeometries</ogc:Function_Name>
  163. <ogc:Function_Name nArgs="1">Collection_Average</ogc:Function_Name>
  164. <ogc:Function_Name nArgs="1">Collection_Bounds</ogc:Function_Name>
  165. <ogc:Function_Name nArgs="0">Collection_Count</ogc:Function_Name>
  166. <ogc:Function_Name nArgs="1">Collection_Max</ogc:Function_Name>
  167. <ogc:Function_Name nArgs="1">Collection_Median</ogc:Function_Name>
  168. <ogc:Function_Name nArgs="1">Collection_Min</ogc:Function_Name>
  169. <ogc:Function_Name nArgs="1">Collection_Sum</ogc:Function_Name>
  170. <ogc:Function_Name nArgs="1">Collection_Unique</ogc:Function_Name>
  171. <ogc:Function_Name nArgs="1">Concatenate</ogc:Function_Name>
  172. <ogc:Function_Name nArgs="2">contains</ogc:Function_Name>
  173. <ogc:Function_Name nArgs="7">Contour</ogc:Function_Name>
  174. <ogc:Function_Name nArgs="2">convert</ogc:Function_Name>
  175. <ogc:Function_Name nArgs="1">convexHull</ogc:Function_Name>
  176. <ogc:Function_Name nArgs="1">cos</ogc:Function_Name>
  177. <ogc:Function_Name nArgs="1">Count</ogc:Function_Name>
  178. <ogc:Function_Name nArgs="2">CropCoverage</ogc:Function_Name>
  179. <ogc:Function_Name nArgs="2">crosses</ogc:Function_Name>
  180. <ogc:Function_Name nArgs="2">dateFormat</ogc:Function_Name>
  181. <ogc:Function_Name nArgs="2">dateParse</ogc:Function_Name>
  182. <ogc:Function_Name nArgs="2">difference</ogc:Function_Name>
  183. <ogc:Function_Name nArgs="1">dimension</ogc:Function_Name>
  184. <ogc:Function_Name nArgs="2">disjoint</ogc:Function_Name>
  185. <ogc:Function_Name nArgs="2">disjoint3D</ogc:Function_Name>
  186. <ogc:Function_Name nArgs="2">distance</ogc:Function_Name>
  187. <ogc:Function_Name nArgs="2">distance3D</ogc:Function_Name>
  188. <ogc:Function_Name nArgs="1">double2bool</ogc:Function_Name>
  189. <ogc:Function_Name nArgs="1">endAngle</ogc:Function_Name>
  190. <ogc:Function_Name nArgs="1">endPoint</ogc:Function_Name>
  191. <ogc:Function_Name nArgs="1">env</ogc:Function_Name>
  192. <ogc:Function_Name nArgs="1">envelope</ogc:Function_Name>
  193. <ogc:Function_Name nArgs="2">EqualInterval</ogc:Function_Name>
  194. <ogc:Function_Name nArgs="2">equalsExact</ogc:Function_Name>
  195. <ogc:Function_Name nArgs="3">equalsExactTolerance</ogc:Function_Name>
  196. <ogc:Function_Name nArgs="2">equalTo</ogc:Function_Name>
  197. <ogc:Function_Name nArgs="1">exp</ogc:Function_Name>
  198. <ogc:Function_Name nArgs="1">exteriorRing</ogc:Function_Name>
  199. <ogc:Function_Name nArgs="3">Feature</ogc:Function_Name>
  200. <ogc:Function_Name nArgs="1">floor</ogc:Function_Name>
  201. <ogc:Function_Name nArgs="1">geometryType</ogc:Function_Name>
  202. <ogc:Function_Name nArgs="1">geomFromWKT</ogc:Function_Name>
  203. <ogc:Function_Name nArgs="1">geomLength</ogc:Function_Name>
  204. <ogc:Function_Name nArgs="2">getGeometryN</ogc:Function_Name>
  205. <ogc:Function_Name nArgs="1">getX</ogc:Function_Name>
  206. <ogc:Function_Name nArgs="1">getY</ogc:Function_Name>
  207. <ogc:Function_Name nArgs="1">getz</ogc:Function_Name>
  208. <ogc:Function_Name nArgs="2">greaterEqualThan</ogc:Function_Name>
  209. <ogc:Function_Name nArgs="2">greaterThan</ogc:Function_Name>
  210. <ogc:Function_Name nArgs="5">Grid</ogc:Function_Name>
  211. <ogc:Function_Name nArgs="7">Heatmap</ogc:Function_Name>
  212. <ogc:Function_Name nArgs="0">id</ogc:Function_Name>
  213. <ogc:Function_Name nArgs="2">IEEEremainder</ogc:Function_Name>
  214. <ogc:Function_Name nArgs="3">if_then_else</ogc:Function_Name>
  215. <ogc:Function_Name nArgs="11">in10</ogc:Function_Name>
  216. <ogc:Function_Name nArgs="3">in2</ogc:Function_Name>
  217. <ogc:Function_Name nArgs="4">in3</ogc:Function_Name>
  218. <ogc:Function_Name nArgs="5">in4</ogc:Function_Name>
  219. <ogc:Function_Name nArgs="6">in5</ogc:Function_Name>
  220. <ogc:Function_Name nArgs="7">in6</ogc:Function_Name>
  221. <ogc:Function_Name nArgs="8">in7</ogc:Function_Name>
  222. <ogc:Function_Name nArgs="9">in8</ogc:Function_Name>
  223. <ogc:Function_Name nArgs="10">in9</ogc:Function_Name>
  224. <ogc:Function_Name nArgs="2">InclusionFeatureCollection</ogc:Function_Name>
  225. <ogc:Function_Name nArgs="1">int2bbool</ogc:Function_Name>
  226. <ogc:Function_Name nArgs="1">int2ddouble</ogc:Function_Name>
  227. <ogc:Function_Name nArgs="1">interiorPoint</ogc:Function_Name>
  228. <ogc:Function_Name nArgs="2">interiorRingN</ogc:Function_Name>
  229. <ogc:Function_Name nArgs="3">Interpolate</ogc:Function_Name>
  230. <ogc:Function_Name nArgs="2">intersection</ogc:Function_Name>
  231. <ogc:Function_Name nArgs="7">IntersectionFeatureCollection</ogc:Function_Name>
  232. <ogc:Function_Name nArgs="2">intersects</ogc:Function_Name>
  233. <ogc:Function_Name nArgs="2">intersects3D</ogc:Function_Name>
  234. <ogc:Function_Name nArgs="1">isClosed</ogc:Function_Name>
  235. <ogc:Function_Name nArgs="0">isCoverage</ogc:Function_Name>
  236. <ogc:Function_Name nArgs="1">isEmpty</ogc:Function_Name>
  237. <ogc:Function_Name nArgs="2">isLike</ogc:Function_Name>
  238. <ogc:Function_Name nArgs="1">isNull</ogc:Function_Name>
  239. <ogc:Function_Name nArgs="2">isometric</ogc:Function_Name>
  240. <ogc:Function_Name nArgs="1">isRing</ogc:Function_Name>
  241. <ogc:Function_Name nArgs="1">isSimple</ogc:Function_Name>
  242. <ogc:Function_Name nArgs="1">isValid</ogc:Function_Name>
  243. <ogc:Function_Name nArgs="3">isWithinDistance</ogc:Function_Name>
  244. <ogc:Function_Name nArgs="3">isWithinDistance3D</ogc:Function_Name>
  245. <ogc:Function_Name nArgs="2">Jenks</ogc:Function_Name>
  246. <ogc:Function_Name nArgs="1">length</ogc:Function_Name>
  247. <ogc:Function_Name nArgs="2">lessEqualThan</ogc:Function_Name>
  248. <ogc:Function_Name nArgs="2">lessThan</ogc:Function_Name>
  249. <ogc:Function_Name nArgs="1">list</ogc:Function_Name>
  250. <ogc:Function_Name nArgs="1">log</ogc:Function_Name>
  251. <ogc:Function_Name nArgs="4">LRSGeocode</ogc:Function_Name>
  252. <ogc:Function_Name nArgs="5">LRSMeasure</ogc:Function_Name>
  253. <ogc:Function_Name nArgs="5">LRSSegment</ogc:Function_Name>
  254. <ogc:Function_Name nArgs="2">max</ogc:Function_Name>
  255. <ogc:Function_Name nArgs="2">max_2</ogc:Function_Name>
  256. <ogc:Function_Name nArgs="2">max_3</ogc:Function_Name>
  257. <ogc:Function_Name nArgs="2">max_4</ogc:Function_Name>
  258. <ogc:Function_Name nArgs="2">min</ogc:Function_Name>
  259. <ogc:Function_Name nArgs="2">min_2</ogc:Function_Name>
  260. <ogc:Function_Name nArgs="2">min_3</ogc:Function_Name>
  261. <ogc:Function_Name nArgs="2">min_4</ogc:Function_Name>
  262. <ogc:Function_Name nArgs="1">mincircle</ogc:Function_Name>
  263. <ogc:Function_Name nArgs="1">minimumdiameter</ogc:Function_Name>
  264. <ogc:Function_Name nArgs="1">minrectangle</ogc:Function_Name>
  265. <ogc:Function_Name nArgs="2">modulo</ogc:Function_Name>
  266. <ogc:Function_Name nArgs="2">MultiplyCoverages</ogc:Function_Name>
  267. <ogc:Function_Name nArgs="3">Nearest</ogc:Function_Name>
  268. <ogc:Function_Name nArgs="1">not</ogc:Function_Name>
  269. <ogc:Function_Name nArgs="2">notEqualTo</ogc:Function_Name>
  270. <ogc:Function_Name nArgs="2">numberFormat</ogc:Function_Name>
  271. <ogc:Function_Name nArgs="5">numberFormat2</ogc:Function_Name>
  272. <ogc:Function_Name nArgs="1">numGeometries</ogc:Function_Name>
  273. <ogc:Function_Name nArgs="1">numInteriorRing</ogc:Function_Name>
  274. <ogc:Function_Name nArgs="1">numPoints</ogc:Function_Name>
  275. <ogc:Function_Name nArgs="1">octagonalenvelope</ogc:Function_Name>
  276. <ogc:Function_Name nArgs="3">offset</ogc:Function_Name>
  277. <ogc:Function_Name nArgs="2">overlaps</ogc:Function_Name>
  278. <ogc:Function_Name nArgs="1">parameter</ogc:Function_Name>
  279. <ogc:Function_Name nArgs="1">parseBoolean</ogc:Function_Name>
  280. <ogc:Function_Name nArgs="1">parseDouble</ogc:Function_Name>
  281. <ogc:Function_Name nArgs="1">parseInt</ogc:Function_Name>
  282. <ogc:Function_Name nArgs="1">parseLong</ogc:Function_Name>
  283. <ogc:Function_Name nArgs="0">pi</ogc:Function_Name>
  284. <ogc:Function_Name nArgs="4">PointBuffers</ogc:Function_Name>
  285. <ogc:Function_Name nArgs="2">pointN</ogc:Function_Name>
  286. <ogc:Function_Name nArgs="7">PointStacker</ogc:Function_Name>
  287. <ogc:Function_Name nArgs="6">PolygonExtraction</ogc:Function_Name>
  288. <ogc:Function_Name nArgs="2">pow</ogc:Function_Name>
  289. <ogc:Function_Name nArgs="1">property</ogc:Function_Name>
  290. <ogc:Function_Name nArgs="1">PropertyExists</ogc:Function_Name>
  291. <ogc:Function_Name nArgs="2">Quantile</ogc:Function_Name>
  292. <ogc:Function_Name nArgs="3">Query</ogc:Function_Name>
  293. <ogc:Function_Name nArgs="0">random</ogc:Function_Name>
  294. <ogc:Function_Name nArgs="5">RangeLookup</ogc:Function_Name>
  295. <ogc:Function_Name nArgs="1">RasterAsPointCollection</ogc:Function_Name>
  296. <ogc:Function_Name nArgs="4">RasterZonalStatistics</ogc:Function_Name>
  297. <ogc:Function_Name nArgs="5">Recode</ogc:Function_Name>
  298. <ogc:Function_Name nArgs="2">RectangularClip</ogc:Function_Name>
  299. <ogc:Function_Name nArgs="2">relate</ogc:Function_Name>
  300. <ogc:Function_Name nArgs="3">relatePattern</ogc:Function_Name>
  301. <ogc:Function_Name nArgs="3">Reproject</ogc:Function_Name>
  302. <ogc:Function_Name nArgs="1">rint</ogc:Function_Name>
  303. <ogc:Function_Name nArgs="1">round</ogc:Function_Name>
  304. <ogc:Function_Name nArgs="1">round_2</ogc:Function_Name>
  305. <ogc:Function_Name nArgs="1">roundDouble</ogc:Function_Name>
  306. <ogc:Function_Name nArgs="6">ScaleCoverage</ogc:Function_Name>
  307. <ogc:Function_Name nArgs="4">sdo_nn</ogc:Function_Name>
  308. <ogc:Function_Name nArgs="2">setCRS</ogc:Function_Name>
  309. <ogc:Function_Name nArgs="3">Simplify</ogc:Function_Name>
  310. <ogc:Function_Name nArgs="1">sin</ogc:Function_Name>
  311. <ogc:Function_Name nArgs="3">Snap</ogc:Function_Name>
  312. <ogc:Function_Name nArgs="1">sqrt</ogc:Function_Name>
  313. <ogc:Function_Name nArgs="2">StandardDeviation</ogc:Function_Name>
  314. <ogc:Function_Name nArgs="1">startAngle</ogc:Function_Name>
  315. <ogc:Function_Name nArgs="1">startPoint</ogc:Function_Name>
  316. <ogc:Function_Name nArgs="1">strCapitalize</ogc:Function_Name>
  317. <ogc:Function_Name nArgs="2">strConcat</ogc:Function_Name>
  318. <ogc:Function_Name nArgs="2">strEndsWith</ogc:Function_Name>
  319. <ogc:Function_Name nArgs="2">strEqualsIgnoreCase</ogc:Function_Name>
  320. <ogc:Function_Name nArgs="2">strIndexOf</ogc:Function_Name>
  321. <ogc:Function_Name nArgs="2">strLastIndexOf</ogc:Function_Name>
  322. <ogc:Function_Name nArgs="1">strLength</ogc:Function_Name>
  323. <ogc:Function_Name nArgs="2">strMatches</ogc:Function_Name>
  324. <ogc:Function_Name nArgs="3">strPosition</ogc:Function_Name>
  325. <ogc:Function_Name nArgs="4">strReplace</ogc:Function_Name>
  326. <ogc:Function_Name nArgs="2">strStartsWith</ogc:Function_Name>
  327. <ogc:Function_Name nArgs="3">strSubstring</ogc:Function_Name>
  328. <ogc:Function_Name nArgs="2">strSubstringStart</ogc:Function_Name>
  329. <ogc:Function_Name nArgs="1">strToLowerCase</ogc:Function_Name>
  330. <ogc:Function_Name nArgs="1">strToUpperCase</ogc:Function_Name>
  331. <ogc:Function_Name nArgs="1">strTrim</ogc:Function_Name>
  332. <ogc:Function_Name nArgs="3">strTrim2</ogc:Function_Name>
  333. <ogc:Function_Name nArgs="2">StyleCoverage</ogc:Function_Name>
  334. <ogc:Function_Name nArgs="2">symDifference</ogc:Function_Name>
  335. <ogc:Function_Name nArgs="1">tan</ogc:Function_Name>
  336. <ogc:Function_Name nArgs="1">toDegrees</ogc:Function_Name>
  337. <ogc:Function_Name nArgs="1">toRadians</ogc:Function_Name>
  338. <ogc:Function_Name nArgs="2">touches</ogc:Function_Name>
  339. <ogc:Function_Name nArgs="1">toWKT</ogc:Function_Name>
  340. <ogc:Function_Name nArgs="2">Transform</ogc:Function_Name>
  341. <ogc:Function_Name nArgs="2">union</ogc:Function_Name>
  342. <ogc:Function_Name nArgs="2">UnionFeatureCollection</ogc:Function_Name>
  343. <ogc:Function_Name nArgs="2">Unique</ogc:Function_Name>
  344. <ogc:Function_Name nArgs="2">UniqueInterval</ogc:Function_Name>
  345. <ogc:Function_Name nArgs="6">VectorToRaster</ogc:Function_Name>
  346. <ogc:Function_Name nArgs="3">VectorZonalStatistics</ogc:Function_Name>
  347. <ogc:Function_Name nArgs="1">vertices</ogc:Function_Name>
  348. <ogc:Function_Name nArgs="2">within</ogc:Function_Name>
  349. </ogc:Function_Names>
  350. </ogc:Functions>
  351. </ogc:Arithmetic_Operators>
  352. </ogc:Scalar_Capabilities>
  353. </ogc:Filter_Capabilities>
  354. </WFS_Capabilities>
  355. <?php
  356. }
  357. public function _getXmlSchemaLocation() {
  358. $schemaLocations = array();
  359. //$schemaLocations[] = 'http://www.opengis.net/wfs http://webgis.regione.sardegna.it:80/geoserver/schemas/wfs/1.0.0/WFS-capabilities.xsd';// @from http://webgis.regione.sardegna.it/geoserver/ows?service=WFS&request=GetCapabilities
  360. return (!empty($schemaLocations))? 'xsi:schemaLocation="' . implode(' ', $schemaLocations) . '"' : '';
  361. }
  362. public function _getXmlNamespaceList() {
  363. $baseNsUri = $this->getBaseNamespaceUri();
  364. $listNs = array();
  365. $listNs[] = 'xmlns:p5_default_db="' . $baseNsUri . '/default_db"';
  366. // $listNs[] = 'xmlns:p5_objects="' . $baseNsUri . '/objects"';
  367. return implode("\n", $listNs);
  368. }
  369. public function _getXmlNamespaceList__OLD() {
  370. $baseNsUri = $this->getBaseNamespaceUri();
  371. $namespaceList = $this->_getSourceNsList();
  372. $namespaceListOut = array();
  373. foreach ($namespaceList as $nsObj) {
  374. $ns = "p5_{$nsObj[0]}_{$nsObj[1]}";
  375. $uri = "{$baseNsUri}/{$nsObj[0]}/{$nsObj[1]}";
  376. $namespaceListOut[] = 'xmlns:' . $ns . '="' . $uri . '"';
  377. }
  378. return implode(' ', $namespaceListOut);
  379. }
  380. public function _getSourceNsList() {
  381. $usrObjList = array();
  382. $tblsAcl = $this->_usrAcl->getTablesAcl();
  383. foreach ($tblsAcl as $tblAcl) {
  384. $dataSourceName = 'default_db';// TODO: getSourceName
  385. $tblName = $tblAcl->getName();
  386. $usrObjList[] = array($dataSourceName, $tblName);
  387. }
  388. return $usrObjList;
  389. }
  390. public function _printGetCapabilitiesXml($wfsServerUrl) {
  391. ?>
  392. <GetCapabilities>
  393. <DCPType>
  394. <HTTP>
  395. <Get onlineResource="<?php echo $wfsServerUrl; ?>?REQUEST=GetCapabilities" />
  396. </HTTP>
  397. </DCPType>
  398. <DCPType>
  399. <HTTP>
  400. <Post onlineResource="<?php echo $wfsServerUrl; ?>" />
  401. </HTTP>
  402. </DCPType>
  403. </GetCapabilities>
  404. <?php
  405. }
  406. public function _printDescribeFeatureTypeXml($wfsServerUrl) {
  407. ?>
  408. <DescribeFeatureType>
  409. <SchemaDescriptionLanguage>
  410. <XMLSCHEMA />
  411. </SchemaDescriptionLanguage>
  412. <DCPType>
  413. <HTTP>
  414. <Get onlineResource="<?php echo $wfsServerUrl; ?>?REQUEST=DescribeFeatureType" />
  415. </HTTP>
  416. </DCPType>
  417. <DCPType>
  418. <HTTP>
  419. <Post onlineResource="<?php echo $wfsServerUrl; ?>" />
  420. </HTTP>
  421. </DCPType>
  422. </DescribeFeatureType>
  423. <?php
  424. }
  425. public function _printGetFeatureXml($wfsServerUrl) {
  426. ?>
  427. <GetFeature>
  428. <ResultFormat>
  429. <WFSKMLOutputFormat />
  430. <GML2 />
  431. <GML3 />
  432. <SHAPE-ZIP />
  433. <CSV />
  434. <JSON />
  435. </ResultFormat>
  436. <DCPType>
  437. <HTTP>
  438. <Get onlineResource="<?php echo $wfsServerUrl; ?>?REQUEST=GetFeature" />
  439. </HTTP>
  440. </DCPType>
  441. <DCPType>
  442. <HTTP>
  443. <Post onlineResource="<?php echo $wfsServerUrl; ?>" />
  444. </HTTP>
  445. </DCPType>
  446. </GetFeature>
  447. <?php
  448. }
  449. public function _printTransactionXml($wfsServerUrl) {
  450. ?>
  451. <Transaction>
  452. <DCPType>
  453. <HTTP>
  454. <Get onlineResource="<?php echo $wfsServerUrl; ?>?request=Transaction" />
  455. </HTTP>
  456. </DCPType>
  457. <DCPType>
  458. <HTTP>
  459. <Post onlineResource="<?php echo $wfsServerUrl; ?>" />
  460. </HTTP>
  461. </DCPType>
  462. </Transaction>
  463. <?php
  464. }
  465. public function _printLockFeatureXml($wfsServerUrl) {
  466. ?>
  467. <LockFeature>
  468. <DCPType>
  469. <HTTP>
  470. <Get onlineResource="<?php echo $wfsServerUrl; ?>?REQUEST=LockFeature" />
  471. </HTTP>
  472. </DCPType>
  473. <DCPType>
  474. <HTTP>
  475. <Post onlineResource="<?php echo $wfsServerUrl; ?>" />
  476. </HTTP>
  477. </DCPType>
  478. </LockFeature>
  479. <?php
  480. }
  481. public function _printGetFeatureWithLockXml($wfsServerUrl) {
  482. ?>
  483. <GetFeatureWithLock>
  484. <ResultFormat>
  485. <GML2 />
  486. </ResultFormat>
  487. <DCPType>
  488. <HTTP>
  489. <Get onlineResource="<?php echo $wfsServerUrl; ?>?REQUEST=GetFeatureWithLock" />
  490. </HTTP>
  491. </DCPType>
  492. <DCPType>
  493. <HTTP>
  494. <Post onlineResource="<?php echo $wfsServerUrl; ?>" />
  495. </HTTP>
  496. </DCPType>
  497. </GetFeatureWithLock>
  498. <?php
  499. }
  500. public function _printFeatureTypeListXml() {
  501. $featureTypes = array();
  502. $tblsAcl = $this->_getTableAclList();
  503. foreach ($tblsAcl as $tblAcl) {
  504. $dataSourceName = 'default_db';// TODO: getSourceName
  505. $tblName = $tblAcl->getName();
  506. $usrObjList[] = array($dataSourceName, $tblName);
  507. $featureType = array();
  508. $featureType['ns'] = "p5_{$dataSourceName}";
  509. $featureType['Title'] = $tblAcl->getRawLabel();
  510. $featureType['Abstract'] = $tblAcl->getRawOpis();
  511. $featureType['Keywords'] = array();
  512. $featureType['Keywords'][] = $tblAcl->getID();
  513. $featureType['Keywords'][] = $tblName;
  514. $featureType['Keywords'][] = $tblAcl->getRawLabel();
  515. $featureType['Keywords'] = implode(", ", $featureType['Keywords']);
  516. $featureType['SRS'] = "EPSG:4326";
  517. $featureType['LatLongBoundingBox'] = array();// TODO: feature LatLongBoundingBox
  518. $featureType['LatLongBoundingBox']['minx'] = "8.12328509871721";
  519. $featureType['LatLongBoundingBox']['miny'] = "38.8575126897477";
  520. $featureType['LatLongBoundingBox']['maxx'] = "9.838674658246807";
  521. $featureType['LatLongBoundingBox']['maxy'] = "41.31378404137082";
  522. $featureTypes[$tblName] = $featureType;
  523. }
  524. if(0){// add p5_objects:File
  525. Lib::loadClass('FileStorage');
  526. $featureType = array();
  527. $featureType['ns'] = "p5_objects";
  528. $featureType['Title'] = "Pliki";
  529. $featureType['Abstract'] = "Pliki";
  530. $featureType['Keywords'] = "Pliki";
  531. $featureType['SRS'] = "EPSG:4326";
  532. // $featureType['LatLongBoundingBox'] = array();// TODO: feature LatLongBoundingBox
  533. // $featureType['LatLongBoundingBox']['minx'] = "8.12328509871721";
  534. // $featureType['LatLongBoundingBox']['miny'] = "38.8575126897477";
  535. // $featureType['LatLongBoundingBox']['maxx'] = "9.838674658246807";
  536. // $featureType['LatLongBoundingBox']['maxy'] = "41.31378404137082";
  537. $featureTypes['File'] = $featureType;
  538. }
  539. /*
  540. <FeatureType>
  541. <Name>ppr06:AMBITIPAESAGGIO</Name>
  542. <Title>AMBITIPAESAGGIO</Title>
  543. <Abstract />
  544. <Keywords>features, AMBITIPAESAGGIO</Keywords>
  545. <SRS>EPSG:4326</SRS>
  546. <LatLongBoundingBox minx="8.12328509871721" miny="38.8575126897477" maxx="9.838674658246807" maxy="41.31378404137082" />
  547. </FeatureType>
  548. */
  549. $featureTypesXml = '';
  550. foreach ($featureTypes as $tblName => $feature) {
  551. $featureTypesXml .= " " . '<FeatureType>' . "\n";
  552. $featureTypesXml .= " " . '<Name>' . "{$feature['ns']}:{$tblName}" . '</Name>' . "\n";
  553. $featureTypesXml .= " " . '<Title>' . "{$feature['Title']}" . '</Title>' . "\n";
  554. if (!empty($feature['Abstract'])) {
  555. $featureTypesXml .= " " . '<Abstract>' . "{$feature['Abstract']}" . '</Abstract>' . "\n";
  556. } else {
  557. $featureTypesXml .= " " . '<Abstract/>' . "\n";
  558. }
  559. if (!empty($feature['Keywords'])) {
  560. $featureTypesXml .= " " . '<Keywords>' . "{$feature['Keywords']}" . '</Keywords>' . "\n";
  561. } else {
  562. $featureTypesXml .= " " . '<Keywords/>' . "\n";
  563. }
  564. $featureTypesXml .= " " . '<SRS>' . "{$feature['SRS']}" . '</SRS>' . "\n";
  565. if (!empty($feature['LatLongBoundingBox'])) {
  566. $latLongBoundingBoxOut = array();
  567. $latLongBoundingBoxOut[] = 'minx="' . $feature['LatLongBoundingBox']['minx'] . '"';
  568. $latLongBoundingBoxOut[] = 'miny="' . $feature['LatLongBoundingBox']['miny'] . '"';
  569. $latLongBoundingBoxOut[] = 'maxx="' . $feature['LatLongBoundingBox']['maxx'] . '"';
  570. $latLongBoundingBoxOut[] = 'maxy="' . $feature['LatLongBoundingBox']['maxy'] . '"';
  571. $featureTypesXml .= " " . '<LatLongBoundingBox ' . implode(' ', $latLongBoundingBoxOut) . ' />' . "\n";
  572. }
  573. $featureTypesXml .= " " . '</FeatureType>' . "\n";
  574. }
  575. echo $featureTypesXml;
  576. }
  577. public function _parseTransactionXmlStruct($requestXml, $requestXmlTags) {
  578. $DBG = (V::get('DBG_XML', '', $_GET) > 0);// TODO: Profiler
  579. $rootTagName = V::get('tag', '', $requestXmlTags[0]);
  580. if ('Transaction' != $rootTagName) {
  581. throw new Api_WfsException("Parse Request XML Error - Missing Transaction as root xml tag", __LINE__, null, 'TransactionParseError', 'request');
  582. }
  583. // 1. convert request: wfs.transaction.convert-wfs-request.xsl
  584. // 2. validate converted request: wfs.transaction-converted-request.xsd
  585. // 3. execute request in data source
  586. // ? acl check?
  587. $usedSourceNsList = array();
  588. $sourceNsList = $this->_getSourceNsList();
  589. //$sourceNsList = array();
  590. //foreach ($requestXmlTags[0]['attributes'] as $attrName => $attrValue) {
  591. // if ('xmlns:p5_' == substr($attrName, 0, 9)) {
  592. // $sourceNsList[substr($attrName, 6)] = $attrValue;
  593. // }
  594. //}
  595. {// get used typeNames
  596. $usedTypeNames = array();
  597. // <Update xmlns="http://www.opengis.net/wfs" typeName="p5_default_db:TEST_PERMS">
  598. foreach ($requestXmlTags as $tag) {
  599. if ('Update' == $tag['tag'] && 'open' == $tag['type']) {
  600. $typeName = $tag['attributes']['typeName'];
  601. foreach ($sourceNsList as $nsInd => $ns) {
  602. if ("p5_{$ns[0]}:{$ns[1]}" == $typeName) {
  603. $usedSourceNsList[$nsInd] = $ns;
  604. }
  605. }
  606. }
  607. }
  608. // TODO: check: <Transaction xmlns:p5_default_db="https://biuro.biall-net.pl/wfs/default_db/TEST_PERMS"
  609. // <Insert xmlns="http://www.opengis.net/wfs">
  610. // <TEST_PERMS xmlns="https://biuro.biall-net.pl/wfs/default_db/TEST_PERMS">
  611. $lastTagName = '';
  612. foreach ($requestXmlTags as $tag) {
  613. if ('Insert' == $lastTagName) {
  614. $typeName = $tag['tag'];
  615. foreach ($sourceNsList as $nsInd => $ns) {
  616. if ("{$ns[1]}" == $typeName) {
  617. $usedSourceNsList[$nsInd] = $ns;
  618. }
  619. }
  620. }
  621. $lastTagName = $tag['tag'];
  622. }
  623. // <Delete xmlns="http://www.opengis.net/wfs" typeName="p5_default_db:TEST_GEOM_POINT">
  624. foreach ($requestXmlTags as $tag) {
  625. if ('Delete' == $tag['tag'] && 'open' == $tag['type']) {
  626. $typeName = $tag['attributes']['typeName'];
  627. foreach ($sourceNsList as $nsInd => $ns) {
  628. if ("p5_{$ns[0]}:{$ns[1]}" == $typeName) {
  629. $usedSourceNsList[$nsInd] = $ns;
  630. }
  631. }
  632. }
  633. }
  634. }
  635. if (empty($usedSourceNsList)) {
  636. throw new Api_WfsException("Parse Request XML Error - Empty source NS list", __LINE__, null, 'TransactionParseError', 'request');
  637. }
  638. $convertedTransaction = $this->_convertTransactionXml($requestXml, $usedSourceNsList);
  639. if($DBG){echo 'L.' . __LINE__ . ' $convertedTransaction:';print_r($convertedTransaction);echo "\n";}
  640. if (empty($convertedTransaction)) {
  641. throw new Api_WfsException("Parse Request XML Error - Empty transaction", __LINE__, null, 'TransactionParseError', 'request');
  642. }
  643. if (!$this->_validateConvertedTransactionXml($convertedTransaction, $usedSourceNsList)) {
  644. // <Transaction version="1.0.0" service="WFS">
  645. // <InsertNs0 typeName="TEST_PERMS">
  646. // <ID>41</ID>
  647. // <ADM_ADMIN_LEVEL>3</ADM_ADMIN_LEVEL>
  648. // </InsertNs0>
  649. // </Transaction>
  650. $transXml = @simplexml_load_string($convertedTransaction);
  651. foreach ($transXml->children() as $funcXml) {
  652. $funcName = substr($funcXml->getName(), 0, 6);// Insert... , Update... , Delete...
  653. if (empty($funcXml['typeName'][0])) throw new Api_WfsException("Missing typeName for function '{$funcName}'", __LINE__, null, 'MissingTypeName', 'request');
  654. $typeName = $funcXml['typeName'][0];
  655. $acl = $this->getAclFromTypeName("p5_default_db:{$typeName}");
  656. $primaryKey = $acl->getPrimaryKeyField();
  657. $pkObject = null;
  658. foreach ($funcXml->children() as $fieldXml) {
  659. if ($primaryKey == $fieldXml->getName()) $pkObject = $fieldXml[0];
  660. }
  661. if ('Insert' == $funcName && $pkObject) $funcName = 'Update';
  662. if ('Update' == $funcName) {// check perm W - skip $primaryKey
  663. if (!$pkObject) throw new Api_WfsException("Missing primary key ({$primaryKey}) for action Update", __LINE__, null, 'MissingPrimaryKey', 'request');
  664. $toUpdateFields = array();
  665. foreach ($funcXml->children() as $fieldXml) {
  666. if ($primaryKey == $fieldXml->getName()) continue;// skip primary key
  667. $toUpdateFields[] = $fieldXml->getName();
  668. }
  669. if (empty($toUpdateFields)) throw new Api_WfsException("Missing fields to update", __LINE__, null, 'MissingFieldToUpdate', 'request');
  670. $oldObject = $acl->getItem($pkObject);
  671. if (!$oldObject) throw new Api_WfsException("Object '{$typeName}.{$pkObject}' not exists", __LINE__, null, 'ObjectNotExists', 'request');
  672. if (!$acl->canWriteRecord($oldObject) && !$acl->hasPermSuperWrite()) {
  673. throw new Api_WfsException("Access Denied to Update object '{$typeName}.{$pkObject}'", __LINE__, null, 'MissingObjectPermUpdate', 'request');
  674. }
  675. foreach ($toUpdateFields as $fieldName) {
  676. $aclIdFld = $acl->getFieldIdByName($fieldName);
  677. if (!$acl->isAllowed($aclIdFld, 'W', $oldObject)) {
  678. throw new Api_WfsException("Access Denied to Update field '{$fieldName}' in object '{$typeName}.{$pkObject}'", __LINE__, null, 'MissingFieldPermWrite', 'request');
  679. }
  680. }
  681. } else if ('Insert' == $funcName) {// check perm C
  682. foreach ($funcXml->children() as $fieldXml) {
  683. $aclIdFld = $acl->getFieldIdByName($fieldXml->getName());
  684. if (!$acl->isAllowed($aclIdFld, 'C')) {
  685. throw new Api_WfsException("Access Denied to Create field '{$fieldName}' in object '{$typeName}.{$pkObject}'", __LINE__, null, 'MissingFieldPermCreate', 'request');
  686. }
  687. }
  688. } else {
  689. // TODO: Delete, ... ?
  690. }
  691. }
  692. throw new Exception("Parse Request xml error #" . __LINE__ . ": schema validation failed");
  693. }
  694. $parserXml = xml_parser_create();
  695. xml_parser_set_option($parserXml, XML_OPTION_CASE_FOLDING, 0);
  696. xml_parser_set_option($parserXml, XML_OPTION_SKIP_WHITE, 1);
  697. if (0 == xml_parse_into_struct($parserXml, $convertedTransaction, $tags)) {
  698. throw new Exception("Parse Request xml error #" . __LINE__ . ": parse converted transaction failed");
  699. }
  700. xml_parser_free($parserXml);
  701. if (empty($tags)) {
  702. throw new Exception("Parse Request xml error #" . __LINE__ . ": parse converted transaction returns empty structure");
  703. }
  704. // [{"tag":"Transaction","type":"open","level":1,"attributes":{"version":"1.0.0","service":"WFS"}},
  705. // {"tag":"Update","type":"open","level":2,"attributes":
  706. // {"typeName":"p5_default_db_13051:TEST_PERMS","featureId":"TEST_PERMS.25"}},
  707. // {"tag":"PARENT_ID","type":"complete","level":3,"value":"0"},
  708. // {"tag":"Update","type":"close","level":2},
  709. // {"tag":"Transaction","type":"close","level":1}]
  710. if($DBG){echo "\nTODO: tags L." . __LINE__ . ":\n"; print_r($tags);echo "\n";}
  711. $actionTag = null;
  712. $prevTagName = '';
  713. $theGeomField = 'the_geom';// TODO: get the geom field name from acl
  714. $itemPatchs = array();
  715. foreach ($tags as $tag) {
  716. switch (substr($tag['tag'], 0, 6)) {
  717. case 'Transa': continue; break;// Transaction
  718. case 'Update':
  719. case 'Insert':
  720. case 'Delete':
  721. case 'Native':
  722. if ('open' == $tag['type'] // Insert, Update
  723. || 'complete' == $tag['type'] // Delete
  724. ) {
  725. $actionTag = array();
  726. $actionTag['tag'] = substr($tag['tag'], 0, 6);
  727. $actionTag['typeName'] = $tag['attributes']['typeName'];
  728. if ('Insert' == substr($tag['tag'], 0, 6)) {
  729. $actionTag['typeName'] = "p5_default_db:{$actionTag['typeName']}";
  730. }
  731. $featureEx = explode('.', $tag['attributes']['featureId'], 2);
  732. $actionTag['featureId'] = $featureEx[1];
  733. if ('Update' == substr($tag['tag'], 0, 6) && empty($actionTag['featureId'])) {
  734. throw new Api_WfsException("Syntax error - could not read feature id!");
  735. }
  736. if ('Delete' == substr($tag['tag'], 0, 6) && empty($actionTag['featureId'])) {
  737. throw new Api_WfsException("Syntax error - could not read feature id!");
  738. }
  739. if ('complete' == $tag['type']) {
  740. $itemPatchs[] = $actionTag;
  741. $actionTag = null;
  742. } else {
  743. $actionTag['itemPatch'] = array();
  744. }
  745. } else {
  746. $itemPatchs[] = $actionTag;
  747. $actionTag = null;
  748. }
  749. break;
  750. default: {// fields
  751. if (3 != $tag['level'] && 'close' == $tag['type']) {
  752. $actionTag = null;
  753. }
  754. if (3 != $tag['level']) continue;
  755. if (empty($actionTag)) continue;
  756. if ('Update' == $actionTag['tag']) {
  757. if ($theGeomField == $tag['tag']) {
  758. $actionTag['itemPatch'][$tag['tag']] = $this->_typeConverter->convertGmlCoordinatesToWkt($tag['value']);
  759. } else {
  760. $actionTag['itemPatch'][$tag['tag']] = $tag['value'];
  761. }
  762. }
  763. else if ('Insert' == $actionTag['tag']) {
  764. if ($theGeomField == $tag['tag']) {
  765. $actionTag['itemPatch'][$tag['tag']] = $this->_typeConverter->convertGmlCoordinatesToWkt($tag['value']);
  766. } else {
  767. $actionTag['itemPatch'][$tag['tag']] = $tag['value'];
  768. }
  769. }
  770. else if ('Delete' == $actionTag['tag']) {
  771. }
  772. }
  773. }
  774. if (empty($prevTagName)) $prevTagName = $tag['tag'];
  775. }
  776. if($DBG){echo "\nTODO: itemPatchs L." . __LINE__ . ":\n"; print_r($itemPatchs);echo "\n";}
  777. if($DBG){echo "\nTODO: _user_id L." . __LINE__ . " '{$this->_usrAcl->_user_id}'" . "\n";}
  778. $changesList = array();
  779. if (!empty($itemPatchs)) {
  780. foreach ($itemPatchs as $itemPatchInfo) {
  781. if($DBG){echo "L." . __LINE__ . " itemPatchInfo['itemPatch']:\n";print_r($itemPatchInfo['itemPatch']);}
  782. $acl = $this->getAclFromTypeName($itemPatchInfo['typeName']);
  783. if ('Delete' == $itemPatchInfo['tag']) {
  784. $itemPatch = array();
  785. $itemPatch[$acl->getPrimaryKeyField()] = $itemPatchInfo['featureId'];
  786. $itemPatch['the_geom'] = 'NULL';
  787. } else {
  788. if (empty($itemPatchInfo['itemPatch'])) continue;
  789. $itemPatch = $itemPatchInfo['itemPatch'];
  790. if ('Update' == $itemPatchInfo['tag']) {
  791. $itemPatch[$acl->getPrimaryKeyField()] = $itemPatchInfo['featureId'];
  792. }
  793. else if ('Insert' == $itemPatchInfo['tag']) {
  794. if (!empty($itemPatch[$acl->getPrimaryKeyField()])) {
  795. $itemPatchInfo['featureId'] = $itemPatch[$acl->getPrimaryKeyField()];
  796. }
  797. else {
  798. //throw new Exception("TODO: Insert #" . __LINE__ . ": Create new record");
  799. }
  800. }
  801. }
  802. if($DBG){echo "L." . __LINE__ . " TODO '" . ($itemPatchInfo['tag'])? 'Insert' : 'Update' . "' itemPatch:\n";print_r($itemPatch);}
  803. if ('Insert' == $itemPatchInfo['tag'] && empty($itemPatch[$acl->getPrimaryKeyField()])) {
  804. $newId = $acl->addItem($itemPatch);
  805. $changesList[$newId] = array('Status'=>(($newId > 0)? 'SUCCESS' : 'FAILED'), 'Message'=>"created {$newId}.");
  806. if ($newId > 0) {
  807. $changesList[$newId]['fid'] = $acl->getName() . '.' . $newId;
  808. }
  809. if($DBG){echo "created {$newId}.\n";}
  810. } else {
  811. $affected = $acl->updateItem($itemPatch);
  812. $changesList[$itemPatchInfo['featureId']] = array('Status'=>(($affected >= 0)? 'SUCCESS' : 'FAILED'), 'Message'=>"affected {$affected}.");
  813. if($DBG){echo "affected {$affected}.\n";}
  814. }
  815. }
  816. //throw new Exception("TODO: run query #" . __LINE__ . " \nitemPatchs:\n" . json_encode($itemPatchs) . " \ntags:\n" . json_encode($tags) . "\n");
  817. }
  818. else {
  819. throw new Exception("Parse Request xml error #" . __LINE__ . ": Nothing to change");
  820. }
  821. return $this->_transactionResponse($changesList);
  822. }
  823. public function _transactionResponse($changesList) {
  824. // <WFS_TransactionResponse>
  825. // <TransactionResult>
  826. // <Status> : SUCCESS / FAILED / PARTIAL
  827. // [<Locator]
  828. // [<Message]
  829. $messageTag = '';
  830. $statusTag = '';
  831. $statusIsFailed = false;
  832. $statusAll = null;
  833. $createdFetureId = array();
  834. foreach ($changesList as $featureId => $change) {
  835. if ('FAILED' == $change['Status']) {
  836. $statusIsFailed = true;
  837. }
  838. if ('SUCCESS' == $change['Status'] && !empty($change['fid'])) {
  839. $createdFetureId[] = $change['fid'];
  840. }
  841. if (!empty($change['Message'])) $messageTag .= "Feature '{$featureId}' {$change['Status']}: {$change['Message']}\n";
  842. }
  843. $statusTag = ($statusIsFailed)? 'FAILED' : 'SUCCESS';
  844. $statusTag = "<wfs:{$statusTag}/>";
  845. $messageTag = '';//"<wfs:Message>{$messageTag}</wfs:Message>";
  846. /* Example:
  847. <?xml version="1.0" encoding="UTF-8"?>
  848. <wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs"
  849. xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  850. xsi:schemaLocation="http://www.opengis.net/wfs http://localhost:8080/geoserver/schemas/wfs/1.0.0/WFS-transaction.xsd">
  851. <wfs:InsertResult>
  852. <ogc:FeatureId fid="archsites.26" />
  853. </wfs:InsertResult>
  854. <wfs:TransactionResult handle="Updating Signature rock label">
  855. <wfs:Status>
  856. <wfs:SUCCESS />
  857. </wfs:Status>
  858. </wfs:TransactionResult>
  859. </wfs:WFS_TransactionResponse>*/
  860. // TODO: build xml by DOMDocument
  861. // TODO: xsi:schemaLocation="http://www.opengis.net/wfs http://localhost:8080/geoserver/schemas/wfs/1.0.0/WFS-transaction.xsd"
  862. $wfsInsertResult = '';
  863. if (!empty($createdFetureId)) {
  864. $wfsInsertResult = "\n<wfs:InsertResult>\n";
  865. foreach ($createdFetureId as $fid) {
  866. $wfsInsertResult .= '<ogc:FeatureId fid="' . $fid . '" xmlns:ogc="http://www.opengis.net/ogc"/>' . "\n";
  867. }
  868. $wfsInsertResult .= "\n</wfs:InsertResult>\n";
  869. EOF;
  870. }
  871. $tranRes = <<<EOF
  872. <wfs:WFS_TransactionResponse version="1.0.0"
  873. xmlns:wfs="http://www.opengis.net/wfs"
  874. xmlns:ogc="http://www.opengis.net/ogc"
  875. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  876. {$wfsInsertResult}
  877. <wfs:TransactionResult>
  878. <wfs:Status>{$statusTag}</wfs:Status>
  879. {$messageTag}
  880. </wfs:TransactionResult>
  881. </wfs:WFS_TransactionResponse>
  882. EOF;
  883. return $tranRes;
  884. }
  885. public function _convertTransactionXml($requestXmlString, $sourceNsList) {
  886. $DBG = (V::get('DBG_XSL', '', $_GET) > 0);// TODO: Profiler
  887. if($DBG){echo 'L.' . __LINE__ . ' sourceNsList:';print_r($sourceNsList);echo "\n";}
  888. $updateActionsXsd = array();
  889. $insertActionsXsd = array();
  890. $deleteActionsXsd = array();
  891. //<!-- TODO: create tag Update{X} where X is namespace index -->
  892. foreach ($sourceNsList as $nsInd => $sourceNs) {
  893. // <Update>
  894. $theGeomField = 'the_geom';// TODO: get from fields list
  895. $typeName = "p5_{$sourceNs[0]}:{$sourceNs[1]}";
  896. $updateElementName = "UpdateNs{$nsInd}";
  897. $geomCoordsUpdateXpath = "//wfs:Value/*/gml:outerBoundaryIs/gml:LinearRing/gml:coordinates";
  898. $geomCoordsInsertXpath = "//*/gml:outerBoundaryIs/gml:LinearRing/gml:coordinates";
  899. $acl = $this->getAclFromTypeName($typeName);
  900. $geomType = $acl->getGeomFieldType($theGeomField);
  901. if ('polygon' == $geomType) {
  902. $geomCoordsUpdateXpath = ".//wfs:Value/*/gml:outerBoundaryIs/gml:LinearRing/gml:coordinates";
  903. $geomCoordsUpdateXpath = "((<xsl:value-of select=\"{$geomCoordsUpdateXpath}\"/>))";
  904. $geomCoordsInsertXpath = ".//*/gml:outerBoundaryIs/gml:LinearRing/gml:coordinates";
  905. $geomCoordsInsertXpath = "((<xsl:value-of select=\"{$geomCoordsInsertXpath}\"/>))";
  906. } else if ('linestring' == $geomType) {
  907. $geomCoordsUpdateXpath = ".//wfs:Value/*/gml:coordinates";
  908. $geomCoordsUpdateXpath = "(<xsl:value-of select=\"{$geomCoordsUpdateXpath}\"/>)";
  909. $geomCoordsInsertXpath = ".//*/gml:coordinates";
  910. $geomCoordsInsertXpath = "(<xsl:value-of select=\"{$geomCoordsInsertXpath}\"/>)";
  911. } else if ('point' == $geomType) {
  912. $geomCoordsUpdateXpath = ".//wfs:Value/*/gml:coordinates";
  913. $geomCoordsUpdateXpath = "(<xsl:value-of select=\"{$geomCoordsUpdateXpath}\"/>)";
  914. $geomCoordsInsertXpath = ".//*/gml:coordinates";
  915. $geomCoordsInsertXpath = "(<xsl:value-of select=\"{$geomCoordsInsertXpath}\"/>)";
  916. }
  917. $actionXsd = <<<EOF
  918. <xsl:when test="@typeName = '{$typeName}'">
  919. <xsl:element name="{$updateElementName}">
  920. <xsl:attribute name="typeName"><xsl:value-of select="@typeName" /></xsl:attribute>
  921. <xsl:attribute name="featureId"><xsl:value-of select="ogc:Filter/ogc:FeatureId/@fid" /></xsl:attribute>
  922. <xsl:for-each select="wfs:Property">
  923. <xsl:element name="{wfs:Name}">
  924. <xsl:choose>
  925. <xsl:when test="wfs:Name = '{$theGeomField}'"><xsl:value-of select="local-name(//wfs:Value/*[1])"/>{$geomCoordsUpdateXpath}</xsl:when>
  926. <xsl:otherwise><xsl:value-of select="wfs:Value"/></xsl:otherwise>
  927. </xsl:choose>
  928. </xsl:element>
  929. </xsl:for-each>
  930. </xsl:element>
  931. </xsl:when>
  932. EOF;
  933. $updateActionsXsd[] = $actionXsd;
  934. $typeName = "{$sourceNs[1]}";//"p5_{$sourceNs[0]}:{$sourceNs[1]}";
  935. $insertElementName = "InsertNs{$nsInd}";
  936. $actionXsd = <<<EOF
  937. <xsl:when test="local-name() = '{$typeName}'">
  938. <xsl:element name="{$insertElementName}">
  939. <xsl:attribute name="typeName"><xsl:value-of select="local-name()" /></xsl:attribute>
  940. <xsl:for-each select="*">
  941. <xsl:element name="{local-name()}">
  942. <xsl:choose>
  943. <xsl:when test="local-name() = '{$theGeomField}'"><xsl:value-of select="local-name(*[1])"/>{$geomCoordsInsertXpath}</xsl:when>
  944. <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
  945. </xsl:choose>
  946. </xsl:element>
  947. </xsl:for-each>
  948. </xsl:element>
  949. </xsl:when>
  950. EOF;
  951. $insertActionsXsd[] = $actionXsd;
  952. $deleteElementName = "DeleteNs{$nsInd}";
  953. $typeName = "p5_{$sourceNs[0]}:{$sourceNs[1]}";
  954. $actionXsd = <<<EOF
  955. <xsl:when test="@typeName = '{$typeName}'">
  956. <xsl:variable name="typeName" select="@typeName" />
  957. <xsl:for-each select="ogc:Filter/ogc:FeatureId">
  958. <xsl:element name="{$deleteElementName}">
  959. <xsl:attribute name="typeName"><xsl:value-of select="\$typeName" /></xsl:attribute>
  960. <xsl:attribute name="featureId"><xsl:value-of select="@fid" /></xsl:attribute>
  961. </xsl:element>
  962. </xsl:for-each>
  963. </xsl:when>
  964. EOF;
  965. $deleteActionsXsd[] = $actionXsd;
  966. }
  967. if (!empty($updateActionsXsd)) {
  968. $updateActionsXsd = implode("\n", $updateActionsXsd);
  969. $updateActionsXsd = <<<EOF
  970. <xsl:choose>
  971. {$updateActionsXsd}
  972. </xsl:choose>
  973. EOF;
  974. } else {
  975. $updateActionsXsd = '';
  976. }
  977. if (!empty($insertActionsXsd)) {
  978. $insertActionsXsd = implode("\n", $insertActionsXsd);
  979. $insertActionsXsd = <<<EOF
  980. <xsl:choose>
  981. {$insertActionsXsd}
  982. </xsl:choose>
  983. EOF;
  984. } else {
  985. $insertActionsXsd = '';
  986. }
  987. if (!empty($deleteActionsXsd)) {
  988. $deleteActionsXsd = implode("\n", $deleteActionsXsd);
  989. $deleteActionsXsd = <<<EOF
  990. <xsl:choose>
  991. {$deleteActionsXsd}
  992. </xsl:choose>
  993. EOF;
  994. } else {
  995. $deleteActionsXsd = '';
  996. }
  997. $convertTransactionXslString = '<?xml version="1.0"?>';
  998. $convertTransactionXslString .= <<<EOF
  999. <xsl:transform version="1.0"
  1000. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  1001. xmlns:wfs="http://www.opengis.net/wfs"
  1002. xmlns:ogc="http://www.opengis.net/ogc"
  1003. xmlns:gml="http://www.opengis.net/gml">
  1004. <xsl:template match="/">
  1005. <xsl:for-each select="wfs:Transaction">
  1006. <Transaction>
  1007. <xsl:attribute name="version"><xsl:value-of select="@version" /></xsl:attribute>
  1008. <xsl:attribute name="service"><xsl:value-of select="@service" /></xsl:attribute>
  1009. <xsl:for-each select="wfs:Update">
  1010. {$updateActionsXsd}
  1011. </xsl:for-each>
  1012. <xsl:for-each select="wfs:Insert/*">
  1013. {$insertActionsXsd}
  1014. </xsl:for-each>
  1015. <xsl:for-each select="wfs:Delete">
  1016. {$deleteActionsXsd}
  1017. </xsl:for-each>
  1018. <!-- TODO: Native -->
  1019. </Transaction>
  1020. </xsl:for-each>
  1021. </xsl:template>
  1022. </xsl:transform>
  1023. EOF;
  1024. if($DBG){echo 'L.' . __LINE__ . ' $convertTransactionXslString:' . $convertTransactionXslString . "\n";}
  1025. $requestXml = new DOMDocument();
  1026. $requestXml->loadXml($requestXmlString);
  1027. $convertTransactionXsl = new DOMDocument();
  1028. $convertTransactionXsl->loadXml($convertTransactionXslString);
  1029. $proc = new XSLTProcessor();
  1030. $proc->importStylesheet($convertTransactionXsl);
  1031. return $proc->transformToXML($requestXml);
  1032. }
  1033. public function _validateConvertedTransactionXml($convertedTransaction, $sourceNsList) {
  1034. $DBG = (V::get('DBG_XSD', '', $_GET) > 0);// TODO: Profiler
  1035. if($DBG){echo 'L.' . __LINE__ . ' sourceNsList:';print_r($sourceNsList);echo "\n";}
  1036. $dom = new DOMDocument('1.0', 'utf-8');
  1037. $dom->formatOutput = true;
  1038. $dom->preserveWhiteSpace = false;
  1039. $rootNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:schema');
  1040. $dom->appendChild($rootNode);
  1041. // $rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gml', 'http://www.opengis.net/gml');
  1042. // $rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:' . $wfsNs, $wfsNsUri);
  1043. $rootNode->setAttribute('elementFormDefault', 'qualified');
  1044. // $rootNode->setAttribute('targetNamespace', $wfsNsUri);
  1045. $rootNode->setAttribute('version', '1.0');
  1046. {// <xsd:element name="Transaction" type="TransactionType">
  1047. $elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
  1048. $rootNode->appendChild($elNode);
  1049. $elNode->setAttribute('name', 'Transaction');
  1050. $elNode->setAttribute('type', 'TransactionType');
  1051. $cTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexType');
  1052. $rootNode->appendChild($cTypeNode);
  1053. $cTypeNode->setAttribute('name', 'TransactionType');
  1054. $seqNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:sequence');
  1055. $cTypeNode->appendChild($seqNode);
  1056. $choiceNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:choice');
  1057. $seqNode->appendChild($choiceNode);
  1058. $choiceNode->setAttribute('minOccurs', '0');
  1059. $choiceNode->setAttribute('maxOccurs', 'unbounded');
  1060. // <!-- <xsd:element ref="Update"/> -->
  1061. foreach ($sourceNsList as $nsInd => $sourceNs) {
  1062. $typeName = "p5_{$sourceNs[0]}:{$sourceNs[1]}";
  1063. $updateElementName = "UpdateNs{$nsInd}";
  1064. $updateElementType = "UpdateNs{$nsInd}ElementType";
  1065. $updateElemNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
  1066. $choiceNode->appendChild($updateElemNode);
  1067. $updateElemNode->setAttribute('name', $updateElementName);
  1068. $updateElemNode->setAttribute('type', $updateElementType);
  1069. }
  1070. // <!-- <xsd:element ref="Insert"/> -->
  1071. foreach ($sourceNsList as $nsInd => $sourceNs) {
  1072. $typeName = "p5_{$sourceNs[0]}:{$sourceNs[1]}";
  1073. $insertElementName = "InsertNs{$nsInd}";
  1074. $insertElementType = "InsertNs{$nsInd}ElementType";
  1075. $insertElemNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
  1076. $choiceNode->appendChild($insertElemNode);
  1077. $insertElemNode->setAttribute('name', $insertElementName);
  1078. $insertElemNode->setAttribute('type', $insertElementType);
  1079. }
  1080. // <!-- <xsd:element ref="Delete"/> -->
  1081. foreach ($sourceNsList as $nsInd => $sourceNs) {
  1082. $typeName = "p5_{$sourceNs[0]}:{$sourceNs[1]}";
  1083. $deleteElementName = "DeleteNs{$nsInd}";
  1084. $deleteElementType = "DeleteNs{$nsInd}ElementType";
  1085. $deleteElemNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
  1086. $choiceNode->appendChild($deleteElemNode);
  1087. $deleteElemNode->setAttribute('name', $deleteElementName);
  1088. $deleteElemNode->setAttribute('type', $deleteElementType);
  1089. }
  1090. // <!-- <xsd:element ref="Native"/> -->
  1091. $attrNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:attribute');
  1092. $cTypeNode->appendChild($attrNode);
  1093. $attrNode->setAttribute('name', 'version');
  1094. $attrNode->setAttribute('type', 'xsd:string');
  1095. $attrNode->setAttribute('use', 'required');
  1096. $attrNode->setAttribute('fixed', '1.0.0');
  1097. $attrNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:attribute');
  1098. $cTypeNode->appendChild($attrNode);
  1099. $attrNode->setAttribute('name', 'service');
  1100. $attrNode->setAttribute('type', 'xsd:string');
  1101. $attrNode->setAttribute('use', 'required');
  1102. $attrNode->setAttribute('fixed', 'WFS');
  1103. }
  1104. foreach ($sourceNsList as $nsInd => $sourceNs) {
  1105. $transactionTypesList = array();
  1106. $transactionTypesList[] = 'Update';
  1107. $transactionTypesList[] = 'Insert';
  1108. foreach ($transactionTypesList as $transactionType) {
  1109. $typeName = "p5_{$sourceNs[0]}:{$sourceNs[1]}";
  1110. $acl = $this->getAclFromTypeName($typeName);
  1111. $updateElementName = "{$transactionType}Ns{$nsInd}";
  1112. $updateElementType = "{$transactionType}Ns{$nsInd}ElementType";
  1113. /*
  1114. <xsd:complexType name="{$updateElementType}">
  1115. <xsd:sequence>
  1116. <xsd:element name="PARENT_ID" minOccurs="0" maxOccurs="1" type="xsd:integer" />
  1117. </xsd:sequence>
  1118. */
  1119. $updateTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexType');
  1120. $rootNode->appendChild($updateTypeNode);
  1121. $updateTypeNode->setAttribute('name', $updateElementType);
  1122. {
  1123. $seqNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:all');
  1124. $updateTypeNode->appendChild($seqNode);
  1125. {
  1126. $pKeyField = $acl->getPrimaryKeyField();
  1127. $fldList = $this->_getFieldListFromAcl($acl);
  1128. // fields without geometry fields
  1129. foreach ($fldList as $fldName) {
  1130. if ($acl->isGeomField($fldName)) continue;
  1131. $elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
  1132. $seqNode->appendChild($elNode);
  1133. $elNode->setAttribute('name', $fldName);
  1134. $minOccurs = 0;
  1135. if ($pKeyField == $fldName) {
  1136. $minOccurs = '1';
  1137. } else {
  1138. $minOccurs = '0';
  1139. }
  1140. $elNode->setAttribute('minOccurs', $minOccurs);
  1141. $fldType = null;
  1142. if ($acl->isIntegerField($fldName)) {
  1143. $fldType = 'xsd:integer';
  1144. }
  1145. else if ($acl->isDecimalField($fldName)) {
  1146. $fldType = 'xsd:decimal';
  1147. }
  1148. else if ($acl->isDateField($fldName)) {
  1149. $fldType = 'xsd:date';
  1150. }
  1151. else if ($acl->isDateTimeField($fldName)) {
  1152. // $fldType = 'xsd:dateTime';
  1153. $fldType = null;// 'xsd:string';
  1154. $patternDataTime = "(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?";
  1155. // <xsd:element name="..." minOccurs="0" nillable="true">
  1156. // <xsd:simpleType>
  1157. // <xsd:restriction base="xsd:string">
  1158. // <xsd:pattern value="[a-zA-Z]+\(\((\-?\d+\.?\d*,\-?\d+\.?\d*)( \-?\d+\.?\d*,\-?\d+\.?\d*)+\)\)"/>
  1159. // </xsd:restriction>
  1160. // </xsd:simpleType>
  1161. // </xsd:element>
  1162. $simpleTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:simpleType');
  1163. $restrictionNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:restriction');
  1164. $patternNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:pattern');
  1165. $restrictionNode->setAttribute('base', 'xsd:string');
  1166. $patternNode->setAttribute('value', $patternDataTime);
  1167. $restrictionNode->appendChild($patternNode);
  1168. $simpleTypeNode->appendChild($restrictionNode);
  1169. $elNode->appendChild($simpleTypeNode);
  1170. // continue;// TODO: ? below added nillable = true, minOccurs = 0, type = $fldType
  1171. }
  1172. else {
  1173. $fldType = 'xsd:string';
  1174. }
  1175. if ($fldType) $elNode->setAttribute('type', $fldType);
  1176. $elNode->setAttribute('nillable', 'true');
  1177. $elNode->setAttribute('minOccurs', '0');
  1178. }
  1179. // only geometry fields
  1180. foreach ($fldList as $fldName) {
  1181. if (!$acl->isGeomField($fldName)) continue;
  1182. $elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
  1183. $seqNode->appendChild($elNode);
  1184. $elNode->setAttribute('name', $fldName);
  1185. $minOccurs = 0;
  1186. if ($pKeyField == $fldName) {
  1187. $minOccurs = '1';
  1188. } else {
  1189. $minOccurs = '0';
  1190. }
  1191. $elNode->setAttribute('minOccurs', $minOccurs);
  1192. if ($acl->isGeomField($fldName)) {
  1193. //$fldType = 'gml:GeometryPropertyType';
  1194. // TODO: use geom types from gml to wkt
  1195. // TODO: pattern wg atrybutów gml:coordinates decimal="." cs="," ts=" "
  1196. $patternWkt = '';// TODO: error if empty - unsupported geom type
  1197. $patternNum = '\-?\d+\.?\d*';
  1198. $patternPoint = $patternNum . ',' . $patternNum;
  1199. $patternPoints = '(' . $patternPoint . ')( ' . $patternPoint . ')+';
  1200. $geomType = $acl->getGeomFieldType($fldName);
  1201. if ('polygon' == $geomType) {
  1202. // [a-zA-Z]+\(\((\-?\d+\.?\d*,\-?\d+\.?\d*)( (\-?\d+\.?\d*,\-?\d+\.?\d*))+\)\)
  1203. $patternWkt = '[a-zA-Z]+\(\(' . $patternPoints . '\)\)';
  1204. } else if ('linestring' == $geomType) {
  1205. // [a-zA-Z]+\((\-?\d+\.?\d*,\-?\d+\.?\d*)( (\-?\d+\.?\d*,\-?\d+\.?\d*))+\)
  1206. $patternWkt = '[a-zA-Z]+\(' . $patternPoints . '\)';
  1207. } else if ('point' == $geomType) {
  1208. // [a-zA-Z]+\(\-?\d\.?\d*,\-?\d\.?\d*\)
  1209. $patternWkt = '[a-zA-Z]+\(' . $patternPoint . '\)';
  1210. }
  1211. $simpleTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:simpleType');
  1212. $restrictionNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:restriction');
  1213. $patternNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:pattern');
  1214. $restrictionNode->setAttribute('base', 'xsd:string');
  1215. $patternNode->setAttribute('value', $patternWkt);
  1216. $restrictionNode->appendChild($patternNode);
  1217. $simpleTypeNode->appendChild($restrictionNode);
  1218. $elNode->appendChild($simpleTypeNode);
  1219. }
  1220. $elNode->setAttribute('nillable', 'true');
  1221. $elNode->setAttribute('minOccurs', '0');
  1222. }
  1223. }
  1224. }
  1225. $attrNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:attribute');
  1226. $updateTypeNode->appendChild($attrNode);
  1227. $attrNode->setAttribute('name', 'typeName');
  1228. $attrNode->setAttribute('type', 'xsd:token');
  1229. $attrNode->setAttribute('use', 'required');
  1230. if ($transactionType == 'Update') {
  1231. $attrNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:attribute');
  1232. $updateTypeNode->appendChild($attrNode);
  1233. $attrNode->setAttribute('name', 'featureId');
  1234. $attrNode->setAttribute('use', 'required');
  1235. $sTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:simpleType');
  1236. $attrNode->appendChild($sTypeNode);
  1237. $resNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:restriction');
  1238. $sTypeNode->appendChild($resNode);
  1239. $resNode->setAttribute('base', 'xsd:string');
  1240. $patternNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:pattern');
  1241. $resNode->appendChild($patternNode);
  1242. $patternNode->setAttribute('value', '[a-zA-Z_][a-zA-Z0-9_]*\.[0-9]*');
  1243. }
  1244. }
  1245. {// 'Delete'
  1246. $typeName = "p5_{$sourceNs[0]}:{$sourceNs[1]}";
  1247. $acl = $this->getAclFromTypeName($typeName);
  1248. $deleteElementType = "DeleteNs{$nsInd}ElementType";
  1249. $deleteTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexType');
  1250. $rootNode->appendChild($deleteTypeNode);
  1251. $deleteTypeNode->setAttribute('name', $deleteElementType);
  1252. /* <xsd:attribute name="typeName" type="xsd:token" use="required"/> */
  1253. $attrNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:attribute');
  1254. $deleteTypeNode->appendChild($attrNode);
  1255. $attrNode->setAttribute('name', 'typeName');
  1256. $attrNode->setAttribute('type', 'xsd:token');
  1257. $attrNode->setAttribute('use', 'required');
  1258. /* <xsd:attribute name="featureId" use="required"> */
  1259. $attrNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:attribute');
  1260. $deleteTypeNode->appendChild($attrNode);
  1261. $attrNode->setAttribute('name', 'featureId');
  1262. $attrNode->setAttribute('use', 'required');
  1263. $sTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:simpleType');
  1264. $attrNode->appendChild($sTypeNode);
  1265. $resNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:restriction');
  1266. $sTypeNode->appendChild($resNode);
  1267. $resNode->setAttribute('base', 'xsd:string');
  1268. $patternNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:pattern');
  1269. $resNode->appendChild($patternNode);
  1270. $patternNode->setAttribute('value', '[a-zA-Z_][a-zA-Z0-9_]*\.[0-9]*');
  1271. }
  1272. }
  1273. $validateConvertedTransactionXsdString = $dom->saveXml();
  1274. if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print_r($validateConvertedTransactionXsdString);echo "\n";}
  1275. $reqXml = new DOMDocument();
  1276. $reqXml->loadXml($convertedTransaction);
  1277. // TODO: fetch PHP Warning: DOMDocument::schemaValidateSource(): Element 'PARENT_ID': 'abc' is not a valid value of the atomic type 'xs:integer'.
  1278. return $reqXml->schemaValidateSource($validateConvertedTransactionXsdString);
  1279. }
  1280. public function _getDescribeFeatureType($nsPrefix, $type, $simple = true) {
  1281. return $this->_getDescribeFeatureTypes(array(array($nsPrefix, $type)), $simple);
  1282. }
  1283. public function _parseDescribeFeatureTypeRequest($reqContent, $simple = true) {
  1284. $parserXml = xml_parser_create();
  1285. xml_parser_set_option($parserXml, XML_OPTION_CASE_FOLDING, 0);
  1286. xml_parser_set_option($parserXml, XML_OPTION_SKIP_WHITE, 1);
  1287. if (0 == xml_parse_into_struct($parserXml, $reqContent, $tags)) {
  1288. throw new Exception("Error parsing xml");
  1289. }
  1290. xml_parser_free($parserXml);
  1291. if (empty($tags)) {
  1292. throw new Exception("Empty structure from request");
  1293. }
  1294. $rootTagName = V::get('tag', '', $tags[0]);
  1295. if ('DescribeFeatureType' != $rootTagName) {
  1296. throw new Api_WfsException("Wrong xml root tag '{$rootTagName}' #" . __LINE__, 501);
  1297. }
  1298. $requestXmlTags = $tags;
  1299. $DBG = (V::get('DBG_XML', '', $_GET) > 0);// TODO: Profiler
  1300. $rootTagName = V::get('tag', '', $requestXmlTags[0]);
  1301. if ('DescribeFeatureType' != $rootTagName) {
  1302. throw new Exception("Parse Request xml error #" . __LINE__);
  1303. }
  1304. /*[1] => Array(
  1305. [tag] => TypeName
  1306. [type] => complete
  1307. [level] => 2
  1308. [value] => p5_default_db:Rozdzielcza_rurociag_wsg84)
  1309. */
  1310. $typeNames = array();
  1311. $totalTypes = count($requestXmlTags) - 1;
  1312. for ($i = 1; $i < $totalTypes; $i++) {
  1313. if($DBG){echo "TAG[{$i}]:" . json_encode($requestXmlTags[$i]) . "\n";}
  1314. $typeNames[] = explode(':', $requestXmlTags[$i]['value'], 2);
  1315. }
  1316. //echo "typeNames: " . json_encode($typeNames) . "\n";
  1317. return $this->_getDescribeFeatureTypes($typeNames, $simple);
  1318. }
  1319. public function _getDescribeFeatureAllTypes($simple = true) {
  1320. $db = DB::getDB();
  1321. $idDefaultDB = $db->_zasob_id;
  1322. $tblsAcl = $this->_getTableAclList();
  1323. foreach ($tblsAcl as $tblAcl) {
  1324. $dataSourceName = 'default_db';// TODO: getSourceName
  1325. $tblName = $tblAcl->getName();
  1326. $typeNames[] = array("p5_{$dataSourceName}", $tblName);
  1327. }
  1328. return $this->_getDescribeFeatureTypes($typeNames, $simple);
  1329. }
  1330. // @param $typeNames = array( array( $nsPrefix, $type ) )
  1331. public function _getDescribeFeatureTypes($typeNames, $simple = true) {
  1332. if (empty($typeNames)) throw new HttpException("Feature Type Names not defined", 400);
  1333. $this->DBG("types:" . json_encode($typeNames), __LINE__, __FUNCTION__, __CLASS__);
  1334. $baseNsUri = $this->getBaseNamespaceUri();
  1335. $rootWfsNs = 'p5';
  1336. $rootWfsNsUri = "{$baseNsUri}";
  1337. $wfsNs = 'p5_default_db';
  1338. $wfsNsUri = "{$baseNsUri}/default_db";
  1339. $featureTypeUri = $this->getBaseUri() . "?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType";
  1340. header('Content-type: application/xml');
  1341. // <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://webgis.regione.sardegna.it:80/geoserver/schemas/gml/2.1.2/feature.xsd"/>
  1342. // <xsd:element name="{type}" substitutionGroup="gml:_Feature" type="dbu:{typeName}"/>
  1343. $dom = new DOMDocument('1.0', 'utf-8');
  1344. $dom->formatOutput = true;
  1345. $dom->preserveWhiteSpace = false;
  1346. $rootNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:schema');
  1347. $dom->appendChild($rootNode);
  1348. $rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gml', 'http://www.opengis.net/gml');
  1349. $rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:' . $wfsNs, $wfsNsUri);
  1350. $rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', "xmlns:{$rootWfsNs}", $rootWfsNsUri);
  1351. $rootNode->setAttribute('elementFormDefault', 'qualified');
  1352. $rootNode->setAttribute('targetNamespace', $wfsNsUri);
  1353. {// <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="...../gml/2.1.2/feature.xsd"/>
  1354. $elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:import');
  1355. $rootNode->appendChild($elNode);
  1356. $elNode->setAttribute('namespace', "http://www.opengis.net/gml");
  1357. $elNode->setAttribute('schemaLocation', $this->getBaseUri() . "/../../../schema/gml/2.1.2/feature.xsd");
  1358. }
  1359. foreach ($typeNames as $typeNameEx) {
  1360. $nsPrefix = $typeNameEx[0];
  1361. $type = $typeNameEx[1];
  1362. $typeName = "{$nsPrefix}:{$type}";
  1363. $acl = $this->getAclFromTypeName($typeName);
  1364. if (!$this->isAllowedFeatureType($nsPrefix, $type)) {
  1365. throw new Api_WfsException("Could not find type: " . htmlspecialchars($type));
  1366. }
  1367. $typeName = $type . 'Type';
  1368. $fldList = $this->_getFieldListFromAcl($acl);
  1369. $cTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexType');
  1370. $rootNode->appendChild($cTypeNode);
  1371. $cTypeNode->setAttribute('name', $typeName);
  1372. if (!$simple) {
  1373. $idZasob = $acl->getID();
  1374. $cTypeNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:web_link", Request::getPathUri() . "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID={$idZasob}");
  1375. }
  1376. $cConNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexContent');
  1377. $cTypeNode->appendChild($cConNode);
  1378. $extNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:extension');
  1379. $cConNode->appendChild($extNode);
  1380. $extNode->setAttribute('base', 'gml:AbstractFeatureType');
  1381. $seqNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:sequence');
  1382. $extNode->appendChild($seqNode);
  1383. // <xsd:element maxOccurs="1" minOccurs="0" name="{$fldName}" nillable="true" type="xsd:integer"/>
  1384. $pKeyField = $acl->getPrimaryKeyField();
  1385. $p5Attributes = ($simple)? array() : $acl->getAttributesFromZasoby();
  1386. foreach ($fldList as $idZasob => $fldName) {
  1387. $elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
  1388. $seqNode->appendChild($elNode);
  1389. $elNode->setAttribute('name', $fldName);
  1390. $minOccurs = 0;
  1391. if ($pKeyField == $fldName) {
  1392. $minOccurs = '1';
  1393. } else {
  1394. $minOccurs = '0';
  1395. }
  1396. $elNode->setAttribute('minOccurs', $minOccurs);
  1397. $elNode->setAttribute('maxOccurs', '1');
  1398. $elNode->setAttribute('nillable', 'true');
  1399. $fldType = 'xsd:string';
  1400. if ($acl->isIntegerField($fldName)) {
  1401. $fldType = 'xsd:integer';
  1402. }
  1403. else if ($acl->isDecimalField($fldName)) {
  1404. $fldType = 'xsd:decimal';
  1405. }
  1406. else if ($acl->isDateField($fldName)) {
  1407. $fldType = 'xsd:date';
  1408. }
  1409. else if ($acl->isDateTimeField($fldName)) {
  1410. $fldType = 'xsd:dateTime';
  1411. }
  1412. else if ($acl->isGeomField($fldName)) {
  1413. //$fldType = 'gml:GeometryPropertyType';
  1414. $geomType = $acl->getGeomFieldType($fldName);
  1415. if ('polygon' == $geomType) {
  1416. $fldType = 'gml:PolygonPropertyType';
  1417. } else if ('point' == $geomType) {
  1418. $fldType = 'gml:PointPropertyType';
  1419. } else if ('linestring' == $geomType) {
  1420. $fldType = 'gml:LineStringPropertyType';
  1421. } else {
  1422. $fldType = 'gml:GeometryPropertyType';
  1423. }
  1424. }
  1425. else if ($acl->isEnumerationField($fldName)) {
  1426. $fldType = ($simple)? 'xsd:string' : "{$nsPrefix}:{$fldName}Type";
  1427. }
  1428. $elNode->setAttribute('type', $fldType);
  1429. if (!$simple) {
  1430. $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:id_zasob", $idZasob);
  1431. if (!empty($p5Attributes[$fldName])) {
  1432. $p5attrs = $p5Attributes[$fldName];
  1433. if (!empty($p5attrs['label'])) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:label", $p5attrs['label']);
  1434. if (!empty($p5attrs['description'])) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:description", $p5attrs['description']);
  1435. }
  1436. if ($acl->hasFieldPerm($idZasob, 'W')) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_write", "true");
  1437. if ($acl->hasFieldPerm($idZasob, 'C')) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_create", "true");
  1438. if (!$acl->hasFieldPerm($idZasob, 'R')) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_read", "false");
  1439. }
  1440. }
  1441. $elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
  1442. $rootNode->appendChild($elNode);
  1443. $elNode->setAttribute('name', $type);
  1444. $elNode->setAttribute('type', $wfsNs . ':' . $typeName);
  1445. if ($simple) {
  1446. $elNode->setAttribute('substitutionGroup', 'gml:_Feature');
  1447. } else {
  1448. $elNode->setAttribute('substitutionGroup', 'gml:AbstractFeature');
  1449. }
  1450. if (!$simple) {
  1451. foreach ($fldList as $fldName) {
  1452. if ($acl->isEnumerationField($fldName)) {
  1453. $enum = $acl->getEnumerations($fldName);
  1454. $stNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:simpleType');
  1455. $stNode->setAttribute('name', "{$fldName}Type");//"{$nsPrefix}:{$fldName}Type");
  1456. $rootNode->appendChild($stNode);
  1457. $resNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:restriction');
  1458. $stNode->appendChild($resNode);
  1459. $resNode->setAttribute('base', 'xsd:string');
  1460. // TODO: if (!empty($p5Attributes[$fldName]['valuesMap'])) -> show only this values
  1461. foreach ($enum as $val => $label) {
  1462. $enumNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:enumeration');
  1463. $resNode->appendChild($enumNode);
  1464. $enumNode->setAttribute('value', "{$val}");
  1465. if (!empty($p5Attributes[$fldName]['valuesMap'][$val])) {
  1466. $enumNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:label", $p5Attributes[$fldName]['valuesMap'][$val]);
  1467. }
  1468. }
  1469. }
  1470. }
  1471. }
  1472. }
  1473. return $dom->saveXML();
  1474. }
  1475. public function _getTableAclList() {// Use only Tables from default_db
  1476. $tblAclList = array();
  1477. $db = DB::getDB();
  1478. $idDefaultDB = $db->_zasob_id;
  1479. $fullTblAclList = $this->_usrAcl->getTablesAcl();
  1480. foreach ($fullTblAclList as $tblAcl) {
  1481. $dataSourceName = 'default_db';// TODO: getSourceName
  1482. $tblName = $tblAcl->getName();
  1483. if ($idDefaultDB != $tblAcl->getDB()) {// hide non default_db tables
  1484. continue;
  1485. }
  1486. try {
  1487. $acl = $this->getAclFromTypeName($typeName = "p5_{$dataSourceName}:{$tblName}");
  1488. } catch (Exception $e) {
  1489. // TODO: error log $e->getMessage();
  1490. }
  1491. if (!$acl) {
  1492. // TODO: error log msg
  1493. continue;
  1494. }
  1495. $tblAclList[] = $tblAcl;
  1496. }
  1497. return $tblAclList;
  1498. }
  1499. public function _getFieldListFromAcl($acl) {
  1500. $fldList = $acl->getRealFieldListByIdZasob();
  1501. return $fldList;
  1502. }
  1503. public function setLogger($logger) {
  1504. $this->_logger = $logger;
  1505. }
  1506. public function DBG($reqLog, $lineNr = null, $funName = null, $className = null) {
  1507. if (!$this->_logger) return;
  1508. $this->_logger->DBG($reqLog, $lineNr, $funName, $className);
  1509. }
  1510. public function convertOgcFilterFromRequestBody($requestOgcFilter) {
  1511. $ogcFilter = '';
  1512. if (empty($requestOgcFilter)) return '';
  1513. {
  1514. $convertOgcFilterXslString .= <<<EOF
  1515. <xsl:transform version="1.0"
  1516. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  1517. xmlns:wfs="http://www.opengis.net/wfs"
  1518. xmlns:ogc="http://www.opengis.net/ogc"
  1519. xmlns:gml="http://www.opengis.net/gml">
  1520. <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
  1521. <xsl:template match="/">
  1522. <xsl:for-each select="//*[local-name() = 'GetFeature']">
  1523. <xsl:copy-of select="ogc:Filter"/>
  1524. </xsl:for-each>
  1525. </xsl:template>
  1526. </xsl:transform>
  1527. EOF;
  1528. DBG::_('DBG_XML', '>2', "convertOgcFilterXslString", $convertOgcFilterXslString, __CLASS__, __FUNCTION__, __LINE__);
  1529. $convertTransactionXsl = new DOMDocument();
  1530. $convertTransactionXsl->loadXml($convertOgcFilterXslString);
  1531. $requestXml = new DOMDocument();
  1532. $requestXml->loadXml($requestOgcFilter);
  1533. $proc = new XSLTProcessor();
  1534. $proc->importStylesheet($convertTransactionXsl);
  1535. $ogcFilter = $proc->transformToXML($requestXml);
  1536. DBG::_('DBG_XML', '>2', "ogcFilter", $ogcFilter, __CLASS__, __FUNCTION__, __LINE__);
  1537. }
  1538. return $ogcFilter;
  1539. }
  1540. }